SimpleMultipart/src/test/java/net/shadowfacts/simplemultipart/test/TestMultipart.java

66 lines
2.0 KiB
Java
Raw Normal View History

2018-12-24 16:29:06 +00:00
package net.shadowfacts.simplemultipart.test;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.StateFactory;
2018-12-24 22:16:38 +00:00
import net.minecraft.state.property.Properties;
2018-12-24 16:29:06 +00:00
import net.minecraft.util.Hand;
2018-12-24 22:16:38 +00:00
import net.minecraft.util.math.Direction;
2018-12-24 16:29:06 +00:00
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.shadowfacts.simplemultipart.multipart.Multipart;
import net.shadowfacts.simplemultipart.multipart.MultipartState;
2018-12-24 22:16:38 +00:00
import net.shadowfacts.simplemultipart.util.MultipartPlacementContext;
2018-12-25 15:20:44 +00:00
import net.shadowfacts.simplemultipart.api.MultipartView;
2018-12-24 16:29:06 +00:00
/**
* @author shadowfacts
*/
public class TestMultipart extends Multipart {
public TestMultipart() {
2018-12-24 22:16:38 +00:00
setDefaultState(getDefaultState().with(Properties.FACING, Direction.DOWN));
2018-12-24 16:29:06 +00:00
}
@Override
protected void appendProperties(StateFactory.Builder<Multipart, MultipartState> builder) {
super.appendProperties(builder);
2018-12-24 22:16:38 +00:00
builder.with(Properties.FACING);
2018-12-24 16:29:06 +00:00
}
@Override
2018-12-24 22:16:38 +00:00
public MultipartState getPlacementState(MultipartPlacementContext context) {
Direction hitSide = context.getFacing();
return getDefaultState().with(Properties.FACING, hitSide.getOpposite());
2018-12-24 16:29:06 +00:00
}
@Override
@Deprecated
2018-12-25 15:20:44 +00:00
public VoxelShape getBoundingShape(MultipartState state, MultipartView view) {
2018-12-24 22:16:38 +00:00
Direction side = state.get(Properties.FACING);
switch (side) {
case UP:
2018-12-24 16:29:06 +00:00
return VoxelShapes.cube(0, 15/16f, 0, 1, 1, 1);
2018-12-24 22:16:38 +00:00
case DOWN:
2018-12-24 16:29:06 +00:00
return VoxelShapes.cube(0, 0, 0, 1, 1/16f, 1);
case NORTH:
return VoxelShapes.cube(0, 0, 0, 1, 1, 1/16f);
case SOUTH:
return VoxelShapes.cube(0, 0, 15/16f, 1, 1, 1);
case WEST:
return VoxelShapes.cube(0, 0, 0, 1/16f, 1, 1);
case EAST:
return VoxelShapes.cube(15/16f, 0, 0, 1, 1, 1);
}
return VoxelShapes.empty();
}
@Override
@Deprecated
2018-12-25 15:20:44 +00:00
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
2018-12-24 22:16:38 +00:00
Direction side = state.get(Properties.FACING);
System.out.println("part activated on " + side);
2018-12-24 16:29:06 +00:00
return true;
}
2018-12-24 22:16:38 +00:00
2018-12-24 16:29:06 +00:00
}