diff --git a/build.gradle b/build.gradle index 0954c7173..54ecc349b 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/examples/config/cyclic.toml b/examples/config/cyclic.toml index 4eedae6c9..2267ab53f 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/base/BlockBase.java b/src/main/java/com/lothrazar/cyclic/base/BlockBase.java index 22f499b64..4d9e56c99 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/base/TileEntityBase.java b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java index dc66c6401..2307ae2b8 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); @@ -508,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; } @@ -520,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; } @@ -588,4 +614,14 @@ 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; + } + + public void updateComparatorOutputLevel() { + world.updateComparatorOutputLevel(pos, this.getBlockState().getBlock()); + } } 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 943cc5a30..383c56eac 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 272930a5e..8789b4757 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/collectfluid/BlockFluidCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java index 879b74941..7b81a0ff7 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/RenderFluidCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectfluid/RenderFluidCollect.java index 0e0942f4c..6449f7c75 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 103ef199b..f98ac1b1b 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; @@ -16,6 +17,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 +51,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; @@ -81,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) { @@ -99,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 @@ -125,16 +129,24 @@ 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); + List shape = UtilShape.squareHorizontalHollow(center, this.radius); + // + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = UtilShape.repeatShapeByHeight(shape, heightWithDirection); + } if (targetPos != null) { shape.add(targetPos); } @@ -143,9 +155,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; } @@ -215,13 +230,13 @@ 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); break; case SIZE: - size = Math.min(value, MAX_SIZE); + radius = Math.min(value, MAX_SIZE); break; } } @@ -236,7 +251,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 3af2c4b8a..791bab88b 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,13 @@ 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.inventory.container.Container; 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; @@ -25,16 +26,26 @@ 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) { - 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/RenderItemCollect.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java index 239bef368..e6f521d8f 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 51146fdd6..b9788c1f9 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 b86b41821..2c9a5365f 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; @@ -14,6 +15,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; @@ -79,6 +81,7 @@ public void tick() { break; } remainder = inventory.insertItem(i, remainder, false); + updateComparatorOutputLevel(); } stackEntity.setItem(remainder); if (remainder.isEmpty()) { @@ -131,25 +134,34 @@ 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 getShapeHollow() { + return getShape(); } 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 @@ -168,7 +180,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/crafter/BlockCrafter.java b/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java index df27befda..a300a96c2 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 42fb5d8ab..782ebfdef 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 c51af8bd8..ad97d7d10 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 e5accef29..a50f69686 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/creativebattery/TileBatteryInfinite.java b/src/main/java/com/lothrazar/cyclic/block/creativebattery/TileBatteryInfinite.java index 642cafdbe..e50f82902 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/detectorentity/RenderDetector.java b/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java index 959c88812..085bfe2df 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 5be9a9e79..41685e6ba 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 fa03e9a0b..8cfaebdfc 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 e66034ff9..eee21dddb 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/dice/TileDice.java b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java index cde4bbbaa..133a47b51 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--; @@ -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/dropper/BlockDropper.java b/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java index 20093f919..4ceaae9c0 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/dropper/RenderDropper.java b/src/main/java/com/lothrazar/cyclic/block/dropper/RenderDropper.java index b7d2a9e3c..8608e0d24 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 b5a63ba7e..6735602ef 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/enderitemshelf/BlockItemShelf.java b/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java index 83686fc88..df798b885 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/fan/BlockFan.java b/src/main/java/com/lothrazar/cyclic/block/fan/BlockFan.java index f772c4096..a00828aed 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 000000000..b855e7a9f --- /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 8a02db2eb..9306a424b 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 46eacc5b5..761d76d57 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/fishing/BlockFisher.java b/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java index 5d6935d8b..82d2c0a07 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 1b9525309..9f9b164b1 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 b958042ca..da5aaabab 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); @@ -43,12 +54,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/ContainerForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java index 9f6ff4aa3..fb2146e77 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 4bd5fd204..40a3e1fb9 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 00997e68b..dc32e6d4d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/ScreenForester.java @@ -17,6 +17,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,12 +37,18 @@ 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, 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 @@ -58,6 +65,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 +73,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 96d943e70..d160507fa 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -3,10 +3,10 @@ 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; -import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -19,6 +19,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,15 +44,16 @@ public class TileForester extends TileEntityBase implements INamedContainerProvider, ITickableTileEntity { static enum Fields { - REDSTONE, RENDER, SIZE; + REDSTONE, RENDER, SIZE, HEIGHT; } 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; + private BlockPos targetPos = null; CustomEnergyStorage energy = new CustomEnergyStorage(MAX, MAX); ItemStackHandler inventory = new ItemStackHandler(1) { @@ -95,8 +97,7 @@ public void tick() { } //update target shapeIndex++; - BlockPos targetPos = getShapeTarget(shape); - skipSomeAirBlocks(shape); + targetPos = getShapeTarget(shape); //only saplings at my level, the rest is harvesting try { if (fakePlayer == null && world instanceof ServerWorld) { @@ -111,13 +112,11 @@ 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) { + updateComparatorOutputLevel(); + //ok then DRAIN POWER + energy.extractEnergy(cost, false); } } } @@ -161,6 +160,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)); @@ -170,6 +170,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); @@ -193,16 +194,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,17 +201,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, 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), this.radius); - BlockPos targetPos = getShapeTarget(shape); + 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); } @@ -228,7 +236,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 +260,8 @@ public int getField(int id) { return render; case SIZE: return radius; + case HEIGHT: + return height; } return 0; } @@ -264,11 +273,18 @@ 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 = Math.min(value, MAX_HEIGHT); break; } } + + public boolean hasSapling() { + return !this.inventory.getStackInSlot(0).isEmpty(); + } } 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 57c92b3d2..e7924aa2e 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 39c50bcae..dd6ad5d2b 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 032a76b25..94d133a42 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 ea7a31dc4..193f5668d 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 f448ed960..d3323c1ea 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 3a07e99e7..32a3b3f42 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 4e1b1283a..aa78ab088 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 e8284b574..4d2e34013 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 aa762fd27..7187e4899 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; @@ -108,6 +109,7 @@ public void tick() { fuelRate = peat.getPeatFuelValue(); inventory.extractItem(0, 1, false); this.timer = BURNTIME; + updateComparatorOutputLevel(); } } } @@ -162,7 +164,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/BlockHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java index e5e5f03a4..bac594b3d 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/RenderHarvester.java b/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java index a617ff180..7b010064c 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 69fd97f36..2be83b9eb 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,20 @@ 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")); + 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,9 +71,11 @@ 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()); + 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 7079cfa29..a99d17d7f 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; @@ -12,6 +13,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,10 +35,11 @@ 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; + BlockPos targetPos = null; private int height = 1; private boolean directionIsUp = false; CustomEnergyStorage energy = new CustomEnergyStorage(MAX_ENERGY, MAX_ENERGY / 4); @@ -64,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)) { @@ -73,8 +77,7 @@ public void tick() { } } - private BlockPos getShapeTarget() { - List shape = this.getShape(); + private BlockPos getShapeTarget(List shape) { if (shape.size() == 0) { return null; } @@ -84,22 +87,36 @@ 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); + } + if (targetPos != null) { + shape.add(targetPos); } return shape; } @@ -133,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/hopper/BlockSimpleHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java index 6bd3bd7c0..8a674acb0 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 8c6ad13d2..556bc8f87 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/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java index 78cabbfda..204c07125 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 c89d3040a..48c5ccf79 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 813a8c897..0dc5efeb0 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/laser/RenderLaser.java b/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java index 06f1cc242..125f36efe 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/melter/BlockMelter.java b/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java index c96590d91..839dbe7e6 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 a00fcd6cd..180d7f196 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/miner/BlockMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java index 4d9a17f59..dff0b1e39 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/RenderMiner.java b/src/main/java/com/lothrazar/cyclic/block/miner/RenderMiner.java index ce05b80ad..4fa3d5f3c 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 653611582..c560b402d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/ScreenMiner.java @@ -73,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 ea974ec9f..fa4ee7d54 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java @@ -3,13 +3,13 @@ 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; 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 +298,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); @@ -349,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/packager/BlockPackager.java b/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java index 846d2b9e9..73cdc347a 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 afc80ca29..18772bf16 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(); } } @@ -120,7 +121,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/RenderPeatFarm.java b/src/main/java/com/lothrazar/cyclic/block/peatfarm/RenderPeatFarm.java index 079c5168b..00fdd292a 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 0502bd5d8..c3fa47087 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)); @@ -250,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/placer/BlockPlacer.java b/src/main/java/com/lothrazar/cyclic/block/placer/BlockPlacer.java index 240293314..e0f526011 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 254b2fd99..2db5d7004 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/placerfluid/TilePlacerFluid.java b/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java index 0342ccb3a..aca267d12 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 9ac9b3636..b2fd5c874 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 4e32c4bfe..dbe293ef2 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 18bd25b7b..004aaac8e 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; @@ -126,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) { @@ -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 c0020af0f..99ab8f1db 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 e9ed0b6ea..c6891b2bc 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/solidifier/BlockSolidifier.java b/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java index 4dadb2fff..14e5d9774 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 3f66a5c3c..adcf674ab 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 d57be639e..c802e1058 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 1d81ddd7c..9b1af7e8a 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 c273b0bab..e93d586a8 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/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java b/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java index fb113e0e0..6c6e87c7e 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/block/wireless/energy/TileWirelessEnergy.java b/src/main/java/com/lothrazar/cyclic/block/wireless/energy/TileWirelessEnergy.java index db8239c07..d6326482a 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 aaf6c5123..4676220cb 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 5f7f6bc1a..163ec50ce 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 9edbc8611..a385d7f3f 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 567ee9bf0..5de1c866b 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/config/ConfigRegistry.java b/src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java index e934fa347..636518f1c 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/src/main/java/com/lothrazar/cyclic/data/PreviewOutlineType.java b/src/main/java/com/lothrazar/cyclic/data/PreviewOutlineType.java new file mode 100644 index 000000000..301d412c4 --- /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 80251d6ef..0bc209e71 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 1bc319703..a5c1ad605 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/UtilItemStack.java b/src/main/java/com/lothrazar/cyclic/util/UtilItemStack.java index 3c39727cd..f0c37d31c 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/java/com/lothrazar/cyclic/util/UtilRender.java b/src/main/java/com/lothrazar/cyclic/util/UtilRender.java index cea26aad5..36c07f1f6 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/blockstates/collector.json b/src/main/resources/assets/cyclic/blockstates/collector.json index 4e0b10ebd..218187174 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 465acc3fd..ae4beb3b5 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 510bbdd3c..6ec66796c 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 ac429f9e5..05b55d804 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 8b35d2598..ef593e546 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 1be5ca3de..2fb438ced 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/lang/en_us.json b/src/main/resources/assets/cyclic/lang/en_us.json index 039397b95..e9ecc8359 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/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 000000000..e727ea5b1 --- /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 000000000..a4023a8c1 --- /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 000000000..4eb86cd39 --- /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 000000000..8a0f9d8d8 --- /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 000000000..83a84afda --- /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 000000000..8bcc7142e --- /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 f6cc9e9f5..3cc0ac247 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 f6cc9e9f5..87531f65c 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 f6cc9e9f5..3954a98a8 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 f6cc9e9f5..e6ab3042d 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 000000000..8884079b7 --- /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 000000000..393ed42a7 --- /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 f88a386c9..ae61720ab 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. " + ,"":"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 " } }