Skip to content

Commit

Permalink
Fix top row of shapes on tanks and silos
Browse files Browse the repository at this point in the history
  • Loading branch information
malte0811 committed Jan 28, 2024
1 parent e528f14 commit 37cfd4c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -46,6 +46,7 @@

public class SheetmetalTankLogic implements IServerTickableComponent<State>, MBOverlayText<State>
{
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);

Expand Down Expand Up @@ -107,12 +108,7 @@ public List<Component> getOverlayText(State state, Player player, boolean hammer
@Override
public Function<BlockPos, VoxelShape> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,6 +39,7 @@

public class SiloLogic implements IMultiblockLogic<State>, IServerTickableComponent<State>
{
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<BlockPos> IO_OFFSETS = Set.of(OUTPUT_POS, new BlockPos(1, 6, 1));
Expand Down Expand Up @@ -90,7 +91,7 @@ public void registerCapabilities(CapabilityRegistrar<State> register)
@Override
public Function<BlockPos, VoxelShape> shapeGetter(ShapeType forType)
{
return SiloShapes.SHAPE_GETTER;
return SHAPE_GETTER;
}

public static class State implements IMultiblockState
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<BlockPos, VoxelShape>
{
@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();
}
}

0 comments on commit 37cfd4c

Please sign in to comment.