diff --git a/scripts/release.sh b/scripts/release.sh index 6ce083db8..b6bf81a0e 100644 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,3 +1,14 @@ #!/bin/bash +echo 'updating example configs...' + +cp ./run/config/cyclic.toml ./examples/config/cyclic.toml +cp ./run/config/cyclic-client.toml ./examples/config/cyclic-client.toml + +echo '... done' + +echo 'deploying...' + ./gradlew cleanJar build signJar + +echo 'jar deployed to ./build/libs/' diff --git a/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java b/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java index 7ab980173..0cea79816 100644 --- a/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java +++ b/src/main/java/com/lothrazar/cyclic/block/PeatBlock.java @@ -8,9 +8,9 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; public class PeatBlock extends BlockCyclic { @@ -32,8 +32,10 @@ public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random List waters = new ArrayList<>(); for (BlockPos p : around) { //try to bake if SOURCE water is nearby - Block bSide = world.getBlockState(p).getBlock(); - if (bSide == Blocks.WATER) { + //using FluidState instead of Block + //backport fix from this PR by PocketSizedWeeb https://github.com/Lothrazar/Cyclic/pull/2404/files#diff-75c5d8aa746dbf1c0a18dfd3f48a80408e4191eb536ea0566c243038eaf05269 + FluidState fluid = world.getFluidState(p); + if (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 a956e1bae..5fb04aa71 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(PoseStack ms, int mouseX, int mouseY) { @Override protected void renderBg(PoseStack 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 042056084..6f352fbda 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 74da5d9ff..a131854ea 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,33 +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")) - // .setSize(18) - ; + 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")) - //.setSize(18) - ; - int w = 110; - int h = 18; + menu.tile.getBlockPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); + 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"); @@ -81,7 +77,7 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { @Override protected void renderBg(PoseStack 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 787d40ce8..007222607 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.cyclic.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 6b9b7ceed..32b0791a4 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 1987a8adf..a31994cdf 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 bc382ea5f..3774cf861 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 @Override public void init() { super.init(); - 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 a1de45f2b..924d56273 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 @Override public void init() { super.init(); - 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 437d06bc7..7bb47f571 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 31b3cc2ba..b1eb1e729 100644 --- a/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java +++ b/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java @@ -410,21 +410,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 " @@ -639,6 +636,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()) { @@ -656,11 +658,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 9a67938cc..1f0b5bacd 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java +++ b/src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java @@ -33,31 +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(); } - /** - * 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); - // } - // } + public double getSliderValue() { + return this.value; // sliderValue + } + + public int getField() { + return this.field; + } /** * Call from Screen class to render tooltip during mouseover */ @@ -87,8 +73,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 +101,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 +111,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 ce9c116a1..0981d100f 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java +++ b/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java @@ -8,6 +8,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -106,4 +107,17 @@ public void drawButtonTooltips(PoseStack ms, 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 051eaba79..d9d36e24b 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 abc250dcb..bf310191b 100644 --- a/src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java +++ b/src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java @@ -20,6 +20,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; @@ -43,6 +44,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 @@ -60,10 +72,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; } @@ -74,11 +83,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; @@ -95,7 +152,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 19865fec1..0c01aae11 100644 --- a/src/main/resources/assets/cyclic/lang/en_us.json +++ b/src/main/resources/assets/cyclic/lang/en_us.json @@ -383,7 +383,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", @@ -1439,7 +1439,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 fdd26a0ae..0e4299979 100644 --- a/update.json +++ b/update.json @@ -90,6 +90,7 @@ + }, "1.18.2": { "1.6.0": "Ported Cyclic[1.16.5]-1.5.8 to Minecraft [1.17.1] & forge-37.0.85+. Altered a few crafting recipes to use new items. Removed Peat Generator (Use Peat items in Material Generator). Removed 5 Mason blocks, replaced with Compressed Cobblestone, Flint Block. Added Peace Candle, Translocation Platform, Stone Mattock, Crushing Macerator, and Lava Sponge. Added Copper Tools and Amethyst Tools, Copper Lantern, Copper Chain, Copper Bars, Gold Chain, Gold Bars, Gold Lantern (Art by @shynieke). Added Copper Nuggets and Netherite Nuggets. Added Netherite Lanterns, chains, and bars. Added 3 Pressure Plates: Copper Netherite and Obsidian. ", @@ -171,8 +172,7 @@ ,"1.10.6":"Backport Mud block solidifier recipe. Fixed bug in the item cyclic:offset_scepter #2427. Tweaked block model visuals of the Transfer Nodes. Fix Mattock not saving contents of Shulker Boxes when mined #2411. Add recipes in the solidifier machine for Waxed copper blocks " - - ,"1.11.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). Backported machine feature 'Preview Outline' mode on machines that already have the button. Backported cable (fluid & energy) buffer and flow speed configs from 1.20.1. Facades overhaul backported from 1.20.1: Renamed 'Concentrated Glowstone' to 'Glowstone Facade' and 'Concentrated Soundproofing' to 'Soundproofing Facade' . Backport cable facades from 1.20.1 (New feature with cables: hide them using solid blocks with a feature called 'facades', just sneak-left-click a block onto the cable; empty hand to remove it) " + ,"1.11.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. Backported cable (fluid & energy) buffer and flow speed configs from 1.20.1. Facades overhaul backported from 1.20.1: Renamed 'Concentrated Glowstone' to 'Glowstone Facade' and 'Concentrated Soundproofing' to 'Soundproofing Facade' . Backport cable facades from 1.20.1 (New feature with cables: hide them using solid blocks with a feature called 'facades', just sneak-left-click a block onto the cable; empty hand to remove it) " } }