diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SheetmetalTankLogic.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SheetmetalTankLogic.java index 8bfe16d41b..d65ea2a350 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SheetmetalTankLogic.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SheetmetalTankLogic.java @@ -19,6 +19,7 @@ import blusunrize.immersiveengineering.client.utils.TextUtils; import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.SheetmetalTankLogic.State; import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.interfaces.MBOverlayText; +import blusunrize.immersiveengineering.common.blocks.multiblocks.shapes.SiloTankShapes; import blusunrize.immersiveengineering.common.fluids.ArrayFluidHandler; import blusunrize.immersiveengineering.common.util.LayeredComparatorOutput; import blusunrize.immersiveengineering.common.util.Utils; @@ -30,7 +31,6 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.neoforged.neoforge.capabilities.Capabilities.FluidHandler; import net.neoforged.neoforge.fluids.FluidStack; @@ -46,6 +46,7 @@ public class SheetmetalTankLogic implements IServerTickableComponent, MBOverlayText { + private static final SiloTankShapes SHAPE_GETTER = new SiloTankShapes(4); public static final BlockPos IO_POS = new BlockPos(1, 0, 1); private static final BlockPos INPUT_POS = new BlockPos(1, 4, 1); @@ -107,12 +108,7 @@ public List getOverlayText(State state, Player player, boolean hammer @Override public Function shapeGetter(ShapeType forType) { - return pos -> { - if(pos.getX()%2==0&&pos.getY()==0&&pos.getZ()%2==0) - return Shapes.box(.375f, 0, .375f, .625f, 1, .625f); - else - return Shapes.block(); - }; + return SHAPE_GETTER; } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SiloLogic.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SiloLogic.java index ceb657d371..03f397bcbe 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SiloLogic.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/logic/SiloLogic.java @@ -18,7 +18,7 @@ import blusunrize.immersiveengineering.api.multiblocks.blocks.util.RelativeBlockFace; import blusunrize.immersiveengineering.api.multiblocks.blocks.util.ShapeType; import blusunrize.immersiveengineering.common.blocks.multiblocks.logic.SiloLogic.State; -import blusunrize.immersiveengineering.common.blocks.multiblocks.shapes.SiloShapes; +import blusunrize.immersiveengineering.common.blocks.multiblocks.shapes.SiloTankShapes; import blusunrize.immersiveengineering.common.util.LayeredComparatorOutput; import blusunrize.immersiveengineering.common.util.Utils; import com.google.common.collect.ImmutableList; @@ -39,6 +39,7 @@ public class SiloLogic implements IMultiblockLogic, IServerTickableComponent { + private static final SiloTankShapes SHAPE_GETTER = new SiloTankShapes(6); private static final int MAX_STORAGE = 41472; public static final BlockPos OUTPUT_POS = new BlockPos(1, 0, 1); private static final Set IO_OFFSETS = Set.of(OUTPUT_POS, new BlockPos(1, 6, 1)); @@ -90,7 +91,7 @@ public void registerCapabilities(CapabilityRegistrar register) @Override public Function shapeGetter(ShapeType forType) { - return SiloShapes.SHAPE_GETTER; + return SHAPE_GETTER; } public static class State implements IMultiblockState diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/shapes/SiloShapes.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/shapes/SiloShapes.java deleted file mode 100644 index c6cc7b35a4..0000000000 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/shapes/SiloShapes.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * BluSunrize - * Copyright (c) 2023 - * - * This code is licensed under "Blu's License of Common Sense" - * Details can be found in the license file in the root folder of this project - */ - -package blusunrize.immersiveengineering.common.blocks.multiblocks.shapes; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; - -import java.util.function.Function; - -public class SiloShapes implements Function -{ - public static final Function SHAPE_GETTER = new SiloShapes(); - - private SiloShapes() - { - } - - @Override - public VoxelShape apply(BlockPos posInMultiblock) - { - if(posInMultiblock.getX()%2!=0||posInMultiblock.getY()!=0||posInMultiblock.getZ()%2!=0) - return Shapes.block(); - float xMin = posInMultiblock.getX()==2?.75f: 0; - float xMax = posInMultiblock.getX()==0?.25f: 1; - float zMin = posInMultiblock.getZ()==2?.75f: 0; - float zMax = posInMultiblock.getZ()==0?.25f: 1; - return Shapes.box(xMin, 0, zMin, xMax, 1, zMax); - } -} diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/shapes/SiloTankShapes.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/shapes/SiloTankShapes.java new file mode 100644 index 0000000000..518b58b554 --- /dev/null +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/shapes/SiloTankShapes.java @@ -0,0 +1,47 @@ +/* + * BluSunrize + * Copyright (c) 2023 + * + * This code is licensed under "Blu's License of Common Sense" + * Details can be found in the license file in the root folder of this project + */ + +package blusunrize.immersiveengineering.common.blocks.multiblocks.shapes; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +import java.util.function.Function; + +public record SiloTankShapes(int height) implements Function +{ + @Override + public VoxelShape apply(BlockPos posInMultiblock) + { + boolean isCenter = posInMultiblock.getX()==1&&posInMultiblock.getZ()==1; + if(!isCenter&&posInMultiblock.getY()==0) + { + // Wooden supports + float xMin = posInMultiblock.getX()==2?.75f: 0; + float xMax = posInMultiblock.getX()==0?.25f: 1; + float zMin = posInMultiblock.getZ()==2?.75f: 0; + float zMax = posInMultiblock.getZ()==0?.25f: 1; + return Shapes.box(xMin, 0, zMin, xMax, 1, zMax); + } + else if(!isCenter&&posInMultiblock.getY()==height) + { + // Top level of the tank, stair-like structure + float xMin = posInMultiblock.getX()==0?0.5f: 0; + float xMax = posInMultiblock.getX()==2?0.5f: 1; + float zMin = posInMultiblock.getZ()==0?0.5f: 0; + float zMax = posInMultiblock.getZ()==2?0.5f: 1; + return Shapes.or( + Shapes.box(0, 0, 0, 1, 0.5, 1), + Shapes.box(xMin, 0, zMin, xMax, 1, zMax) + ); + } + else + return Shapes.block(); + } +}