Skip to content

Commit

Permalink
Merge branch '1.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Jun 12, 2022
2 parents 3ca95b5 + 4869120 commit e978b1b
Show file tree
Hide file tree
Showing 46 changed files with 503 additions and 539 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ repositories {
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

compileOnly fg.deobf("mezz.jei:jei-${jei_version}:api")
runtimeOnly fg.deobf("mezz.jei:jei-${jei_version}")
// compileOnly fg.deobf("mezz.jei:jei-${jei_version}:api")
// runtimeOnly fg.deobf("mezz.jei:jei-${jei_version}")
}

jar {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
minecraft_version=1.18.2
forge_version=40.0.34
version=3.13.0
minecraft_version=1.19
forge_version=41.0.17
version=3.14.0
jei_version=1.18.2:9.+
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
package com.direwolf20.buildinggadgets.client;

import com.direwolf20.buildinggadgets.client.screen.TemplateManagerGUI;
import com.direwolf20.buildinggadgets.common.items.AbstractGadget;
import com.direwolf20.buildinggadgets.common.items.OurItems;
import com.direwolf20.buildinggadgets.common.util.ref.Reference;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.ISubtypeRegistration;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@JeiPlugin
public class BuildingGadgetsJEI implements IModPlugin {
@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(Reference.MODID, "jei_plugin");
}

@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
registration.addGuiContainerHandler(TemplateManagerGUI.class, new GuiContainerHandler());
}

@Override
public void registerItemSubtypes(ISubtypeRegistration registration) {
List<Item> gadgets = new ArrayList<>() {{
add(OurItems.BUILDING_GADGET_ITEM.get());
add(OurItems.EXCHANGING_GADGET_ITEM.get());
add(OurItems.DESTRUCTION_GADGET_ITEM.get());
add(OurItems.COPY_PASTE_GADGET_ITEM.get());
}};

for (Item gadget : gadgets) {
registration.registerSubtypeInterpreter(gadget, (itemStack, uidContext) -> {
if (!(itemStack.getItem() instanceof AbstractGadget))
return "";

double energy = itemStack.getOrCreateTag().getDouble("energy");
if (energy == 0)
return "empty";
else if (energy == ((AbstractGadget) itemStack.getItem()).getEnergyMax())
return "charged";

return "";
});
}
}

private static class GuiContainerHandler implements IGuiContainerHandler<TemplateManagerGUI> {
@Override
public List<Rect2i> getGuiExtraAreas(TemplateManagerGUI containerScreen) {
return new ArrayList<>(Collections.singleton(new Rect2i((containerScreen.width / 2) + 80, (containerScreen.height / 2) - 80, 60, 120)));
}
}
}
//package com.direwolf20.buildinggadgets.client;
//
//import com.direwolf20.buildinggadgets.client.screen.TemplateManagerGUI;
//import com.direwolf20.buildinggadgets.common.items.AbstractGadget;
//import com.direwolf20.buildinggadgets.common.items.OurItems;
//import com.direwolf20.buildinggadgets.common.util.ref.Reference;
//import mezz.jei.api.IModPlugin;
//import mezz.jei.api.JeiPlugin;
//import mezz.jei.api.gui.handlers.IGuiContainerHandler;
//import mezz.jei.api.registration.IGuiHandlerRegistration;
//import mezz.jei.api.registration.ISubtypeRegistration;
//import net.minecraft.client.renderer.Rect2i;
//import net.minecraft.resources.ResourceLocation;
//import net.minecraft.world.item.Item;
//
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.List;
//
//@JeiPlugin
//public class BuildingGadgetsJEI implements IModPlugin {
// @Override
// public ResourceLocation getPluginUid() {
// return new ResourceLocation(Reference.MODID, "jei_plugin");
// }
//
// @Override
// public void registerGuiHandlers(IGuiHandlerRegistration registration) {
// registration.addGuiContainerHandler(TemplateManagerGUI.class, new GuiContainerHandler());
// }
//
// @Override
// public void registerItemSubtypes(ISubtypeRegistration registration) {
// List<Item> gadgets = new ArrayList<>() {{
// add(OurItems.BUILDING_GADGET_ITEM.get());
// add(OurItems.EXCHANGING_GADGET_ITEM.get());
// add(OurItems.DESTRUCTION_GADGET_ITEM.get());
// add(OurItems.COPY_PASTE_GADGET_ITEM.get());
// }};
//
// for (Item gadget : gadgets) {
// registration.registerSubtypeInterpreter(gadget, (itemStack, uidContext) -> {
// if (!(itemStack.getItem() instanceof AbstractGadget))
// return "";
//
// double energy = itemStack.getOrCreateTag().getDouble("energy");
// if (energy == 0)
// return "empty";
// else if (energy == ((AbstractGadget) itemStack.getItem()).getEnergyMax())
// return "charged";
//
// return "";
// });
// }
// }
//
// private static class GuiContainerHandler implements IGuiContainerHandler<TemplateManagerGUI> {
// @Override
// public List<Rect2i> getGuiExtraAreas(TemplateManagerGUI containerScreen) {
// return new ArrayList<>(Collections.singleton(new Rect2i((containerScreen.width / 2) + 80, (containerScreen.height / 2) - 80, 60, 120)));
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.direwolf20.buildinggadgets.client.cache.CacheTemplateProvider;
import com.direwolf20.buildinggadgets.client.events.EventTooltip;
import com.direwolf20.buildinggadgets.client.models.ConstructionBakedModel;
import com.direwolf20.buildinggadgets.client.screen.TemplateManagerGUI;
import com.direwolf20.buildinggadgets.common.blocks.ConstructionBlock;
import com.direwolf20.buildinggadgets.common.blocks.OurBlocks;
Expand All @@ -26,6 +25,7 @@
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -42,7 +42,6 @@
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class ClientProxy {
public static final CacheTemplateProvider CACHE_TEMPLATE_PROVIDER = new CacheTemplateProvider();
Expand Down Expand Up @@ -88,9 +87,8 @@ private static void bakeModels(ModelBakeEvent event) {
ModelResourceLocation ConstrLocation3a = new ModelResourceLocation(ConstrName, "ambient_occlusion=true,bright=false,neighbor_brightness=true");
ModelResourceLocation ConstrLocation4 = new ModelResourceLocation(ConstrName, "ambient_occlusion=false,bright=true,neighbor_brightness=true");
ModelResourceLocation ConstrLocation4a = new ModelResourceLocation(ConstrName, "ambient_occlusion=true,bright=true,neighbor_brightness=true");
IDynamicBakedModel constructionBakedModel = new ConstructionBakedModel();
IDynamicBakedModel bakedModelLoader = new IDynamicBakedModel() {

IDynamicBakedModel bakedModelLoader = new IDynamicBakedModel() {
@Override
public boolean isGui3d() {
return false;
Expand All @@ -112,7 +110,7 @@ public boolean useAmbientOcclusion() {
}

@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData) {
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, IModelData modelData) {
BakedModel model;
BlockState facadeState = modelData.getData(ConstructionBlockTileEntity.FACADE_STATE);
RenderType layer = MinecraftForgeClient.getRenderType();
Expand Down Expand Up @@ -166,7 +164,7 @@ public boolean useAmbientOcclusion() {
}

@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData) {
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, IModelData modelData) {
BakedModel model;
BlockState facadeState = modelData.getData(ConstructionBlockTileEntity.FACADE_STATE);
RenderType layer = MinecraftForgeClient.getRenderType();
Expand Down
36 changes: 9 additions & 27 deletions src/main/java/com/direwolf20/buildinggadgets/client/OurSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,20 @@
import com.direwolf20.buildinggadgets.common.util.ref.Reference;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

@EventBusSubscriber(modid = Reference.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public enum OurSounds {
BEEP("beep");
private SoundEvent sound;
public interface OurSounds {
DeferredRegister<SoundEvent> REGISTRY = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, Reference.MODID);

OurSounds(String name) {
ResourceLocation loc = new ResourceLocation(Reference.MODID, name);
sound = new SoundEvent(loc).setRegistryName(name);
}

public SoundEvent getSound() {
return sound;
}
RegistryObject<SoundEvent> BEEP = REGISTRY.register("beep", () -> new SoundEvent(new ResourceLocation(Reference.MODID, "beep")));

public void playSound() {
playSound(1.0F);
}

public void playSound(float pitch) {
static void playSound(SoundEvent sound, float pitch) {
ClientProxy.playSound(sound, pitch);
}

@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> event) {
for (OurSounds sound : values()) {
event.getRegistry().register(sound.getSound());
}
static void playSound(SoundEvent sound) {
ClientProxy.playSound(sound, 1.0F);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

import com.direwolf20.buildinggadgets.common.blocks.OurBlocks;
import com.direwolf20.buildinggadgets.common.tileentities.ConstructionBlockTileEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
Expand All @@ -22,10 +23,10 @@
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class ConstructionBakedModel implements IDynamicBakedModel {
private BlockState facadeState;

@Override
public boolean isGui3d() {
return false;
Expand Down Expand Up @@ -55,13 +56,13 @@ public boolean useAmbientOcclusion() {
}

@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData) {
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, IModelData modelData) {
BakedModel model;
facadeState = modelData.getData(ConstructionBlockTileEntity.FACADE_STATE);
RenderType layer = MinecraftForgeClient.getRenderType();
if (facadeState == null || facadeState == Blocks.AIR.defaultBlockState())
facadeState = OurBlocks.CONSTRUCTION_DENSE_BLOCK.get().defaultBlockState();
if (layer != null && ! ItemBlockRenderTypes.canRenderInLayer(facadeState, layer)) { // always render in the null layer or the block-breaking textures don't show up
if (layer != null && !ItemBlockRenderTypes.canRenderInLayer(facadeState, layer)) { // always render in the null layer or the block-breaking textures don't show up
return Collections.emptyList();
}
model = Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getBlockModel(facadeState);
Expand Down
Loading

0 comments on commit e978b1b

Please sign in to comment.