diff --git a/src/main/java/com/fureniku/metropolis/RegistrationBase.java b/src/main/java/com/fureniku/metropolis/RegistrationBase.java index 04c9f67..54b85c0 100644 --- a/src/main/java/com/fureniku/metropolis/RegistrationBase.java +++ b/src/main/java/com/fureniku/metropolis/RegistrationBase.java @@ -63,9 +63,10 @@ public RegistrationBase(String modid, IEventBus modEventBus) { modEventBus.addListener(this::common); modEventBus.addListener(this::client); modEventBus.addListener(this::buildCreativeTabs); - modEventBus.addListener(this::modelInit); - modEventBus.addListener(this::modelBakeComplete); - modEventBus.addListener(this::modifyBake); + //These need to be client only. Unused for now so disabled //todo + //modEventBus.addListener(this::modelInit); + //modEventBus.addListener(this::modelBakeComplete); + //modEventBus.addListener(this::modifyBake); modEventBus.addListener(this::generate); blockRegistry.register(modEventBus); itemRegistry.register(modEventBus); @@ -217,9 +218,9 @@ public void buildCreativeTabs(BuildCreativeModeTabContentsEvent event) { * Model setup event. Register model overrides etc here. (Client only) * @param event ModelEvent.RegisterGeometryLoaders */ - protected abstract void modelSetup(ModelEvent.RegisterGeometryLoaders event); - protected abstract void modifyBakingResult(ModelEvent.ModifyBakingResult event); - protected abstract void bakingComplete(ModelEvent.BakingCompleted event); + //protected abstract void modelSetup(ModelEvent.RegisterGeometryLoaders event); + //protected abstract void modifyBakingResult(ModelEvent.ModifyBakingResult event); + //protected abstract void bakingComplete(ModelEvent.BakingCompleted event); /** * Data generation event. Register data generations here. @@ -284,7 +285,7 @@ protected void client(final FMLClientSetupEvent event) { } //Call anything we want on the model setup then offer it to end mods - @SubscribeEvent + /*@SubscribeEvent protected void modelInit(ModelEvent.RegisterGeometryLoaders event) { Debug.Log("EVENT CALL: Register Geometry Loaders"); modelSetup(event); @@ -300,7 +301,7 @@ protected void modifyBake(ModelEvent.ModifyBakingResult event) { protected void modelBakeComplete(ModelEvent.BakingCompleted event) { Debug.Log("EVENT CALL: Baking completed"); bakingComplete(event); - } + }*/ //Add a block to the registry private void addBlock(String key, RegistryObject value) { diff --git a/src/main/java/com/fureniku/metropolis/blocks/BlockSet.java b/src/main/java/com/fureniku/metropolis/blocks/BlockSet.java index 308c7a0..83091c9 100644 --- a/src/main/java/com/fureniku/metropolis/blocks/BlockSet.java +++ b/src/main/java/com/fureniku/metropolis/blocks/BlockSet.java @@ -10,6 +10,7 @@ import net.minecraftforge.client.event.RegisterColorHandlersEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.registries.RegistryObject; import java.util.function.BiFunction; @@ -77,10 +78,12 @@ private void init(RegistrationBase register) { * @return An instance of BlockSet for method chaining. */ public BlockSet addColorTints(IEventBus modEventBus, BiFunction blockColor, Supplier itemColor) { - modEventBus.addListener(this::registerBlockColors); - modEventBus.addListener(this::registerItemColors); - tintColorBlock = blockColor; - tintColorItem = itemColor; + if (FMLEnvironment.dist.isClient()) { + modEventBus.addListener(this::registerBlockColors); + modEventBus.addListener(this::registerItemColors); + tintColorBlock = blockColor; + tintColorItem = itemColor; + } return this; } diff --git a/src/main/java/com/fureniku/metropolis/client/screens/MetroScreenContainerBase.java b/src/main/java/com/fureniku/metropolis/client/screens/MetroScreenContainerBase.java new file mode 100644 index 0000000..5989597 --- /dev/null +++ b/src/main/java/com/fureniku/metropolis/client/screens/MetroScreenContainerBase.java @@ -0,0 +1,41 @@ +package com.fureniku.metropolis.client.screens; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; + +public abstract class MetroScreenContainerBase extends AbstractContainerScreen { + + private final ScreenImage _background; + + public MetroScreenContainerBase(T menu, Inventory inventory, Component component, ScreenImage background) { + super(menu, inventory, component); + _background = background; + this.imageWidth = background.getWidth(); + this.imageHeight = background.getHeight(); + } + + protected abstract ResourceLocation getBackground(); + + @Override + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) { + this.renderBackground(graphics); + super.render(graphics, mouseX, mouseY, partialTick); + this.renderTooltip(graphics, mouseX, mouseY); + } + + @Override + protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) { + RenderSystem.setShaderTexture(0, getBackground()); + graphics.blit(_background.getResourceLocation(), this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + } + + @Override + protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { + super.renderLabels(graphics, mouseX, mouseY); + } +} diff --git a/src/main/java/com/fureniku/metropolis/client/screens/ScreenImage.java b/src/main/java/com/fureniku/metropolis/client/screens/ScreenImage.java new file mode 100644 index 0000000..d631e0c --- /dev/null +++ b/src/main/java/com/fureniku/metropolis/client/screens/ScreenImage.java @@ -0,0 +1,40 @@ +package com.fureniku.metropolis.client.screens; + +import net.minecraft.resources.ResourceLocation; + +public class ScreenImage { + + private ResourceLocation _resourceLocation; + private int _startLeft; + private int _startTop; + private int _width; + private int _height; + + public ScreenImage(ResourceLocation loc, int startLeft, int startTop, int width, int height) { + _resourceLocation = loc; + _startLeft = startLeft; + _startTop = startTop; + _width = width; + _height = height; + } + + public ResourceLocation getResourceLocation() { + return _resourceLocation; + } + + public int getStartLeft() { + return _startLeft; + } + + public int getStartTop() { + return _startTop; + } + + public int getWidth() { + return _width; + } + + public int getHeight() { + return _height; + } +} diff --git a/src/main/java/com/fureniku/metropolis/test/RegistrationTest.java b/src/main/java/com/fureniku/metropolis/test/RegistrationTest.java index 5f445af..0da890d 100644 --- a/src/main/java/com/fureniku/metropolis/test/RegistrationTest.java +++ b/src/main/java/com/fureniku/metropolis/test/RegistrationTest.java @@ -195,15 +195,6 @@ protected void commonSetup(FMLCommonSetupEvent event) {} @Override protected void clientSetup(FMLClientSetupEvent event) {} - @Override - protected void modelSetup(ModelEvent.RegisterGeometryLoaders event) {} - - @Override - protected void modifyBakingResult(ModelEvent.ModifyBakingResult event) {} - - @Override - protected void bakingComplete(ModelEvent.BakingCompleted event) {} - @Override protected void dataGen(GatherDataEvent event, DataGenerator gen, PackOutput packOutput, ExistingFileHelper efh) { gen.addProvider(event.includeClient(), new MetroBlockStateProvider(packOutput, Metropolis.MODID, efh, Metropolis.INSTANCE.registrationTest));