finishing touches to refactor

new shapes for cannon and schematic table
viewing shapes for mixer and press now differ from regular shape to allow for levers being placed on their side

entirely removed economy package

Signed-off-by: Zelophed <zefren1@googlemail.com>
This commit is contained in:
zelophed 2019-12-10 17:45:42 +01:00 committed by Zelophed
parent 7166aeeb52
commit ac3f2ba85c
14 changed files with 74 additions and 241 deletions

View file

@ -4,6 +4,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.DirectionalBlock; import net.minecraft.block.DirectionalBlock;
import net.minecraft.block.PistonHeadBlock; import net.minecraft.block.PistonHeadBlock;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.shapes.VoxelShapes;
@ -12,7 +13,9 @@ import static net.minecraft.block.Block.makeCuboidShape;
public class AllShapes { public class AllShapes {
public static final VoxelShaper public static final VoxelShaper
SHORT_CASING = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 12, 16), Direction.UP), SHORT_CASING_14_VOXEL = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 14, 16), Direction.UP),
SHORT_CASING_12_VOXEL = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 12, 16), Direction.UP),
SHORT_CASING_11_VOXEL = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 11, 16), Direction.UP),
HARVESTER_BASE = VoxelShaper.forHorizontal(makeCuboidShape(0, 2, 0, 16, 14, 3), Direction.SOUTH), HARVESTER_BASE = VoxelShaper.forHorizontal(makeCuboidShape(0, 2, 0, 16, 14, 3), Direction.SOUTH),
MOTOR_BLOCK = VoxelShaper.forHorizontal(makeCuboidShape(0, 3, 3, 16, 13, 13), Direction.EAST), MOTOR_BLOCK = VoxelShaper.forHorizontal(makeCuboidShape(0, 3, 3, 16, 13, 13), Direction.EAST),
FOUR_VOXEL_POLE = VoxelShaper.forDirectionalAxis(makeCuboidShape(6, 0, 6, 10, 16, 10), Direction.Axis.Y), FOUR_VOXEL_POLE = VoxelShaper.forDirectionalAxis(makeCuboidShape(6, 0, 6, 10, 16, 10), Direction.Axis.Y),
@ -37,7 +40,7 @@ public class AllShapes {
makeCuboidShape(-2, 0, 1, 18, 13, 15)), makeCuboidShape(-2, 0, 1, 18, 13, 15)),
MECHANICAL_PISTON_HEAD_SHAPE_UP = Blocks.PISTON_HEAD.getShape(Blocks.PISTON_HEAD.getStateContainer().getBaseState().with(DirectionalBlock.FACING, Direction.UP).with(PistonHeadBlock.SHORT, true), null, null, null), MECHANICAL_PISTON_HEAD_SHAPE_UP = Blocks.PISTON_HEAD.getShape(Blocks.PISTON_HEAD.getStateContainer().getBaseState().with(DirectionalBlock.FACING, Direction.UP).with(PistonHeadBlock.SHORT, true), null, null, null),
MECHANICAL_PISTON_EXTENDED_SHAPE_UP = VoxelShapes.or( MECHANICAL_PISTON_EXTENDED_SHAPE_UP = VoxelShapes.or(
SHORT_CASING.get(Direction.UP), SHORT_CASING_12_VOXEL.get(Direction.UP),
FOUR_VOXEL_POLE.get(Direction.Axis.Y)), FOUR_VOXEL_POLE.get(Direction.Axis.Y)),
SMALL_GEAR_SHAPE = makeCuboidShape(2, 6, 2, 14, 10, 14), SMALL_GEAR_SHAPE = makeCuboidShape(2, 6, 2, 14, 10, 14),
LARGE_GEAR_SHAPE = makeCuboidShape(0, 6, 0, 16, 10, 16), LARGE_GEAR_SHAPE = makeCuboidShape(0, 6, 0, 16, 10, 16),
@ -50,7 +53,11 @@ public class AllShapes {
LOGISTICS_TABLE_SLOPE_SOUTH = VoxelShapes.or( LOGISTICS_TABLE_SLOPE_SOUTH = VoxelShapes.or(
makeCuboidShape(0, 10D, 15, 16, 14, 10.667), makeCuboidShape(0, 10D, 15, 16, 14, 10.667),
makeCuboidShape(0, 12, 10.667, 16, 16, 6.333), makeCuboidShape(0, 12, 10.667, 16, 16, 6.333),
makeCuboidShape(0, 14, 6.333, 16, 18, 2)) makeCuboidShape(0, 14, 6.333, 16, 18, 2)),
SCHEMATICS_TABLE_SLOPE_SOUTH = VoxelShapes.or(
makeCuboidShape(0, 10, 16, 16, 14, 11),
makeCuboidShape(0, 12, 11, 16, 16, 6),
makeCuboidShape(0, 14, 6, 16, 18, 1))
; ;
@ -59,14 +66,21 @@ public class AllShapes {
makeCuboidShape(0, 0, 0, 16, 2, 16), makeCuboidShape(0, 0, 0, 16, 2, 16),
makeCuboidShape(1, 1, 1, 15, 15, 15), makeCuboidShape(1, 1, 1, 15, 15, 15),
makeCuboidShape(0, 14, 0, 16, 16, 16)), makeCuboidShape(0, 14, 0, 16, 16, 16)),
BASIN_BLOCK_SHAPE = makeCuboidShape(0, 0, 0, 16, 13, 16),//todo maybe BASIN_BLOCK_SHAPE = makeCuboidShape(0, 0, 0, 16, 13, 16),//todo can be improved when someone finds the time :D
CRUSHING_WHEEL_COLLISION_SHAPE = makeCuboidShape(0, 0, 0, 16, 22, 16), CRUSHING_WHEEL_COLLISION_SHAPE = makeCuboidShape(0, 0, 0, 16, 22, 16),
MECHANICAL_PRESS_SHAPE = VoxelShapes.fullCube(),//todo maybe MECHANICAL_PROCESSOR_SHAPE = VoxelShapes.combineAndSimplify(
VoxelShapes.fullCube(),
makeCuboidShape(4, 0, 4, 12, 16, 12),
IBooleanFunction.ONLY_FIRST),
TURNTABLE_SHAPE = VoxelShapes.or( TURNTABLE_SHAPE = VoxelShapes.or(
makeCuboidShape(1, 6, 1, 15, 8, 15), makeCuboidShape(1, 6, 1, 15, 8, 15),
makeCuboidShape(5, 0, 5, 11, 6, 11)), makeCuboidShape(5, 0, 5, 11, 6, 11)),
CRATE_BLOCK_SHAPE = makeCuboidShape(1, 0, 1, 15, 14, 15), CRATE_BLOCK_SHAPE = makeCuboidShape(1, 0, 1, 15, 14, 15),
LOGISTICS_TABLE_BASE = TABLE_POLE_SHAPE LOGISTICS_TABLE_BASE = TABLE_POLE_SHAPE,
BELT_COLLISION_MASK = makeCuboidShape(0, 0, 0, 16, 19, 16),
SCHEMATICANNON_SHAPE = VoxelShapes.or(
makeCuboidShape(1, 0, 1, 15, 8, 15),
makeCuboidShape(0.5, 8, 0.5, 15.5, 11, 15.5))
; ;
@ -78,7 +92,7 @@ public class AllShapes {
LOGISTICAL_CASING_CAP = VoxelShaper.forDirectional(LOGISTICAL_CASING_CAP_SHAPE, Direction.UP), LOGISTICAL_CASING_CAP = VoxelShaper.forDirectional(LOGISTICAL_CASING_CAP_SHAPE, Direction.UP),
CART_ASSEMBLER = VoxelShaper.forHorizontalAxis(CART_ASSEMBLER_SHAPE, Direction.SOUTH), CART_ASSEMBLER = VoxelShaper.forHorizontalAxis(CART_ASSEMBLER_SHAPE, Direction.SOUTH),
MECHANICAL_PISTON_HEAD = VoxelShaper.forDirectional(MECHANICAL_PISTON_HEAD_SHAPE_UP, Direction.UP), MECHANICAL_PISTON_HEAD = VoxelShaper.forDirectional(MECHANICAL_PISTON_HEAD_SHAPE_UP, Direction.UP),
MECHANICAL_PISTON = SHORT_CASING, MECHANICAL_PISTON = SHORT_CASING_12_VOXEL,
MECHANICAL_PISTON_EXTENDED = VoxelShaper.forDirectional(MECHANICAL_PISTON_EXTENDED_SHAPE_UP, Direction.UP), MECHANICAL_PISTON_EXTENDED = VoxelShaper.forDirectional(MECHANICAL_PISTON_EXTENDED_SHAPE_UP, Direction.UP),
SMALL_GEAR = VoxelShaper.forDirectionalAxis(VoxelShapes.or(SMALL_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), Direction.Axis.Y), SMALL_GEAR = VoxelShaper.forDirectionalAxis(VoxelShapes.or(SMALL_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), Direction.Axis.Y),
LARGE_GEAR = VoxelShaper.forDirectionalAxis(VoxelShapes.or(LARGE_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), Direction.Axis.Y), LARGE_GEAR = VoxelShaper.forDirectionalAxis(VoxelShapes.or(LARGE_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), Direction.Axis.Y),
@ -86,7 +100,8 @@ public class AllShapes {
REDSTONE_BRIDGE = VoxelShaper.forHorizontal(VERTICAL_TABLET_SHAPE_SOUTH, Direction.SOUTH).withVerticalShapes(LOGISTICAL_CONTROLLER.get(Direction.UP)), REDSTONE_BRIDGE = VoxelShaper.forHorizontal(VERTICAL_TABLET_SHAPE_SOUTH, Direction.SOUTH).withVerticalShapes(LOGISTICAL_CONTROLLER.get(Direction.UP)),
LOGISTICAL_INDEX = REDSTONE_BRIDGE, LOGISTICAL_INDEX = REDSTONE_BRIDGE,
PACKAGE_FUNNEL = VoxelShaper.forDirectional(PACKAGE_FUNNEL_SHAPE_UP, Direction.UP), PACKAGE_FUNNEL = VoxelShaper.forDirectional(PACKAGE_FUNNEL_SHAPE_UP, Direction.UP),
LOGISTICS_TABLE = VoxelShaper.forHorizontal(VoxelShapes.or(TABLE_POLE_SHAPE, LOGISTICS_TABLE_SLOPE_SOUTH), Direction.SOUTH) LOGISTICS_TABLE = VoxelShaper.forHorizontal(VoxelShapes.or(TABLE_POLE_SHAPE, LOGISTICS_TABLE_SLOPE_SOUTH), Direction.SOUTH),
SCHEMATICS_TABLE = VoxelShaper.forDirectional(VoxelShapes.or(TABLE_POLE_SHAPE, SCHEMATICS_TABLE_SLOPE_SOUTH), Direction.SOUTH)
; ;

View file

@ -35,7 +35,7 @@ public class VoxelShaper {
return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.SOUTH, Direction.EAST), new HorizontalRotationValues()); return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.SOUTH, Direction.EAST), new HorizontalRotationValues());
} }
public static VoxelShaper forRotatedPillar(VoxelShape zShape) {//dunno what this was intended for public static VoxelShaper forRotatedPillar(VoxelShape zShape) {//todo dunno what this was intended for
VoxelShaper voxelShaper = new VoxelShaper(); VoxelShaper voxelShaper = new VoxelShaper();
for (Axis axis : Axis.values()) { for (Axis axis : Axis.values()) {
Direction facing = axisAsFace(axis); Direction facing = axisAsFace(axis);
@ -71,7 +71,6 @@ public class VoxelShaper {
VoxelShaper voxelShaper = new VoxelShaper(); VoxelShaper voxelShaper = new VoxelShaper();
for (Direction dir : directions) { for (Direction dir : directions) {
voxelShaper.shapes.put(dir, rotate(shape, facing, dir, rotationValues)); voxelShaper.shapes.put(dir, rotate(shape, facing, dir, rotationValues));
//voxelShaper.shapes.put(dir, rotatedCopy(shape, rotationValues.apply(dir)));
} }
return voxelShaper; return voxelShaper;
} }

View file

@ -49,7 +49,7 @@ public class DrillBlock extends DirectionalKineticBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.SHORT_CASING.get(state.get(FACING)); return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING));
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import com.simibubi.create.modules.contraptions.base.KineticBlock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -45,7 +46,10 @@ public class MechanicalMixerBlock extends KineticBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.MECHANICAL_PRESS_SHAPE; if (context.getEntity() instanceof PlayerEntity)
return AllShapes.SHORT_CASING_14_VOXEL.get(Direction.DOWN);
return AllShapes.MECHANICAL_PROCESSOR_SHAPE;
} }
@Override @Override

View file

@ -22,6 +22,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock; import net.minecraft.block.HorizontalBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.StateContainer.Builder;
@ -44,7 +45,10 @@ public class MechanicalPressBlock extends HorizontalKineticBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.MECHANICAL_PRESS_SHAPE; if (context.getEntity() instanceof PlayerEntity)
return AllShapes.SHORT_CASING_14_VOXEL.get(Direction.DOWN);
return AllShapes.MECHANICAL_PROCESSOR_SHAPE;
} }
@Override @Override

View file

@ -82,7 +82,7 @@ public class SawBlock extends DirectionalAxisKineticBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.SHORT_CASING.get(state.get(FACING)); return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING));
} }
@Override @Override

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.IWithoutBlockItem; import com.simibubi.create.foundation.block.IWithoutBlockItem;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.modules.contraptions.relays.belt.BeltMovementHandler.TransportedEntityInfo; import com.simibubi.create.modules.contraptions.relays.belt.BeltMovementHandler.TransportedEntityInfo;
@ -55,7 +56,6 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
public static final IProperty<Slope> SLOPE = EnumProperty.create("slope", Slope.class); public static final IProperty<Slope> SLOPE = EnumProperty.create("slope", Slope.class);
public static final IProperty<Part> PART = EnumProperty.create("part", Part.class); public static final IProperty<Part> PART = EnumProperty.create("part", Part.class);
public static final BooleanProperty CASING = BooleanProperty.create("casing"); public static final BooleanProperty CASING = BooleanProperty.create("casing");
private final VoxelShape collisionMask = makeCuboidShape(0, 0, 0, 16, 19, 16);//todo review
public BeltBlock() { public BeltBlock() {
super(Properties.from(Blocks.BROWN_WOOL)); super(Properties.from(Blocks.BROWN_WOOL));
@ -288,7 +288,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
if (controller == null) if (controller == null)
return shape; return shape;
if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) { if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) {
return VoxelShapes.combine(collisionMask, shape, IBooleanFunction.AND); return VoxelShapes.combine(AllShapes.BELT_COLLISION_MASK, shape, IBooleanFunction.AND);
} }
return shape; return shape;

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.relays.belt;
import static net.minecraft.block.Block.makeCuboidShape; import static net.minecraft.block.Block.makeCuboidShape;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.VoxelShaper; import com.simibubi.create.foundation.utility.VoxelShaper;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
@ -94,6 +95,8 @@ public class BeltShapes {
SLOPE_ASC_END = VoxelShaper.forHorizontal(compose(FLAT_END_PART, SLOPE_ASC_PART), Direction.SOUTH), SLOPE_ASC_END = VoxelShaper.forHorizontal(compose(FLAT_END_PART, SLOPE_ASC_PART), Direction.SOUTH),
SLOPE_ASC_START = VoxelShaper.forHorizontal(compose(SLOPE_ASC_PART, FLAT_END_PART), Direction.SOUTH); SLOPE_ASC_START = VoxelShaper.forHorizontal(compose(SLOPE_ASC_PART, FLAT_END_PART), Direction.SOUTH);
private static final VoxelShaper
PARTIAL_CASING = VoxelShaper.forHorizontal(makeCuboidShape(0, 0, 5, 16, 11, 16), Direction.SOUTH);
private static VoxelShape compose(VoxelShape southPart, VoxelShape northPart){ private static VoxelShape compose(VoxelShape southPart, VoxelShape northPart){
@ -130,10 +133,6 @@ public class BeltShapes {
return makeCuboidShape(1,3,0,15,13,16); return makeCuboidShape(1,3,0,15,13,16);
} }
private static final VoxelShape CASING_HORIZONTAL = makeCuboidShape(0, 0, 0, 16, 11, 16);
//todo still need to remove these two
private static final VoxelShaper CASING_TOP_END = VoxelShaper.forHorizontal(makeCuboidShape(0, 0, 0, 16, 11, 11), Direction.SOUTH);
public static VoxelShape getShape(BlockState state) { public static VoxelShape getShape(BlockState state) {
Direction facing = state.get(BeltBlock.HORIZONTAL_FACING); Direction facing = state.get(BeltBlock.HORIZONTAL_FACING);
Axis axis = facing.getAxis(); Axis axis = facing.getAxis();
@ -170,7 +169,7 @@ public class BeltShapes {
} }
public static VoxelShape getCasingShape(BlockState state) {//todo public static VoxelShape getCasingShape(BlockState state) {
if (!state.get(BeltBlock.CASING)) if (!state.get(BeltBlock.CASING))
return VoxelShapes.empty(); return VoxelShapes.empty();
@ -178,25 +177,23 @@ public class BeltShapes {
Part part = state.get(BeltBlock.PART); Part part = state.get(BeltBlock.PART);
Slope slope = state.get(BeltBlock.SLOPE); Slope slope = state.get(BeltBlock.SLOPE);
if (slope == Slope.HORIZONTAL)
return CASING_HORIZONTAL;
if (slope == Slope.VERTICAL) if (slope == Slope.VERTICAL)
return VoxelShapes.empty(); return VoxelShapes.empty();
if (part != Part.MIDDLE) { if (slope == Slope.HORIZONTAL) {
boolean upward = slope == Slope.UPWARD; return AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP);
if (part == Part.START)
upward = !upward;
else
facing = facing.getOpposite();
return upward ? CASING_TOP_END.get(facing) : CASING_HORIZONTAL;
} }
if (slope == Slope.DOWNWARD) if (part == Part.MIDDLE || part == Part.PULLEY)
facing = facing.getOpposite(); return PARTIAL_CASING.get(slope == Slope.UPWARD ? facing : facing.getOpposite());
return CASING_TOP_END.get(facing.getOpposite()); if (part == Part.START)
return slope == Slope.UPWARD ? AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP) : PARTIAL_CASING.get(facing.getOpposite());
if (part == Part.END)
return slope == Slope.DOWNWARD ? AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP) : PARTIAL_CASING.get(facing);
//something went wrong
return VoxelShapes.fullCube();
} }
private static class VerticalBeltShaper extends VoxelShaper { private static class VerticalBeltShaper extends VoxelShaper {

View file

@ -1,101 +0,0 @@
package com.simibubi.create.modules.economy;
import com.simibubi.create.foundation.block.IWithoutBlockItem;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
public class ShopShelfBlock extends HorizontalBlock implements IWithoutBlockItem {
public static final VoxelShape TOP_SHAPE = makeCuboidShape(0, 14, 0, 16, 16, 16);//todo review
public static final VoxelShape BODY_SOUTH_SHAPE = makeCuboidShape(0, 0, 0, 16, 14, 14);
public static final VoxelShape BODY_NORTH_SHAPE = makeCuboidShape(0, 0, 2, 16, 14, 16);
public static final VoxelShape BODY_EAST_SHAPE = makeCuboidShape(0, 0, 0, 14, 14, 16);
public static final VoxelShape BODY_WEST_SHAPE = makeCuboidShape(2, 0, 0, 16, 14, 16);
public ShopShelfBlock() {
super(Properties.from(Blocks.SPRUCE_PLANKS));
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new ShopShelfTileEntity();
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
ShopShelfTileEntity te = (ShopShelfTileEntity) worldIn.getTileEntity(pos);
te.setOwner(placer.getUniqueID());
worldIn.notifyBlockUpdate(pos, state, state, 2);
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
BlockRayTraceResult hit) {
ShopShelfTileEntity te = (ShopShelfTileEntity) worldIn.getTileEntity(pos);
if (te == null)
return false;
if (!worldIn.isRemote)
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
return true;
}
@Override
protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(HORIZONTAL_FACING);
super.fillStateContainer(builder);
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
VoxelShape body = VoxelShapes.empty();
switch (state.get(HORIZONTAL_FACING)) {
case EAST:
body = BODY_EAST_SHAPE;
break;
case NORTH:
body = BODY_NORTH_SHAPE;
break;
case SOUTH:
body = BODY_SOUTH_SHAPE;
break;
case WEST:
body = BODY_WEST_SHAPE;
break;
default:
break;
}
return VoxelShapes.or(TOP_SHAPE, body);
}
}

View file

@ -1,25 +0,0 @@
package com.simibubi.create.modules.economy;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.network.PacketBuffer;
public class ShopShelfContainer extends Container {
public ShopShelfContainer(int id, PlayerInventory inv, ShopShelfTileEntity te) {
// super(AllContainers.SHOP_SHELF.type, id);
super(null, id);
}
public ShopShelfContainer(int id, PlayerInventory inv, PacketBuffer extraData) {
// super(AllContainers.SHOP_SHELF.type, id);
super(null, id);
}
@Override
public boolean canInteractWith(PlayerEntity playerIn) {
return true;
}
}

View file

@ -1,19 +0,0 @@
package com.simibubi.create.modules.economy;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
public class ShopShelfScreen extends AbstractSimiContainerScreen<ShopShelfContainer> {
public ShopShelfScreen(ShopShelfContainer container, PlayerInventory inv, ITextComponent title) {
super(container, inv, title);
}
@Override
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
renderTooltip("Hi", mouseX, mouseY);
}
}

View file

@ -1,62 +0,0 @@
package com.simibubi.create.modules.economy;
import java.util.UUID;
import com.simibubi.create.foundation.block.SyncedTileEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
public class ShopShelfTileEntity extends SyncedTileEntity implements INamedContainerProvider {
private UUID owner;
public ShopShelfTileEntity() {
super(null);
// super(AllTileEntities.SHOP_SHELF.type);
}
@Override
public void read(CompoundNBT compound) {
if (compound.contains("Owner"))
setOwner(NBTUtil.readUniqueId(compound.getCompound("Owner")));
super.read(compound);
}
@Override
public CompoundNBT write(CompoundNBT compound) {
if (getOwner() != null)
compound.put("Owner", NBTUtil.writeUniqueId(getOwner()));
return super.write(compound);
}
public UUID getOwner() {
return owner;
}
public void setOwner(UUID owner) {
this.owner = owner;
}
public void sendToContainer(PacketBuffer buffer) {
buffer.writeUniqueId(getOwner());
}
@Override
public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
return new ShopShelfContainer(id, inventory, this);
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent(getType().getRegistryName().toString());
}
}

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.schematics.block; package com.simibubi.create.modules.schematics.block;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -13,6 +14,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
@ -39,6 +42,16 @@ public class SchematicTableBlock extends HorizontalBlock {
return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
} }
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.LOGISTICS_TABLE_BASE;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.SCHEMATICS_TABLE.get(state.get(HORIZONTAL_FACING));
}
@Override @Override
public boolean hasTileEntity(BlockState state) { public boolean hasTileEntity(BlockState state) {
return true; return true;

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.schematics.block;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -14,6 +15,8 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
@ -48,6 +51,11 @@ public class SchematicannonBlock extends Block {
return false; return false;
} }
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.SCHEMATICANNON_SHAPE;
}
@Override @Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
((SchematicannonTileEntity) world.getTileEntity(pos)).findInventories(); ((SchematicannonTileEntity) world.getTileEntity(pos)).findInventories();