diff --git a/build.gradle b/build.gradle index ecb79d5df..78a73ca37 100644 --- a/build.gradle +++ b/build.gradle @@ -165,9 +165,8 @@ dependencies { compileOnly fg.deobf("vazkii.botania:Botania:${mc_version}-${botania_version}-FORGE:api") runtimeOnly fg.deobf("vazkii.botania:Botania:${mc_version}-${botania_version}-FORGE") - - - implementation fg.deobf("curse.maven:jade-324717:5493390") + // implementation fg.deobf("curse.maven:jade-324717:5493390") + // Example mod dependency using a mod jar from ./libs with a flat dir repository // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar // The group id is ignored when searching -- in this case, it is "blank" diff --git a/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java b/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java index 7a0e64b6f..38bc4ffb9 100644 --- a/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java +++ b/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java @@ -34,7 +34,7 @@ public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random //try to bake if SOURCE water is nearby //using FluidState instead of Block FluidState fluid = world.getFluidState(p); - if (fluid.getType() == Fluids.WATER.getSource()) { + if (fluid != null && fluid.is(Fluids.WATER)) { sidesWet++; waters.add(p); } diff --git a/src/main/java/com/lothrazar/cyclic/block/clock/ContainerClock.java b/src/main/java/com/lothrazar/cyclic/block/clock/ContainerClock.java index 6686e5702..1aadd4835 100644 --- a/src/main/java/com/lothrazar/cyclic/block/clock/ContainerClock.java +++ b/src/main/java/com/lothrazar/cyclic/block/clock/ContainerClock.java @@ -18,7 +18,7 @@ public ContainerClock(int windowId, Level world, BlockPos pos, Inventory playerI tile = (TileRedstoneClock) world.getBlockEntity(pos); this.playerEntity = player; this.playerInventory = playerInventory; - layoutPlayerInventorySlots(8, 153); + layoutPlayerInventorySlots(8, 84); this.trackAllIntFields(tile, TileRedstoneClock.Fields.values().length); } diff --git a/src/main/java/com/lothrazar/cyclic/block/clock/ScreenClock.java b/src/main/java/com/lothrazar/cyclic/block/clock/ScreenClock.java index 3e28b6088..72f0b2251 100644 --- a/src/main/java/com/lothrazar/cyclic/block/clock/ScreenClock.java +++ b/src/main/java/com/lothrazar/cyclic/block/clock/ScreenClock.java @@ -14,30 +14,29 @@ public class ScreenClock extends ScreenBase { public ScreenClock(ContainerClock screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); - this.imageHeight = 256; } @Override public void init() { super.init(); int x, y; - x = leftPos + 8; - y = topPos + 8; + x = leftPos + 6; + y = topPos + 6; btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, TileRedstoneClock.Fields.REDSTONE.ordinal(), menu.tile.getBlockPos())); int w = 160; - int h = 20; + int h = 18; int f = TileRedstoneClock.Fields.DURATION.ordinal(); x = leftPos + 8; - y = topPos + 38; + y = topPos + 26; GuiSliderInteger dur = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 1, 200, menu.tile.getField(f))); dur.setTooltip("cyclic.clock.duration"); - y += 26; + y += h + 1; f = TileRedstoneClock.Fields.DELAY.ordinal(); GuiSliderInteger delay = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 1, 200, menu.tile.getField(f))); delay.setTooltip("cyclic.clock.delay"); - y += 26; + y += h + 1; f = TileRedstoneClock.Fields.POWER.ordinal(); GuiSliderInteger power = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 1, 15, menu.tile.getField(f))); @@ -60,9 +59,6 @@ protected void renderLabels(GuiGraphics ms, int mouseX, int mouseY) { @Override protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) { - this.drawBackground(ms, TextureRegistry.INVENTORY_LARGE_PLAIN); - // this.txtDuration.render(ms, mouseX, mouseX, partialTicks); - // this.txtDelay.render(ms, mouseX, mouseX, partialTicks); - // this.txtPower.render(ms, mouseX, mouseX, partialTicks); + this.drawBackground(ms, TextureRegistry.INVENTORY); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/ContainerItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/ContainerItemCollector.java index e246c39b1..738ded1b7 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/ContainerItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/ContainerItemCollector.java @@ -37,7 +37,7 @@ public void setChanged() { } } addSlot(new SlotItemHandler(tile.filter, 0, 152, 9)); - layoutPlayerInventorySlots(8, 153); + layoutPlayerInventorySlots(8, 132); this.trackAllIntFields(tile, TileItemCollector.Fields.values().length); } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/ScreenItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/ScreenItemCollector.java index d589da2b5..9c8193a18 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/ScreenItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/ScreenItemCollector.java @@ -14,13 +14,13 @@ public class ScreenItemCollector extends ScreenBase { private ButtonMachineField btnRedstone; private ButtonMachineField btnRender; - private GuiSliderInteger sizeSlider; private ButtonMachineField btnDirection; + private GuiSliderInteger sizeSlider; private GuiSliderInteger heightslider; public ScreenItemCollector(ContainerItemCollector screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); - this.imageHeight = 256; + this.imageHeight = 214; } @Override @@ -29,29 +29,29 @@ public void init() { int x = leftPos + 6; int y = topPos + 6; int f = TileItemCollector.Fields.REDSTONE.ordinal(); + int h = 20; btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos())); f = TileItemCollector.Fields.RENDER.ordinal(); - y += 20; + y += h; btnRender = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); //then toggle f = TileItemCollector.Fields.DIRECTION.ordinal(); - y += 20; + y += h; btnDirection = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); - int w = 110; - int h = 18; + int w = 140; //now start sliders // - y = topPos + 22; - x = leftPos + 34; + x = leftPos + 30; + y = topPos + 34; f = TileItemCollector.Fields.HEIGHT.ordinal(); heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, TileItemCollector.Fields.HEIGHT.ordinal(), menu.tile.getBlockPos(), 0, TileItemCollector.MAX_HEIGHT, menu.tile.getField(f))); heightslider.setTooltip("buildertype.height.tooltip"); //then size f = TileItemCollector.Fields.SIZE.ordinal(); - y += h + 1; + y += h + 4; sizeSlider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, TileItemCollector.Fields.SIZE.ordinal(), menu.tile.getBlockPos(), 0, TileItemCollector.MAX_SIZE, menu.tile.getField(f))); sizeSlider.setTooltip("buildertype.size.tooltip"); @@ -77,7 +77,7 @@ protected void renderLabels(GuiGraphics ms, int mouseX, int mouseY) { @Override protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) { - this.drawBackground(ms, TextureRegistry.INVENTORY_LARGE_PLAIN); + this.drawBackground(ms, TextureRegistry.INVENTORY_MEDIUM); for (int i = 0; i < 9; i++) { int y = 81; this.drawSlot(ms, 7 + i * Const.SQ, y); diff --git a/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java b/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java index 365e001f2..d35bd1a98 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java @@ -6,6 +6,7 @@ import com.lothrazar.library.util.BlockstatesUtil; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.Containers; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -50,4 +51,17 @@ public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntit protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); } + + @Override + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (state.getBlock() != newState.getBlock()) { + TileDropper tileentity = (TileDropper) worldIn.getBlockEntity(pos); + if (tileentity != null && tileentity.gpsSlots != null) { + for (int s = 0; s < tileentity.gpsSlots.getSlots(); s++) { + Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.gpsSlots.getStackInSlot(s)); + } + } + } + super.onRemove(state, worldIn, pos, newState, isMoving); + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/dropper/ScreenDropper.java b/src/main/java/com/lothrazar/cyclic/block/dropper/ScreenDropper.java index b4f69c67b..b262079ce 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/ScreenDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/ScreenDropper.java @@ -37,7 +37,7 @@ public void init() { x = leftPos + 32; y = topPos + 18; w = 120; - h = 16; + h = 18; int f = TileDropper.Fields.DROPCOUNT.ordinal(); GuiSliderInteger dropcount = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 1, 64, menu.tile.getField(f))); diff --git a/src/main/java/com/lothrazar/cyclic/block/fan/ScreenFan.java b/src/main/java/com/lothrazar/cyclic/block/fan/ScreenFan.java index ffdf70fc9..9da37d7d5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fan/ScreenFan.java +++ b/src/main/java/com/lothrazar/cyclic/block/fan/ScreenFan.java @@ -25,11 +25,11 @@ public void init() { x = leftPos + 6; y = topPos + 6; btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, TileFan.Fields.REDSTONE.ordinal(), menu.tile.getBlockPos())); - y += 20; + x += 20; btnRender = addRenderableWidget(new ButtonMachineField(x, y, TileFan.Fields.RENDER.ordinal(), menu.tile.getBlockPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); // - int w = 160; + int w = 140; int h = 20; int f = TileFan.Fields.SPEED.ordinal(); x = leftPos + 8; diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java index b414c18d2..ede309fd0 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java @@ -27,26 +27,27 @@ public ScreenForester(ContainerForester screenContainer, Inventory inv, Componen public void init() { super.init(); this.energy = new EnergyBar(this.font, TileForester.MAX); - int x, y; + int x = leftPos + 6; + int y = topPos + 6; energy.guiLeft = leftPos; energy.guiTop = topPos; energy.visible = TileForester.POWERCONF.get() > 0; - x = leftPos + 6; - y = topPos + 6; - btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, TileForester.Fields.REDSTONE.ordinal(), menu.tile.getBlockPos())); - y += 20; - btnRender = addRenderableWidget(new ButtonMachineField(x, y, TileForester.Fields.RENDER.ordinal(), + final int w = 120; + final int h = 20; + int f = TileForester.Fields.REDSTONE.ordinal(); + btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos())); + y += h; + f = TileForester.Fields.RENDER.ordinal(); + btnRender = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); - int w = 110; - int h = 18; - int f = TileForester.Fields.HEIGHT.ordinal(); - x += 28; - y += 12; + x += 30; + y += 36; + f = TileForester.Fields.HEIGHT.ordinal(); heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, TileForester.Fields.HEIGHT.ordinal(), menu.tile.getBlockPos(), 0, TileForester.MAX_HEIGHT, menu.tile.getField(f))); // + y += h + 4; f = TileForester.Fields.SIZE.ordinal(); - y += 20; size = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 0, 10, menu.tile.getField(f))); } diff --git a/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java index fcf5d1a64..61d19de43 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java @@ -27,33 +27,33 @@ public ScreenHarvester(ContainerHarvester screenContainer, Inventory inv, Compon public void init() { super.init(); this.energy = new EnergyBar(this.font, TileHarvester.MAX_ENERGY); - int x, y; energy.guiLeft = leftPos; energy.guiTop = topPos; energy.visible = TileHarvester.POWERCONF.get() > 0; - x = leftPos + 6; - y = topPos + 6; - btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, TileHarvester.Fields.REDSTONE.ordinal(), menu.tile.getBlockPos())); + int x = leftPos + 6; + int y = topPos + 6; + final int w = 120; + final int h = 20; + int f = TileHarvester.Fields.REDSTONE.ordinal(); + btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos())); y += 20; - btnRender = addRenderableWidget(new ButtonMachineField(x, y, TileHarvester.Fields.RENDER.ordinal(), + f = TileHarvester.Fields.RENDER.ordinal(); + btnRender = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); // - int f = TileHarvester.Fields.DIRECTION.ordinal(); - y += 20; + y += h; + f = TileHarvester.Fields.DIRECTION.ordinal(); btnDirection = addRenderableWidget(new ButtonMachineField(x, y, f, menu.tile.getBlockPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); - int w = 110; - int h = 18; //now start sliders // - y = topPos + 22; - x = leftPos + 34; + y = topPos + 30; + x = leftPos + 36; f = TileHarvester.Fields.HEIGHT.ordinal(); - heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, TileHarvester.Fields.HEIGHT.ordinal(), menu.tile.getBlockPos(), - 0, TileHarvester.MAX_HEIGHT, menu.tile.getField(f))); + heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 0, TileHarvester.MAX_HEIGHT, menu.tile.getField(f))); heightslider.setTooltip("buildertype.height.tooltip"); + y += h + 4; f = TileHarvester.Fields.SIZE.ordinal(); - y += 26; size = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 0, TileHarvester.MAX_SIZE, menu.tile.getField(f))); } diff --git a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java index 26a7c2d4f..74b08d6a9 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java @@ -73,7 +73,10 @@ public void tick() { //then pull from hopper facey side Direction exportToSide = this.getBlockState().getValue(BlockFluidHopper.FACING); if (exportToSide != null && exportToSide != Direction.UP) { + //if the target is a tank moveFluids(exportToSide, worldPosition.relative(exportToSide), FLOW, tank); + //if the target is a cauldron + FluidHelpers.insertSourceCauldron(level, worldPosition.relative(exportToSide), tank); this.updateComparatorOutputLevel(); this.updateComparatorOutputLevelAt(worldPosition.relative(exportToSide)); } diff --git a/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java index 96eef789e..a9d705597 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java @@ -43,14 +43,14 @@ public void init() { // int w = 120; int h = 20; - x = leftPos + 32; - y += h + 1; + x = leftPos + 30; + y += h + 4; // height fi f = TileMiner.Fields.HEIGHT.ordinal(); GuiSliderInteger heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 0, TileMiner.MAX_HEIGHT, menu.tile.getField(f))); heightslider.setTooltip("buildertype.height.tooltip"); - y += h + 1; + y += h + 4; // f = TileMiner.Fields.SIZE.ordinal(); sizeSlider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), diff --git a/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java b/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java index aab1ddddb..52ccd5076 100644 --- a/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java +++ b/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java @@ -437,21 +437,18 @@ private static void initConfig() { CABLE_FACADES = CFG.comment("\r\n Allow cables to have blocks placed in them as facades (sneak-left-click to set; use empty hand to remove). Set to false to disable facades") .define("cables.enabled", true); //a few default - List list = Arrays.asList("minecraft:ladder", "minecraft:double_plant", "minecraft:waterlily", + List list = Arrays.asList("minecraft:double_plant", "minecraft:waterlily", "minecraft:torch", "minecraft:*_torch", "minecraft:redstone", "minecraft:iron_bars", "minecraft:chest", "minecraft:ender_chest", "minecraft:sculk_vein", "minecraft:string", "minecraft:vine", - "minecraft:rail", - "minecraft:*_rail", "minecraft:brewing_stand", "minecraft:*_dripleaf", "minecraft:*_pane", "minecraft:*_sapling", "minecraft:*_sign", "minecraft:*_door", "minecraft:*_banner", "minecraft:*_shulker_box", - "cyclic:*_pipe", "cyclic:*_bars", "storagenetwork:*"); - FACADE_IGNORELIST = CFG.comment("\r\n These blocks are not allowed to be used as Facades for blocks because they look weird (used by cables and Glowstone Facade and Soundproofing Facade and others)") - .define("itemsNotAllowed", list); + FACADE_IGNORELIST = CFG.comment("\r\n These blocks are not allowed to be used as Facades for blocks because they look weird (used by cables and Glowstone Facade and Soundproofing Facade and others). If you want to ignore one entire mod use an entry like this : storagenetwork:* ") + .defineList("itemsNotAllowed", list, it -> it instanceof String); CFG.pop(); // TRANSFER_NODES_DIMENSIONAL = CFG.comment(" Allows the dimensional Transfer Nodes to cross dimensions " @@ -655,6 +652,11 @@ public static List getGloomIgnoreList() { return (List) GLOOM_IGNORE_LIST.get(); } + @SuppressWarnings("unchecked") + public static List getFacadeIgnoreList() { + return (List) FACADE_IGNORELIST.get(); + } + public static Map getMappedBeheading() { Map mappedBeheading = new HashMap(); for (String s : BEHEADING_SKINS.get()) { @@ -672,11 +674,11 @@ public static Map getMappedBeheading() { } public static BooleanValue CABLE_FACADES; - private static ConfigValue> FACADE_IGNORELIST; + private static ConfigValue> FACADE_IGNORELIST; public static boolean isFacadeAllowed(ItemStack item) { ResourceLocation itemId = ForgeRegistries.ITEMS.getKey(item.getItem()); - if (StringParseUtil.isInList(FACADE_IGNORELIST.get(), itemId)) { + if (StringParseUtil.isInList(getFacadeIgnoreList(), itemId)) { return false; } return true; diff --git a/src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java b/src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java index 91b7abfe0..573e6de72 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java +++ b/src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java @@ -33,30 +33,17 @@ public GuiSliderInteger(int x, int y, int width, int height, int field, this.pos = pos; this.min = min; this.max = max; - setSliderValueActual((int) initialVal); + setSliderPercentageOfMax((int) initialVal); + this.updateMessage(); + } + + public double getSliderValue() { + return this.value; // sliderValue + } + + public int getField() { + return this.field; } - /** - * exact copy of super() but replaced hardcoded 20 with this.height - */ - // @Override - // protected void renderWidget(PoseStack matrixStack, Minecraft minecraft, int mouseX, int mouseY) { - // // minecraft.getTextureManager().bind(WIDGETS_LOCATION); - // RenderSystem.setShader(GameRenderer::getPositionTexShader); - // RenderSystem.setShaderTexture(0, WIDGETS_LOCATION); - // RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - // int i = (this.isHovered ? 2 : 1) * 20; - // if (this.height != 20) { - // this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i + 20 - this.height, 4, this.height); - // this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i + 20 - this.height, 4, this.height); - // int height = this.height - 2; - // this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i, 4, height); - // this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, height); - // } - // else { - // this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i, 4, this.height); - // this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, this.height); - // } - // } /** * Call from Screen class to render tooltip during mouseover @@ -87,8 +74,7 @@ public void addTooltip(String ttIn) { @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { if (delta != 0) { - setSliderValueActual(this.getSliderValueActual() + (int) delta); - this.updateMessage(); + moveSliderAndUpdate((int) delta); return true; } return super.mouseScrolled(mouseX, mouseY, delta); @@ -116,8 +102,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { else if (Screen.hasAltDown()) { delta = delta * 10; } - setSliderValueActual(this.getSliderValueActual() + delta); - this.updateMessage(); + moveSliderAndUpdate(delta); return true; } return super.keyPressed(keyCode, scanCode, modifiers); @@ -127,43 +112,49 @@ else if (Screen.hasAltDown()) { * Refresh display message */ @Override - protected void updateMessage() { - int val = getSliderValueActual(); + protected void updateMessage() { // func_230972_a_(); + int val = getSliderAsInteger(); this.setMessage(Component.translatable("" + val)); } /** - * SAVE to tile entity with packet + * Save to tile entity with packet */ @Override - protected void applyValue() { - int val = getSliderValueActual(); + protected void applyValue() { // func_230979_b_(); + int val = getSliderAsInteger(); PacketRegistry.INSTANCE.sendToServer(new PacketTileData(this.field, val, pos)); } @Override protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) { - // this.changeSliderValueActual(mouseX); super.onDrag(mouseX, mouseY, dragX, dragY); - // ("ondrag" + mouseX); applyValue(); updateMessage(); } /** - * Set inner [0,1] value relative to maximum and trigger save/ & refresh + * clamp sliderValue to an integer between min and max */ - private void setSliderValueActual(int val) { - this.value = val / max; - this.updateMessage(); - this.applyValue(); + public int getSliderAsInteger() { + return Mth.floor(Mth.clampedLerp(min, max, this.value)); } - public int getSliderValueActual() { - return Mth.floor(Mth.clampedLerp(min, max, this.value)); + /** + * move position by delta and save and refresh. adds delta to integer version of slider value and sends both updates + * + * @param delta + */ + private void moveSliderAndUpdate(int delta) { + setSliderPercentageOfMax(this.getSliderAsInteger() + delta); + this.updateMessage(); + this.applyValue(); } - public int getField() { - return this.field; + /** + * Set inner [0,1] value relative to maximum and trigger save/ & refresh + */ + private void setSliderPercentageOfMax(int val) { + this.value = val / max; } } diff --git a/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java b/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java index 325deabe8..0737a2b79 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java +++ b/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java @@ -7,6 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.renderer.GameRenderer; @@ -97,4 +98,17 @@ public void drawButtonTooltips(GuiGraphics gg, int mouseX, int mouseY) { } } } + + /** + * Propogate mouse drag events down to slider widgets + */ + @Override + public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) { + for (GuiEventListener btn : this.children()) { + if (btn.isMouseOver(mouseX, mouseY) && btn instanceof AbstractSliderButton) { + ((AbstractSliderButton) btn).mouseDragged(mouseX, mouseY, button, dragX, dragY); + } + } + return super.mouseDragged(mouseX, mouseY, button, dragX, dragY); + } } diff --git a/src/main/java/com/lothrazar/cyclic/registry/TextureRegistry.java b/src/main/java/com/lothrazar/cyclic/registry/TextureRegistry.java index 09416a058..d3d8e9ded 100644 --- a/src/main/java/com/lothrazar/cyclic/registry/TextureRegistry.java +++ b/src/main/java/com/lothrazar/cyclic/registry/TextureRegistry.java @@ -12,6 +12,7 @@ public class TextureRegistry { public static final ResourceLocation INVENTORY_PLAIN = new ResourceLocation(ModCyclic.MODID, "textures/gui/inventory_plain.png"); public static final ResourceLocation INVENTORY_LARGE = new ResourceLocation(ModCyclic.MODID, "textures/gui/inventory_large.png"); public static final ResourceLocation INVENTORY_LARGE_PLAIN = new ResourceLocation(ModCyclic.MODID, "textures/gui/inventory_large_plain.png"); + public static final ResourceLocation INVENTORY_MEDIUM = new ResourceLocation(ModCyclic.MODID, "textures/gui/inventory_medium.png"); // 176x214 public static final ResourceLocation INVENTORY_SOUND = new ResourceLocation(ModCyclic.MODID, "textures/gui/inventory_sound.png"); public static final ResourceLocation SLOT = new ResourceLocation(ModCyclic.MODID, "textures/gui/slot.png"); public static final ResourceLocation SLOT_CHARGE = new ResourceLocation(ModCyclic.MODID, "textures/gui/slot_charge.png"); diff --git a/src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java b/src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java index b2e8e3397..570d5efb4 100644 --- a/src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java +++ b/src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java @@ -19,6 +19,7 @@ import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LayeredCauldronBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -42,6 +43,17 @@ public class FluidHelpers { public static final FluidRenderMap> CACHED_FLUIDS = new FluidRenderMap<>(); public static final int STAGES = 1400; + public static class FluidAttributes { + + public static final int BUCKET_VOLUME = net.minecraftforge.fluids.FluidType.BUCKET_VOLUME; + } + + /** + * maps fluid to colour hex code as int value. Used by itemstack durability bar on filled held tanks + * + * @param fstack + * @return + */ public static int getColorFromFluid(FluidStack fstack) { if (fstack != null && fstack.getFluid() != null) { //first check mine @@ -59,10 +71,7 @@ else if (fstack.getFluid() == FluidSlimeHolder.STILL.get()) { } else if (fstack.getFluid() == FluidXpJuiceHolder.STILL.get()) { return FluidXpJuiceHolder.COLOR; - } //now check if the fluid has a color - // else if (fstack.getFluid().getAttributes().getColor() > 0) { - // return fstack.getFluid().getAttributes().getColor(); - // } + } else if (fstack.getFluid() == ForgeMod.MILK.get()) { return COLOUR_MILK; } @@ -73,11 +82,59 @@ else if (fstack.getFluid() == Fluids.LAVA) { return COLOUR_DEFAULT; } - public static class FluidAttributes { - - public static final int BUCKET_VOLUME = net.minecraftforge.fluids.FluidType.BUCKET_VOLUME; + /** + * Internally knows that water cauldrons fil to level 3, but lava cauldrons are a different block without the level property. + * + * Ignores partially filled water cauldrons. + * + * a full cauldron is 1000mb + * + * @param level + * @param posTarget + * where the cauldron exists + * @param tank + * of myself that i want to extract frm for the target + * @return + */ + public static boolean insertSourceCauldron(Level level, BlockPos posTarget, IFluidHandler tank) { + //for mc 1.16.5 cauldrons only allow water. lava cauldron added in 1.17 and levels blockstate removed + BlockState targetState = level.getBlockState(posTarget); + if (targetState.getBlock() == Blocks.CAULDRON) { + //cauldron is hardcoded mojang with two fluids + FluidStack simulate = tank.drain(new FluidStack(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.SIMULATE); + if (simulate.getAmount() == FluidAttributes.BUCKET_VOLUME) { + //we are able to fill the tank + if (level.setBlock(posTarget, Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), 3)) { + //we filled the cauldron, so now drain with execute + tank.drain(new FluidStack(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.EXECUTE); + return true; + } + } + //try the same thing with lava + simulate = tank.drain(new FluidStack(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.SIMULATE); + if (simulate.getAmount() == FluidAttributes.BUCKET_VOLUME) { + //we are able to fill the tank + if (level.setBlock(posTarget, Blocks.LAVA_CAULDRON.defaultBlockState(), 3)) { + //we filled the cauldron, so now drain with execute + tank.drain(new FluidStack(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.EXECUTE); + return true; + } + } + } + return false; } + /** + * Internally knows that water cauldrons fil to level 3, but lava cauldrons are a different block without the level property. + * + * Ignores partially filled water cauldrons. + * + * a full cauldron is 1000mb + * + * @param level + * @param posTarget + * @param tank + */ public static void extractSourceWaterloggedCauldron(Level level, BlockPos posTarget, IFluidHandler tank) { if (tank == null) { return; @@ -94,7 +151,7 @@ public static void extractSourceWaterloggedCauldron(Level level, BlockPos posTar tank.fill(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAction.EXECUTE); } } - else if (targetState.getBlock() == Blocks.WATER_CAULDRON) { + else if (targetState.getBlock() == Blocks.WATER_CAULDRON && targetState.getValue(LayeredCauldronBlock.LEVEL) >= 3) { int simFill = tank.fill(new FluidStack(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.SIMULATE); if (simFill == FluidAttributes.BUCKET_VOLUME && level.setBlockAndUpdate(posTarget, Blocks.CAULDRON.defaultBlockState())) { diff --git a/src/main/resources/assets/cyclic/lang/en_us.json b/src/main/resources/assets/cyclic/lang/en_us.json index 7f6d19e82..5eda64ec4 100644 --- a/src/main/resources/assets/cyclic/lang/en_us.json +++ b/src/main/resources/assets/cyclic/lang/en_us.json @@ -384,7 +384,7 @@ "block.cyclic.breaker": "Block Breaker", "block.cyclic.breaker.tooltip": "Breaks blocks placed in front of it", "block.cyclic.breaker.guide": "Breakers can be used to break the block placed directly in front of it, like a player would.Breakers do not have internal item storage, so the broken block will drop itself (or its loot) in the world to be picked up.", - "item.cyclic.rotation_wand": "Block Rotatator", + "item.cyclic.rotation_wand": "Block Rotator", "item.cyclic.rotation_wand.tooltip": "Rotates simple blocks", "item.cyclic.rotation_wand.guide": "Its not really a wrench, see the data tags. This sipmle tool can be used to rotate simple blocks such as stairs, slabs, and similar compatible blocks that face certain directions. Try hitting blocks from different angles", "item.cyclic.cable_wrench": "Wrench", @@ -1446,7 +1446,6 @@ "item.minecraft.lingering_potion.effect.cyclic_reach_distance": "Lingering Potion of Reach Distance", "item.minecraft.tipped_arrow.effect.cyclic_reach_distance": "Arrow of Reach Distance", - "effect.cyclic.haste": "Haste", "item.minecraft.potion.effect.cyclic_haste": "Potion of Haste", "item.minecraft.splash_potion.effect.cyclic_haste": "Splash Potion of Haste", diff --git a/src/main/resources/assets/cyclic/textures/gui/inventory_medium.png b/src/main/resources/assets/cyclic/textures/gui/inventory_medium.png new file mode 100644 index 000000000..e1365b398 Binary files /dev/null and b/src/main/resources/assets/cyclic/textures/gui/inventory_medium.png differ diff --git a/update.json b/update.json index 81bf82d7f..4f87af7f7 100644 --- a/update.json +++ b/update.json @@ -184,7 +184,7 @@ ,"1.12.16":"Merge pull request #2438 from gavinwie: Fixed Filter Data Card Issues #2423, #2370, #2355, and #2330." ,"1.12.17":"Fix Game crashed after placing soundproofing facade on energy cable #2440 " - ,"1.13.0":"Added an optional item slot in the Block Breaker using the BlockState Data Card so players have the option to limit the block breaker to only the targets listed in the data card. Add new block data tags cyclic:ignored/breaker and cyclic:ignored/miner so that pack devs can customize these machines to not break certain blocks (regardless of hardness). Many blocks now allow minecraft:comparator to pull a redstone signal based on inventory contents (most machines and blocks that have inventory). Fluid collector will now place air and scoop up the fluid if the itemslot is empty. New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). Several blocks added to block-tag mineable/pickaxe (thanks to darkosto) " + ,"1.13.0":"Add mouse-dragging capability to the slider controls in machines. Fluid Hoppers can now insert into cauldrons. Backport #2399 Dry Peat Bog can now hydrate from waterlogged blocks such as scaffolding. Fix spelling #2435. Clock gui-screen size reduced from large to normal. Added an optional item slot in the Block Breaker using the BlockState Data Card so players have the option to limit the block breaker to only the targets listed in the data card. Add new block data tags cyclic:ignored/breaker and cyclic:ignored/miner so that pack devs can customize these machines to not break certain blocks (regardless of hardness). Many blocks now allow minecraft:comparator to pull a redstone signal based on inventory contents (most machines and blocks that have inventory). Fluid collector will now place air and scoop up the fluid if the itemslot is empty. New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). Backported machine feature 'Preview Outline' mode on machines that already have the button. Several blocks added to block-tag mineable/pickaxe (thanks to darkosto) " }