diff --git a/build.gradle b/build.gradle index d1bd7aa20..73c090b3a 100644 --- a/build.gradle +++ b/build.gradle @@ -86,6 +86,14 @@ dependencies { runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}") + // implementation fg.deobf("curse.maven:autoreglib-250363:3642382") + // implementation fg.deobf("curse.maven:quark-243121:3840125") + // implementation fg.deobf("curse.maven:more-villagers-484954:3843498") + // implementation fg.deobf("curse.maven:yungs-api-421850:4428184") + // implementation fg.deobf("curse.maven:yungs-better-strongholds-465575:3778231") + // implementation fg.deobf("curse.maven:mekanism-268560:3875976") + + // implementation fg.deobf("curse.maven:jade-324717:5079263") } @@ -107,7 +115,7 @@ repositories { maven { url 'https://maven.theillusivec4.top/' } maven { url 'https://maven.blamejared.com' } maven { url 'https://modmaven.dev' } -// maven { url 'https://www.cursemaven.com' } + maven { url 'https://www.cursemaven.com' } } // Example for how to get properties into the manifest for reading by the runtime.. jar { diff --git a/gradle.properties b/gradle.properties index a4cab21d4..7cb2779a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,12 +6,15 @@ org.gradle.daemon=false # as needed run/server.properties : online-mode=false curse_id=239286 -mod_version=1.8.5 +mod_version=1.9.0 + mc_version=1.19.2 forge_version=43.2.14 + + # optional dependencies jei_version=11.4.0.285 curios_version=5.1.1.0 diff --git a/src/main/java/com/lothrazar/cyclic/block/TileBlockEntityCyclic.java b/src/main/java/com/lothrazar/cyclic/block/TileBlockEntityCyclic.java index 2ec0b7e90..cf5e7c229 100644 --- a/src/main/java/com/lothrazar/cyclic/block/TileBlockEntityCyclic.java +++ b/src/main/java/com/lothrazar/cyclic/block/TileBlockEntityCyclic.java @@ -520,7 +520,11 @@ public void setFluid(FluidStack fluid) {} /************************** IInventory needed for IRecipe **********************************/ @Deprecated @Override - public int getContainerSize() { + public int getContainerSize() { // was getSizeInventory + IItemHandler invo = this.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(null); + if (invo != null) { + return invo.getSlots(); + } return 0; } @@ -532,7 +536,14 @@ public boolean isEmpty() { @Deprecated @Override - public ItemStack getItem(int index) { + public ItemStack getItem(int index) { // was getStackInSlot + IItemHandler invo = this.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(null); + try { + if (invo != null && index < invo.getSlots()) { + return invo.getStackInSlot(index); + } + } + catch (Exception e) {} return ItemStack.EMPTY; } @@ -667,4 +678,30 @@ else if (beaconblockentity$beaconbeamsection != null) { beamStuff.beamSections = beamStuff.checkingBeamSections; } } + + // 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 boolean getBlockStateVertical() { + if (this.getBlockState().hasProperty(BlockStateProperties.FACING)) + return this.getBlockState().getValue(BlockStateProperties.FACING).getAxis().isVertical(); + return false; + } + + public void updateComparatorOutputLevel() { + //was updateComparatorOutputLevel() + level.updateNeighbourForOutputSignal(worldPosition, this.getBlockState().getBlock()); + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/breaker/ContainerBreaker.java b/src/main/java/com/lothrazar/cyclic/block/breaker/ContainerBreaker.java index a4494f1d1..75b5e58d3 100644 --- a/src/main/java/com/lothrazar/cyclic/block/breaker/ContainerBreaker.java +++ b/src/main/java/com/lothrazar/cyclic/block/breaker/ContainerBreaker.java @@ -8,6 +8,8 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.ContainerLevelAccess; import net.minecraft.world.level.Level; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.items.SlotItemHandler; public class ContainerBreaker extends ContainerBase { @@ -18,6 +20,10 @@ public ContainerBreaker(int windowId, Level world, BlockPos pos, Inventory playe tile = (TileBreaker) world.getBlockEntity(pos); this.playerEntity = player; this.playerInventory = playerInventory; + tile.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(h -> { + this.endInv = h.getSlots(); + addSlot(new SlotItemHandler(h, 0, 81, 31)); + }); layoutPlayerInventorySlots(8, 84); trackEnergy(tile); this.trackAllIntFields(tile, TileBreaker.Fields.values().length); diff --git a/src/main/java/com/lothrazar/cyclic/block/breaker/ScreenBreaker.java b/src/main/java/com/lothrazar/cyclic/block/breaker/ScreenBreaker.java index a12e9571e..cbb451c99 100644 --- a/src/main/java/com/lothrazar/cyclic/block/breaker/ScreenBreaker.java +++ b/src/main/java/com/lothrazar/cyclic/block/breaker/ScreenBreaker.java @@ -41,5 +41,6 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { @Override protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) { this.drawBackground(ms, TextureRegistry.INVENTORY); + this.drawSlot(ms, 80, 30, TextureRegistry.SLOT_BSDATA); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/breaker/TileBreaker.java b/src/main/java/com/lothrazar/cyclic/block/breaker/TileBreaker.java index 345efab28..9f44b07c3 100644 --- a/src/main/java/com/lothrazar/cyclic/block/breaker/TileBreaker.java +++ b/src/main/java/com/lothrazar/cyclic/block/breaker/TileBreaker.java @@ -1,18 +1,31 @@ package com.lothrazar.cyclic.block.breaker; +import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; +import com.lothrazar.cyclic.data.DataTags; +import com.lothrazar.cyclic.item.datacard.BlockStateMatcher; +import com.lothrazar.cyclic.item.datacard.BlockstateCard; import com.lothrazar.cyclic.registry.BlockRegistry; +import com.lothrazar.cyclic.registry.ItemRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; public class TileBreaker extends TileBlockEntityCyclic implements MenuProvider { @@ -22,6 +35,19 @@ static enum Fields { static final int MAX = 64000; public static final int TIMER_FULL = 500; + ItemStackHandler inventory = new ItemStackHandler() { + + @Override + public int getSlotLimit(int slot) { + return 1; + } + + @Override + public boolean isItemValid(int slot, ItemStack stack) { + return stack.getItem() == ItemRegistry.STATECARD.get(); + } + }; + private LazyOptional inventoryCap = LazyOptional.of(() -> inventory); public TileBreaker(BlockPos pos, BlockState state) { super(TileRegistry.BREAKER.get(), pos, state); @@ -35,6 +61,14 @@ public static void clientTick(Level level, BlockPos bloc e.tick(); } + @Override + public LazyOptional getCapability(Capability cap, Direction side) { + if (cap == ForgeCapabilities.ITEM_HANDLER) { + return inventoryCap.cast(); + } + return super.getCapability(cap, side); + } + public void tick() { if (this.requiresRedstone() && !this.isPowered()) { setLitProperty(false); @@ -45,32 +79,60 @@ public void tick() { return; } BlockPos target = this.worldPosition.relative(this.getCurrentFacing()); // offset -> relative - if (this.isValid(target)) { + if (this.isTargetValid(target)) { this.level.destroyBlock(target, true); } } + @Override + public void invalidateCaps() { + inventoryCap.invalidate(); + super.invalidateCaps(); + } + /** * Avoid mining source liquid blocks and unbreakable */ - private boolean isValid(BlockPos target) { - BlockState state = level.getBlockState(target); - if (state.isAir()) { + private boolean isTargetValid(BlockPos targetPos) { + BlockState targetState = level.getBlockState(targetPos); + if (targetState.isAir()) { + return false; + } + if (targetState.getDestroySpeed(level, targetPos) < 0) { return false; } - if (state.getDestroySpeed(level, target) < 0) { //getBlockHardness -> getDestroySpeed + //check the tag ignore list so modpack/datapack can filter this + if (targetState.is(DataTags.BREAKER_IGNORED)) { + ModCyclic.LOGGER.info("breaker/ignored tag skips " + targetPos); return false; } - if (state.getFluidState() != null && state.getFluidState().isEmpty() == false) { + if (targetState.getFluidState() != null && targetState.getFluidState().isEmpty() == false) { //am i a solid waterlogged state block? - if (state.hasProperty(BlockStateProperties.WATERLOGGED) == false) { + if (targetState.hasProperty(BlockStateProperties.WATERLOGGED) == false) { //pure liquid. but this will make canHarvestBlock go true return false; } } + if (!this.isValidFromDatacard(targetState)) { + return false; + } + // else filter is empty return true; } + private boolean isValidFromDatacard(BlockState targetState) { + ItemStack filter = inventory.getStackInSlot(0); + if (filter.isEmpty()) { + return true; //ya go + } + for (BlockStateMatcher m : BlockstateCard.getSavedStates(filter)) { + if (m.doesMatch(targetState)) { + return true; // i am allowed to mine this + } + } + return false; //filter is my allow list, and you aint in it so not allowed + } + @Override public Component getDisplayName() { return BlockRegistry.BREAKER.get().getName(); @@ -81,6 +143,18 @@ public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player return new ContainerBreaker(i, level, worldPosition, playerInventory, playerEntity); } + @Override + public void load(CompoundTag tag) { + inventory.deserializeNBT(tag.getCompound(NBTINV)); + super.load(tag); + } + + @Override + public void saveAdditional(CompoundTag tag) { + tag.put(NBTINV, inventory.serializeNBT()); + super.saveAdditional(tag); + } + @Override public void setField(int field, int value) { switch (Fields.values()[field]) { 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 c5bea356b..54a06d995 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 @@ -1,7 +1,7 @@ package com.lothrazar.cyclic.block.cable.energy; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import com.google.common.collect.Maps; import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.block.cable.CableBase; @@ -24,19 +24,21 @@ public class TileCableEnergy extends TileBlockEntityCyclic { + final CustomEnergyStorage energy; + private LazyOptional energyCap; public static IntValue BUFFERSIZE; public static IntValue TRANSFER_RATE; - CustomEnergyStorage energy; - private LazyOptional energyCap; - private final Map mapIncomingEnergy = new ConcurrentHashMap<>(); - private int energyLastSynced = -1; //fluid tanks have 'onchanged', energy caps do not + // + // private final ConcurrentHashMap> flow = new ConcurrentHashMap<>(); + private final Map mapIncomingEnergy = Maps.newHashMap(); + private int energyLastSynced = -1; //fluid tanks have 'onchanged', energy caps do not public TileCableEnergy(BlockPos pos, BlockState state) { super(TileRegistry.ENERGY_PIPE.get(), pos, state); for (Direction f : Direction.values()) { mapIncomingEnergy.put(f, 0); } - energy = new CustomEnergyStorage(BUFFERSIZE.get(), BUFFERSIZE.get()); + energy = new CustomEnergyStorage(BUFFERSIZE.get(), TRANSFER_RATE.get()); energyCap = LazyOptional.of(() -> energy); } 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 1f0e0589b..60d0d37de 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectfluid/BlockFluidCollect.java @@ -42,12 +42,12 @@ public BlockEntityTicker getTicker(Level world, Block @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlock(pos, state.setValue(BlockStateProperties.HORIZONTAL_FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2); } } @Override protected void createBlockStateDefinition(StateDefinition.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 2113a839e..123c0316a 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.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderFluidCollect implements BlockEntityRenderer { @@ -13,8 +16,14 @@ public RenderFluidCollect(BlockEntityRendererProvider.Context d) {} @Override public void render(TileFluidCollect te, float v, PoseStack matrix, MultiBufferSource 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) { RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.4F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } } } 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 78c4ac099..4dc1856d7 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectfluid/TileFluidCollect.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.CustomEnergyStorage; import com.lothrazar.cyclic.capabilities.block.FluidTankBase; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.FluidHelpers.FluidAttributes; @@ -22,6 +23,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.ForgeConfigSpec.IntValue; @@ -48,7 +50,7 @@ static enum Fields { FluidTankBase tank; private final LazyOptional fluidCap = 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; @@ -87,9 +89,8 @@ public void tick() { return; } ItemStack stack = inventory.getStackInSlot(0); - if (stack.isEmpty() || Block.byItem(stack.getItem()) == Blocks.AIR) { - return; - } + //use air if its empty + BlockState newState = Block.byItem(stack.getItem()).defaultBlockState(); this.setLitProperty(true); List shape = this.getShapeFilled(); if (shape.size() == 0) { @@ -104,8 +105,8 @@ public void tick() { FluidStack fstack = new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME); int result = tank.fill(fstack, FluidAction.SIMULATE); if (result == FluidAttributes.BUCKET_VOLUME) { - //we got enough - if (level.setBlockAndUpdate(targetPos, Block.byItem(stack.getItem()).defaultBlockState())) { + //we got enough + if (level.setBlockAndUpdate(targetPos, newState)) { //build the block, shrink the item stack.shrink(1); //drink fluid @@ -131,16 +132,24 @@ public AABB getRenderBoundingBox() { return BlockEntity.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().getValue(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 = ShapeUtil.squareHorizontalHollow(ctr.below(height), this.size); - shape = ShapeUtil.repeatShapeByHeight(shape, height); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.squareHorizontalHollow(center, this.radius); + // + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); + } if (targetPos != null) { shape.add(targetPos); } @@ -149,9 +158,12 @@ public List getShapeHollow() { //for harvest public List getShapeFilled() { - BlockPos ctr = getTargetCenter(); - List shape = ShapeUtil.squareHorizontalFull(ctr.below(height), this.size); - shape = ShapeUtil.repeatShapeByHeight(shape, height - 1); + BlockPos center = getFacingShapeCenter(radius); + int heightWithDirection = heightWithDirection(); + List shape = ShapeUtil.squareHorizontalFull(center, this.radius); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); + } return shape; } @@ -221,13 +233,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; } } @@ -242,7 +254,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 e341c6917..f3ea5fee6 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java @@ -7,16 +7,17 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; public class BlockItemCollector extends BlockCyclic { @@ -28,13 +29,23 @@ public BlockItemCollector(Properties properties) { @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlock(pos, state.setValue(HorizontalDirectionalBlock.FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2); } } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(HorizontalDirectionalBlock.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 b6ec41418..728e87892 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/RenderItemCollect.java @@ -1,21 +1,29 @@ package com.lothrazar.cyclic.block.collectitem; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderItemCollect implements BlockEntityRenderer { public RenderItemCollect(BlockEntityRendererProvider.Context d) {} @Override - public void render(TileItemCollector te, float v, PoseStack matrix, - MultiBufferSource ibuffer, int partialTicks, int destroyStage) { - if (1 == te.getField(TileItemCollector.Fields.RENDER.ordinal())) { - RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrix, 0.5F, ClientConfigCyclic.getColor(te)); + public void render(TileItemCollector te, float v, PoseStack matrix, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileItemCollector.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.7F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } } } } 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 edac9f774..74da5d9ff 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 renderLabels(PoseStack ms, int mouseX, int mouseY) { sizeSlider.setTooltip("cyclic.screen.size" + menu.tile.getField(sizeSlider.getField())); this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, this.title.getString()); + btnDirection.visible = !menu.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 ed7d4a132..7821a78dd 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java @@ -2,6 +2,7 @@ import java.util.List; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.filter.FilterCardItem; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.ItemRegistry; @@ -21,6 +22,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ForgeCapabilities; @@ -88,6 +90,7 @@ public void tick() { break; } remainder = inventory.insertItem(i, remainder, false); + updateComparatorOutputLevel(); } stackEntity.setItem(remainder); if (remainder.isEmpty()) { @@ -140,33 +143,31 @@ public void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); } - private BlockPos getTargetCenter() { - // move center over that much, not including exact horizontal - return this.getBlockPos().relative(this.getCurrentFacing(), radius + 1); + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().getValue(BlockStateProperties.FACING); + int diff = directionIsUp ? 1 : -1; + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; + } + return diff * height; } - public List getShape() { - List shape = ShapeUtil.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), radius); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = ShapeUtil.repeatShapeByHeight(shape, diff * height); + public List getShapeHollow() { + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { // if (heightWithDirection > 1) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); } return shape; } private AABB getRange() { - BlockPos center = getTargetCenter(); - int diff = directionIsUp ? 1 : -1; - int yMin = center.getY(); - int yMax = center.getY() + diff * height; - //for some reason - if (!directionIsUp) { - // when aiming down, we dont have the offset to get [current block] without this - yMin++; - } - AABB aabb = new AABB( - center.getX() - radius, yMin, center.getZ() - radius, - center.getX() + radius + 1, yMax, center.getZ() + radius + 1); + BlockPos center = getFacingShapeCenter(radius); + int heightWithDirection = heightWithDirection(); + AABB aabb = new AABB(center); + aabb = aabb.expandTowards(0, heightWithDirection, 0); // was .expand() + aabb = aabb.inflate(radius, 0, radius); // was .grow() return aabb; } @@ -177,7 +178,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 505a44398..50cb7b084 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java +++ b/src/main/java/com/lothrazar/cyclic/block/crafter/BlockCrafter.java @@ -29,6 +29,7 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.world.Containers; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.entity.BlockEntity; @@ -44,6 +45,16 @@ public BlockCrafter(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public void onRemove(BlockState state, Level 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 c267b4fb6..22ed2e099 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java +++ b/src/main/java/com/lothrazar/cyclic/block/crafter/TileCrafter.java @@ -175,6 +175,7 @@ public void serverTick() { //otherwise its something like bucket->empty bucket, so different item, so right side depositOutput(s, this.outHandler); } + 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 311fc4f21..2adfced38 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.nbt.CompoundTag; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; @@ -30,9 +31,18 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new TileCrate(pos, state); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - // if (state.hasTileEntity() && (!state.is(newState.getBlock()) || !newState.hasTileEntity())) { if (!state.is(newState.getBlock())) { worldIn.removeBlockEntity(pos); } 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 0e3888ace..28fba72e4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/crate/TileCrate.java +++ b/src/main/java/com/lothrazar/cyclic/block/crate/TileCrate.java @@ -34,11 +34,13 @@ public Component getDisplayName() { @Override public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player playerEntity) { + this.updateComparatorOutputLevel(); return new ContainerCrate(i, level, worldPosition, playerInventory, playerEntity); } @Override public void invalidateCaps() { + this.updateComparatorOutputLevel(); inventoryCap.invalidate(); super.invalidateCaps(); } diff --git a/src/main/java/com/lothrazar/cyclic/block/cratemini/BlockCrateMini.java b/src/main/java/com/lothrazar/cyclic/block/cratemini/BlockCrateMini.java index 5cfd60214..4c1cd8887 100644 --- a/src/main/java/com/lothrazar/cyclic/block/cratemini/BlockCrateMini.java +++ b/src/main/java/com/lothrazar/cyclic/block/cratemini/BlockCrateMini.java @@ -4,9 +4,11 @@ import com.lothrazar.cyclic.registry.MenuTypeRegistry; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.SoundType; @@ -33,6 +35,16 @@ public BlockCrateMini(Properties properties) { this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false)); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AABB; 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 6d51d0e8b..a5effca80 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 TileBlockEntityCyclic { - 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 ddc63f1aa..b1d96bae2 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectorentity/RenderDetector.java @@ -1,20 +1,29 @@ package com.lothrazar.cyclic.block.detectorentity; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderDetector implements BlockEntityRenderer { public RenderDetector(BlockEntityRendererProvider.Context d) {} @Override - public void render(TileDetector te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TileDetector.Fields.RENDER.ordinal()) == 1) { - RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrixStack, 0.6F, ClientConfigCyclic.getColor(te)); + public void render(TileDetector te, float v, PoseStack matrix, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileDetector.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrix, 0.6F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } } } } 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 ae903cf41..0692ca13e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectorentity/TileDetector.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectorentity/TileDetector.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.data.EntityFilterType; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.ShapeUtil; @@ -110,6 +111,10 @@ public boolean isPowered() { return isPoweredNow; } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { return ShapeUtil.getShape(getRange(), worldPosition.getY()); } @@ -154,7 +159,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 96a04c74d..445c0674e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectoritem/RenderDetectorItem.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectoritem/RenderDetectorItem.java @@ -1,21 +1,29 @@ package com.lothrazar.cyclic.block.detectoritem; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderDetectorItem implements BlockEntityRenderer { public RenderDetectorItem(BlockEntityRendererProvider.Context d) {} @Override - public void render(TileDetectorItem te, float v, PoseStack matrixStack, - MultiBufferSource iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.getField(TileDetectorItem.Fields.RENDER.ordinal()) == 1) { + public void render(TileDetectorItem te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileDetectorItem.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrixStack, 0.6F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrixStack, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } } } 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 c56d1a1a4..cc4c60daa 100644 --- a/src/main/java/com/lothrazar/cyclic/block/detectoritem/TileDetectorItem.java +++ b/src/main/java/com/lothrazar/cyclic/block/detectoritem/TileDetectorItem.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.block.detectorentity.CompareType; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.ShapeUtil; @@ -190,7 +191,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; } } @@ -218,6 +219,10 @@ public void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { return ShapeUtil.getShape(getRange(), worldPosition.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 8ecf1f011..d505d9133 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java +++ b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java @@ -54,7 +54,7 @@ public void startSpinning() { public void tick() { if (this.timer == 0) { this.spinningIfZero = 1; - level.updateNeighbourForOutputSignal(worldPosition, this.getBlockState().getBlock()); + updateComparatorOutputLevel(); } else { this.timer--; @@ -68,26 +68,6 @@ public void tick() { // 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 72d696366..787d40ce8 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/BlockDropper.java @@ -42,12 +42,12 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlock(pos, state.setValue(BlockStateProperties.HORIZONTAL_FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2); } } @Override protected void createBlockStateDefinition(StateDefinition.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 123f92236..8f4aaa344 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.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderDropper implements BlockEntityRenderer { @@ -13,8 +16,14 @@ public RenderDropper(BlockEntityRendererProvider.Context d) {} @Override public void render(TileDropper te, float v, PoseStack matrixStack, MultiBufferSource 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) { RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrixStack, 0.5F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrixStack, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } } } 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 73efa1b53..0c25276de 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dropper/TileDropper.java +++ b/src/main/java/com/lothrazar/cyclic/block/dropper/TileDropper.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.CustomEnergyStorage; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -194,11 +195,15 @@ public void setField(int id, int value) { dropCount = Math.max(1, 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 ccace8540..152786d5f 100644 --- a/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java +++ b/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java @@ -16,6 +16,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -33,7 +34,14 @@ public BlockItemShelf(Properties properties) { } @Override - public void registerClient() {} + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { @@ -45,10 +53,6 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new TileItemShelf(pos, state); } - // @Override - // public BlockEntityTicker getTicker(Level world, BlockState state, BlockEntityType type) { - // return createTickerHelper(type,TileRegistry.ENDER_ITEM_SHELF.get(), world.isClientSide ? TileItemShelf::clientTick : TileItemShelf::serverTick); - // } @Override public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { // if (state.hasTileEntity() && (!state.is(newState.getBlock()) || !newState.hasTileEntity())) { @@ -86,6 +90,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player //try to insert boolean oldEmpty = shelfStack.isEmpty(); ItemStack remaining = shelf.inventory.insertItem(slot, heldItem, false); + shelf.updateComparatorOutputLevel(); if (remaining.isEmpty() || remaining.getCount() != shelfStack.getCount()) { player.setItemInHand(hand, remaining); player.swing(hand); @@ -101,6 +106,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player ItemStack retrieved = shelf.inventory.extractItem(slot, q, false); player.setItemInHand(hand, retrieved); player.swing(hand); + shelf.updateComparatorOutputLevel(); } if (!shelfStack.isEmpty() && !heldItem.isEmpty()) { // @@ -111,6 +117,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player.setItemInHand(hand, forPlayer); player.swing(hand); shelf.inventory.insertItem(slot, forShelf, false); + shelf.updateComparatorOutputLevel(); } return InteractionResult.SUCCESS; } 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..923eb7b66 --- /dev/null +++ b/src/main/java/com/lothrazar/cyclic/block/fan/RenderFan.java @@ -0,0 +1,29 @@ +package com.lothrazar.cyclic.block.fan; + +import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; +import com.lothrazar.cyclic.render.RenderUtils; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; + +public class RenderFan implements BlockEntityRenderer { + + public RenderFan(BlockEntityRendererProvider.Context d) {} + + @Override + public void render(TileFan te, float v, PoseStack matrix, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileFan.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.7F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } + } +} 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 5eb733239..1987a8adf 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.gui.ButtonMachineField; import com.lothrazar.cyclic.gui.GuiSliderInteger; import com.lothrazar.cyclic.gui.ScreenBase; +import com.lothrazar.cyclic.gui.TextureEnum; import com.lothrazar.cyclic.registry.TextureRegistry; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.network.chat.Component; @@ -11,6 +12,7 @@ public class ScreenFan extends ScreenBase { private ButtonMachineField btnRedstone; + private ButtonMachineField btnRender; public ScreenFan(ContainerFan screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); @@ -23,6 +25,9 @@ public void init() { x = leftPos + 6; y = topPos + 6; btnRedstone = addRenderableWidget(new ButtonMachineField(x, y, TileFan.Fields.REDSTONE.ordinal(), menu.tile.getBlockPos())); + y += 20; + btnRender = addRenderableWidget(new ButtonMachineField(x, y, TileFan.Fields.RENDER.ordinal(), + menu.tile.getBlockPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); // int w = 160; int h = 20; @@ -53,6 +58,7 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, this.title.getString()); btnRedstone.onValueUpdate(menu.tile); + btnRender.onValueUpdate(menu.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 ef8b100f6..a1d00fbfb 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fan/TileFan.java +++ b/src/main/java/com/lothrazar/cyclic/block/fan/TileFan.java @@ -2,6 +2,7 @@ import java.util.List; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.EntityDataCard; import com.lothrazar.cyclic.net.PacketPlayerFalldamage; import com.lothrazar.cyclic.registry.BlockRegistry; @@ -29,7 +30,7 @@ public class TileFan extends TileBlockEntityCyclic implements MenuProvider { static enum Fields { - REDSTONE, RANGE, SPEED; + REDSTONE, RANGE, SPEED, RENDER; } public static final int MIN_RANGE = 1; @@ -102,6 +103,10 @@ private boolean canBlowThrough(BlockPos tester) { return !level.getBlockState(tester).canOcclude(); } + public List getShapeHollow() { + return getShape(); + } + public List getShape() { return ShapeUtil.line(getBlockPos(), getCurrentFacing(), getCurrentRange()); } @@ -231,6 +236,8 @@ public int getField(int f) { return this.needsRedstone; case SPEED: return this.speed; + case RENDER: + return this.render; } return 0; } @@ -239,6 +246,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 6c7a3b2a2..77b0630df 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java +++ b/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -20,6 +21,16 @@ public BlockFisher(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter 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 54d088633..c852093d8 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java +++ b/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java @@ -123,6 +123,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 1e241ef47..95b19ff60 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -24,6 +25,16 @@ public BlockForester(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public void registerClient() { MenuScreens.register(MenuTypeRegistry.FORESTER.get(), ScreenForester::new); @@ -42,12 +53,12 @@ public BlockEntityTicker getTicker(Level world, Block @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlock(pos, state.setValue(BlockStateProperties.HORIZONTAL_FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2); } } @Override protected void createBlockStateDefinition(StateDefinition.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 864dcab57..5d924dcc1 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/ContainerForester.java @@ -23,13 +23,7 @@ public ContainerForester(int windowId, Level world, BlockPos pos, Inventory play this.playerInventory = playerInventory; tile.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(h -> { this.endInv = h.getSlots(); - addSlot(new SlotItemHandler(h, 0, 80, 25) { - - @Override - public void setChanged() { - tile.setChanged(); - } - }); + addSlot(new SlotItemHandler(h, 0, 80, 17)); // 25 }); 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 5b517d47b..3bd705dc5 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/RenderForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/RenderForester.java @@ -1,21 +1,29 @@ package com.lothrazar.cyclic.block.forester; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderForester implements BlockEntityRenderer { public RenderForester(BlockEntityRendererProvider.Context d) {} @Override - public void render(TileForester te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int partialTicks, int destroyStage) { - // ok - if (te.getField(TileForester.Fields.RENDER.ordinal()) == 1) { - RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrixStack, 0.5F, ClientConfigCyclic.getColor(te)); + public void render(TileForester te, float v, PoseStack matrix, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileForester.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.7F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } } } } 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 cd9264a3c..bc382ea5f 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, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); @@ -38,8 +39,13 @@ public void init() { menu.tile.getBlockPos(), TextureEnum.RENDER_HIDE, TextureEnum.RENDER_SHOW, "gui.cyclic.render")); int w = 110; int h = 18; - int f = TileForester.Fields.SIZE.ordinal(); + int f = TileForester.Fields.HEIGHT.ordinal(); x += 28; + y += 12; + heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, TileForester.Fields.HEIGHT.ordinal(), menu.tile.getBlockPos(), + 0, TileForester.MAX_HEIGHT, menu.tile.getField(f))); + // + f = TileForester.Fields.SIZE.ordinal(); y += 20; size = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 0, 10, menu.tile.getField(f))); } @@ -58,6 +64,7 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { this.drawName(ms, this.title.getString()); btnRedstone.onValueUpdate(menu.tile); btnRender.onValueUpdate(menu.tile); + heightslider.setTooltip("buildertype.height.tooltip"); size.setTooltip("cyclic.screen.size" + menu.tile.getField(size.getField())); } @@ -65,7 +72,14 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { protected void renderBg(PoseStack 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); energy.draw(ms, menu.getEnergy()); + int y = 16; + // + if (menu.tile.hasSapling()) { + this.drawSlot(ms, relX, y); + } + else { + this.drawSlot(ms, relX, y, TextureRegistry.SLOT_SAPLING, Const.SQ); + } } } 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 4de74a81d..ff20d4abf 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -1,11 +1,11 @@ package com.lothrazar.cyclic.block.forester; import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.List; import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.ShapeUtil; @@ -29,6 +29,7 @@ import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.ForgeConfigSpec.IntValue; import net.minecraftforge.common.capabilities.Capability; @@ -42,15 +43,16 @@ public class TileForester extends TileBlockEntityCyclic implements MenuProvider { 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) { @@ -101,8 +103,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 && level instanceof ServerLevel) { @@ -117,14 +118,13 @@ public void tick() { } } else if (this.isSapling(dropMe)) { - //plant me . if im on the lowest level - if (targetPos.getY() == this.worldPosition.getY()) { - InteractionResult result = TileBlockEntityCyclic.interactUseOnBlock(fakePlayer, level, targetPos, InteractionHand.OFF_HAND, Direction.DOWN); - if (result == InteractionResult.CONSUME) { - //ok then DRAIN POWER - energy.extractEnergy(cost, false); - } + //plant me . if im on the lowest level + InteractionResult result = TileBlockEntityCyclic.interactUseOnBlock(fakePlayer, level, targetPos, InteractionHand.OFF_HAND, Direction.DOWN); + if (result == InteractionResult.CONSUME) { + updateComparatorOutputLevel(); } + //ok then DRAIN POWER + energy.extractEnergy(cost, false); } } catch (Exception e) { @@ -167,6 +167,7 @@ public LazyOptional getCapability(Capability cap, Direction side) { @Override public void load(CompoundTag tag) { + height = tag.getInt("height"); shapeIndex = tag.getInt("shapeIndex"); radius = tag.getInt("radius"); energy.deserializeNBT(tag.getCompound(NBTENERGY)); @@ -176,6 +177,7 @@ public void load(CompoundTag tag) { @Override public void saveAdditional(CompoundTag tag) { + tag.putInt("height", height); tag.putInt("shapeIndex", shapeIndex); tag.put(NBTENERGY, energy.serializeNBT()); tag.putInt("radius", radius); @@ -198,16 +200,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; @@ -215,17 +207,35 @@ private BlockPos getShapeTarget(List shape) { return shape.get(shapeIndex); } + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().getValue(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 = ShapeUtil.cubeSquareBase(this.getCurrentFacingPos(radius + 1), radius, height); + // List shape = ShapeUtil.cubeSquareBase(this.getCurrentFacingPos(radius + 1), radius, height); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.cubeSquareBase(center, radius, 0); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); + } return shape; } //for render public List getShapeHollow() { - List shape = ShapeUtil.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), this.radius); - BlockPos targetPos = getShapeTarget(shape); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); + } if (targetPos != null) { shape.add(targetPos); } @@ -233,7 +243,6 @@ public List getShapeHollow() { } private boolean isSapling(ItemStack dropMe) { - // if(dropMe.getItem().isIn(Tags.Blocks.SAND)) //sapling tag SHOULD exist. it doesnt. idk WHY BlockState block = Block.byItem(dropMe.getItem()).defaultBlockState(); return block.is(BlockTags.SAPLINGS) || block.getBlock() instanceof SaplingBlock; @@ -257,6 +266,8 @@ public int getField(int id) { return render; case SIZE: return radius; + case HEIGHT: + return height; } return 0; } @@ -268,11 +279,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 163cc3c40..94d27ff66 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -28,6 +29,16 @@ protected void createBlockStateDefinition(StateDefinition.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 7dd49dbe7..532412088 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java @@ -118,6 +118,7 @@ private void findMatchingRecipe() { final int slot = 0; final int qty = 1; this.inputSlots.extractItem(slot, qty, false); + updateComparatorOutputLevel(); return; } } 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 7e8d83ff6..f89782c0d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/BlockHarvester.java @@ -42,12 +42,12 @@ public BlockEntityTicker getTicker(Level world, Block @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlock(pos, state.setValue(BlockStateProperties.HORIZONTAL_FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2); } } @Override protected void createBlockStateDefinition(StateDefinition.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 c8e1c627b..da61e64af 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/RenderHarvester.java @@ -1,21 +1,29 @@ package com.lothrazar.cyclic.block.harvester; import com.lothrazar.cyclic.config.ClientConfigCyclic; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderHarvester implements BlockEntityRenderer { public RenderHarvester(BlockEntityRendererProvider.Context d) {} @Override - public void render(TileHarvester te, float v, PoseStack matrix, - MultiBufferSource ibuffer, int partialTicks, int destroyStage) { - if (1 == te.getField(TileHarvester.Fields.RENDER.ordinal())) { - RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.5F, ClientConfigCyclic.getColor(te)); + public void render(TileHarvester te, float v, PoseStack matrix, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileHarvester.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.7F, ClientConfigCyclic.getColor(te)); + } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } } } } 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 600440009..a1de45f2b 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, Inventory inv, Component titleIn) { @@ -41,9 +41,7 @@ public void init() { int f = TileHarvester.Fields.DIRECTION.ordinal(); y += 20; btnDirection = addRenderableWidget(new ButtonMachineField(x, y, f, - menu.tile.getBlockPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")) - //.setSize(18) - ; + menu.tile.getBlockPos(), TextureEnum.DIR_DOWN, TextureEnum.DIR_UPWARDS, "gui.cyclic.direction")); int w = 110; int h = 18; //now start sliders @@ -54,8 +52,6 @@ public void init() { heightslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, TileHarvester.Fields.HEIGHT.ordinal(), menu.tile.getBlockPos(), 0, TileHarvester.MAX_HEIGHT, menu.tile.getField(f))); heightslider.setTooltip("buildertype.height.tooltip"); - // w = 130; - // int h = 18; f = TileHarvester.Fields.SIZE.ordinal(); y += 26; size = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), 0, TileHarvester.MAX_SIZE, menu.tile.getField(f))); @@ -74,9 +70,11 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { btnRedstone.onValueUpdate(menu.tile); btnRender.onValueUpdate(menu.tile); btnDirection.onValueUpdate(menu.tile); + heightslider.setTooltip("buildertype.height.tooltip"); size.setTooltip("cyclic.screen.size" + menu.tile.getField(size.getField())); this.drawButtonTooltips(ms, mouseX, mouseY); this.drawName(ms, title.getString()); + btnDirection.visible = !menu.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 b8d7b3d00..ede649522 100644 --- a/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java +++ b/src/main/java/com/lothrazar/cyclic/block/harvester/TileHarvester.java @@ -3,6 +3,7 @@ import java.util.List; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.CustomEnergyStorage; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.HarvestUtil; @@ -18,6 +19,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.ForgeConfigSpec.IntValue; import net.minecraftforge.common.capabilities.Capability; @@ -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); @@ -71,7 +74,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.level, targetPos)) { @@ -80,8 +84,7 @@ public void tick() { } } - private BlockPos getShapeTarget() { - List shape = this.getShape(); + private BlockPos getShapeTarget(List shape) { if (shape.size() == 0) { return null; } @@ -91,22 +94,36 @@ private BlockPos getShapeTarget() { return shape.get(shapeIndex); } + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().getValue(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 = ShapeUtil.cubeSquareBase(this.getCurrentFacingPos(radius + 1), radius, 0); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = ShapeUtil.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.cubeSquareBase(center, radius, 0); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); } return shape; } //for render public List getShapeHollow() { - List shape = ShapeUtil.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), radius); - int diff = directionIsUp ? 1 : -1; - if (height > 0) { - shape = ShapeUtil.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); + } + if (targetPos != null) { + shape.add(targetPos); } return shape; } @@ -140,7 +157,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 95e7954f1..fab938925 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 com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -30,6 +31,16 @@ public BlockSimpleHopper(Properties properties) { super(properties.strength(1.3F)); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override protected void createBlockStateDefinition(StateDefinition.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 810fb7d94..7126f5c50 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java @@ -2,7 +2,6 @@ import java.util.List; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; -import com.lothrazar.cyclic.block.hopperfluid.BlockFluidHopper; import com.lothrazar.cyclic.block.hoppergold.TileGoldHopper; import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.core.BlockPos; @@ -66,10 +65,11 @@ public void tick() { //no cooldown unlike mojang hopper this.tryPullFromWorld(worldPosition.relative(Direction.UP)); this.tryExtract(inventory, Direction.UP, getFlow(), null); - Direction exportToSide = this.getBlockState().getValue(BlockFluidHopper.FACING); + Direction exportToSide = this.getBlockState().getValue(BlockSimpleHopper.FACING); //is it a composter this.moveItemToCompost(exportToSide, inventory); this.moveItems(exportToSide, getFlow(), inventory); + updateComparatorOutputLevel(); } public int getFlow() { @@ -86,6 +86,7 @@ private void tryPullFromWorld(BlockPos center) { if (remainder.isEmpty()) { stackEntity.remove(Entity.RemovalReason.KILLED); } + 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 d502d8b24..e61ada25a 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/BlockFluidHopper.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -28,6 +29,16 @@ public BlockFluidHopper(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(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 7021210e5..92a2121e8 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopperfluid/TileFluidHopper.java @@ -85,11 +85,13 @@ private void tryExtract() { IFluidHandler tankAbove = FluidHelpers.getTank(level, target, Direction.DOWN); boolean success = FluidHelpers.tryFillPositionFromTank(level, worldPosition, Direction.UP, tankAbove, FLOW); if (success) { + this.updateComparatorOutputLevel(); return; } //try from the world if (tank.getSpace() >= FluidAttributes.BUCKET_VOLUME) { FluidHelpers.extractSourceWaterloggedCauldron(level, 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 48eab2b4c..ebcac0717 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hoppergold/BlockGoldHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hoppergold/BlockGoldHopper.java @@ -3,6 +3,7 @@ import com.lothrazar.cyclic.block.hopper.BlockSimpleHopper; import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.core.BlockPos; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; @@ -15,6 +16,16 @@ public BlockGoldHopper(Properties properties) { super(properties.strength(1.3F)); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new TileGoldHopper(pos, state); 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 1fa67ecad..21f383260 100644 --- a/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java +++ b/src/main/java/com/lothrazar/cyclic/block/laser/RenderLaser.java @@ -112,7 +112,7 @@ public static void drawDirewolfLaser(VertexConsumer builder, Matrix4f positionMa } @Override - public boolean shouldRenderOffScreen(TileLaser te) { + public boolean shouldRenderOffScreen(TileLaser te) { // isGlobalRenderer 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 b06590818..6d9afddd1 100644 --- a/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java +++ b/src/main/java/com/lothrazar/cyclic/block/melter/BlockMelter.java @@ -6,6 +6,7 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -24,6 +25,16 @@ public BlockMelter(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override @Deprecated public float getShadeBrightness(BlockState state, BlockGetter 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 47d5aaea1..2a53c77ba 100644 --- a/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java +++ b/src/main/java/com/lothrazar/cyclic/block/melter/TileMelter.java @@ -231,6 +231,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 44932d8ea..07ae440a4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/BlockMiner.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -24,6 +25,16 @@ public BlockMiner(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public void registerClient() { MenuScreens.register(MenuTypeRegistry.MINER.get(), ScreenMiner::new); @@ -42,12 +53,12 @@ public BlockEntityTicker getTicker(Level world, Block @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { - world.setBlock(pos, state.setValue(BlockStateProperties.HORIZONTAL_FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2); + world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2); } } @Override protected void createBlockStateDefinition(StateDefinition.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 2a9032c09..fae22dab6 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.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderMiner implements BlockEntityRenderer { @@ -13,8 +16,14 @@ public RenderMiner(BlockEntityRendererProvider.Context d) {} @Override public void render(TileMiner te, float v, PoseStack matrixStack, MultiBufferSource 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) { RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrixStack, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } } } 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 7bb005860..437d06bc7 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 renderLabels(PoseStack ms, int mouseX, int mouseY) { btnRender.onValueUpdate(menu.tile); btnDirection.onValueUpdate(menu.tile); sizeSlider.setTooltip("cyclic.screen.size" + menu.tile.getField(sizeSlider.getField())); + btnDirection.visible = !menu.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 7254700aa..c071aebfc 100644 --- a/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java +++ b/src/main/java/com/lothrazar/cyclic/block/miner/TileMiner.java @@ -1,11 +1,12 @@ package com.lothrazar.cyclic.block.miner; import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.List; import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.CustomEnergyStorage; +import com.lothrazar.cyclic.data.DataTags; +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.BlockRegistry; @@ -27,7 +28,6 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.ForgeConfigSpec.IntValue; import net.minecraftforge.common.capabilities.Capability; @@ -227,40 +227,6 @@ private boolean updateMiningProgress(List shape) { return false; } - private boolean isValidTarget(BlockState targetState) { - ItemStack filter = inventory.getStackInSlot(SLOT_FILTER); - if (filter.isEmpty()) { - return true; //ya go - } - for (BlockStateMatcher m : BlockstateCard.getSavedStates(filter)) { - BlockState st = m.getState(); - if (targetState.getBlock() == st.getBlock()) { - if (m.isExactProperties() == false) { - // the blocks DO match, isExact is flagged as no, so we are good - return true; - } - //tag DOES want to match Exactly on Properties - return this.propertiesMatch(targetState, st); - } - } - return false; - } - - private boolean propertiesMatch(BlockState targetState, BlockState st) { - try { - for (Property p : st.getProperties()) { - if (!st.getValue(p).equals(targetState.getValue(p))) { - return false; - } - } - } - catch (Exception e) { - return false; - } - //none had a mismatch - return true; - } - /*** * Unbreakable blocks and fluid blocks are not valid. Otherwise checks if player:canHarvestBlock using its equipped item */ @@ -269,30 +235,48 @@ private boolean isTargetValid() { return false; //dont mine air or liquid. } //is this valid - BlockState blockSt = level.getBlockState(targetPos); - if (blockSt.destroySpeed < 0) { + BlockState targetState = level.getBlockState(targetPos); + if (targetState.destroySpeed < 0) { return false; //unbreakable } + //check the tag ignore list so modpack/datapack can filter this + if (targetState.is(DataTags.MINER_IGNORED)) { + ModCyclic.LOGGER.info("miner/ignored tag skips " + targetPos); + return false; + } //water logged is - if (blockSt.getFluidState() != null && blockSt.getFluidState().isEmpty() == false) { + if (targetState.getFluidState() != null && targetState.getFluidState().isEmpty() == false) { //am i PURE liquid? or just a WATERLOGGED block - if (blockSt.hasProperty(BlockStateProperties.WATERLOGGED) == false) { + if (targetState.hasProperty(BlockStateProperties.WATERLOGGED) == false) { // ModCyclic.LOGGER.info(targetPos + " Mining FLUID is not valid " + blockSt); //pure liquid. but this will make canHarvestBlock go true , which is a lie actually so, no. dont get stuck here return false; } } - if (!this.isValidTarget(blockSt)) { + if (!this.isValidFromDatacard(targetState)) { return false; } //its a solid non-air, non-fluid block (but might be like waterlogged stairs or something) - boolean canHarvest = blockSt.canHarvestBlock(level, targetPos, fakePlayer.get()); + boolean canHarvest = targetState.canHarvestBlock(level, targetPos, fakePlayer.get()); if (!canHarvest) { // ModCyclic.LOGGER.info(targetPos + " Mining target is not valid " + blockSt); } return canHarvest; } + private boolean isValidFromDatacard(BlockState targetState) { + ItemStack filter = inventory.getStackInSlot(SLOT_FILTER); + if (filter.isEmpty()) { + return true; //ya go + } + for (BlockStateMatcher m : BlockstateCard.getSavedStates(filter)) { + if (m.doesMatch(targetState)) { + return true; // i am allowed to mine this + } + } + return false; //filter is my allow list, and you aint in it so not allowed + } + private void updateTargetPos(List shape) { shapeIndex++; if (this.shapeIndex < 0 || this.shapeIndex >= shape.size()) { @@ -305,26 +289,35 @@ private void resetProgress() { isCurrentlyMining = false; curBlockDamage = 0; if (fakePlayer != null && targetPos != null) { - //BlockPos targetPos = pos.offset(state.getValue(BlockMiner.PROPERTYFACING)); - getLevel().destroyBlockProgress(fakePlayer.get().getUUID().hashCode(), targetPos, -1); + getLevel().destroyBlockProgress(fakePlayer.get().getUUID().hashCode(), targetPos, -1); // sendBlockBreakProgress + } + } + + private int heightWithDirection() { + Direction blockFacing = this.getBlockState().getValue(BlockStateProperties.FACING); + int diff = directionIsUp ? 1 : -1; + if (blockFacing.getAxis().isVertical()) { + diff = (blockFacing == Direction.UP) ? 1 : -1; } + return diff * height; } public List getShape() { - List shape = ShapeUtil.squareHorizontalFull(this.getCurrentFacingPos(radius + 1), radius); - if (height > 0) { - int diff = directionIsUp ? 1 : -1; - shape = ShapeUtil.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.squareHorizontalFull(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); } return shape; } public List getShapeHollow() { - List shape = new ArrayList(); - shape = ShapeUtil.squareHorizontalHollow(this.getCurrentFacingPos(radius + 1), radius); - if (height > 0) { - int diff = directionIsUp ? 1 : -1; - shape = ShapeUtil.repeatShapeByHeight(shape, diff * height); + BlockPos center = getFacingShapeCenter(radius); + List shape = ShapeUtil.squareHorizontalHollow(center, radius); + int heightWithDirection = heightWithDirection(); + if (heightWithDirection != 0) { + shape = ShapeUtil.repeatShapeByHeight(shape, heightWithDirection); } if (targetPos != null) { shape.add(targetPos); @@ -356,7 +349,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 0af205d06..e9af142b2 100644 --- a/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java +++ b/src/main/java/com/lothrazar/cyclic/block/packager/BlockPackager.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -21,6 +22,16 @@ public BlockPackager(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override protected void createBlockStateDefinition(StateDefinition.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 9523a6b4a..82cf68155 100644 --- a/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java +++ b/src/main/java/com/lothrazar/cyclic/block/packager/TilePackager.java @@ -113,6 +113,7 @@ private void tryDoPackage() { inputSlots.extractItem(0, total, false); outputSlots.insertItem(0, output, false); energy.extractEnergy(POWERCONF.get(), false); + this.updateComparatorOutputLevel(); } } @@ -194,7 +195,7 @@ public void invalidateCaps() { @Override public LazyOptional getCapability(Capability cap, Direction side) { - if (cap == ForgeCapabilities.ENERGY) { + if (cap == ForgeCapabilities.ENERGY && POWERCONF.get() > 0) { return energyCap.cast(); } if (cap == ForgeCapabilities.ITEM_HANDLER) { 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 e0b9ad2c5..9f2d25a9c 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.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderPeatFarm implements BlockEntityRenderer { @@ -13,8 +16,14 @@ public RenderPeatFarm(BlockEntityRendererProvider.Context d) {} @Override public void render(TilePeatFarm te, float v, PoseStack matrixStack, MultiBufferSource 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) { RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrixStack, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } } } 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 6202c661e..3cc1edde4 100644 --- a/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java +++ b/src/main/java/com/lothrazar/cyclic/block/peatfarm/TilePeatFarm.java @@ -29,6 +29,7 @@ import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.CustomEnergyStorage; import com.lothrazar.cyclic.capabilities.block.FluidTankBase; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.FluidHelpers.FluidAttributes; @@ -155,7 +156,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; } } @@ -185,6 +186,10 @@ public boolean canPlaceItem(int index, ItemStack stack) { return Block.byItem(stack.getItem()) == BlockRegistry.PEAT_UNBAKED.get(); } + public List getShapeHollow() { + return getShape(); + } + List getShape() { List outer = ShapeUtil.squareHorizontalHollow(this.worldPosition, 7); outer.addAll(ShapeUtil.squareHorizontalHollow(this.worldPosition, 5)); @@ -253,7 +258,7 @@ public LazyOptional getCapability(Capability cap, Direction side) { if (cap == ForgeCapabilities.FLUID_HANDLER) { return fluidCap.cast(); } - if (cap == ForgeCapabilities.ENERGY) { + if (cap == ForgeCapabilities.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 02ac8ba9d..f9f10d235 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.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -24,6 +25,16 @@ public BlockPlacer(Properties properties) { this.setHasGui(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public void registerClient() { MenuScreens.register(MenuTypeRegistry.PLACER.get(), 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 2a0402b15..4c9945583 100644 --- a/src/main/java/com/lothrazar/cyclic/block/placer/TilePlacer.java +++ b/src/main/java/com/lothrazar/cyclic/block/placer/TilePlacer.java @@ -64,9 +64,9 @@ public void tick() { Direction dir = this.getBlockState().getValue(BlockStateProperties.FACING); BlockPos offset = worldPosition.relative(dir); BlockState state = Block.byItem(stack.getItem()).defaultBlockState(); - if (level.isEmptyBlock(offset) && - level.setBlockAndUpdate(offset, state)) { + if (level.isEmptyBlock(offset) && level.setBlockAndUpdate(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 46508b55b..85276023b 100644 --- a/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/placerfluid/TilePlacerFluid.java @@ -3,6 +3,7 @@ import java.util.function.Predicate; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.FluidTankBase; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; import com.lothrazar.cyclic.util.FluidHelpers.FluidAttributes; @@ -140,7 +141,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 fbd9cbfce..c96a6b623 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.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.core.BlockPos; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.items.IItemHandler; @@ -16,11 +19,12 @@ public RenderStructure(BlockEntityRendererProvider.Context d) {} @Override public void render(TileStructure te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { - IItemHandler inv = te.getCapability(ForgeCapabilities.ITEM_HANDLER).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(ForgeCapabilities.ITEM_HANDLER).orElse(null); + if (inv == null) { + return; + } ItemStack stack = inv.getStackInSlot(0); if (stack.isEmpty()) { RenderUtils.renderOutline(te.getBlockPos(), te.getShape(), matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); @@ -29,5 +33,10 @@ public void render(TileStructure te, float v, PoseStack matrixStack, MultiBuffer RenderUtils.renderAsBlock(te.getBlockPos(), te.getShape(), matrixStack, stack, 1, 1); } } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : te.getShape()) { + RenderUtils.createBox(matrixStack, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } } } 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 09d2edcf8..993a668b5 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 = leftPos + 8; y = topPos + 82; GuiSliderInteger durationslider = this.addRenderableWidget(new GuiSliderInteger(x, y, w, h, f, menu.tile.getBlockPos(), - 1, TileStructure.MAXHEIGHT, menu.tile.getField(f))); + 1, TileStructure.MAX_HEIGHT, menu.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 0d69f67e5..e3fbd807b 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapebuilder/TileStructure.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.capabilities.block.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; @@ -40,7 +41,7 @@ public class TileStructure extends TileBlockEntityCyclic implements MenuProvider 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; @@ -139,7 +140,7 @@ public void invalidateCaps() { @Override public LazyOptional getCapability(Capability cap, Direction side) { - if (cap == ForgeCapabilities.ENERGY) { + if (cap == ForgeCapabilities.ENERGY && POWERCONF.get() > 0) { return energyCap.cast(); } if (cap == ForgeCapabilities.ITEM_HANDLER) { @@ -164,16 +165,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 cc224d23b..0d968fe90 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapedata/RenderShapedata.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapedata/RenderShapedata.java @@ -1,26 +1,22 @@ package com.lothrazar.cyclic.block.shapedata; import java.awt.Color; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.RenderUtils; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.world.phys.Vec3; public class RenderShapedata implements BlockEntityRenderer { public RenderShapedata(BlockEntityRendererProvider.Context d) {} @Override - public void render(TileShapedata te, float v, PoseStack matrixStack, - MultiBufferSource ibuffer, int partialTicks, int destroyStage) { - IItemHandler inv = te.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(null); - if (inv == null) { - return; - } - if (1 == te.getField(TileShapedata.Fields.RENDER.ordinal())) { + public void render(TileShapedata te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { + int previewType = te.getField(TileShapedata.Fields.RENDER.ordinal()); + if (PreviewOutlineType.SHADOW.ordinal() == previewType) { if (te.getTarget(0) != null) { RenderUtils.renderOutline(te.getBlockPos(), te.getTarget(0), matrixStack, 1.05F, Color.BLUE); } @@ -28,5 +24,10 @@ public void render(TileShapedata te, float v, PoseStack matrixStack, RenderUtils.renderOutline(te.getBlockPos(), te.getTarget(1), matrixStack, 1.05F, Color.RED); } } + else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + // for (BlockPos crd : te.getShapeHollow()) { + RenderUtils.createBox(matrixStack, te.getTarget(0), Vec3.atLowerCornerOf(te.getBlockPos())); + RenderUtils.createBox(matrixStack, te.getTarget(1), Vec3.atLowerCornerOf(te.getBlockPos())); + } } } 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 3fe481d8f..d244b6d32 100644 --- a/src/main/java/com/lothrazar/cyclic/block/shapedata/TileShapedata.java +++ b/src/main/java/com/lothrazar/cyclic/block/shapedata/TileShapedata.java @@ -4,6 +4,7 @@ import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; 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; @@ -246,7 +247,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 5167630a4..e22707992 100644 --- a/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java +++ b/src/main/java/com/lothrazar/cyclic/block/solidifier/BlockSolidifier.java @@ -6,6 +6,7 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -26,6 +27,17 @@ public BlockSolidifier(Properties properties) { } @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + + @Override + @Deprecated public float getShadeBrightness(BlockState state, BlockGetter worldIn, BlockPos pos) { return 1.0f; } 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 dfd5b415c..d60c41872 100644 --- a/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java +++ b/src/main/java/com/lothrazar/cyclic/block/solidifier/TileSolidifier.java @@ -220,6 +220,7 @@ private boolean tryProcessRecipe() { inputSlots.getStackInSlot(2).shrink(1); tank.drain(this.currentRecipe.fluidIngredient.getAmount(), FluidAction.EXECUTE); outputSlots.insertItem(0, currentRecipe.getResultItem(), false); + updateComparatorOutputLevel(); return true; } return false; 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 8f371ab5e..45cba5837 100644 --- a/src/main/java/com/lothrazar/cyclic/block/tank/BlockFluidTank.java +++ b/src/main/java/com/lothrazar/cyclic/block/tank/BlockFluidTank.java @@ -13,6 +13,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.BlockGetter; @@ -43,6 +44,16 @@ public BlockFluidTank(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { if (!player.isCrouching() && player.getItemInHand(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 57d31348f..ad37e31da 100644 --- a/src/main/java/com/lothrazar/cyclic/block/tank/TileTank.java +++ b/src/main/java/com/lothrazar/cyclic/block/tank/TileTank.java @@ -75,6 +75,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 c43d62f40..608d2de24 100644 --- a/src/main/java/com/lothrazar/cyclic/block/tankcask/BlockCask.java +++ b/src/main/java/com/lothrazar/cyclic/block/tankcask/BlockCask.java @@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -26,6 +27,16 @@ public BlockCask(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasAnalogOutputSignal(BlockState bs) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState st, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new TileCask(pos, state); 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 50b0fdc1a..fbb89e0f7 100644 --- a/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java +++ b/src/main/java/com/lothrazar/cyclic/block/user/TileUser.java @@ -222,7 +222,7 @@ public LazyOptional getCapability(Capability cap, Direction side) { if (cap == ForgeCapabilities.ITEM_HANDLER) { return inventoryCap.cast(); } - if (cap == ForgeCapabilities.ENERGY) { + if (POWERCONF.get() > 0 && cap == ForgeCapabilities.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 95edfc56f..66325cb32 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 @@ -6,6 +6,7 @@ import com.lothrazar.cyclic.capabilities.block.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.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -141,7 +142,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 788e29c91..fcb35bcbe 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.capabilities.block.FluidTankBase; 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.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -152,7 +153,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 bfd6f5727..e6c9e23d7 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.block.TileBlockEntityCyclic; 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.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -136,7 +137,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 90cb69b83..4385eb2f7 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,8 +1,12 @@ package com.lothrazar.cyclic.block.wireless.redstone; +import java.util.ArrayList; +import java.util.List; import com.lothrazar.cyclic.block.laser.RenderLaser; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.render.FakeBlockRenderTypes; +import com.lothrazar.cyclic.render.RenderUtils; import com.lothrazar.cyclic.util.LevelWorldUtil; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -12,24 +16,12 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class RenderTransmit implements BlockEntityRenderer { public RenderTransmit(BlockEntityRendererProvider.Context d) {} - @Override - public void render(TileWirelessTransmit te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int partialTicks, int destroyStage) { - if (te.requiresRedstone() && !te.isPowered()) { - return; - } - if (te.getField(TileWirelessTransmit.Fields.RENDER.ordinal()) < 1) { - return; - } - for (int slot = 0; slot < te.inventory.getSlots(); slot++) { - draw(slot, te, matrixStack, iRenderTypeBuffer); - } - } - public static void draw(int slot, TileWirelessTransmit tile, PoseStack matrixStackIn, MultiBufferSource bufferIn) { BlockPosDim posPosTarget = tile.getTargetInSlot(slot); if (posPosTarget == null) { @@ -63,4 +55,61 @@ public static void draw(int slot, TileWirelessTransmit tile, PoseStack matrixSta public boolean shouldRenderOffScreen(TileWirelessTransmit te) { return true; } + + @Override + public void render(TileWirelessTransmit te, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int partialTicks, int destroyStage) { + if (te.requiresRedstone() && !te.isPowered()) { + return; + } + int previewType = te.getField(TileWirelessTransmit.Fields.RENDER.ordinal()); + if (previewType <= 0) { + return; + } + List shape = new ArrayList<>(); + String dimensionId = LevelWorldUtil.dimensionToString(te.getLevel()); + 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); + } + if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + for (BlockPos crd : shape) { + RenderUtils.createBox(matrixStack, crd, Vec3.atLowerCornerOf(te.getBlockPos())); + } + } + else + for (int slot = 0; slot < te.inventory.getSlots(); slot++) { + draw(slot, te, matrixStack, iRenderTypeBuffer); + } + } + // @Override + // public void render(TileWirelessTransmit te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) { + // // if (te.requiresRedstone() && !te.isPowered()) { + // // return; + // // } + // int previewType = te.getField(TileWirelessTransmit.Fields.RENDER.ordinal()); + // if (previewType <= 0) { + // return; + // } + // 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); + // } + // if (PreviewOutlineType.SHADOW.ordinal() == previewType) { + // UtilRender.renderOutline(te.getPos(), shape, matrixStack, 0.4F, ClientConfigCyclic.getColor(te)); + // } + // else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) { + // for (BlockPos crd : shape) { + // UtilRender.createBox(matrixStack, crd, Vector3d.copy(te.getPos())); + // } + // } } 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 d4dea8f90..a5cf151eb 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.ModCyclic; import com.lothrazar.cyclic.block.TileBlockEntityCyclic; import com.lothrazar.cyclic.data.BlockPosDim; +import com.lothrazar.cyclic.data.PreviewOutlineType; import com.lothrazar.cyclic.item.datacard.LocationGpsCard; import com.lothrazar.cyclic.registry.BlockRegistry; import com.lothrazar.cyclic.registry.TileRegistry; @@ -136,7 +137,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/compat/CompatConstants.java b/src/main/java/com/lothrazar/cyclic/compat/CompatConstants.java index 94876f901..34cf39f7f 100644 --- a/src/main/java/com/lothrazar/cyclic/compat/CompatConstants.java +++ b/src/main/java/com/lothrazar/cyclic/compat/CompatConstants.java @@ -1,5 +1,4 @@ package com.lothrazar.cyclic.compat; - public class CompatConstants { public static final String RESYNTH_GROWTH_STAGE = "growth_stage"; diff --git a/src/main/java/com/lothrazar/cyclic/data/DataTags.java b/src/main/java/com/lothrazar/cyclic/data/DataTags.java index 4d4175577..1f9ef82ef 100644 --- a/src/main/java/com/lothrazar/cyclic/data/DataTags.java +++ b/src/main/java/com/lothrazar/cyclic/data/DataTags.java @@ -22,6 +22,8 @@ public class DataTags { public static final TagKey MUSHROOMS = BlockTags.create(new ResourceLocation("forge:mushrooms")); public static final TagKey VINES = BlockTags.create(new ResourceLocation("forge:vines")); public static final TagKey CACTUS = BlockTags.create(new ResourceLocation("forge:cactus")); + public static final TagKey BREAKER_IGNORED = BlockTags.create(new ResourceLocation("cyclic:ignored/breaker")); + public static final TagKey MINER_IGNORED = BlockTags.create(new ResourceLocation("cyclic:ignored/miner")); public static final TagKey CROP_BLOCKS = BlockTags.create(new ResourceLocation("forge:crop_blocks")); public static final TagKey FISHING_RODS = ItemTags.create(new ResourceLocation("forge:fishing_rods")); public static final TagKey GLASS_DARKI = ItemTags.create(new ResourceLocation("forge:glass/dark")); 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 a696a9f97..37d259815 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,16 @@ public void onValueUpdate(TileBlockEntityCyclic tile) { private void onValueUpdate(int val) { setTooltip(ChatUtil.lang(this.tooltipPrefix + val)); - setTextureId(val == 1 ? textureOne : textureZero); + 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/ScreenBase.java b/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java index d039d856e..b71b2671d 100644 --- a/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java +++ b/src/main/java/com/lothrazar/cyclic/gui/ScreenBase.java @@ -2,6 +2,7 @@ import java.util.List; import com.lothrazar.cyclic.api.IHasTooltip; +import com.lothrazar.cyclic.data.Const; import com.lothrazar.cyclic.registry.TextureRegistry; import com.lothrazar.cyclic.util.ChatUtil; import com.mojang.blaze3d.systems.RenderSystem; @@ -23,7 +24,6 @@ public ScreenBase(T screenContainer, Inventory inv, Component titleIn) { } protected void drawBackground(PoseStack ms, ResourceLocation gui) { - // this.minecraft.getTextureManager().bind(gui); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderTexture(0, gui); int relX = (this.width - this.imageWidth) / 2; @@ -55,18 +55,17 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { } protected void drawSlot(PoseStack ms, int x, int y, ResourceLocation texture) { - drawSlot(ms, x, y, texture, 18); + drawSlot(ms, x, y, texture, Const.SQ); } protected void drawSlot(PoseStack ms, int x, int y, ResourceLocation texture, int size) { - // this.minecraft.getTextureManager().bind(texture); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderTexture(0, texture); blit(ms, leftPos + x, topPos + y, 0, 0, size, size, size, size); } protected void drawSlot(PoseStack ms, int x, int y) { - drawSlot(ms, x, y, TextureRegistry.SLOT, 18); + drawSlot(ms, x, y, TextureRegistry.SLOT, Const.SQ); } protected void drawSlotLarge(PoseStack ms, int x, int y) { diff --git a/src/main/java/com/lothrazar/cyclic/gui/TextureEnum.java b/src/main/java/com/lothrazar/cyclic/gui/TextureEnum.java index f5a858a04..66ef81288 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, SQUARE_RED, SQUARE_ENDER; + REDSTONE_ON, REDSTONE_NEEDED, POWER_MOVING, POWER_STOP, RENDER_HIDE, RENDER_SHOW, CRAFT_EMPTY, CRAFT_BALANCE, CRAFT_MATCH, DIR_DOWN, DIR_UPWARDS, SQUARE_RED, SQUARE_ENDER, RENDER_OUTLINE; public int getX() { switch (this) { @@ -31,6 +31,8 @@ public int getX() { return 609; case CRAFT_MATCH: return 593; + case RENDER_OUTLINE: + return 1 - 3; } return 0; } @@ -63,6 +65,8 @@ public int getY() { return 129; case CRAFT_MATCH: return 129; + case RENDER_OUTLINE: + return 129 - 3; } return 0; } @@ -79,6 +83,7 @@ public int getWidth() { return 14; case DIR_DOWN: case DIR_UPWARDS: + case RENDER_OUTLINE: return 18; default: return 20; @@ -97,6 +102,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/item/datacard/BlockStateMatcher.java b/src/main/java/com/lothrazar/cyclic/item/datacard/BlockStateMatcher.java index 914b62963..d87a85b89 100644 --- a/src/main/java/com/lothrazar/cyclic/item/datacard/BlockStateMatcher.java +++ b/src/main/java/com/lothrazar/cyclic/item/datacard/BlockStateMatcher.java @@ -7,7 +7,16 @@ public class BlockStateMatcher { private BlockState state; private boolean exactProperties = true; - public boolean doesMatch(BlockState other) { + // returns true if target state matches this + public boolean doesMatch(BlockState targetState) { + if (targetState.getBlock() == this.getState().getBlock()) { + if (this.isExactProperties() == false) { + // the blocks DO match, isExact is flagged as no, so we are good + return true; + } + //tag DOES want to match Exactly on Properties + return BlockstateCard.propertiesMatch(targetState, this.getState()); + } return false; } diff --git a/src/main/java/com/lothrazar/cyclic/item/datacard/BlockstateCard.java b/src/main/java/com/lothrazar/cyclic/item/datacard/BlockstateCard.java index 7a349fe60..ac96301d1 100644 --- a/src/main/java/com/lothrazar/cyclic/item/datacard/BlockstateCard.java +++ b/src/main/java/com/lothrazar/cyclic/item/datacard/BlockstateCard.java @@ -18,6 +18,7 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -71,12 +72,26 @@ public static List getSavedStates(ItemStack held) { return st; } + public static boolean propertiesMatch(BlockState targetState, BlockState st) { + try { + for (Property p : st.getProperties()) { + if (!st.getValue(p).equals(targetState.getValue(p))) { + return false; + } + } + } + catch (Exception e) { + return false; + } + //none had a mismatch + return true; + } + @Override public InteractionResult useOn(UseOnContext context) { Player player = context.getPlayer(); InteractionHand hand = context.getHand(); BlockPos pos = context.getClickedPos(); - // Direction side = context.getFace(); ItemStack held = player.getItemInHand(hand); BlockState state = context.getLevel().getBlockState(pos); CompoundTag stateTag = NbtUtils.writeBlockState(state); diff --git a/src/main/java/com/lothrazar/cyclic/registry/ClientRegistryCyclic.java b/src/main/java/com/lothrazar/cyclic/registry/ClientRegistryCyclic.java index 5c25fd077..d34f9fc84 100644 --- a/src/main/java/com/lothrazar/cyclic/registry/ClientRegistryCyclic.java +++ b/src/main/java/com/lothrazar/cyclic/registry/ClientRegistryCyclic.java @@ -14,6 +14,7 @@ import com.lothrazar.cyclic.block.dropper.RenderDropper; import com.lothrazar.cyclic.block.enderitemshelf.ItemShelfRenderer; import com.lothrazar.cyclic.block.endershelf.EnderShelfRenderer; +import com.lothrazar.cyclic.block.fan.RenderFan; import com.lothrazar.cyclic.block.fishing.RenderFisher; import com.lothrazar.cyclic.block.forester.RenderForester; import com.lothrazar.cyclic.block.harvester.RenderHarvester; @@ -141,6 +142,7 @@ public static void onRegisterRenderers(EntityRenderersEvent.RegisterRenderers ev event.registerBlockEntityRenderer(TileRegistry.DETECTOR_ITEM.get(), RenderDetectorItem::new); event.registerBlockEntityRenderer(TileRegistry.DROPPER.get(), RenderDropper::new); event.registerBlockEntityRenderer(TileRegistry.ENDER_ITEM_SHELF.get(), ItemShelfRenderer::new); + event.registerBlockEntityRenderer(TileRegistry.FAN.get(), RenderFan::new); event.registerBlockEntityRenderer(TileRegistry.ENDER_SHELF.get(), EnderShelfRenderer::new); event.registerBlockEntityRenderer(TileRegistry.FISHER.get(), RenderFisher::new); event.registerBlockEntityRenderer(TileRegistry.FORESTER.get(), RenderForester::new); diff --git a/src/main/java/com/lothrazar/cyclic/render/RenderUtils.java b/src/main/java/com/lothrazar/cyclic/render/RenderUtils.java index 8e4fbc53c..9f84711e9 100644 --- a/src/main/java/com/lothrazar/cyclic/render/RenderUtils.java +++ b/src/main/java/com/lothrazar/cyclic/render/RenderUtils.java @@ -421,15 +421,35 @@ public static void renderColourCubes(RenderLevelLastEvent evt, Map 200d) { // could be 300 diff --git a/src/main/java/com/lothrazar/cyclic/util/ItemStackUtil.java b/src/main/java/com/lothrazar/cyclic/util/ItemStackUtil.java index 409c36f8a..1ff7d9b82 100644 --- a/src/main/java/com/lothrazar/cyclic/util/ItemStackUtil.java +++ b/src/main/java/com/lothrazar/cyclic/util/ItemStackUtil.java @@ -36,14 +36,6 @@ public static ItemStack findItem(String id) { } return ItemStack.EMPTY; } - // public static void dropAll(IItemHandler items, Level world, BlockPos pos) { - // if (items == null) { - // return; - // } - // for (int i = 0; i < items.getSlots(); i++) { - // Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), items.getStackInSlot(i)); - // } - // } public static void repairItem(ItemStack s) { repairItem(s, 1); @@ -113,9 +105,8 @@ public static void dropItemStackMotionless(Level world, BlockPos pos, ItemStack if (world.isClientSide == 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.addFreshEntity(entityItem); entityItem.setDeltaMovement(0, 0, 0); - // entityItem.motionX = entityItem.motionY = entityItem.motionZ = 0; + world.addFreshEntity(entityItem); } } 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 05a44f2d7..b6a29cc44 100644 --- a/src/main/resources/assets/cyclic/lang/en_us.json +++ b/src/main/resources/assets/cyclic/lang/en_us.json @@ -1279,7 +1279,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/src/main/resources/data/cyclic/tags/blocks/ignored/breaker.json b/src/main/resources/data/cyclic/tags/blocks/ignored/breaker.json new file mode 100644 index 000000000..4355fff9f --- /dev/null +++ b/src/main/resources/data/cyclic/tags/blocks/ignored/breaker.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + {"required":false, "id": "minecraft:command_block"} + ] +} \ No newline at end of file diff --git a/src/main/resources/data/cyclic/tags/blocks/ignored/miner.json b/src/main/resources/data/cyclic/tags/blocks/ignored/miner.json new file mode 100644 index 000000000..731a9f0c3 --- /dev/null +++ b/src/main/resources/data/cyclic/tags/blocks/ignored/miner.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "#cyclic:ignored/breaker" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index fb08e6645..863a796d2 100644 --- a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -1,7 +1,102 @@ { "replace": false, "values": [ + "cyclic:altar_destruction", + "cyclic:anti_beacon", + "cyclic:anvil", + "cyclic:anvil_magma", + "cyclic:anvil_void", + "cyclic:battery", + "cyclic:battery_clay", + "cyclic:beacon", + "cyclic:beacon_redstone", + "cyclic:breaker", + "cyclic:button_basalt", + "cyclic:button_blackstone", + "cyclic:clock", + "cyclic:collector", + "cyclic:collector_fluid", "cyclic:compressed_cobblestone", - "cyclic:flint_block" + "cyclic:computer_shape", + "cyclic:conveyor", + "cyclic:copper_bars", + "cyclic:copper_chain", + "cyclic:copper_lantern", + "cyclic:copper_pressure_plate", + "cyclic:copper_soul_lantern", + "cyclic:crafter", + "cyclic:crusher", + "cyclic:detector_entity", + "cyclic:detector_item", + "cyclic:detector_moon", + "cyclic:detector_weather", + "cyclic:dice", + "cyclic:disenchanter", + "cyclic:dropper", + "cyclic:ender_controller", + "cyclic:ender_shelf", + "cyclic:energy_pipe", + "cyclic:experience_pylon", + "cyclic:eye_redstone", + "cyclic:eye_teleport", + "cyclic:fan", + "cyclic:fan_slab", + "cyclic:fireplace", + "cyclic:fisher", + "cyclic:flint_block", + "cyclic:fluid_pipe", + "cyclic:forester", + "cyclic:generator_fluid", + "cyclic:generator_food", + "cyclic:generator_fuel", + "cyclic:generator_item", + "cyclic:generator_solar", + "cyclic:gold_bars", + "cyclic:gold_chain", + "cyclic:gold_lantern", + "cyclic:gold_soul_lantern", + "cyclic:harvester", + "cyclic:hopper_fluid", + "cyclic:hopper_gold", + "cyclic:item_pipe", + "cyclic:light_camo", + "cyclic:magnet_block", + "cyclic:melter", + "cyclic:miner", + "cyclic:netherite_bars", + "cyclic:netherite_chain", + "cyclic:netherite_lantern", + "cyclic:netherite_pressure_plate", + "cyclic:packager", + "cyclic:peace_candle", + "cyclic:peat_farm", + "cyclic:placer", + "cyclic:placer_fluid", + "cyclic:plate_launch", + "cyclic:plate_launch_redstone", + "cyclic:rotator", + "cyclic:screen", + "cyclic:shearing", + "cyclic:solidifier", + "cyclic:spikes_curse", + "cyclic:spikes_diamond", + "cyclic:spikes_fire", + "cyclic:spikes_iron", + "cyclic:sprinkler", + "cyclic:structure", + "cyclic:tank", + "cyclic:teleport", + "cyclic:trash", + "cyclic:unbreakable_block", + "cyclic:unbreakable_reactive", + "cyclic:uncrafter", + "cyclic:user", + "cyclic:water_candle", + "cyclic:waxed_redstone", + "cyclic:wireless_energy", + "cyclic:wireless_fluid", + "cyclic:wireless_item", + "cyclic:wireless_receiver", + "cyclic:wireless_transmitter" ] } \ No newline at end of file diff --git a/update.json b/update.json index 342b36950..c0c060311 100644 --- a/update.json +++ b/update.json @@ -1,12 +1,12 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/cyclic", "promos": { - "1.19.2-latest":"1.8.5", + "1.19.2-latest":"1.9.0", "1.19.4-latest":"1.8.1", "1.18-latest": "1.6.7", "1.18.1-latest": "1.6.15", "1.18.2-latest": "1.7.20", - "1.16.5-latest": "1.5.24" + "1.16.5-latest": "1.6.0" }, "1.16.5": { "0.6.1": "Ported ", @@ -89,6 +89,7 @@ + }, "1.18.2": { "1.6.0": "Ported Cyclic[1.16.5]-1.5.8 to Minecraft [1.17.1] & forge-37.0.85+. Altered a few crafting recipes to use new items. Removed Peat Generator (Use Peat items in Material Generator). Removed 5 Mason blocks, replaced with Compressed Cobblestone, Flint Block. Added Peace Candle, Translocation Platform, Stone Mattock, Crushing Macerator, and Lava Sponge. Added Copper Tools and Amethyst Tools, Copper Lantern, Copper Chain, Copper Bars, Gold Chain, Gold Bars, Gold Lantern (Art by @shynieke). Added Copper Nuggets and Netherite Nuggets. Added Netherite Lanterns, chains, and bars. Added 3 Pressure Plates: Copper Netherite and Obsidian. ", @@ -150,5 +151,8 @@ ,"1.8.4":"Fix buckets not filling tanks" ,"1.8.5":"Backport Mud block solidifier recipe. Fixed bug in the item cyclic:offset_scepter #2427. Tweaked block model visuals of the Transfer Nodes. Fix Mattock not saving contents of Shulker Boxes when mined #2411. Add recipes in the solidifier machine for Waxed copper blocks " + + ,"1.9.0":"Added an optional item slot in the Block Breaker using the BlockState Data Card so players have the option to limit the block breaker to only the targets listed in the data card. Add new block data tags cyclic:ignored/breaker and cyclic:ignored/miner so that pack devs can customize these machines to not break certain blocks (regardless of hardness). Many blocks now allow minecraft:comparator to pull a redstone signal based on inventory contents (most machines and blocks that have inventory). Fluid collector will now place air and scoop up the fluid if the itemslot is empty. New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). Backported machine feature 'Preview Outline' mode on machines that already have the button. Backported cable (fluid & energy) buffer and flow speed configs from 1.20.1. Several blocks added to block-tag mineable/pickaxe (thanks to darkosto) " + } }