From d08f53b8871fa5c34d4e7bd4871edca2df8f30df Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sat, 19 Oct 2024 10:51:56 -0700 Subject: [PATCH 1/5] feature more blocks with vertical facings --- .../lothrazar/cyclic/base/TileEntityBase.java | 21 +++++++ .../block/collectfluid/BlockFluidCollect.java | 4 +- .../block/collectfluid/TileFluidCollect.java | 35 +++++++---- .../block/collectitem/BlockItemCollector.java | 6 +- .../block/collectitem/TileItemCollector.java | 26 ++++---- .../cyclic/block/dropper/BlockDropper.java | 4 +- .../cyclic/block/forester/BlockForester.java | 4 +- .../cyclic/block/forester/ScreenForester.java | 26 ++++++-- .../cyclic/block/forester/TileForester.java | 60 +++++++++++-------- .../block/harvester/BlockHarvester.java | 4 +- .../block/harvester/ScreenHarvester.java | 21 ++++--- .../cyclic/block/harvester/TileHarvester.java | 32 ++++++---- .../cyclic/block/miner/BlockMiner.java | 4 +- .../cyclic/block/miner/ScreenMiner.java | 1 + .../cyclic/block/miner/TileMiner.java | 30 ++++++---- .../lothrazar/cyclic/util/UtilItemStack.java | 2 +- .../assets/cyclic/blockstates/collector.json | 8 ++- .../cyclic/blockstates/collector_fluid.json | 8 ++- .../assets/cyclic/blockstates/dropper.json | 8 ++- .../assets/cyclic/blockstates/forester.json | 8 ++- .../assets/cyclic/blockstates/harvester.json | 8 ++- .../assets/cyclic/blockstates/miner.json | 8 ++- .../models/block/collector_fluid_up.json | 7 +++ .../models/block/collector_fluid_up_on.json | 7 +++ .../cyclic/models/block/collector_up.json | 7 +++ .../cyclic/models/block/collector_up_on.json | 7 +++ .../cyclic/models/block/dropper_up.json | 7 +++ .../cyclic/models/block/dropper_up_on.json | 7 +++ .../cyclic/models/block/forester_up.json | 7 +-- .../cyclic/models/block/forester_up_on.json | 9 +-- .../cyclic/models/block/harvester_up.json | 7 +-- .../cyclic/models/block/harvester_up_on.json | 9 +-- .../assets/cyclic/models/block/miner_up.json | 7 +++ .../cyclic/models/block/miner_up_on.json | 7 +++ update.json | 1 + 35 files changed, 292 insertions(+), 125 deletions(-) create mode 100644 src/main/resources/assets/cyclic/models/block/collector_fluid_up.json create mode 100644 src/main/resources/assets/cyclic/models/block/collector_fluid_up_on.json create mode 100644 src/main/resources/assets/cyclic/models/block/collector_up.json create mode 100644 src/main/resources/assets/cyclic/models/block/collector_up_on.json create mode 100644 src/main/resources/assets/cyclic/models/block/dropper_up.json create mode 100644 src/main/resources/assets/cyclic/models/block/dropper_up_on.json create mode 100644 src/main/resources/assets/cyclic/models/block/miner_up.json create mode 100644 src/main/resources/assets/cyclic/models/block/miner_up_on.json diff --git a/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java index dc66c6401c..4c35874c11 100644 --- a/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java +++ b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java @@ -190,6 +190,21 @@ public void setLitProperty(boolean lit) { } } + // was getTargetCenter + protected BlockPos getFacingShapeCenter(int radiusIn) { + BlockPos center = null; + if (this.getCurrentFacing() != null) { + if (this.getCurrentFacing().getAxis().isVertical()) { + //vertical center point + center = this.getCurrentFacingPos(1); + } + else { //horizontal center point + center = this.getCurrentFacingPos(radiusIn + 1); + } + } + return center; + } + public Direction getCurrentFacing() { if (this.getBlockState().hasProperty(BlockStateProperties.FACING)) { return this.getBlockState().get(BlockStateProperties.FACING); @@ -588,4 +603,10 @@ public void exportEnergyAllSides() { moveEnergy(exportToSide, MENERGY / 2); } } + + public boolean getBlockStateVertical() { + if (this.getBlockState().hasProperty(BlockStateProperties.FACING)) + return this.getBlockState().get(BlockStateProperties.FACING).getAxis().isVertical(); + return false; + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java index 879b749415..7b81a0ff76 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java @@ -43,12 +43,12 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlockState(pos, state.with(BlockStateProperties.HORIZONTAL_FACING, UtilBlockstates.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlockState(pos, state.with(BlockStateProperties.FACING, UtilBlockstates.getFacingFromEntity(pos, entity)), 2); } } @Override protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(BlockStateProperties.HORIZONTAL_FACING).add(LIT); + builder.add(BlockStateProperties.FACING).add(LIT); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java index 103ef199b5..999b7a737d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java @@ -16,6 +16,7 @@ import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -49,7 +50,7 @@ static enum Fields { FluidTankBase tank; private final LazyOptional tankWrapper = LazyOptional.of(() -> tank); private int shapeIndex = 0; // current index of shape array - private int size = 4 * 2; + private int radius = 4 * 2; private int height = 4; BlockPos targetPos = null; static final int MAX = 64000; @@ -125,16 +126,23 @@ public AxisAlignedBB getRenderBoundingBox() { return TileEntity.INFINITE_EXTENT_AABB; } - private BlockPos getTargetCenter() { - //move center over that much, not including exact horizontal - return this.getCurrentFacingPos(size + 1); //this.getPos().offset(this.getCurrentFacing(), size + 1); + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().get(BlockStateProperties.FACING); + int diff = 1; // directionIsUp ? 1 : -1; + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; + } + return diff * height; } //for render public List getShapeHollow() { - BlockPos ctr = getTargetCenter(); - List shape = UtilShape.squareHorizontalHollow(ctr.down(height), this.size); - shape = UtilShape.repeatShapeByHeight(shape, height); + BlockPos center = getFacingShapeCenter(radius); + int heightWithDirection = heightWithDirection(); + List shape = UtilShape.squareHorizontalHollow(center.down(height), this.radius); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); + } if (targetPos != null) { shape.add(targetPos); } @@ -143,9 +151,12 @@ public List getShapeHollow() { //for harvest public List getShapeFilled() { - BlockPos ctr = getTargetCenter(); - List shape = UtilShape.squareHorizontalFull(ctr.down(height), this.size); - shape = UtilShape.repeatShapeByHeight(shape, height - 1); + BlockPos center = getFacingShapeCenter(radius); + int heightWithDirection = heightWithDirection(); + List shape = UtilShape.squareHorizontalFull(center, this.radius); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); + } return shape; } @@ -221,7 +232,7 @@ public void setField(int field, int value) { height = Math.min(value, MAX_HEIGHT); break; case SIZE: - size = Math.min(value, MAX_SIZE); + radius = Math.min(value, MAX_SIZE); break; } } @@ -236,7 +247,7 @@ public int getField(int field) { case HEIGHT: return height; case SIZE: - return size; + return radius; } return 0; } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java index 3af2c4b8aa..025209d862 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java @@ -6,12 +6,12 @@ import com.lothrazar.cyclic.util.UtilBlockstates; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; import net.minecraft.block.SoundType; import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; @@ -28,13 +28,13 @@ public BlockItemCollector(Properties properties) { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlockState(pos, state.with(HorizontalBlock.HORIZONTAL_FACING, UtilBlockstates.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlockState(pos, state.with(BlockStateProperties.FACING, UtilBlockstates.getFacingFromEntity(pos, entity)), 2); } } @Override protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(HorizontalBlock.HORIZONTAL_FACING).add(LIT); + builder.add(BlockStateProperties.FACING).add(LIT); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java index b86b41821b..04ae62da63 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java @@ -14,6 +14,7 @@ import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; @@ -131,25 +132,30 @@ public CompoundNBT write(CompoundNBT tag) { return super.write(tag); } - private BlockPos getTargetCenter() { - // move center over that much, not including exact horizontal - return this.getPos().offset(this.getCurrentFacing(), radius + 1); + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().get(BlockStateProperties.FACING); + int diff = directionIsUp ? 1 : -1; + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; + } + return diff * height; } public List getShape() { - List shape = UtilShape.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), radius); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = UtilShape.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } return shape; } private AxisAlignedBB getRange() { - BlockPos center = getTargetCenter(); - int diff = directionIsUp ? 1 : -1; + BlockPos center = getFacingShapeCenter(radius); + int heightWithDirection = heightWithDirection(); int yMin = center.getY(); - int yMax = center.getY() + diff * height; + int yMax = center.getY() + heightWithDirection; //for some reason if (!directionIsUp) { // when aiming down, we dont have the offset to get [current block] without this 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 20093f9197..4ceaae9c04 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java @@ -43,12 +43,12 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlockState(pos, state.with(BlockStateProperties.HORIZONTAL_FACING, UtilBlockstates.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlockState(pos, state.with(BlockStateProperties.FACING, UtilBlockstates.getFacingFromEntity(pos, entity)), 2); } } @Override protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(BlockStateProperties.HORIZONTAL_FACING).add(LIT); + builder.add(BlockStateProperties.FACING).add(LIT); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java index b958042ca1..cf3bd23beb 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java @@ -43,12 +43,12 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlockState(pos, state.with(BlockStateProperties.HORIZONTAL_FACING, UtilBlockstates.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlockState(pos, state.with(BlockStateProperties.FACING, UtilBlockstates.getFacingFromEntity(pos, entity)), 2); } } @Override protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(BlockStateProperties.HORIZONTAL_FACING).add(LIT); + builder.add(BlockStateProperties.FACING).add(LIT); } } 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 00997e68b3..b6ae4b7ba5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java @@ -1,6 +1,7 @@ package com.lothrazar.cyclic.block.forester; import com.lothrazar.cyclic.base.ScreenBase; +import com.lothrazar.cyclic.block.harvester.TileHarvester; import com.lothrazar.cyclic.data.Const; import com.lothrazar.cyclic.gui.ButtonMachineField; import com.lothrazar.cyclic.gui.EnergyBar; @@ -17,6 +18,7 @@ public class ScreenForester extends ScreenBase { private ButtonMachineField btnRedstone; private EnergyBar energy; private GuiSliderInteger size; + private GuiSliderInteger heightslider; public ScreenForester(ContainerForester screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); @@ -36,10 +38,16 @@ public void init() { y += 20; btnRender = addButton(new ButtonMachineField(x, y, TileForester.Fields.RENDER.ordinal(), container.tile.getPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); - int w = 110; - int h = 18; - int f = TileForester.Fields.SIZE.ordinal(); - x += 28; + final int w = 110; + final int h = 18; + int f = TileForester.Fields.HEIGHT.ordinal(); + x = guiLeft + 34; + y = guiTop + 38; + heightslider = this.addButton(new GuiSliderInteger(x, y, w, h, TileForester.Fields.HEIGHT.ordinal(), container.tile.getPos(), + 0, TileHarvester.MAX_HEIGHT, container.tile.getField(f))); + // + f = TileForester.Fields.SIZE.ordinal(); + // x += 28; y += 20; size = this.addButton(new GuiSliderInteger(x, y, w, h, f, container.tile.getPos(), 0, 10, container.tile.getField(f))); } @@ -58,6 +66,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m this.drawName(ms, this.title.getString()); btnRedstone.onValueUpdate(container.tile); btnRender.onValueUpdate(container.tile); + heightslider.setTooltip("buildertype.height.tooltip"); size.setTooltip("cyclic.screen.size" + container.tile.getField(size.getField())); } @@ -65,7 +74,14 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int mouseX, int mouseY) { this.drawBackground(ms, TextureRegistry.INVENTORY); int relX = this.getXSize() / 2 - 9; - this.drawSlot(ms, relX, 24, TextureRegistry.SLOT_SAPLING, Const.SQ); + int y = 16; + // + if (container.tile.hasSapling()) { + this.drawSlot(ms, relX, y); + } + else { + this.drawSlot(ms, relX, y, TextureRegistry.SLOT_SAPLING, Const.SQ); + } energy.draw(ms, container.getEnergy()); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java index 96d943e70e..7cccdf18ed 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -6,7 +6,6 @@ import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -19,6 +18,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tags.BlockTags; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; @@ -43,7 +43,7 @@ public class TileForester extends TileEntityBase implements INamedContainerProvider, ITickableTileEntity { static enum Fields { - REDSTONE, RENDER, SIZE; + REDSTONE, RENDER, SIZE, HEIGHT; } static final int MAX = 64000; @@ -96,7 +96,6 @@ public void tick() { //update target shapeIndex++; BlockPos targetPos = getShapeTarget(shape); - skipSomeAirBlocks(shape); //only saplings at my level, the rest is harvesting try { if (fakePlayer == null && world instanceof ServerWorld) { @@ -111,13 +110,10 @@ public void tick() { } } else if (this.isSapling(dropMe)) { - //plant me . if im on the lowest level - if (targetPos.getY() == this.pos.getY()) { - ActionResultType result = TileEntityBase.rightClickBlock(fakePlayer, world, targetPos, Hand.OFF_HAND, Direction.DOWN); - if (result == ActionResultType.CONSUME) { - //ok then DRAIN POWER - energy.extractEnergy(cost, false); - } + ActionResultType result = TileEntityBase.rightClickBlock(fakePlayer, world, targetPos, Hand.OFF_HAND, Direction.DOWN); + if (result == ActionResultType.CONSUME) { + //ok then DRAIN POWER + energy.extractEnergy(cost, false); } } } @@ -193,16 +189,6 @@ private void equipTool() { } } - private void skipSomeAirBlocks(List shape) { - // int skipping = MAX_HEIGHT - 2; - // int i = 0; - // while (world.isAirBlock(targetPos) && i < skipping - // && targetPos.getY() > pos.getY()) { - // updateTargetPos(shape); - // i++; - // } - } - private BlockPos getShapeTarget(List shape) { if (this.shapeIndex < 0 || this.shapeIndex >= shape.size()) { this.shapeIndex = 0; @@ -210,16 +196,34 @@ private BlockPos getShapeTarget(List shape) { return shape.get(shapeIndex); } + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().get(BlockStateProperties.FACING); + int diff = 1;//directionIsUp ? 1 : -1; + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; + } + return diff * height; + } + //for harvest public List getShape() { - List shape = new ArrayList(); - shape = UtilShape.cubeSquareBase(this.getCurrentFacingPos(radius + 1), radius, height); + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.cubeSquareBase(center, radius, height); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); + } return shape; } //for render public List getShapeHollow() { - List shape = UtilShape.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), this.radius); + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.squareHorizontalHollow(center, radius); + // int heightWithDirection = heightWithDirection(); + // if (heightWithDirection != 0) { + // shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); + // } BlockPos targetPos = getShapeTarget(shape); if (targetPos != null) { shape.add(targetPos); @@ -228,7 +232,6 @@ public List getShapeHollow() { } private boolean isSapling(ItemStack dropMe) { - // if(dropMe.getItem().isIn(Tags.Blocks.SAND)) //sapling tag SHOULD exist. it doesnt. idk WHY Block block = Block.getBlockFromItem(dropMe.getItem()); return block.isIn(BlockTags.SAPLINGS) || @@ -253,6 +256,8 @@ public int getField(int id) { return render; case SIZE: return radius; + case HEIGHT: + return height; } return 0; } @@ -269,6 +274,13 @@ public void setField(int id, int value) { case SIZE: radius = value % MAX_SIZE; break; + case HEIGHT: + this.height = value & MAX_HEIGHT; + break; } } + + public boolean hasSapling() { + return !this.inventory.getStackInSlot(0).isEmpty(); + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java index e5e5f03a47..bac594b3d2 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java @@ -43,12 +43,12 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlockState(pos, state.with(BlockStateProperties.HORIZONTAL_FACING, UtilBlockstates.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlockState(pos, state.with(BlockStateProperties.FACING, UtilBlockstates.getFacingFromEntity(pos, entity)), 2); } } @Override protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(BlockStateProperties.HORIZONTAL_FACING).add(LIT); + builder.add(BlockStateProperties.FACING).add(LIT); } } 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 69fd97f363..de59db8c71 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java @@ -15,8 +15,8 @@ public class ScreenHarvester extends ScreenBase { private EnergyBar energy; private ButtonMachineField btnRedstone; private ButtonMachineField btnRender; - private GuiSliderInteger size; private ButtonMachineField btnDirection; + private GuiSliderInteger size; private GuiSliderInteger heightslider; public ScreenHarvester(ContainerHarvester screenContainer, PlayerInventory inv, ITextComponent titleIn) { @@ -41,23 +41,21 @@ public void init() { int f = TileHarvester.Fields.DIRECTION.ordinal(); y += 20; btnDirection = addButton(new ButtonMachineField(x, y, f, - container.tile.getPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")) - //.setSize(18) - ; - int w = 110; - int h = 18; + container.tile.getPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); + btnDirection.visible = !container.tile.getBlockStateVertical(); + final int w = 110; + final int h = 18; //now start sliders // - y = guiTop + 22; + // + y = guiTop + 24; x = guiLeft + 34; f = TileHarvester.Fields.HEIGHT.ordinal(); heightslider = this.addButton(new GuiSliderInteger(x, y, w, h, TileHarvester.Fields.HEIGHT.ordinal(), container.tile.getPos(), 0, TileHarvester.MAX_HEIGHT, container.tile.getField(f))); - heightslider.setTooltip("buildertype.height.tooltip"); - // w = 130; - // int h = 18; + // f = TileHarvester.Fields.SIZE.ordinal(); - y += 26; + y += 28; size = this.addButton(new GuiSliderInteger(x, y, w, h, f, container.tile.getPos(), 0, TileHarvester.MAX_SIZE, container.tile.getField(f))); } @@ -74,6 +72,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m btnRedstone.onValueUpdate(container.tile); btnRender.onValueUpdate(container.tile); btnDirection.onValueUpdate(container.tile); + heightslider.setTooltip("buildertype.height.tooltip"); size.setTooltip("cyclic.screen.size" + container.tile.getField(size.getField())); this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, title.getString()); diff --git a/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java index 7079cfa294..cdef25772e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java @@ -12,6 +12,7 @@ import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -33,9 +34,9 @@ static enum Fields { public static final int MAX_SIZE = 12; static final int MAX_ENERGY = 640000; - static final int MAX_HEIGHT = 16; + public static final int MAX_HEIGHT = 16; public static IntValue POWERCONF; - private int radius = MAX_SIZE; + private int radius = MAX_SIZE / 2; private int shapeIndex = 0; private int height = 1; private boolean directionIsUp = false; @@ -84,22 +85,33 @@ private BlockPos getShapeTarget() { return shape.get(shapeIndex); } + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().get(BlockStateProperties.FACING); + int diff = directionIsUp ? 1 : -1; + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; + } + return diff * height; + } + //for harvest public List getShape() { - List shape = UtilShape.cubeSquareBase(this.getCurrentFacingPos(radius + 1), radius, 0); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = UtilShape.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.cubeSquareBase(center, radius, 0); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } return shape; } //for render public List getShapeHollow() { - List shape = UtilShape.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), radius); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = UtilShape.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } return shape; } diff --git a/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java index 4d9a17f594..dff0b1e39a 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java @@ -43,12 +43,12 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlockState(pos, state.with(BlockStateProperties.HORIZONTAL_FACING, UtilBlockstates.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlockState(pos, state.with(BlockStateProperties.FACING, UtilBlockstates.getFacingFromEntity(pos, entity)), 2); } } @Override protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(BlockStateProperties.HORIZONTAL_FACING).add(LIT); + builder.add(BlockStateProperties.FACING).add(LIT); } } 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 653611582b..66e14eb7af 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java @@ -40,6 +40,7 @@ public void init() { f = TileMiner.Fields.DIRECTION.ordinal(); btnDirection = addButton(new ButtonMachineField(x, y + 40, f, container.tile.getPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); + btnDirection.visible = !container.tile.getBlockStateVertical(); // int w = 120; int h = 20; diff --git a/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java index ea974ec9fe..a4f3222114 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java @@ -9,7 +9,6 @@ import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.List; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -298,26 +297,35 @@ private void resetProgress() { isCurrentlyMining = false; curBlockDamage = 0; if (fakePlayer != null && targetPos != null) { - //BlockPos targetPos = pos.offset(state.getValue(BlockMiner.PROPERTYFACING)); getWorld().sendBlockBreakProgress(fakePlayer.get().getUniqueID().hashCode(), targetPos, -1); } } - public List getShape() { - List shape = UtilShape.squareHorizontalFull(this.getCurrentFacingPos(radius + 1), radius); + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().get(BlockStateProperties.FACING); int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = UtilShape.repeatShapeByHeight(shape, diff * height); + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; + } + return diff * height; + } + + public List getShape() { + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.squareHorizontalFull(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } return shape; } public List getShapeHollow() { - List shape = new ArrayList(); - shape = UtilShape.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), radius); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = UtilShape.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } if (targetPos != null) { shape.add(targetPos); diff --git a/src/main/java/com/lothrazar/cyclic/util/UtilItemStack.java b/src/main/java/com/lothrazar/cyclic/util/UtilItemStack.java index 3c39727cd9..f0c37d31c0 100644 --- a/src/main/java/com/lothrazar/cyclic/util/UtilItemStack.java +++ b/src/main/java/com/lothrazar/cyclic/util/UtilItemStack.java @@ -103,8 +103,8 @@ public static void dropItemStackMotionless(World world, BlockPos pos, ItemStack if (world.isRemote == false) { ItemEntity entityItem = new ItemEntity(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, stack); // do not spawn a second 'ghost' one onclient side - world.addEntity(entityItem); entityItem.setMotion(0, 0, 0); + world.addEntity(entityItem); // entityItem.motionX = entityItem.motionY = entityItem.motionZ = 0; } } diff --git a/src/main/resources/assets/cyclic/blockstates/collector.json b/src/main/resources/assets/cyclic/blockstates/collector.json index 4e0b10ebdb..2181871744 100644 --- a/src/main/resources/assets/cyclic/blockstates/collector.json +++ b/src/main/resources/assets/cyclic/blockstates/collector.json @@ -10,6 +10,12 @@ "facing=south,lit=true": { "model": "cyclic:block/collector_on" , "y": 180 }, "facing=west,lit=false": { "model": "cyclic:block/collector", "y": 270 }, - "facing=west,lit=true": { "model": "cyclic:block/collector_on", "y": 270 } + "facing=west,lit=true": { "model": "cyclic:block/collector_on", "y": 270 }, + + "facing=up,lit=false": { "model": "cyclic:block/collector_up" }, + "facing=up,lit=true": { "model": "cyclic:block/collector_up_on" }, + + "facing=down,lit=false": { "model": "cyclic:block/collector_up", "x": 180 }, + "facing=down,lit=true": { "model": "cyclic:block/collector_up_on", "x": 180 } } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/blockstates/collector_fluid.json b/src/main/resources/assets/cyclic/blockstates/collector_fluid.json index 465acc3fd1..ae4beb3b5b 100644 --- a/src/main/resources/assets/cyclic/blockstates/collector_fluid.json +++ b/src/main/resources/assets/cyclic/blockstates/collector_fluid.json @@ -10,6 +10,12 @@ "facing=south,lit=true": { "model": "cyclic:block/collector_fluid_on" , "y": 180 }, "facing=west,lit=false": { "model": "cyclic:block/collector_fluid", "y": 270 }, - "facing=west,lit=true": { "model": "cyclic:block/collector_fluid_on", "y": 270 } + "facing=west,lit=true": { "model": "cyclic:block/collector_fluid_on", "y": 270 }, + + "facing=up,lit=false": { "model": "cyclic:block/collector_fluid_up" }, + "facing=up,lit=true": { "model": "cyclic:block/collector_fluid_up_on" }, + + "facing=down,lit=false": { "model": "cyclic:block/collector_fluid_up", "x": 180 }, + "facing=down,lit=true": { "model": "cyclic:block/collector_fluid_up_on", "x": 180 } } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/blockstates/dropper.json b/src/main/resources/assets/cyclic/blockstates/dropper.json index 510bbdd3c0..6ec66796ca 100644 --- a/src/main/resources/assets/cyclic/blockstates/dropper.json +++ b/src/main/resources/assets/cyclic/blockstates/dropper.json @@ -10,6 +10,12 @@ "facing=south,lit=true": { "model": "cyclic:block/dropper_on" , "y": 180 }, "facing=west,lit=false": { "model": "cyclic:block/dropper", "y": 270 }, - "facing=west,lit=true": { "model": "cyclic:block/dropper_on", "y": 270 } + "facing=west,lit=true": { "model": "cyclic:block/dropper_on", "y": 270 }, + + "facing=up,lit=false": { "model": "cyclic:block/dropper_up" }, + "facing=up,lit=true": { "model": "cyclic:block/dropper_up_on" }, + + "facing=down,lit=false": { "model": "cyclic:block/dropper_up", "x": 180 }, + "facing=down,lit=true": { "model": "cyclic:block/dropper_up_on", "x": 180 } } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/blockstates/forester.json b/src/main/resources/assets/cyclic/blockstates/forester.json index ac429f9e51..05b55d804e 100644 --- a/src/main/resources/assets/cyclic/blockstates/forester.json +++ b/src/main/resources/assets/cyclic/blockstates/forester.json @@ -10,6 +10,12 @@ "facing=south,lit=true": { "model": "cyclic:block/forester_on" , "y": 180 }, "facing=west,lit=false": { "model": "cyclic:block/forester", "y": 270 }, - "facing=west,lit=true": { "model": "cyclic:block/forester_on", "y": 270 } + "facing=west,lit=true": { "model": "cyclic:block/forester_on", "y": 270 }, + + "facing=up,lit=false": { "model": "cyclic:block/forester_up" }, + "facing=up,lit=true": { "model": "cyclic:block/forester_up_on" }, + + "facing=down,lit=false": { "model": "cyclic:block/forester_up", "x": 180 }, + "facing=down,lit=true": { "model": "cyclic:block/forester_up_on", "x": 180 } } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/blockstates/harvester.json b/src/main/resources/assets/cyclic/blockstates/harvester.json index 8b35d25980..ef593e5469 100644 --- a/src/main/resources/assets/cyclic/blockstates/harvester.json +++ b/src/main/resources/assets/cyclic/blockstates/harvester.json @@ -10,6 +10,12 @@ "facing=south,lit=true": { "model": "cyclic:block/harvester_on" , "y": 180 }, "facing=west,lit=false": { "model": "cyclic:block/harvester", "y": 270 }, - "facing=west,lit=true": { "model": "cyclic:block/harvester_on", "y": 270 } + "facing=west,lit=true": { "model": "cyclic:block/harvester_on", "y": 270 }, + + "facing=up,lit=false": { "model": "cyclic:block/harvester_up" }, + "facing=up,lit=true": { "model": "cyclic:block/harvester_up_on" }, + + "facing=down,lit=false": { "model": "cyclic:block/harvester_up", "x": 180 }, + "facing=down,lit=true": { "model": "cyclic:block/harvester_up_on", "x": 180 } } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/blockstates/miner.json b/src/main/resources/assets/cyclic/blockstates/miner.json index 1be5ca3de4..2fb438ced6 100644 --- a/src/main/resources/assets/cyclic/blockstates/miner.json +++ b/src/main/resources/assets/cyclic/blockstates/miner.json @@ -10,6 +10,12 @@ "facing=south,lit=true": { "model": "cyclic:block/miner_on" , "y": 180 }, "facing=west,lit=false": { "model": "cyclic:block/miner", "y": 270 }, - "facing=west,lit=true": { "model": "cyclic:block/miner_on", "y": 270 } + "facing=west,lit=true": { "model": "cyclic:block/miner_on", "y": 270 }, + + "facing=up,lit=false": { "model": "cyclic:block/miner_up" }, + "facing=up,lit=true": { "model": "cyclic:block/miner_up_on" }, + + "facing=down,lit=false": { "model": "cyclic:block/miner_up", "x": 180 }, + "facing=down,lit=true": { "model": "cyclic:block/miner_up_on", "x": 180 } } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/collector_fluid_up.json b/src/main/resources/assets/cyclic/models/block/collector_fluid_up.json new file mode 100644 index 0000000000..e727ea5b1e --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/collector_fluid_up.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical", + "textures": { + "base": "cyclic:blocks/machine/blue", + "stem": "cyclic:blocks/machine/white" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/collector_fluid_up_on.json b/src/main/resources/assets/cyclic/models/block/collector_fluid_up_on.json new file mode 100644 index 0000000000..a4023a8c1f --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/collector_fluid_up_on.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical_on", + "textures": { + "base": "cyclic:blocks/machine/blue", + "stem": "cyclic:blocks/machine/white" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/collector_up.json b/src/main/resources/assets/cyclic/models/block/collector_up.json new file mode 100644 index 0000000000..4eb86cd39d --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/collector_up.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical", + "textures":{ + "base": "cyclic:blocks/machine/white", + "stem": "cyclic:blocks/machine/lapis" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/collector_up_on.json b/src/main/resources/assets/cyclic/models/block/collector_up_on.json new file mode 100644 index 0000000000..8a0f9d8d89 --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/collector_up_on.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical_on", + "textures":{ + "base": "cyclic:blocks/machine/white", + "stem": "cyclic:blocks/machine/lapis" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/dropper_up.json b/src/main/resources/assets/cyclic/models/block/dropper_up.json new file mode 100644 index 0000000000..83a84afda2 --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/dropper_up.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical", + "textures": { + "base": "cyclic:blocks/machine/iron", + "stem": "cyclic:blocks/machine/stone" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/dropper_up_on.json b/src/main/resources/assets/cyclic/models/block/dropper_up_on.json new file mode 100644 index 0000000000..8bcc7142ee --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/dropper_up_on.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical_on", + "textures": { + "base": "cyclic:blocks/machine/iron", + "stem": "cyclic:blocks/machine/stone" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/forester_up.json b/src/main/resources/assets/cyclic/models/block/forester_up.json index f6cc9e9f5b..3cc0ac247d 100644 --- a/src/main/resources/assets/cyclic/models/block/forester_up.json +++ b/src/main/resources/assets/cyclic/models/block/forester_up.json @@ -1,10 +1,7 @@ { "parent": "cyclic:parent/machine_vertical", "textures":{ - "front": "cyclic:blocks/breaker/front", - "side": "cyclic:blocks/breaker/side", - "base": "minecraft:block/quartz_block_bottom", - "stem": "minecraft:block/mossy_cobblestone", - "particle": "minecraft:block/iron_block" + "base": "cyclic:blocks/machine/white", + "stem": "cyclic:blocks/machine/peat" } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/forester_up_on.json b/src/main/resources/assets/cyclic/models/block/forester_up_on.json index f6cc9e9f5b..87531f65c0 100644 --- a/src/main/resources/assets/cyclic/models/block/forester_up_on.json +++ b/src/main/resources/assets/cyclic/models/block/forester_up_on.json @@ -1,10 +1,7 @@ { - "parent": "cyclic:parent/machine_vertical", + "parent": "cyclic:parent/machine_vertical_on", "textures":{ - "front": "cyclic:blocks/breaker/front", - "side": "cyclic:blocks/breaker/side", - "base": "minecraft:block/quartz_block_bottom", - "stem": "minecraft:block/mossy_cobblestone", - "particle": "minecraft:block/iron_block" + "base": "cyclic:blocks/machine/white", + "stem": "cyclic:blocks/machine/peat" } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/harvester_up.json b/src/main/resources/assets/cyclic/models/block/harvester_up.json index f6cc9e9f5b..3954a98a82 100644 --- a/src/main/resources/assets/cyclic/models/block/harvester_up.json +++ b/src/main/resources/assets/cyclic/models/block/harvester_up.json @@ -1,10 +1,7 @@ { "parent": "cyclic:parent/machine_vertical", "textures":{ - "front": "cyclic:blocks/breaker/front", - "side": "cyclic:blocks/breaker/side", - "base": "minecraft:block/quartz_block_bottom", - "stem": "minecraft:block/mossy_cobblestone", - "particle": "minecraft:block/iron_block" + "base": "cyclic:blocks/machine/green", + "stem": "cyclic:blocks/machine/obsidian" } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/harvester_up_on.json b/src/main/resources/assets/cyclic/models/block/harvester_up_on.json index f6cc9e9f5b..e6ab3042d8 100644 --- a/src/main/resources/assets/cyclic/models/block/harvester_up_on.json +++ b/src/main/resources/assets/cyclic/models/block/harvester_up_on.json @@ -1,10 +1,7 @@ { - "parent": "cyclic:parent/machine_vertical", + "parent": "cyclic:parent/machine_vertical_on", "textures":{ - "front": "cyclic:blocks/breaker/front", - "side": "cyclic:blocks/breaker/side", - "base": "minecraft:block/quartz_block_bottom", - "stem": "minecraft:block/mossy_cobblestone", - "particle": "minecraft:block/iron_block" + "base": "cyclic:blocks/machine/green", + "stem": "cyclic:blocks/machine/obsidian" } } \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/miner_up.json b/src/main/resources/assets/cyclic/models/block/miner_up.json new file mode 100644 index 0000000000..8884079b7d --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/miner_up.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical", + "textures": { + "base": "cyclic:blocks/machine/lapis", + "stem": "cyclic:blocks/machine/obsidian" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cyclic/models/block/miner_up_on.json b/src/main/resources/assets/cyclic/models/block/miner_up_on.json new file mode 100644 index 0000000000..393ed42a7b --- /dev/null +++ b/src/main/resources/assets/cyclic/models/block/miner_up_on.json @@ -0,0 +1,7 @@ +{ + "parent": "cyclic:parent/machine_vertical_on", + "textures": { + "base": "cyclic:blocks/machine/lapis", + "stem": "cyclic:blocks/machine/obsidian" + } +} \ No newline at end of file diff --git a/update.json b/update.json index f88a386c9b..3c6eba07e4 100644 --- a/update.json +++ b/update.json @@ -81,5 +81,6 @@ ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " ,"1.5.23":"Growth enchantment now uses the same logic as Sprinkler & Terra Soil (only minecraft:crops or minecraft::saplings can grow, respect IGrowable::canUseBonemeal). New gloomIgnored config Gloom enchant (cyclic:curse) to ignore and not use these effects #2217 #2325. Fix Soundproofing block not muting Mekanism sounds #2389 (for example Precision Sawmill and others - you may need four or more soundproofing blocks for the desired effect). Patch an edge-case where User might drop items on the ground. New config [cyclic.blocks.soundproofing] radius = 6 to control the area. Fix item cable routing #2245 #2230. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions #1913. Balance recipe changes for #2372. Balance changes made for Excavate enchant it will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. New feature for Excavate enchant #2116 it will not trigger on anything matching the block data-tag 'cyclic:ignored/excavate'. [Backported changes from mc1.20.1] #2182 candle model assets; Block Breaker no longer tries (and fails) to mine liquid source blocks; Block Randomizer use wireframe rendering only of non-air instead of solid shading; Glistering & Corrupted chorus only restores 1 food-unit down from 3; a few recipes tweaked/backported to match mc1.20.1+, ported crafttweaker zenscript support for generator_fluid and generator_item; backported item data tags for use in recipes for example forge:vines, forge:sandstone, forge:mushrooms " ,"1.5.24":"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. " + ,"":"New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). " } } From 28d6d6abdd57d0d841590942548b0445582bec9f Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sat, 19 Oct 2024 19:46:57 -0700 Subject: [PATCH 2/5] tidied up block facing and preview outline feature. fluid collector air feature --- .../collectfluid/RenderFluidCollect.java | 11 +- .../block/collectfluid/TileFluidCollect.java | 16 ++- .../block/collectitem/RenderItemCollect.java | 14 +- .../collectitem/ScreenItemCollector.java | 1 + .../block/collectitem/TileItemCollector.java | 7 +- .../block/detectorentity/RenderDetector.java | 11 +- .../block/detectorentity/TileDetector.java | 7 +- .../detectoritem/RenderDetectorItem.java | 14 +- .../block/detectoritem/TileDetectorItem.java | 7 +- .../cyclic/block/dropper/RenderDropper.java | 11 +- .../cyclic/block/dropper/TileDropper.java | 7 +- .../lothrazar/cyclic/block/fan/BlockFan.java | 3 + .../lothrazar/cyclic/block/fan/RenderFan.java | 31 +++++ .../lothrazar/cyclic/block/fan/ScreenFan.java | 6 + .../lothrazar/cyclic/block/fan/TileFan.java | 12 +- .../block/forester/ContainerForester.java | 2 +- .../cyclic/block/forester/RenderForester.java | 12 +- .../cyclic/block/forester/ScreenForester.java | 5 +- .../cyclic/block/forester/TileForester.java | 19 +-- .../generatorpeat/TileGeneratorPeat.java | 3 +- .../block/harvester/RenderHarvester.java | 16 ++- .../block/harvester/ScreenHarvester.java | 2 +- .../cyclic/block/harvester/TileHarvester.java | 13 +- .../cyclic/block/laser/RenderLaser.java | 10 +- .../cyclic/block/miner/RenderMiner.java | 11 +- .../cyclic/block/miner/ScreenMiner.java | 2 +- .../cyclic/block/miner/TileMiner.java | 3 +- .../cyclic/block/peatfarm/RenderPeatFarm.java | 11 +- .../cyclic/block/peatfarm/TilePeatFarm.java | 7 +- .../block/placerfluid/TilePlacerFluid.java | 3 +- .../block/shapebuilder/RenderStructure.java | 19 ++- .../block/shapebuilder/ScreenStructure.java | 2 +- .../block/shapebuilder/TileStructure.java | 10 +- .../block/shapedata/RenderShapedata.java | 28 ++-- .../cyclic/block/shapedata/TileShapedata.java | 3 +- .../wireless/energy/TileWirelessEnergy.java | 3 +- .../wireless/fluid/TileWirelessFluid.java | 3 +- .../block/wireless/item/TileWirelessItem.java | 3 +- .../wireless/redstone/RenderTransmit.java | 131 +++++------------- .../redstone/TileWirelessTransmit.java | 3 +- .../cyclic/data/PreviewOutlineType.java | 4 + .../cyclic/gui/ButtonMachineField.java | 15 +- .../com/lothrazar/cyclic/gui/TextureEnum.java | 8 +- .../com/lothrazar/cyclic/util/UtilRender.java | 28 ++-- .../resources/assets/cyclic/lang/en_us.json | 3 +- update.json | 2 +- 46 files changed, 343 insertions(+), 199 deletions(-) create mode 100644 src/main/java/com/lothrazar/cyclic/block/fan/RenderFan.java create mode 100644 src/main/java/com/lothrazar/cyclic/data/PreviewOutlineType.java diff --git a/src/main/java/com/lothrazar/cyclic/block/collectfluid/RenderFluidCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectfluid/RenderFluidCollect.java index 0e0942f4ce..6449f7c75d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectfluid/RenderFluidCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectfluid/RenderFluidCollect.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.collectfluid; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderFluidCollect extends TileEntityRenderer { @@ -15,8 +18,14 @@ public RenderFluidCollect(TileEntityRendererDispatcher d) { @Override public void render(TileFluidCollect te, float v, MatrixStack matrix, IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { - if (1 == te.getField(TileFluidCollect.Fields.RENDER.ordinal())) { + int previewType = te.getField(TileFluidCollect.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShapeHollow(), matrix, 0.4F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrix, crd, Vector3d.copy(te.getPos())); + } + } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java index 999b7a737d..f98ac1b1b0 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.base.FluidTankBase; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; import java.util.List; @@ -82,9 +83,11 @@ public void tick() { return; } ItemStack stack = inventory.getStackInSlot(0); - if (stack.isEmpty() || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) { - return; - } + // if (stack.isEmpty() || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) { + // return; + // } + //use air if its empty + BlockState newState = Block.getBlockFromItem(stack.getItem()).getDefaultState(); this.setLitProperty(true); List shape = this.getShapeFilled(); if (shape.size() == 0) { @@ -100,7 +103,7 @@ public void tick() { int result = tank.fill(fstack, FluidAction.SIMULATE); if (result == FluidAttributes.BUCKET_VOLUME) { //we got enough - if (world.setBlockState(targetPos, Block.getBlockFromItem(stack.getItem()).getDefaultState())) { + if (world.setBlockState(targetPos, newState)) { //build the block, shrink the item stack.shrink(1); //drink fluid @@ -138,8 +141,9 @@ private int heightWithDirection() { //for render public List getShapeHollow() { BlockPos center = getFacingShapeCenter(radius); + List shape = UtilShape.squareHorizontalHollow(center, this.radius); + // int heightWithDirection = heightWithDirection(); - List shape = UtilShape.squareHorizontalHollow(center.down(height), this.radius); if (heightWithDirection != 0) { shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } @@ -226,7 +230,7 @@ public void setField(int field, int value) { this.setNeedsRedstone(value); break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case HEIGHT: height = Math.min(value, MAX_HEIGHT); diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java index 239bef368b..e6f521d8fb 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.collectitem; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderItemCollect extends TileEntityRenderer { @@ -14,10 +17,15 @@ public RenderItemCollect(TileEntityRendererDispatcher d) { } @Override - public void render(TileItemCollector te, float v, MatrixStack matrix, - IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { - if (1 == te.getField(TileItemCollector.Fields.RENDER.ordinal())) { + public void render(TileItemCollector te, float v, MatrixStack matrix, IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileItemCollector.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShape(), matrix, 0.7F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrix, crd, Vector3d.copy(te.getPos())); + } + } } } 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 51146fdd61..b9788c1f93 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/ScreenItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/ScreenItemCollector.java @@ -76,6 +76,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m sizeSlider.setTooltip("cyclic.screen.size" + container.tile.getField(sizeSlider.getField())); this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, this.title.getString()); + btnDirection.visible = !container.tile.getBlockStateVertical(); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java index 04ae62da63..551ad42174 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java @@ -1,6 +1,7 @@ package com.lothrazar.cyclic.block.collectitem; import com.lothrazar.cyclic.base.TileEntityBase; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.filter.FilterCardItem; import com.lothrazar.cyclic.registry.ItemRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -141,6 +142,10 @@ private int heightWithDirection() { return diff * height; } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { BlockPos center = getFacingShapeCenter(radius); List shape = UtilShape.squareHorizontalHollow(center, radius); @@ -174,7 +179,7 @@ public void setField(int field, int value) { this.setNeedsRedstone(value); break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case SIZE: radius = Math.min(value, MAX_SIZE); diff --git a/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java b/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java index 959c888122..085bfe2dff 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.detectorentity; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderDetector extends TileEntityRenderer { @@ -15,8 +18,14 @@ public RenderDetector(TileEntityRendererDispatcher d) { @Override public void render(TileDetector te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TileDetector.Fields.RENDER.ordinal()) == 1) { + int previewType = te.getField(TileDetector.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShape(), matrixStack, 0.6F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/detectorentity/TileDetector.java b/src/main/java/com/lothrazar/cyclic/block/detectorentity/TileDetector.java index 5be9a9e793..41685e6bac 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectorentity/TileDetector.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectorentity/TileDetector.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.data.EntityFilterType; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; import java.util.List; @@ -103,6 +104,10 @@ public boolean isPowered() { return isPoweredNow; } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { return UtilShape.getShape(getRange(), pos.getY()); } @@ -147,7 +152,7 @@ public int getField(int f) { public void setField(int field, int value) { switch (Fields.values()[field]) { case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case GREATERTHAN: if (value >= CompareType.values().length) { diff --git a/src/main/java/com/lothrazar/cyclic/block/detectoritem/RenderDetectorItem.java b/src/main/java/com/lothrazar/cyclic/block/detectoritem/RenderDetectorItem.java index fa03e9a0b7..8cfaebdfc8 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectoritem/RenderDetectorItem.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectoritem/RenderDetectorItem.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.detectoritem; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderDetectorItem extends TileEntityRenderer { @@ -14,10 +17,15 @@ public RenderDetectorItem(TileEntityRendererDispatcher d) { } @Override - public void render(TileDetectorItem te, float v, MatrixStack matrixStack, - IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TileDetectorItem.Fields.RENDER.ordinal()) == 1) { + public void render(TileDetectorItem te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileDetectorItem.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShape(), matrixStack, 0.6F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/detectoritem/TileDetectorItem.java b/src/main/java/com/lothrazar/cyclic/block/detectoritem/TileDetectorItem.java index e66034ff9a..eee21dddb5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectoritem/TileDetectorItem.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectoritem/TileDetectorItem.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.block.detectorentity.CompareType; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; import java.util.List; @@ -183,7 +184,7 @@ public void setField(int field, int value) { this.rangeZ = value; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } @@ -211,6 +212,10 @@ public CompoundNBT write(CompoundNBT tag) { return super.write(tag); } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { return UtilShape.getShape(getRange(), pos.getY()); } diff --git a/src/main/java/com/lothrazar/cyclic/block/dropper/RenderDropper.java b/src/main/java/com/lothrazar/cyclic/block/dropper/RenderDropper.java index b7d2a9e3c8..8608e0d240 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/RenderDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/RenderDropper.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.dropper; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderDropper extends TileEntityRenderer { @@ -15,8 +18,14 @@ public RenderDropper(TileEntityRendererDispatcher d) { @Override public void render(TileDropper te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TileDropper.Fields.RENDER.ordinal()) == 1) { + int previewType = te.getField(TileDropper.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShape(), matrixStack, 0.5F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/dropper/TileDropper.java b/src/main/java/com/lothrazar/cyclic/block/dropper/TileDropper.java index b5a63ba7e9..6735602efe 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/TileDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/TileDropper.java @@ -2,6 +2,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilItemStack; import java.util.ArrayList; @@ -176,11 +177,15 @@ public void setField(int id, int value) { hOffset = Math.max(0, value); break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { List shape = new ArrayList<>(); shape.add(getTargetPos()); diff --git a/src/main/java/com/lothrazar/cyclic/block/fan/BlockFan.java b/src/main/java/com/lothrazar/cyclic/block/fan/BlockFan.java index f772c40968..a00828aed1 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fan/BlockFan.java +++ b/src/main/java/com/lothrazar/cyclic/block/fan/BlockFan.java @@ -2,6 +2,7 @@ import com.lothrazar.cyclic.base.BlockBase; import com.lothrazar.cyclic.registry.ContainerScreenRegistry; +import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilBlockstates; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -20,6 +21,7 @@ import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraftforge.fml.client.registry.ClientRegistry; public class BlockFan extends BlockBase { @@ -49,6 +51,7 @@ public boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader w @Override public void registerClient() { + ClientRegistry.bindTileEntityRenderer(TileRegistry.fantile, RenderFan::new); RenderTypeLookup.setRenderLayer(this, RenderType.getCutoutMipped()); ScreenManager.registerFactory(ContainerScreenRegistry.FAN, ScreenFan::new); } diff --git a/src/main/java/com/lothrazar/cyclic/block/fan/RenderFan.java b/src/main/java/com/lothrazar/cyclic/block/fan/RenderFan.java new file mode 100644 index 0000000000..b855e7a9f3 --- /dev/null +++ b/src/main/java/com/lothrazar/cyclic/block/fan/RenderFan.java @@ -0,0 +1,31 @@ +package com.lothrazar.cyclic.block.fan; + +import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; +import com.lothrazar.cyclic.util.UtilRender; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; + +public class RenderFan extends TileEntityRenderer { + + public RenderFan(TileEntityRendererDispatcher d) { + super(d); + } + + @Override + public void render(TileFan te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileFan.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + UtilRender.renderOutline(te.getPos(), te.getShapeHollow(), matrixStack, 0.7F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } + } +} 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 8a02db2eb0..9306a424bb 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fan/ScreenFan.java +++ b/src/main/java/com/lothrazar/cyclic/block/fan/ScreenFan.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.base.ScreenBase; import com.lothrazar.cyclic.gui.ButtonMachineField; import com.lothrazar.cyclic.gui.GuiSliderInteger; +import com.lothrazar.cyclic.gui.TextureEnum; import com.lothrazar.cyclic.registry.TextureRegistry; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.entity.player.PlayerInventory; @@ -11,6 +12,7 @@ public class ScreenFan extends ScreenBase { private ButtonMachineField btnRedstone; + private ButtonMachineField btnRender; public ScreenFan(ContainerFan screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); @@ -23,6 +25,9 @@ public void init() { x = guiLeft + 6; y = guiTop + 6; btnRedstone = addButton(new ButtonMachineField(x, y, TileFan.Fields.REDSTONE.ordinal(), container.tile.getPos())); + y += 20; + btnRender = addButton(new ButtonMachineField(x, y, TileFan.Fields.RENDER.ordinal(), + container.tile.getPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); // int w = 160; int h = 20; @@ -53,6 +58,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, this.title.getString()); btnRedstone.onValueUpdate(container.tile); + btnRender.onValueUpdate(container.tile); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/fan/TileFan.java b/src/main/java/com/lothrazar/cyclic/block/fan/TileFan.java index 46eacc5b50..761d76d579 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fan/TileFan.java +++ b/src/main/java/com/lothrazar/cyclic/block/fan/TileFan.java @@ -1,6 +1,7 @@ package com.lothrazar.cyclic.block.fan; import com.lothrazar.cyclic.base.TileEntityBase; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.net.PacketPlayerFalldamage; import com.lothrazar.cyclic.registry.PacketRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -23,7 +24,7 @@ public class TileFan extends TileEntityBase implements ITickableTileEntity, INamedContainerProvider { static enum Fields { - REDSTONE, RANGE, SPEED; + REDSTONE, RANGE, SPEED, RENDER; } public static final int MIN_RANGE = 1; @@ -82,6 +83,10 @@ private boolean canBlowThrough(BlockPos tester) { return !world.getBlockState(tester).isSolid(); } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { return UtilShape.line(getPos(), getCurrentFacing(), getCurrentRange()); } @@ -204,6 +209,8 @@ public int getField(int f) { return this.needsRedstone; case SPEED: return this.speed; + case RENDER: + return this.render; } return 0; } @@ -212,6 +219,9 @@ public int getField(int f) { public void setField(int field, int value) { Fields f = Fields.values()[field]; switch (f) { + case RENDER: + this.render = value % PreviewOutlineType.values().length; + break; case RANGE: range = value; if (range < MIN_RANGE) { diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java index 9f6ff4aa3b..fb2146e77f 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java @@ -24,7 +24,7 @@ public ContainerForester(int windowId, World world, BlockPos pos, PlayerInventor this.playerInventory = playerInventory; tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { this.endInv = h.getSlots(); - addSlot(new SlotItemHandler(h, 0, 80, 25)); + addSlot(new SlotItemHandler(h, 0, 80, 17)); }); layoutPlayerInventorySlots(8, 84); this.trackAllIntFields(tile, TileForester.Fields.values().length); diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/RenderForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/RenderForester.java index 4bd5fd2044..40a3e1fb9e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/RenderForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/RenderForester.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.forester; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderForester extends TileEntityRenderer { @@ -15,9 +18,14 @@ public RenderForester(TileEntityRendererDispatcher d) { @Override public void render(TileForester te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - // ok - if (te.getField(TileForester.Fields.RENDER.ordinal()) == 1) { + int previewType = te.getField(TileForester.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShapeHollow(), matrixStack, 0.7F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } 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 b6ae4b7ba5..dc32e6d4dd 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java @@ -1,7 +1,6 @@ package com.lothrazar.cyclic.block.forester; import com.lothrazar.cyclic.base.ScreenBase; -import com.lothrazar.cyclic.block.harvester.TileHarvester; import com.lothrazar.cyclic.data.Const; import com.lothrazar.cyclic.gui.ButtonMachineField; import com.lothrazar.cyclic.gui.EnergyBar; @@ -44,12 +43,12 @@ public void init() { x = guiLeft + 34; y = guiTop + 38; heightslider = this.addButton(new GuiSliderInteger(x, y, w, h, TileForester.Fields.HEIGHT.ordinal(), container.tile.getPos(), - 0, TileHarvester.MAX_HEIGHT, container.tile.getField(f))); + 0, TileForester.MAX_HEIGHT, container.tile.getField(f))); // f = TileForester.Fields.SIZE.ordinal(); // x += 28; y += 20; - size = this.addButton(new GuiSliderInteger(x, y, w, h, f, container.tile.getPos(), 0, 10, container.tile.getField(f))); + size = this.addButton(new GuiSliderInteger(x, y, w, h, f, container.tile.getPos(), 0, TileForester.MAX_SIZE, container.tile.getField(f))); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java index 7cccdf18ed..f10e16a34f 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; import java.lang.ref.WeakReference; @@ -48,7 +49,7 @@ static enum Fields { static final int MAX = 64000; static final int MAX_HEIGHT = 32; - private static final int MAX_SIZE = 12; //radius 7 translates to 15x15 area (center block + 7 each side) + static final int MAX_SIZE = 12; //radius 7 translates to 15x15 area (center block + 7 each side) public static IntValue POWERCONF; private int height = MAX_HEIGHT; private int radius = MAX_SIZE; @@ -157,6 +158,7 @@ public void invalidateCaps() { @Override public void read(BlockState bs, CompoundNBT tag) { + height = tag.getInt("height"); shapeIndex = tag.getInt("shapeIndex"); radius = tag.getInt("radius"); energy.deserializeNBT(tag.getCompound(NBTENERGY)); @@ -166,6 +168,7 @@ public void read(BlockState bs, CompoundNBT tag) { @Override public CompoundNBT write(CompoundNBT tag) { + tag.putInt("height", height); tag.putInt("shapeIndex", shapeIndex); tag.put(NBTENERGY, energy.serializeNBT()); tag.putInt("radius", radius); @@ -220,10 +223,10 @@ public List getShape() { public List getShapeHollow() { BlockPos center = getFacingShapeCenter(radius); List shape = UtilShape.squareHorizontalHollow(center, radius); - // int heightWithDirection = heightWithDirection(); - // if (heightWithDirection != 0) { - // shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); - // } + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); + } BlockPos targetPos = getShapeTarget(shape); if (targetPos != null) { shape.add(targetPos); @@ -269,13 +272,13 @@ public void setField(int id, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case SIZE: - radius = value % MAX_SIZE; + radius = Math.min(value, MAX_SIZE); break; case HEIGHT: - this.height = value & MAX_HEIGHT; + this.height = Math.min(value, MAX_HEIGHT); break; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java index aa762fd270..09393a20d0 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java @@ -2,6 +2,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.PeatItem; import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.block.BlockState; @@ -162,7 +163,7 @@ public void setField(int field, int value) { setNeedsRedstone(value); break; case RENDER: - render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case BURNTIME: this.setBurnTime(value); diff --git a/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java index a617ff180e..7b010064ce 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.harvester; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderHarvester extends TileEntityRenderer { @@ -14,10 +17,15 @@ public RenderHarvester(TileEntityRendererDispatcher d) { } @Override - public void render(TileHarvester te, float v, MatrixStack matrix, - IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { - if (1 == te.getField(TileHarvester.Fields.RENDER.ordinal())) { - UtilRender.renderOutline(te.getPos(), te.getShapeHollow(), matrix, 0.7F, ClientConfigCyclic.getColor(te)); + public void render(TileHarvester te, float v, MatrixStack matrixStack, IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileHarvester.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + UtilRender.renderOutline(te.getPos(), te.getShapeHollow(), matrixStack, 0.7F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } } } } 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 de59db8c71..2be83b9ebe 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/ScreenHarvester.java @@ -42,7 +42,6 @@ public void init() { y += 20; btnDirection = addButton(new ButtonMachineField(x, y, f, container.tile.getPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); - btnDirection.visible = !container.tile.getBlockStateVertical(); final int w = 110; final int h = 18; //now start sliders @@ -76,6 +75,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m size.setTooltip("cyclic.screen.size" + container.tile.getField(size.getField())); this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, title.getString()); + btnDirection.visible = !container.tile.getBlockStateVertical(); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java index cdef25772e..a99d17d7f4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java @@ -2,6 +2,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.HarvestUtil; import com.lothrazar.cyclic.util.UtilShape; @@ -38,6 +39,7 @@ static enum Fields { public static IntValue POWERCONF; private int radius = MAX_SIZE / 2; private int shapeIndex = 0; + BlockPos targetPos = null; private int height = 1; private boolean directionIsUp = false; CustomEnergyStorage energy = new CustomEnergyStorage(MAX_ENERGY, MAX_ENERGY / 4); @@ -65,7 +67,8 @@ public void tick() { return; } //get and update target - BlockPos targetPos = getShapeTarget(); + List shape = this.getShape(); + targetPos = getShapeTarget(shape); shapeIndex++; //does it exist if (targetPos != null && HarvestUtil.tryHarvestSingle(this.world, targetPos)) { @@ -74,8 +77,7 @@ public void tick() { } } - private BlockPos getShapeTarget() { - List shape = this.getShape(); + private BlockPos getShapeTarget(List shape) { if (shape.size() == 0) { return null; } @@ -113,6 +115,9 @@ public List getShapeHollow() { if (heightWithDirection != 0) { shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } + if (targetPos != null) { + shape.add(targetPos); + } return shape; } @@ -145,7 +150,7 @@ public void setField(int id, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case SIZE: radius = Math.min(value, MAX_SIZE); diff --git a/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java b/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java index 06f1cc2426..125f36efe2 100644 --- a/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java +++ b/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java @@ -27,6 +27,11 @@ public RenderLaser(TileEntityRendererDispatcher d) { super(d); } + @Override + public boolean isGlobalRenderer(TileLaser te) { + return true; + } + @Override public void render(TileLaser te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { if (te.requiresRedstone() && !te.isPowered()) { @@ -114,9 +119,4 @@ public static void drawDirewolfLaser(IVertexBuilder builder, Matrix4f positionMa .lightmap(15728880) .endVertex(); } - - @Override - public boolean isGlobalRenderer(TileLaser te) { - return true; - } } diff --git a/src/main/java/com/lothrazar/cyclic/block/miner/RenderMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/RenderMiner.java index ce05b80ad1..4fa3d5f3cd 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/RenderMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/RenderMiner.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.miner; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderMiner extends TileEntityRenderer { @@ -15,8 +18,14 @@ public RenderMiner(TileEntityRendererDispatcher d) { @Override public void render(TileMiner te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TileMiner.Fields.RENDER.ordinal()) == 1) { + int previewType = te.getField(TileMiner.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShapeHollow(), matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } 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 66e14eb7af..c560b402d6 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java @@ -40,7 +40,6 @@ public void init() { f = TileMiner.Fields.DIRECTION.ordinal(); btnDirection = addButton(new ButtonMachineField(x, y + 40, f, container.tile.getPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); - btnDirection.visible = !container.tile.getBlockStateVertical(); // int w = 120; int h = 20; @@ -74,6 +73,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int m btnRender.onValueUpdate(container.tile); btnDirection.onValueUpdate(container.tile); sizeSlider.setTooltip("cyclic.screen.size" + container.tile.getField(sizeSlider.getField())); + btnDirection.visible = !container.tile.getBlockStateVertical(); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java index a4f3222114..fa4ee7d54e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.BlockStateMatcher; import com.lothrazar.cyclic.item.datacard.BlockstateCard; import com.lothrazar.cyclic.registry.ItemRegistry; @@ -357,7 +358,7 @@ public void setField(int id, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case DIRECTION: this.directionIsUp = value == 1; diff --git a/src/main/java/com/lothrazar/cyclic/block/peatfarm/RenderPeatFarm.java b/src/main/java/com/lothrazar/cyclic/block/peatfarm/RenderPeatFarm.java index 079c5168b3..00fdd292a3 100644 --- a/src/main/java/com/lothrazar/cyclic/block/peatfarm/RenderPeatFarm.java +++ b/src/main/java/com/lothrazar/cyclic/block/peatfarm/RenderPeatFarm.java @@ -1,11 +1,14 @@ package com.lothrazar.cyclic.block.peatfarm; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; public class RenderPeatFarm extends TileEntityRenderer { @@ -15,8 +18,14 @@ public RenderPeatFarm(TileEntityRendererDispatcher d) { @Override public void render(TilePeatFarm te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TilePeatFarm.Fields.RENDER.ordinal()) == 1) { + int previewType = te.getField(TilePeatFarm.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { UtilRender.renderOutline(te.getPos(), te.getShape(), matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java b/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java index 0502bd5d8d..1832e67476 100644 --- a/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java +++ b/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java @@ -27,6 +27,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.block.PeatFuelBlock; import com.lothrazar.cyclic.capability.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilShape; @@ -156,7 +157,7 @@ public void setField(int field, int value) { this.setNeedsRedstone(value); break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } @@ -190,6 +191,10 @@ public boolean isItemValidForSlot(int index, ItemStack stack) { return Block.getBlockFromItem(stack.getItem()) == unbaked; } + public List getShapeHollow() { + return getShape(); + } + List getShape() { List outer = UtilShape.squareHorizontalHollow(this.pos, 7); outer.addAll(UtilShape.squareHorizontalHollow(this.pos, 5)); diff --git a/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java b/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java index 0342ccb3a4..aca267d124 100644 --- a/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java @@ -2,6 +2,7 @@ import com.lothrazar.cyclic.base.FluidTankBase; import com.lothrazar.cyclic.base.TileEntityBase; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.TileRegistry; import java.util.function.Predicate; import net.minecraft.block.BlockState; @@ -133,7 +134,7 @@ public void setField(int id, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/RenderStructure.java b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/RenderStructure.java index 9ac9b36367..b2fd5c8746 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/RenderStructure.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/RenderStructure.java @@ -1,12 +1,15 @@ package com.lothrazar.cyclic.block.shapebuilder; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; @@ -18,11 +21,12 @@ public RenderStructure(TileEntityRendererDispatcher d) { @Override public void render(TileStructure te, float v, MatrixStack matrixStack, IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { - IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); - if (inv == null) { - return; - } - if (1 == te.getField(TileStructure.Fields.RENDER.ordinal())) { + int previewType = te.getField(TileStructure.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); + if (inv == null) { + return; + } ItemStack stack = inv.getStackInSlot(0); if (stack.isEmpty()) { UtilRender.renderOutline(te.getPos(), te.getShape(), matrixStack, 0.7F, ClientConfigCyclic.getColor(te)); @@ -31,5 +35,10 @@ public void render(TileStructure te, float v, MatrixStack matrixStack, IRenderTy UtilRender.renderAsBlock(te.getPos(), te.getShape(), matrixStack, stack, 1, 1); } } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShape()) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } + } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/ScreenStructure.java b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/ScreenStructure.java index 4e32c4bfe9..dbe293ef23 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/ScreenStructure.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/ScreenStructure.java @@ -46,7 +46,7 @@ public void init() { x = guiLeft + 8; y = guiTop + 82; GuiSliderInteger durationslider = this.addButton(new GuiSliderInteger(x, y, w, h, f, container.tile.getPos(), - 1, TileStructure.MAXHEIGHT, container.tile.getField(f))); + 1, TileStructure.MAX_HEIGHT, container.tile.getField(f))); durationslider.setTooltip("buildertype.height.tooltip"); y += 21; f = TileStructure.Fields.SIZE.ordinal(); diff --git a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java index 18bd25b7bc..e59aef07d9 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.capability.CustomEnergyStorage; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.data.RelativeShape; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.item.datacard.ShapeCard; @@ -42,7 +43,7 @@ public class TileStructure extends TileEntityBase implements INamedContainerProv static final int SLOT_BUILD = 0; protected static final int SLOT_SHAPE = 1; protected static final int SLOT_GPS = 2; - public static final int MAXHEIGHT = 100; + public static final int MAX_HEIGHT = 100; static enum Fields { TIMER, BUILDTYPE, SIZE, HEIGHT, REDSTONE, RENDER; @@ -158,16 +159,13 @@ public void setField(int field, int value) { this.buildSize = value; break; case HEIGHT: - if (value > MAXHEIGHT) { - value = MAXHEIGHT; - } - this.height = Math.max(1, value); + height = Math.min(value, MAX_HEIGHT); break; case REDSTONE: this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/shapedata/RenderShapedata.java b/src/main/java/com/lothrazar/cyclic/block/shapedata/RenderShapedata.java index c0020af0f2..99ab8f1db7 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapedata/RenderShapedata.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapedata/RenderShapedata.java @@ -1,13 +1,13 @@ package com.lothrazar.cyclic.block.shapedata; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.util.UtilRender; import com.mojang.blaze3d.matrix.MatrixStack; import java.awt.Color; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.util.math.vector.Vector3d; public class RenderShapedata extends TileEntityRenderer { @@ -16,24 +16,24 @@ public RenderShapedata(TileEntityRendererDispatcher d) { } @Override - public void render(TileShapedata te, float v, MatrixStack matrixStack, - IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { - IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); - if (inv == null) { - return; - } - if (1 == te.getField(TileShapedata.Fields.RENDER.ordinal())) { + public void render(TileShapedata te, float v, MatrixStack matrixStack, IRenderTypeBuffer ibuffer, int partialTicks, int destroyStage) { + // IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); + // if (inv == null) { + // return; + // } + int previewType = te.getField(TileShapedata.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { if (te.getTarget(0) != null) { UtilRender.renderOutline(te.getPos(), te.getTarget(0), matrixStack, 1.05F, Color.BLUE); } if (te.getTarget(1) != null) { UtilRender.renderOutline(te.getPos(), te.getTarget(1), matrixStack, 1.05F, Color.RED); } - // ItemStack stack = inv.getStackInSlot(0); - // if (stack.isEmpty()) { - // } - // else { - // // UtilRender.renderAsBlock(te.getPos(), te.getShape(), matrixStack, stack, 0.5F, 1.0F); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + // for (BlockPos crd : te.getShapeHollow()) { + UtilRender.createBox(matrixStack, te.getTarget(0), Vector3d.copy(te.getPos())); + UtilRender.createBox(matrixStack, te.getTarget(1), Vector3d.copy(te.getPos())); // } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/shapedata/TileShapedata.java b/src/main/java/com/lothrazar/cyclic/block/shapedata/TileShapedata.java index e9ed0b6eaf..c6891b2bc8 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapedata/TileShapedata.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapedata/TileShapedata.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.data.RelativeShape; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.item.datacard.ShapeCard; @@ -239,7 +240,7 @@ public void setField(int field, int value) { this.execute(cmd); break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/energy/TileWirelessEnergy.java b/src/main/java/com/lothrazar/cyclic/block/wireless/energy/TileWirelessEnergy.java index db8239c072..d6326482ac 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/energy/TileWirelessEnergy.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/energy/TileWirelessEnergy.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.capability.CustomEnergyStorage; import com.lothrazar.cyclic.config.ConfigRegistry; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilWorld; @@ -125,7 +126,7 @@ public void setField(int field, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case TRANSFER_RATE: transferRate = value; diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/fluid/TileWirelessFluid.java b/src/main/java/com/lothrazar/cyclic/block/wireless/fluid/TileWirelessFluid.java index aaf6c5123b..4676220cbb 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/fluid/TileWirelessFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/fluid/TileWirelessFluid.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.config.ConfigRegistry; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilWorld; @@ -138,7 +139,7 @@ public void setField(int field, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case TRANSFER_RATE: transferRate = value; diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/item/TileWirelessItem.java b/src/main/java/com/lothrazar/cyclic/block/wireless/item/TileWirelessItem.java index 5f7f6bc1ac..163ec50ce5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/item/TileWirelessItem.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/item/TileWirelessItem.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.config.ConfigRegistry; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilWorld; @@ -121,7 +122,7 @@ public void setField(int field, int value) { this.needsRedstone = value % 2; break; case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; case TRANSFER_RATE: transferRate = value; diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/RenderTransmit.java b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/RenderTransmit.java index 9edbc86116..a385d7f3ff 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/RenderTransmit.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/RenderTransmit.java @@ -1,19 +1,18 @@ package com.lothrazar.cyclic.block.wireless.redstone; -import com.lothrazar.cyclic.ModCyclic; +import com.lothrazar.cyclic.config.ClientConfigCyclic; import com.lothrazar.cyclic.data.BlockPosDim; -import com.lothrazar.cyclic.render.FakeBlockRenderTypes; +import com.lothrazar.cyclic.data.PreviewOutlineType; +import com.lothrazar.cyclic.util.UtilRender; +import com.lothrazar.cyclic.util.UtilWorld; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.util.math.vector.Vector3d; public class RenderTransmit extends TileEntityRenderer { @@ -21,105 +20,37 @@ public RenderTransmit(TileEntityRendererDispatcher d) { super(d); } + @Override + public boolean isGlobalRenderer(TileWirelessTransmit te) { + return true; + } + @Override public void render(TileWirelessTransmit te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.requiresRedstone() && !te.isPowered()) { + // if (te.requiresRedstone() && !te.isPowered()) { + // return; + // } + int previewType = te.getField(TileWirelessTransmit.Fields.RENDER.ordinal()); + if (previewType <= 0) { return; } - if (te.getField(TileWirelessTransmit.Fields.RENDER.ordinal()) < 1) { - return; - } - try { - for (int slot = 0; slot < te.inventory.getSlots(); slot++) { - draw(slot, te, matrixStack, iRenderTypeBuffer); + List shape = new ArrayList<>(); + String dimensionId = UtilWorld.dimensionToString(te.getWorld()); + for (int slot = 0; slot < te.inventory.getSlots(); slot++) { + BlockPosDim dimPosSaved = te.getTargetInSlot(slot); + if (dimPosSaved != null + && dimPosSaved.getDimension().equalsIgnoreCase(dimensionId)) { + shape.add(dimPosSaved.getPos()); } + // draw(slot, te, matrixStack, iRenderTypeBuffer); } - catch (Exception e) { - ModCyclic.LOGGER.error("TileWirelessTransmit.java ", e); - } - } - - private static Vector3f adjustBeamToEyes(Vector3f from, Vector3f to, BlockPos tile) { - //This method takes the player's position into account, and adjusts the beam so that its rendered properly whereever you stand - PlayerEntity player = Minecraft.getInstance().player; - Vector3f vectP = new Vector3f((float) player.getPosX() - tile.getX(), (float) player.getPosYEye() - tile.getY(), (float) player.getPosZ() - tile.getZ()); - Vector3f vectS = from.copy(); - vectS.sub(vectP); - Vector3f vectE = to.copy(); - vectE.sub(from); - Vector3f adjustedVec = vectS.copy(); - adjustedVec.cross(vectE); - adjustedVec.normalize(); - return adjustedVec; - } - - public static void draw(int slot, TileWirelessTransmit tile, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn) throws Exception { - BlockPosDim posPosTarget = tile.getTargetInSlot(slot); - if (posPosTarget == null) { - return; + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + UtilRender.renderOutline(te.getPos(), shape, matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); } - BlockPos posTarget = posPosTarget.getPos(); - if (posTarget == null || posTarget.equals(BlockPos.ZERO)) { - return; + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : shape) { + UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + } } - // //now render - matrixStackIn.push(); - Matrix4f positionMatrix = matrixStackIn.getLast().getMatrix(); - //diff between target and tile, targets always centered - BlockPos tilePos = tile.getPos(); - Vector3f from = new Vector3f( - posTarget.getX() + .5F - tilePos.getX(), - posTarget.getY() + .5F - tilePos.getY(), - posTarget.getZ() + .5F - tilePos.getZ()); - Vector3f to = new Vector3f(.5F, .5F, .5F); - IVertexBuilder builder = bufferIn.getBuffer(FakeBlockRenderTypes.LASER_MAIN_BEAM); - drawDirewolfLaser(builder, positionMatrix, from, to, tile.getRed(), tile.getGreen(), tile.getBlue(), tile.getAlpha(), tile.getThick(), tilePos); - //TODO: boolean to toggle core with tiny thickness - final float coreThick = 0.01F; - drawDirewolfLaser(builder, positionMatrix, from, to, 1, 1, 1, tile.getAlpha(), coreThick, tilePos); - matrixStackIn.pop(); - } - - public static void drawDirewolfLaser(IVertexBuilder builder, Matrix4f positionMatrix, Vector3f from, Vector3f to, float r, float g, float b, float alpha, float thickness, BlockPos tilePos) { - final float v = 1; - Vector3f adjustedVec = adjustBeamToEyes(from, to, tilePos); - adjustedVec.mul(thickness); //Determines how thick the beam is - Vector3f p1 = from.copy(); - p1.add(adjustedVec); - Vector3f p2 = from.copy(); - p2.sub(adjustedVec); - Vector3f p3 = to.copy(); - p3.add(adjustedVec); - Vector3f p4 = to.copy(); - p4.sub(adjustedVec); - builder.pos(positionMatrix, p1.getX(), p1.getY(), p1.getZ()) - .color(r, g, b, alpha) - .tex(1, v) - .overlay(OverlayTexture.NO_OVERLAY) - .lightmap(15728880) - .endVertex(); - builder.pos(positionMatrix, p3.getX(), p3.getY(), p3.getZ()) - .color(r, g, b, alpha) - .tex(1, v) - .overlay(OverlayTexture.NO_OVERLAY) - .lightmap(15728880) - .endVertex(); - builder.pos(positionMatrix, p4.getX(), p4.getY(), p4.getZ()) - .color(r, g, b, alpha) - .tex(0, v) - .overlay(OverlayTexture.NO_OVERLAY) - .lightmap(15728880) - .endVertex(); - builder.pos(positionMatrix, p2.getX(), p2.getY(), p2.getZ()) - .color(r, g, b, alpha) - .tex(0, v) - .overlay(OverlayTexture.NO_OVERLAY) - .lightmap(15728880) - .endVertex(); - } - - @Override - public boolean isGlobalRenderer(TileWirelessTransmit te) { - return true; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/TileWirelessTransmit.java b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/TileWirelessTransmit.java index 567ee9bf09..5de1c866bd 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/TileWirelessTransmit.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/TileWirelessTransmit.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.config.ConfigRegistry; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.UtilWorld; @@ -149,7 +150,7 @@ BlockPosDim getTargetInSlot(int s) { public void setField(int field, int value) { switch (Fields.values()[field]) { case RENDER: - this.render = value % 2; + this.render = value % PreviewOutlineType.values().length; break; } } diff --git a/src/main/java/com/lothrazar/cyclic/data/PreviewOutlineType.java b/src/main/java/com/lothrazar/cyclic/data/PreviewOutlineType.java new file mode 100644 index 0000000000..301d412c4b --- /dev/null +++ b/src/main/java/com/lothrazar/cyclic/data/PreviewOutlineType.java @@ -0,0 +1,4 @@ +package com.lothrazar.cyclic.data; +public enum PreviewOutlineType { + NONE, SHADOW, WIREFRAME; +} diff --git a/src/main/java/com/lothrazar/cyclic/gui/ButtonMachineField.java b/src/main/java/com/lothrazar/cyclic/gui/ButtonMachineField.java index 80251d6ef6..0bc209e713 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/ButtonMachineField.java +++ b/src/main/java/com/lothrazar/cyclic/gui/ButtonMachineField.java @@ -11,6 +11,7 @@ public class ButtonMachineField extends ButtonMachine { BlockPos tilePos; private TextureEnum textureOne; private TextureEnum textureZero; + private TextureEnum textureTwo = TextureEnum.RENDER_OUTLINE; private String tooltipPrefix; public ButtonMachineField(int xPos, int yPos, int field, BlockPos pos) { @@ -43,6 +44,18 @@ public void onValueUpdate(TileEntityBase tile) { private void onValueUpdate(int val) { setTooltip(UtilChat.lang(this.tooltipPrefix + val)); - setTextureId(val == 1 ? textureOne : textureZero); + // setTextureId(val == 1 ? textureOne : textureZero); + // PreviewOutlineType.NONE.ordinal(); // TODO: use enum in switch + switch (val) { + case 0: + setTextureId(textureZero); + break; + case 1: + setTextureId(textureOne); + break; + case 2: + setTextureId(textureTwo); + break; + } } } diff --git a/src/main/java/com/lothrazar/cyclic/gui/TextureEnum.java b/src/main/java/com/lothrazar/cyclic/gui/TextureEnum.java index 1bc3197034..a5c1ad6051 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/TextureEnum.java +++ b/src/main/java/com/lothrazar/cyclic/gui/TextureEnum.java @@ -1,7 +1,7 @@ package com.lothrazar.cyclic.gui; public enum TextureEnum { - REDSTONE_ON, REDSTONE_NEEDED, POWER_MOVING, POWER_STOP, RENDER_HIDE, RENDER_SHOW, CRAFT_EMPTY, CRAFT_BALANCE, CRAFT_MATCH, DIR_DOWN, DIR_UPWARDS; + REDSTONE_ON, REDSTONE_NEEDED, POWER_MOVING, POWER_STOP, RENDER_HIDE, RENDER_SHOW, CRAFT_EMPTY, CRAFT_BALANCE, CRAFT_MATCH, DIR_DOWN, DIR_UPWARDS, RENDER_OUTLINE; public int getX() { switch (this) { @@ -27,6 +27,8 @@ public int getX() { return 609; case CRAFT_MATCH: return 593; + case RENDER_OUTLINE: + return 1 - 3; } return 0; } @@ -55,6 +57,8 @@ public int getY() { return 129; case CRAFT_MATCH: return 129; + case RENDER_OUTLINE: + return 129 - 3; } return 0; } @@ -69,6 +73,7 @@ public int getWidth() { return 14; case DIR_DOWN: case DIR_UPWARDS: + case RENDER_OUTLINE: return 18; default: return 20; @@ -85,6 +90,7 @@ public int getHeight() { return 14; case DIR_DOWN: case DIR_UPWARDS: + case RENDER_OUTLINE: return 18; default: return 20; diff --git a/src/main/java/com/lothrazar/cyclic/util/UtilRender.java b/src/main/java/com/lothrazar/cyclic/util/UtilRender.java index cea26aad54..36c07f1f66 100644 --- a/src/main/java/com/lothrazar/cyclic/util/UtilRender.java +++ b/src/main/java/com/lothrazar/cyclic/util/UtilRender.java @@ -386,37 +386,41 @@ public static void renderColourCubes(RenderWorldLastEvent evt, Map 200d) { // could be 300 vec = vec.normalize().scale(200d); x += vec.x; y += vec.y; z += vec.z; } - x -= viewPosition.getX(); - y -= viewPosition.getY(); - z -= viewPosition.getZ(); + // x -= cameraPosition.getX(); + // y -= cameraPosition.getY(); + // z -= cameraPosition.getZ(); + matrixStack.translate(-cameraPosition.getX(), -cameraPosition.getY(), -cameraPosition.getZ()); RenderSystem.multMatrix(matrixStack.getLast().getMatrix()); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder renderer = tessellator.getBuffer(); @@ -457,6 +461,12 @@ public static void createBox(MatrixStack matrixStack, BlockPos pos) { // RenderSystem.color4f(1f, 1f, 1f, 1f); } + private static float[] getRandomColour() { + long c = (System.currentTimeMillis() / 15L) % 360L; + float[] color = getHSBtoRGBF(c / 360f, 1f, 1f); + return color; + } + /** * From https://github.com/Lothrazar/SimpleTomb/blob/704bad5a33731125285d700c489bfe2c3a9e387d/src/main/java/com/lothrazar/simpletomb/helper/WorldHelper.java#L163 * diff --git a/src/main/resources/assets/cyclic/lang/en_us.json b/src/main/resources/assets/cyclic/lang/en_us.json index 039397b95d..e9ecc83599 100644 --- a/src/main/resources/assets/cyclic/lang/en_us.json +++ b/src/main/resources/assets/cyclic/lang/en_us.json @@ -1272,7 +1272,8 @@ "block.cyclic.plate_vector.tooltip.yaw": "Yaw:", "block.cyclic.poison": "Poison", "gui.cyclic.render0": "Preview Hidden", - "gui.cyclic.render1": "Preview Rendered", + "gui.cyclic.render1": "Preview Shadow", + "gui.cyclic.render2": "Preview Outline", "gui.cyclic.redstone0": "Always On", "gui.cyclic.redstone1": "Requires Redstone", "block.cyclic.spikes.guide": "Spikes can be placed in the world in any orientation to damage creatures or players that touch them. Spikes are only extended when they receive a redstone signal.", diff --git a/update.json b/update.json index 3c6eba07e4..bb6b8a8376 100644 --- a/update.json +++ b/update.json @@ -81,6 +81,6 @@ ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " ,"1.5.23":"Growth enchantment now uses the same logic as Sprinkler & Terra Soil (only minecraft:crops or minecraft::saplings can grow, respect IGrowable::canUseBonemeal). New gloomIgnored config Gloom enchant (cyclic:curse) to ignore and not use these effects #2217 #2325. Fix Soundproofing block not muting Mekanism sounds #2389 (for example Precision Sawmill and others - you may need four or more soundproofing blocks for the desired effect). Patch an edge-case where User might drop items on the ground. New config [cyclic.blocks.soundproofing] radius = 6 to control the area. Fix item cable routing #2245 #2230. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions #1913. Balance recipe changes for #2372. Balance changes made for Excavate enchant it will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. New feature for Excavate enchant #2116 it will not trigger on anything matching the block data-tag 'cyclic:ignored/excavate'. [Backported changes from mc1.20.1] #2182 candle model assets; Block Breaker no longer tries (and fails) to mine liquid source blocks; Block Randomizer use wireframe rendering only of non-air instead of solid shading; Glistering & Corrupted chorus only restores 1 food-unit down from 3; a few recipes tweaked/backported to match mc1.20.1+, ported crafttweaker zenscript support for generator_fluid and generator_item; backported item data tags for use in recipes for example forge:vines, forge:sandstone, forge:mushrooms " ,"1.5.24":"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. " - ,"":"New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). " + ,"":"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 " } } From 88570c93461793d745bfc182bb5ca712beca5cee Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sat, 19 Oct 2024 19:49:58 -0700 Subject: [PATCH 3/5] backport fluid/energy cable capacity configs --- examples/config/cyclic.toml | 20 ++++++++++++++++++- .../block/cable/energy/TileCableEnergy.java | 14 +++++++++---- .../block/cable/fluid/TileCableFluid.java | 16 ++++++++------- .../creativebattery/TileBatteryInfinite.java | 2 +- .../cyclic/block/forester/TileForester.java | 6 +++--- .../cyclic/block/packager/TilePackager.java | 2 +- .../cyclic/block/peatfarm/TilePeatFarm.java | 2 +- .../block/shapebuilder/TileStructure.java | 2 +- .../lothrazar/cyclic/block/user/TileUser.java | 2 +- .../cyclic/config/ConfigRegistry.java | 14 +++++++++++++ update.json | 2 +- 11 files changed, 61 insertions(+), 21 deletions(-) diff --git a/examples/config/cyclic.toml b/examples/config/cyclic.toml index 4eedae6c94..2267ab53ff 100644 --- a/examples/config/cyclic.toml +++ b/examples/config/cyclic.toml @@ -190,7 +190,7 @@ ##################################################################################### [cyclic.logging] #Unblock info logs; very spammy; can be useful for testing certain issues - info = true + info = false ##################################################################################### #Fluid cost for various machines @@ -418,6 +418,24 @@ ##################################################################################### [cyclic.energy] + [cyclic.energy.cables] + + [cyclic.energy.cables.fluid] + # How many buckets of buffer fluid the fluid cable can hold (for each direction. for example 2 here means 2000ub in each face) + #Range: 1 ~ 32 + buffer = 16 + # How many fluid units per tick can flow through these cables each tick (1 bucket = 1000) including normal flow and extraction mode + #Range: > 100 + flow = 16000 + + [cyclic.energy.cables.energy] + # How much buffer the energy cables hold (must not be smaller than flow) + #Range: > 1 + buffer = 32000 + # How fast energy flows in these cables (must not be greater than buffer) + #Range: > 100 + flow = 32000 + ##################################################################################### #Energy cost for various machines, either per use of an action or per tick (twenty ticks per second). Setting as zero (0) lets machine run for free ##################################################################################### diff --git a/src/main/java/com/lothrazar/cyclic/block/cable/energy/TileCableEnergy.java b/src/main/java/com/lothrazar/cyclic/block/cable/energy/TileCableEnergy.java index 943cc5a30b..383c56eac0 100644 --- a/src/main/java/com/lothrazar/cyclic/block/cable/energy/TileCableEnergy.java +++ b/src/main/java/com/lothrazar/cyclic/block/cable/energy/TileCableEnergy.java @@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.ForgeConfigSpec.IntValue; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; @@ -24,9 +25,12 @@ public class TileCableEnergy extends TileCableBase implements ITickableTileEntity { - private static final int MAX = 32000; - final CustomEnergyStorage energy = new CustomEnergyStorage(MAX, MAX); - private final LazyOptional energyCap = LazyOptional.of(() -> energy); + // + public static IntValue BUFFERSIZE; + public static IntValue TRANSFER_RATE; + // + final CustomEnergyStorage energy;// = new CustomEnergyStorage(MAX, MAX); + private final LazyOptional energyCap;// = LazyOptional.of(() -> energy); private final ConcurrentHashMap> flow = new ConcurrentHashMap<>(); private final Map mapIncomingEnergy = Maps.newHashMap(); private int energyLastSynced = -1; //fluid tanks have 'onchanged', energy caps do not @@ -36,6 +40,8 @@ public TileCableEnergy() { for (Direction f : Direction.values()) { mapIncomingEnergy.put(f, 0); } + energy = new CustomEnergyStorage(BUFFERSIZE.get(), TRANSFER_RATE.get()); + energyCap = LazyOptional.of(() -> energy); } @Override @@ -109,7 +115,7 @@ private void tickCableFlow() { continue; } if (!this.isEnergyIncomingFromFace(outgoingSide)) { - moveEnergy(outgoingSide, MAX); + moveEnergy(outgoingSide, TRANSFER_RATE.get()); } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/cable/fluid/TileCableFluid.java b/src/main/java/com/lothrazar/cyclic/block/cable/fluid/TileCableFluid.java index 272930a5ec..8789b47578 100644 --- a/src/main/java/com/lothrazar/cyclic/block/cable/fluid/TileCableFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/cable/fluid/TileCableFluid.java @@ -23,6 +23,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; +import net.minecraftforge.common.ForgeConfigSpec.IntValue; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidAttributes; @@ -40,15 +41,16 @@ public boolean isItemValid(int slot, ItemStack stack) { return stack.getItem() == ItemRegistry.filter_data; } }; - public static final int CAPACITY = 16 * FluidAttributes.BUCKET_VOLUME; - public static final int FLOW_RATE = CAPACITY; //normal non-extract flow - public static final int EXTRACT_RATE = CAPACITY; - private final FluidTank fluidTank = new FluidTankBase(this, CAPACITY, fluidStack -> FilterCardItem.filterAllowsExtract(filter.getStackInSlot(0), fluidStack)); - private final LazyOptional fluidCap = LazyOptional.of(() -> fluidTank); + public static IntValue BUFFERSIZE; + public static IntValue TRANSFER_RATE; + private final FluidTank fluidTank; + private final LazyOptional fluidCap; private final ConcurrentHashMap> flow = new ConcurrentHashMap<>(); public TileCableFluid() { super(TileRegistry.fluid_pipeTile); + fluidTank = new FluidTankBase(this, BUFFERSIZE.get() * FluidAttributes.BUCKET_VOLUME, fluidStack -> FilterCardItem.filterAllowsExtract(filter.getStackInSlot(0), fluidStack)); + fluidCap = LazyOptional.of(() -> fluidTank); } @Override @@ -92,7 +94,7 @@ private void tryExtract(Direction extractSide) { return; } //first try standard fluid transfer - if (UtilFluid.tryFillPositionFromTank(world, pos, extractSide, tankTarget, EXTRACT_RATE)) { + if (UtilFluid.tryFillPositionFromTank(world, pos, extractSide, tankTarget, TRANSFER_RATE.get())) { return; } //handle special cases @@ -112,7 +114,7 @@ private void normalFlow() { if (connection.isExtraction() || connection.isBlocked()) { continue; } - this.moveFluids(outgoingSide, pos.offset(outgoingSide), FLOW_RATE, fluidTank); + this.moveFluids(outgoingSide, pos.offset(outgoingSide), TRANSFER_RATE.get(), fluidTank); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/creativebattery/TileBatteryInfinite.java b/src/main/java/com/lothrazar/cyclic/block/creativebattery/TileBatteryInfinite.java index 642cafdbea..e50f82902c 100644 --- a/src/main/java/com/lothrazar/cyclic/block/creativebattery/TileBatteryInfinite.java +++ b/src/main/java/com/lothrazar/cyclic/block/creativebattery/TileBatteryInfinite.java @@ -19,7 +19,7 @@ public class TileBatteryInfinite extends TileEntityBase implements ITickableTileEntity { - static final int MAX = 960000000; + static final int MAX = Integer.MAX_VALUE; static enum Fields { N, E, S, W, U, D; diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java index f10e16a34f..17aafba3a6 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -53,6 +53,7 @@ static enum Fields { public static IntValue POWERCONF; private int height = MAX_HEIGHT; private int radius = MAX_SIZE; + private BlockPos targetPos = null; CustomEnergyStorage energy = new CustomEnergyStorage(MAX, MAX); ItemStackHandler inventory = new ItemStackHandler(1) { @@ -96,7 +97,7 @@ public void tick() { } //update target shapeIndex++; - BlockPos targetPos = getShapeTarget(shape); + targetPos = getShapeTarget(shape); //only saplings at my level, the rest is harvesting try { if (fakePlayer == null && world instanceof ServerWorld) { @@ -211,7 +212,7 @@ private int heightWithDirection() { //for harvest public List getShape() { BlockPos center = getFacingShapeCenter(radius); - List shape = UtilShape.cubeSquareBase(center, radius, height); + List shape = UtilShape.cubeSquareBase(center, radius, 0); int heightWithDirection = heightWithDirection(); if (heightWithDirection != 0) { shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); @@ -227,7 +228,6 @@ public List getShapeHollow() { if (heightWithDirection != 0) { shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); } - BlockPos targetPos = getShapeTarget(shape); if (targetPos != null) { shape.add(targetPos); } diff --git a/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java b/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java index afc80ca294..b9e4606ddc 100644 --- a/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java +++ b/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java @@ -120,7 +120,7 @@ public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity @Override public LazyOptional getCapability(Capability cap, Direction side) { - if (cap == CapabilityEnergy.ENERGY) { + if (cap == CapabilityEnergy.ENERGY && POWERCONF.get() > 0) { return energyCap.cast(); } if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { diff --git a/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java b/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java index 1832e67476..c3fa470878 100644 --- a/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java +++ b/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java @@ -255,7 +255,7 @@ public LazyOptional getCapability(Capability cap, Direction side) { if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return tankWrapper.cast(); } - if (cap == CapabilityEnergy.ENERGY) { + if (cap == CapabilityEnergy.ENERGY && POWERCONF.get() > 0) { return energyCap.cast(); } return super.getCapability(cap, side); diff --git a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java index e59aef07d9..004aaac8e5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java @@ -127,7 +127,7 @@ public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity @Override public LazyOptional getCapability(Capability cap, Direction side) { - if (cap == CapabilityEnergy.ENERGY) { + if (cap == CapabilityEnergy.ENERGY && POWERCONF.get() > 0) { return energyCap.cast(); } if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { diff --git a/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java b/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java index fb113e0e01..6c6e87c7e2 100644 --- a/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java +++ b/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java @@ -170,7 +170,7 @@ public LazyOptional getCapability(Capability cap, Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return inventoryCap.cast(); } - if (cap == CapabilityEnergy.ENERGY) { + if (POWERCONF.get() > 0 && cap == CapabilityEnergy.ENERGY) { return energyCap.cast(); } return super.getCapability(cap, side); diff --git a/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java b/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java index e934fa3473..636518f1c7 100644 --- a/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java +++ b/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java @@ -8,6 +8,8 @@ import com.lothrazar.cyclic.block.anvilvoid.TileAnvilVoid; import com.lothrazar.cyclic.block.battery.TileBattery; import com.lothrazar.cyclic.block.beaconpotion.TilePotion; +import com.lothrazar.cyclic.block.cable.energy.TileCableEnergy; +import com.lothrazar.cyclic.block.cable.fluid.TileCableFluid; import com.lothrazar.cyclic.block.collectfluid.TileFluidCollect; import com.lothrazar.cyclic.block.crafter.TileCrafter; import com.lothrazar.cyclic.block.disenchant.TileDisenchant; @@ -261,6 +263,18 @@ private static void initConfig() { PEATERICHPOWER = CFG.comment("Power gained burning one of this") .defineInRange("peat_fuel_enriched", 256 * 4, 1, 64000); CFG.pop(); //fuel + // + TileCableFluid.BUFFERSIZE = CFG.comment(" How many buckets of buffer fluid the fluid cable can hold (for each direction. for example 2 here means 2000ub in each face)") + .defineInRange("cables.fluid.buffer", 16, 1, 32); + TileCableFluid.TRANSFER_RATE = CFG.comment(" How many fluid units per tick can flow through these cables each tick (1 bucket = 1000) including normal flow and extraction mode") + .defineInRange("cables.fluid.flow", 16000, 100, Integer.MAX_VALUE); + TileCableEnergy.BUFFERSIZE = CFG.comment(" How much buffer the energy cables hold (must not be smaller than flow)") + .defineInRange("cables.energy.buffer", 32000, 1, Integer.MAX_VALUE); + TileCableEnergy.TRANSFER_RATE = CFG.comment(" How fast energy flows in these cables (must not be greater than buffer)") + .defineInRange("cables.energy.flow", 32000, 100, Integer.MAX_VALUE); + // + // + // TileGeneratorFuel.RF_PER_TICK = CFG.comment("RF energy per tick generated while burning furnace fuel in this machine. Burn time in ticks is the same as furnace values, so 1 coal = 1600 ticks") .defineInRange("generator_fuel.rf_per_tick", 80, 1, 6400); TileGeneratorFood.RF_PER_TICK = CFG.comment("RF energy per tick generated while burning food in this machine") diff --git a/update.json b/update.json index bb6b8a8376..1b71188be5 100644 --- a/update.json +++ b/update.json @@ -81,6 +81,6 @@ ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " ,"1.5.23":"Growth enchantment now uses the same logic as Sprinkler & Terra Soil (only minecraft:crops or minecraft::saplings can grow, respect IGrowable::canUseBonemeal). New gloomIgnored config Gloom enchant (cyclic:curse) to ignore and not use these effects #2217 #2325. Fix Soundproofing block not muting Mekanism sounds #2389 (for example Precision Sawmill and others - you may need four or more soundproofing blocks for the desired effect). Patch an edge-case where User might drop items on the ground. New config [cyclic.blocks.soundproofing] radius = 6 to control the area. Fix item cable routing #2245 #2230. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions #1913. Balance recipe changes for #2372. Balance changes made for Excavate enchant it will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. New feature for Excavate enchant #2116 it will not trigger on anything matching the block data-tag 'cyclic:ignored/excavate'. [Backported changes from mc1.20.1] #2182 candle model assets; Block Breaker no longer tries (and fails) to mine liquid source blocks; Block Randomizer use wireframe rendering only of non-air instead of solid shading; Glistering & Corrupted chorus only restores 1 food-unit down from 3; a few recipes tweaked/backported to match mc1.20.1+, ported crafttweaker zenscript support for generator_fluid and generator_item; backported item data tags for use in recipes for example forge:vines, forge:sandstone, forge:mushrooms " ,"1.5.24":"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. " - ,"":"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 " + ,"":"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 " } } From 9501a0ed94dd0817c055272fb7706552543a9e2e Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sat, 19 Oct 2024 21:44:00 -0700 Subject: [PATCH 4/5] adding comparator support to more blocks --- build.gradle | 2 ++ .../com/lothrazar/cyclic/base/TileEntityBase.java | 15 +++++++++++++++ .../block/collectitem/BlockItemCollector.java | 11 +++++++++++ .../block/collectitem/TileItemCollector.java | 1 + .../com/lothrazar/cyclic/block/dice/TileDice.java | 2 +- .../block/enderitemshelf/BlockItemShelf.java | 14 ++++++++++++++ .../cyclic/block/fishing/BlockFisher.java | 12 ++++++++++++ .../cyclic/block/fishing/TileFisher.java | 1 + .../cyclic/block/forester/BlockForester.java | 11 +++++++++++ .../cyclic/block/forester/TileForester.java | 1 + .../block/generatorfluid/BlockGeneratorFluid.java | 13 +++++++++++++ .../block/generatorfood/BlockGeneratorFood.java | 13 +++++++++++++ .../block/generatorfood/TileGeneratorFood.java | 1 + .../block/generatorfuel/BlockGeneratorFuel.java | 13 +++++++++++++ .../block/generatorfuel/TileGeneratorFuel.java | 1 + .../block/generatoritem/BlockGeneratorDrops.java | 13 +++++++++++++ .../block/generatoritem/TileGeneratorDrops.java | 3 +-- .../block/generatorpeat/BlockGeneratorPeat.java | 13 +++++++++++++ .../block/generatorpeat/TileGeneratorPeat.java | 1 + .../cyclic/block/hopper/BlockSimpleHopper.java | 12 ++++++++++++ .../cyclic/block/hopper/TileSimpleHopper.java | 5 +++-- update.json | 2 +- 22 files changed, 154 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 0954c7173e..54ecc349bd 100644 --- a/build.gradle +++ b/build.gradle @@ -97,6 +97,8 @@ dependencies { // optional dependencies & mods for testing compat + implementation fg.deobf("curse.maven:jade-324717:3910873") + implementation fg.deobf("curse.maven:mantle-74924:3482897") implementation fg.deobf("curse.maven:tinkers-construct-74072:3482903") implementation fg.deobf("curse.maven:cucumber-272335:3507886") diff --git a/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java index 4c35874c11..2307ae2b8b 100644 --- a/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java +++ b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java @@ -523,6 +523,10 @@ public void setFluid(FluidStack fluid) {} @Deprecated @Override public int getSizeInventory() { + IItemHandler invo = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); + if (invo != null) { + return invo.getSlots(); + } return 0; } @@ -535,6 +539,13 @@ public boolean isEmpty() { @Deprecated @Override public ItemStack getStackInSlot(int index) { + IItemHandler invo = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); + try { + if (invo != null && index < invo.getSlots()) { + return invo.getStackInSlot(index); + } + } + catch (Exception e) {} return ItemStack.EMPTY; } @@ -609,4 +620,8 @@ public boolean getBlockStateVertical() { return this.getBlockState().get(BlockStateProperties.FACING).getAxis().isVertical(); return false; } + + public void updateComparatorOutputLevel() { + world.updateComparatorOutputLevel(pos, this.getBlockState().getBlock()); + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java index 025209d862..791bab88b5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java @@ -9,6 +9,7 @@ import net.minecraft.block.SoundType; import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; @@ -25,6 +26,16 @@ public BlockItemCollector(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java index 551ad42174..2c9a5365fe 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java @@ -81,6 +81,7 @@ public void tick() { break; } remainder = inventory.insertItem(i, remainder, false); + updateComparatorOutputLevel(); } stackEntity.setItem(remainder); if (remainder.isEmpty()) { diff --git a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java index cde4bbbaa9..22f2a9c381 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java +++ b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java @@ -44,7 +44,7 @@ public void startSpinning() { public void tick() { if (this.timer == 0) { this.spinningIfZero = 1; - world.updateComparatorOutputLevel(pos, this.getBlockState().getBlock()); + updateComparatorOutputLevel(); } else { this.timer--; diff --git a/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java b/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java index 83686fc88d..df798b885c 100644 --- a/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java +++ b/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java @@ -14,6 +14,7 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.StateContainer; @@ -35,6 +36,16 @@ public BlockItemShelf(Properties properties) { super(properties.hardnessAndResistance(0.8F).notSolid()); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void registerClient() { ClientRegistry.bindTileEntityRenderer(TileRegistry.ENDER_ITEM_SHELF.get(), ItemShelfRenderer::new); @@ -89,6 +100,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos //try to insert boolean oldEmpty = shelfStack.isEmpty(); ItemStack remaining = shelf.inventory.insertItem(slot, heldItem, false); + world.updateComparatorOutputLevel(pos, shelf.getBlockState().getBlock()); if (remaining.isEmpty() || remaining.getCount() != shelfStack.getCount()) { player.setHeldItem(hand, remaining); player.swingArm(hand); @@ -102,6 +114,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos //withdraw direct to players empty hand int q = player.isCrouching() ? 1 : 64; ItemStack retrieved = shelf.inventory.extractItem(slot, q, false); + world.updateComparatorOutputLevel(pos, shelf.getBlockState().getBlock()); player.setHeldItem(hand, retrieved); player.swingArm(hand); } @@ -114,6 +127,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos player.setHeldItem(hand, forPlayer); player.swingArm(hand); shelf.inventory.insertItem(slot, forShelf, false); + world.updateComparatorOutputLevel(pos, shelf.getBlockState().getBlock()); } return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java b/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java index 5d6935d8bb..82d2c0a07a 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java +++ b/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java @@ -8,10 +8,12 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.fluid.FluidState; +import net.minecraft.inventory.container.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; import net.minecraftforge.fml.client.registry.ClientRegistry; public class BlockFisher extends BlockBase { @@ -21,6 +23,16 @@ public BlockFisher(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader world, BlockPos pos, FluidState fluidState) { return true; diff --git a/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java b/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java index 1b95253097..9f9b164b10 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java +++ b/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java @@ -116,6 +116,7 @@ public void tick() { catch (Exception e) { ModCyclic.LOGGER.error("Fishing Block: Loot table failed", e); } + updateComparatorOutputLevel(); } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java index cf3bd23beb..da5aaababd 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java @@ -8,6 +8,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; @@ -24,6 +25,16 @@ public BlockForester(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void registerClient() { ClientRegistry.bindTileEntityRenderer(TileRegistry.FORESTER, RenderForester::new); diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java index 17aafba3a6..d160507fa1 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -114,6 +114,7 @@ public void tick() { else if (this.isSapling(dropMe)) { ActionResultType result = TileEntityBase.rightClickBlock(fakePlayer, world, targetPos, Hand.OFF_HAND, Direction.DOWN); if (result == ActionResultType.CONSUME) { + updateComparatorOutputLevel(); //ok then DRAIN POWER energy.extractEnergy(cost, false); } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java index 57c92b3d28..e7924aa2ee 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorFluid extends BlockBase { @@ -21,6 +24,16 @@ public BlockGeneratorFluid(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java b/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java index 39c50bcaed..dd6ad5d2b2 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorFood extends BlockBase { @@ -20,6 +23,16 @@ public BlockGeneratorFood(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java b/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java index 032a76b255..94d133a42d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java @@ -92,6 +92,7 @@ private void tryConsumeFuel() { this.burnTimeMax = burnTimeTicks; this.burnTime = this.burnTimeMax; stack.shrink(1); + updateComparatorOutputLevel(); //nether items, mob drops // lava fluid //exp fluid diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java index ea7a31dc4a..193f5668db 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorFuel extends BlockBase { @@ -20,6 +23,16 @@ public BlockGeneratorFuel(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java index f448ed9603..d3323c1ea7 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java @@ -97,6 +97,7 @@ private void tryConsumeFuel() { else { stack.shrink(1); } + updateComparatorOutputLevel(); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java b/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java index 3a07e99e7d..32a3b3f429 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java @@ -7,9 +7,12 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorDrops extends BlockBase { @@ -19,6 +22,16 @@ public BlockGeneratorDrops(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java b/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java index 4e1b1283a2..aa78ab0882 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java @@ -1,6 +1,5 @@ package com.lothrazar.cyclic.block.generatoritem; -import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.block.battery.TileBattery; import com.lothrazar.cyclic.capability.CustomEnergyStorage; @@ -106,7 +105,7 @@ private void findMatchingRecipe() { this.burnTime = this.burnTimeMax; this.burnPerTick = this.currentRecipe.getRfpertick(); this.inputSlots.extractItem(0, 1, false); - ModCyclic.LOGGER.info("found genrecipe" + currentRecipe.getId()); + updateComparatorOutputLevel(); return; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java index e8284b5743..4d2e34013c 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java @@ -5,9 +5,12 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.gui.ScreenManager; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorPeat extends BlockBase { @@ -16,6 +19,16 @@ public BlockGeneratorPeat(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public boolean hasTileEntity(BlockState state) { return true; diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java index 09393a20d0..7187e48991 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java @@ -109,6 +109,7 @@ public void tick() { fuelRate = peat.getPeatFuelValue(); inventory.extractItem(0, 1, false); this.timer = BURNTIME; + updateComparatorOutputLevel(); } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java index 6bd3bd7c0f..8a674acb0e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.inventory.container.Container; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; @@ -16,6 +17,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; @SuppressWarnings("deprecation") public class BlockSimpleHopper extends BlockBase { @@ -26,6 +28,16 @@ public BlockSimpleHopper(Properties properties) { super(properties.hardnessAndResistance(1.3F)); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(FACING); diff --git a/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java index 8c6ad13d29..556bc8f876 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java @@ -1,7 +1,6 @@ package com.lothrazar.cyclic.block.hopper; import com.lothrazar.cyclic.base.TileEntityBase; -import com.lothrazar.cyclic.block.hopperfluid.BlockFluidHopper; import com.lothrazar.cyclic.registry.TileRegistry; import java.util.List; import net.minecraft.block.BlockState; @@ -55,9 +54,10 @@ public void tick() { } this.tryPullFromWorld(pos.offset(Direction.UP)); this.tryExtract(inventory, Direction.UP, getFlow(), null); - Direction exportToSide = this.getBlockState().get(BlockFluidHopper.FACING); + Direction exportToSide = this.getBlockState().get(BlockSimpleHopper.FACING); this.moveItemToCompost(exportToSide, inventory); this.moveItems(exportToSide, getFlow(), inventory); + updateComparatorOutputLevel(); } public int getFlow() { @@ -74,6 +74,7 @@ private void tryPullFromWorld(BlockPos center) { if (remainder.isEmpty()) { stackEntity.remove(); } + updateComparatorOutputLevel(); } } diff --git a/update.json b/update.json index 1b71188be5..96d83aba74 100644 --- a/update.json +++ b/update.json @@ -81,6 +81,6 @@ ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " ,"1.5.23":"Growth enchantment now uses the same logic as Sprinkler & Terra Soil (only minecraft:crops or minecraft::saplings can grow, respect IGrowable::canUseBonemeal). New gloomIgnored config Gloom enchant (cyclic:curse) to ignore and not use these effects #2217 #2325. Fix Soundproofing block not muting Mekanism sounds #2389 (for example Precision Sawmill and others - you may need four or more soundproofing blocks for the desired effect). Patch an edge-case where User might drop items on the ground. New config [cyclic.blocks.soundproofing] radius = 6 to control the area. Fix item cable routing #2245 #2230. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions #1913. Balance recipe changes for #2372. Balance changes made for Excavate enchant it will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. New feature for Excavate enchant #2116 it will not trigger on anything matching the block data-tag 'cyclic:ignored/excavate'. [Backported changes from mc1.20.1] #2182 candle model assets; Block Breaker no longer tries (and fails) to mine liquid source blocks; Block Randomizer use wireframe rendering only of non-air instead of solid shading; Glistering & Corrupted chorus only restores 1 food-unit down from 3; a few recipes tweaked/backported to match mc1.20.1+, ported crafttweaker zenscript support for generator_fluid and generator_item; backported item data tags for use in recipes for example forge:vines, forge:sandstone, forge:mushrooms " ,"1.5.24":"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. " - ,"":"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 " + ,"":"Some blocks allow minecraft:comparator to pull a redstone signal based on inventory contents: Wooden Hopper, Item Collector, Forester, Item Shelf, . 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 " } } From b4cc54208a9b9c2b211027464f4916c0ae097392 Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sat, 19 Oct 2024 23:41:05 -0700 Subject: [PATCH 5/5] adding comparator support for fluids --- .../com/lothrazar/cyclic/base/BlockBase.java | 13 ++++++++++++ .../cyclic/block/crafter/BlockCrafter.java | 11 ++++++++++ .../cyclic/block/crafter/TileCrafter.java | 1 + .../cyclic/block/crate/BlockCrate.java | 11 ++++++++++ .../cyclic/block/crate/TileCrate.java | 1 + .../lothrazar/cyclic/block/dice/TileDice.java | 21 ------------------- .../block/hopperfluid/BlockFluidHopper.java | 11 ++++++++++ .../block/hopperfluid/TileFluidHopper.java | 2 ++ .../block/hoppergold/BlockGoldHopper.java | 13 ++++++++++++ .../cyclic/block/melter/BlockMelter.java | 12 +++++++++++ .../cyclic/block/melter/TileMelter.java | 1 + .../cyclic/block/packager/BlockPackager.java | 13 ++++++++++++ .../cyclic/block/packager/TilePackager.java | 1 + .../cyclic/block/placer/BlockPlacer.java | 11 ++++++++++ .../cyclic/block/placer/TilePlacer.java | 4 ++-- .../block/solidifier/BlockSolidifier.java | 12 +++++++++++ .../block/solidifier/TileSolidifier.java | 1 + .../cyclic/block/tank/BlockFluidTank.java | 10 +++++++++ .../lothrazar/cyclic/block/tank/TileTank.java | 2 ++ .../cyclic/block/tankcask/BlockCask.java | 10 +++++++++ update.json | 2 +- 21 files changed, 139 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/lothrazar/cyclic/base/BlockBase.java b/src/main/java/com/lothrazar/cyclic/base/BlockBase.java index 22f499b645..4d9e56c998 100644 --- a/src/main/java/com/lothrazar/cyclic/base/BlockBase.java +++ b/src/main/java/com/lothrazar/cyclic/base/BlockBase.java @@ -22,6 +22,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; @@ -192,4 +193,16 @@ private static boolean hasCapabilityDir(Direction facing, IWorld world, BlockPos } return false; } + + //for comparators that dont use item inventories + protected int calcRedstoneFromFluid(TileEntity tileEntity) { + IFluidHandler fluid = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY).orElse(null); + if (fluid.getFluidInTank(0).isEmpty()) { + return 0; + } + float cap = fluid.getTankCapacity(0); + float amt = fluid.getFluidInTank(0).getAmount(); + float f = amt / cap; + return MathHelper.floor(f * 14.0F) + 1; + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java b/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java index df27befdaa..a300a96c2d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java +++ b/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java @@ -28,6 +28,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.gui.ScreenManager; import net.minecraft.inventory.InventoryHelper; +import net.minecraft.inventory.container.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; @@ -42,6 +43,16 @@ public BlockCrafter(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { diff --git a/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java b/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java index 42fb5d8ab3..782ebfdefb 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java +++ b/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java @@ -236,6 +236,7 @@ else if (!itemStacksInGrid.equals(lastRecipeGrid)) { break; } } + this.updateComparatorOutputLevel(); } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/crate/BlockCrate.java b/src/main/java/com/lothrazar/cyclic/block/crate/BlockCrate.java index c51af8bd8e..ad97d7d100 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crate/BlockCrate.java +++ b/src/main/java/com/lothrazar/cyclic/block/crate/BlockCrate.java @@ -10,6 +10,7 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -26,6 +27,16 @@ public BlockCrate(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public boolean hasTileEntity(BlockState state) { return true; diff --git a/src/main/java/com/lothrazar/cyclic/block/crate/TileCrate.java b/src/main/java/com/lothrazar/cyclic/block/crate/TileCrate.java index e5accef293..a50f69686f 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crate/TileCrate.java +++ b/src/main/java/com/lothrazar/cyclic/block/crate/TileCrate.java @@ -33,6 +33,7 @@ public ITextComponent getDisplayName() { @Override public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) { + this.updateComparatorOutputLevel(); return new ContainerCrate(i, world, pos, playerInventory, playerEntity); } diff --git a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java index 22f2a9c381..133a47b51c 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java +++ b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java @@ -55,29 +55,8 @@ public void tick() { BlockState stateold = world.getBlockState(pos); BlockState newstate = stateold.with(BlockStateProperties.FACING, fac); world.setBlockState(pos, newstate); - // world.notifyBlockUpdate(pos, stateold, newstate, 3); } } - // - // - // @Override - // public void update() { - // if (this.timer == 0) { - // this.spinningIfZero = 1; - // world.updateComparatorOutputLevel(pos, this.blockType); - // } - // else { - // this.timer--; - // //toggle block state - // if (this.timer % TICKS_PER_CHANGE == 0) { - // this.spinningIfZero = 0; - // EnumFacing fac = UtilDirection.getRandom(world.rand); - // IBlockState stateold = world.getBlockState(pos); - // IBlockState newstate = stateold.withProperty(BlockDice.PROPERTYFACING, fac); - // world.setBlockState(pos, newstate); - // // world.notifyBlockUpdate(pos, stateold, newstate, 3); - // } - // } } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java index 78cabbfdaf..204c071255 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java @@ -14,6 +14,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockFluidHopper extends BlockBase { @@ -24,6 +25,16 @@ public BlockFluidHopper(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return calcRedstoneFromFluid(worldIn.getTileEntity(pos)); + } + @Override public void registerClient() { // RenderTypeLookup.setRenderLayer(this, RenderType.getTranslucent()); 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 c89d3040a9..48c5ccf799 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java @@ -79,11 +79,13 @@ private void tryExtract(Direction extractSide) { if (stuff != null) { success = UtilFluid.tryFillPositionFromTank(world, pos, extractSide, stuff, FLOW); if (success) { + this.updateComparatorOutputLevel(); return; } } if (!success && tank.getSpace() >= FluidAttributes.BUCKET_VOLUME) { UtilFluid.extractSourceWaterloggedCauldron(world, target, tank); + this.updateComparatorOutputLevel(); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/hoppergold/BlockGoldHopper.java b/src/main/java/com/lothrazar/cyclic/block/hoppergold/BlockGoldHopper.java index 813a8c897e..0dc5efeb04 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hoppergold/BlockGoldHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hoppergold/BlockGoldHopper.java @@ -2,8 +2,11 @@ import com.lothrazar.cyclic.block.hopper.BlockSimpleHopper; import net.minecraft.block.BlockState; +import net.minecraft.inventory.container.Container; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGoldHopper extends BlockSimpleHopper { @@ -11,6 +14,16 @@ public BlockGoldHopper(Properties properties) { super(properties.hardnessAndResistance(1.3F)); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new TileGoldHopper(); diff --git a/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java b/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java index c96590d910..839dbe7e61 100644 --- a/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java +++ b/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java @@ -9,12 +9,14 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.fluid.FluidState; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; import net.minecraftforge.common.ToolType; import net.minecraftforge.fml.client.registry.ClientRegistry; @@ -25,6 +27,16 @@ public BlockMelter(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override @Deprecated public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) { diff --git a/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java b/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java index a00fcd6cdc..180d7f1967 100644 --- a/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java +++ b/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java @@ -211,6 +211,7 @@ private boolean tryProcessRecipe() { inventory.getStackInSlot(0).shrink(1); inventory.getStackInSlot(1).shrink(1); tank.fill(this.currentRecipe.getRecipeFluid(), FluidAction.EXECUTE); + updateComparatorOutputLevel(); return true; } return false; diff --git a/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java b/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java index 846d2b9e94..73cdc347a6 100644 --- a/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java +++ b/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockPackager extends BlockBase { @@ -19,6 +22,16 @@ public BlockPackager(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java b/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java index b9e4606ddc..18772bf166 100644 --- a/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java +++ b/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java @@ -97,6 +97,7 @@ private void tryDoPackage() { inputSlots.extractItem(0, total, false); outputSlots.insertItem(0, output, false); energy.extractEnergy(POWERCONF.get(), false); + this.updateComparatorOutputLevel(); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/placer/BlockPlacer.java b/src/main/java/com/lothrazar/cyclic/block/placer/BlockPlacer.java index 240293314e..e0f5260118 100644 --- a/src/main/java/com/lothrazar/cyclic/block/placer/BlockPlacer.java +++ b/src/main/java/com/lothrazar/cyclic/block/placer/BlockPlacer.java @@ -7,6 +7,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; @@ -22,6 +23,16 @@ public BlockPlacer(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void registerClient() { ScreenManager.registerFactory(ContainerScreenRegistry.placer, ScreenPlacer::new); diff --git a/src/main/java/com/lothrazar/cyclic/block/placer/TilePlacer.java b/src/main/java/com/lothrazar/cyclic/block/placer/TilePlacer.java index 254b2fd99e..2db5d7004b 100644 --- a/src/main/java/com/lothrazar/cyclic/block/placer/TilePlacer.java +++ b/src/main/java/com/lothrazar/cyclic/block/placer/TilePlacer.java @@ -56,9 +56,9 @@ public void tick() { Direction dir = this.getBlockState().get(BlockStateProperties.FACING); BlockPos offset = pos.offset(dir); BlockState state = Block.getBlockFromItem(stack.getItem()).getDefaultState(); - if (world.isAirBlock(offset) && - world.setBlockState(offset, state)) { + if (world.isAirBlock(offset) && world.setBlockState(offset, state)) { stack.shrink(1); + this.updateComparatorOutputLevel(); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java b/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java index 4dadb2fffd..14e5d97741 100644 --- a/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java +++ b/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java @@ -9,12 +9,14 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.fluid.FluidState; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; import net.minecraftforge.common.ToolType; import net.minecraftforge.fml.client.registry.ClientRegistry; @@ -26,6 +28,16 @@ public BlockSolidifier(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override @Deprecated public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) { diff --git a/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java b/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java index 3f66a5c3c1..adcf674ab4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java +++ b/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java @@ -205,6 +205,7 @@ private boolean tryProcessRecipe() { inputSlots.getStackInSlot(2).shrink(1); tank.drain(this.currentRecipe.fluidIngredient.getAmount(), FluidAction.EXECUTE); outputSlots.insertItem(0, currentRecipe.getRecipeOutput(), false); + updateComparatorOutputLevel(); return true; } ModCyclic.LOGGER.info(pos + " recipe stop on fluid not enoughl"); diff --git a/src/main/java/com/lothrazar/cyclic/block/tank/BlockFluidTank.java b/src/main/java/com/lothrazar/cyclic/block/tank/BlockFluidTank.java index d57be639e4..c802e1058b 100644 --- a/src/main/java/com/lothrazar/cyclic/block/tank/BlockFluidTank.java +++ b/src/main/java/com/lothrazar/cyclic/block/tank/BlockFluidTank.java @@ -45,6 +45,16 @@ public BlockFluidTank(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return calcRedstoneFromFluid(worldIn.getTileEntity(pos)); + } + @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { if (!player.isCrouching() && player.getHeldItem(hand).getItem() == this.asItem() diff --git a/src/main/java/com/lothrazar/cyclic/block/tank/TileTank.java b/src/main/java/com/lothrazar/cyclic/block/tank/TileTank.java index 1d81ddd7ce..9b1af7e8a6 100644 --- a/src/main/java/com/lothrazar/cyclic/block/tank/TileTank.java +++ b/src/main/java/com/lothrazar/cyclic/block/tank/TileTank.java @@ -49,6 +49,7 @@ public LazyOptional getCapability(Capability cap, Direction side) { return super.getCapability(cap, side); } + @Override public void invalidateCaps() { fluidCap.invalidate(); super.invalidateCaps(); @@ -65,6 +66,7 @@ public int getField(int field) { @Override public void setFluid(FluidStack fluid) { tank.setFluid(fluid); + this.updateComparatorOutputLevel(); } @Override diff --git a/src/main/java/com/lothrazar/cyclic/block/tankcask/BlockCask.java b/src/main/java/com/lothrazar/cyclic/block/tankcask/BlockCask.java index c273b0bab6..e93d586a85 100644 --- a/src/main/java/com/lothrazar/cyclic/block/tankcask/BlockCask.java +++ b/src/main/java/com/lothrazar/cyclic/block/tankcask/BlockCask.java @@ -28,6 +28,16 @@ public BlockCask(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return calcRedstoneFromFluid(worldIn.getTileEntity(pos)); + } + @Override public boolean hasTileEntity(BlockState state) { return true; diff --git a/update.json b/update.json index 96d83aba74..ae61720ab3 100644 --- a/update.json +++ b/update.json @@ -81,6 +81,6 @@ ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " ,"1.5.23":"Growth enchantment now uses the same logic as Sprinkler & Terra Soil (only minecraft:crops or minecraft::saplings can grow, respect IGrowable::canUseBonemeal). New gloomIgnored config Gloom enchant (cyclic:curse) to ignore and not use these effects #2217 #2325. Fix Soundproofing block not muting Mekanism sounds #2389 (for example Precision Sawmill and others - you may need four or more soundproofing blocks for the desired effect). Patch an edge-case where User might drop items on the ground. New config [cyclic.blocks.soundproofing] radius = 6 to control the area. Fix item cable routing #2245 #2230. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions #1913. Balance recipe changes for #2372. Balance changes made for Excavate enchant it will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. New feature for Excavate enchant #2116 it will not trigger on anything matching the block data-tag 'cyclic:ignored/excavate'. [Backported changes from mc1.20.1] #2182 candle model assets; Block Breaker no longer tries (and fails) to mine liquid source blocks; Block Randomizer use wireframe rendering only of non-air instead of solid shading; Glistering & Corrupted chorus only restores 1 food-unit down from 3; a few recipes tweaked/backported to match mc1.20.1+, ported crafttweaker zenscript support for generator_fluid and generator_item; backported item data tags for use in recipes for example forge:vines, forge:sandstone, forge:mushrooms " ,"1.5.24":"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. " - ,"":"Some blocks allow minecraft:comparator to pull a redstone signal based on inventory contents: Wooden Hopper, Item Collector, Forester, Item Shelf, . 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 " + ,"":"Many blocks now allow minecraft:comparator to pull a redstone signal based on inventory contents. 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 " } }