mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 12:43:43 +01:00
water logging and contraptions
This commit is contained in:
parent
dc43f10451
commit
c51e2abf48
9 changed files with 1329 additions and 1174 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,16 +1,17 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
||||||
|
|
||||||
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState;
|
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.IWaterLoggable;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.EnumProperty;
|
import net.minecraft.state.EnumProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
@ -22,67 +23,91 @@ import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
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.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class MechanicalPistonHeadBlock extends ProperDirectionalBlock {
|
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole;
|
||||||
|
|
||||||
public static final EnumProperty<PistonType> TYPE = BlockStateProperties.PISTON_TYPE;
|
public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements IWaterLoggable {
|
||||||
|
|
||||||
public MechanicalPistonHeadBlock(Properties p_i48415_1_) {
|
public static final EnumProperty<PistonType> TYPE = BlockStateProperties.PISTON_TYPE;
|
||||||
super(p_i48415_1_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public MechanicalPistonHeadBlock(Properties p_i48415_1_) {
|
||||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
super(p_i48415_1_);
|
||||||
builder.add(TYPE);
|
setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false));
|
||||||
super.fillStateContainer(builder);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
return PushReaction.NORMAL;
|
builder.add(TYPE, BlockStateProperties.WATERLOGGED);
|
||||||
}
|
super.fillStateContainer(builder);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
|
public PushReaction getPushReaction(BlockState state) {
|
||||||
PlayerEntity player) {
|
return PushReaction.NORMAL;
|
||||||
return AllBlocks.PISTON_EXTENSION_POLE.asStack();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
|
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
|
||||||
Direction direction = state.get(FACING);
|
PlayerEntity player) {
|
||||||
BlockPos pistonHead = pos;
|
return AllBlocks.PISTON_EXTENSION_POLE.asStack();
|
||||||
BlockPos pistonBase = null;
|
}
|
||||||
|
|
||||||
for (int offset = 1; offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset++) {
|
@Override
|
||||||
BlockPos currentPos = pos.offset(direction.getOpposite(), offset);
|
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
BlockState block = worldIn.getBlockState(currentPos);
|
Direction direction = state.get(FACING);
|
||||||
|
BlockPos pistonHead = pos;
|
||||||
|
BlockPos pistonBase = null;
|
||||||
|
|
||||||
if (isExtensionPole(block) && direction.getAxis() == block.get(BlockStateProperties.FACING)
|
for (int offset = 1; offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset++) {
|
||||||
.getAxis())
|
BlockPos currentPos = pos.offset(direction.getOpposite(), offset);
|
||||||
continue;
|
BlockState block = worldIn.getBlockState(currentPos);
|
||||||
|
|
||||||
if (MechanicalPistonBlock.isPiston(block) && block.get(BlockStateProperties.FACING) == direction)
|
if (isExtensionPole(block) && direction.getAxis() == block.get(BlockStateProperties.FACING)
|
||||||
pistonBase = currentPos;
|
.getAxis())
|
||||||
|
continue;
|
||||||
|
|
||||||
break;
|
if (MechanicalPistonBlock.isPiston(block) && block.get(BlockStateProperties.FACING) == direction)
|
||||||
}
|
pistonBase = currentPos;
|
||||||
|
|
||||||
if (pistonHead != null && pistonBase != null) {
|
break;
|
||||||
final BlockPos basePos = pistonBase;
|
}
|
||||||
BlockPos.getAllInBox(pistonBase, pistonHead)
|
|
||||||
.filter(p -> !p.equals(pos) && !p.equals(basePos))
|
|
||||||
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
|
||||||
worldIn.setBlockState(basePos, worldIn.getBlockState(basePos)
|
|
||||||
.with(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onBlockHarvested(worldIn, pos, state, player);
|
if (pistonHead != null && pistonBase != null) {
|
||||||
}
|
final BlockPos basePos = pistonBase;
|
||||||
|
BlockPos.getAllInBox(pistonBase, pistonHead)
|
||||||
|
.filter(p -> !p.equals(pos) && !p.equals(basePos))
|
||||||
|
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
||||||
|
worldIn.setBlockState(basePos, worldIn.getBlockState(basePos)
|
||||||
|
.with(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
super.onBlockHarvested(worldIn, pos, state, player);
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
}
|
||||||
return AllShapes.MECHANICAL_PISTON_HEAD.get(state.get(FACING));
|
|
||||||
}
|
@Override
|
||||||
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
|
return AllShapes.MECHANICAL_PISTON_HEAD.get(state.get(FACING));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidState getFluidState(BlockState state) {
|
||||||
|
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState,
|
||||||
|
IWorld world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
|
if (state.get(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
|
||||||
|
return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
||||||
|
|
||||||
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole;
|
|
||||||
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPiston;
|
|
||||||
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState;
|
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.*;
|
||||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.IWaterLoggable;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -21,75 +21,98 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
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.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable {
|
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.*;
|
||||||
|
|
||||||
public PistonExtensionPoleBlock(Properties properties) {
|
public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable {
|
||||||
super(properties);
|
|
||||||
setDefaultState(getDefaultState().with(FACING, Direction.UP));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public PistonExtensionPoleBlock(Properties properties) {
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
super(properties);
|
||||||
return PushReaction.NORMAL;
|
setDefaultState(getDefaultState().with(FACING, Direction.UP).with(BlockStateProperties.WATERLOGGED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
|
public PushReaction getPushReaction(BlockState state) {
|
||||||
Axis axis = state.get(FACING)
|
return PushReaction.NORMAL;
|
||||||
.getAxis();
|
}
|
||||||
Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
|
|
||||||
BlockPos pistonHead = null;
|
|
||||||
BlockPos pistonBase = null;
|
|
||||||
|
|
||||||
for (int modifier : new int[] { 1, -1 }) {
|
@Override
|
||||||
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
|
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
modifier) {
|
Axis axis = state.get(FACING)
|
||||||
BlockPos currentPos = pos.offset(direction, offset);
|
.getAxis();
|
||||||
BlockState block = worldIn.getBlockState(currentPos);
|
Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
|
||||||
|
BlockPos pistonHead = null;
|
||||||
|
BlockPos pistonBase = null;
|
||||||
|
|
||||||
if (isExtensionPole(block) && axis == block.get(FACING)
|
for (int modifier : new int[]{1, -1}) {
|
||||||
.getAxis())
|
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
|
||||||
continue;
|
modifier) {
|
||||||
|
BlockPos currentPos = pos.offset(direction, offset);
|
||||||
|
BlockState block = worldIn.getBlockState(currentPos);
|
||||||
|
|
||||||
if (isPiston(block) && block.get(BlockStateProperties.FACING)
|
if (isExtensionPole(block) && axis == block.get(FACING)
|
||||||
.getAxis() == axis)
|
.getAxis())
|
||||||
pistonBase = currentPos;
|
continue;
|
||||||
|
|
||||||
if (isPistonHead(block) && block.get(BlockStateProperties.FACING)
|
if (isPiston(block) && block.get(BlockStateProperties.FACING)
|
||||||
.getAxis() == axis)
|
.getAxis() == axis)
|
||||||
pistonHead = currentPos;
|
pistonBase = currentPos;
|
||||||
|
|
||||||
break;
|
if (isPistonHead(block) && block.get(BlockStateProperties.FACING)
|
||||||
}
|
.getAxis() == axis)
|
||||||
}
|
pistonHead = currentPos;
|
||||||
|
|
||||||
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead)
|
break;
|
||||||
.get(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase)
|
}
|
||||||
.get(BlockStateProperties.FACING)) {
|
}
|
||||||
|
|
||||||
final BlockPos basePos = pistonBase;
|
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead)
|
||||||
BlockPos.getAllInBox(pistonBase, pistonHead)
|
.get(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase)
|
||||||
.filter(p -> !p.equals(pos) && !p.equals(basePos))
|
.get(BlockStateProperties.FACING)) {
|
||||||
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
|
||||||
worldIn.setBlockState(basePos, worldIn.getBlockState(basePos)
|
|
||||||
.with(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onBlockHarvested(worldIn, pos, state, player);
|
final BlockPos basePos = pistonBase;
|
||||||
}
|
BlockPos.getAllInBox(pistonBase, pistonHead)
|
||||||
|
.filter(p -> !p.equals(pos) && !p.equals(basePos))
|
||||||
|
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
||||||
|
worldIn.setBlockState(basePos, worldIn.getBlockState(basePos)
|
||||||
|
.with(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
super.onBlockHarvested(worldIn, pos, state, player);
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
}
|
||||||
return AllShapes.FOUR_VOXEL_POLE.get(state.get(FACING)
|
|
||||||
.getAxis());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return getDefaultState().with(FACING, context.getFace()
|
return AllShapes.FOUR_VOXEL_POLE.get(state.get(FACING)
|
||||||
.getOpposite());
|
.getAxis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
|
||||||
|
return getDefaultState().with(FACING, context.getFace().getOpposite())
|
||||||
|
.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidState getFluidState(BlockState state) {
|
||||||
|
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(BlockStateProperties.WATERLOGGED);
|
||||||
|
super.fillStateContainer(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState,
|
||||||
|
IWorld world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
|
if (state.get(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,17 @@ import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.content.contraptions.base.HorizontalAxisKineticBlock;
|
import com.simibubi.create.content.contraptions.base.HorizontalAxisKineticBlock;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
import com.simibubi.create.foundation.block.ITE;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.IWaterLoggable;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.EnumProperty;
|
import net.minecraft.state.EnumProperty;
|
||||||
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
|
@ -24,128 +28,156 @@ import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
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.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<PulleyTileEntity> {
|
public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<PulleyTileEntity> {
|
||||||
|
|
||||||
public static EnumProperty<Axis> HORIZONTAL_AXIS = BlockStateProperties.HORIZONTAL_AXIS;
|
public static EnumProperty<Axis> HORIZONTAL_AXIS = BlockStateProperties.HORIZONTAL_AXIS;
|
||||||
|
|
||||||
public PulleyBlock(Properties properties) {
|
public PulleyBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static void onRopeBroken(World world, BlockPos pulleyPos) {
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
TileEntity te = world.getTileEntity(pulleyPos);
|
||||||
return AllTileEntities.ROPE_PULLEY.create();
|
if (!(te instanceof PulleyTileEntity))
|
||||||
}
|
return;
|
||||||
|
PulleyTileEntity pulley = (PulleyTileEntity) te;
|
||||||
|
pulley.offset = 0;
|
||||||
|
pulley.sendData();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
if (state.getBlock() != newState.getBlock()) {
|
return AllTileEntities.ROPE_PULLEY.create();
|
||||||
if (!worldIn.isRemote) {
|
}
|
||||||
BlockState below = worldIn.getBlockState(pos.down());
|
|
||||||
if (below.getBlock() instanceof RopeBlockBase)
|
|
||||||
worldIn.destroyBlock(pos.down(), true);
|
|
||||||
}
|
|
||||||
if (state.hasTileEntity())
|
|
||||||
worldIn.removeTileEntity(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
@Override
|
||||||
BlockRayTraceResult hit) {
|
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (!player.isAllowEdit())
|
if (state.getBlock() != newState.getBlock()) {
|
||||||
return ActionResultType.PASS;
|
if (!worldIn.isRemote) {
|
||||||
if (player.isSneaking())
|
BlockState below = worldIn.getBlockState(pos.down());
|
||||||
return ActionResultType.PASS;
|
if (below.getBlock() instanceof RopeBlockBase)
|
||||||
if (player.getHeldItem(handIn)
|
worldIn.destroyBlock(pos.down(), true);
|
||||||
.isEmpty()) {
|
}
|
||||||
withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true);
|
if (state.hasTileEntity())
|
||||||
return ActionResultType.SUCCESS;
|
worldIn.removeTileEntity(pos);
|
||||||
}
|
}
|
||||||
return ActionResultType.PASS;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
BlockRayTraceResult hit) {
|
||||||
return AllShapes.PULLEY.get(state.get(HORIZONTAL_AXIS));
|
if (!player.isAllowEdit())
|
||||||
}
|
return ActionResultType.PASS;
|
||||||
|
if (player.isSneaking())
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
if (player.getHeldItem(handIn)
|
||||||
|
.isEmpty()) {
|
||||||
|
withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true);
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
}
|
||||||
|
|
||||||
private static void onRopeBroken(World world, BlockPos pulleyPos) {
|
@Override
|
||||||
TileEntity te = world.getTileEntity(pulleyPos);
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
if (!(te instanceof PulleyTileEntity))
|
return AllShapes.PULLEY.get(state.get(HORIZONTAL_AXIS));
|
||||||
return;
|
}
|
||||||
PulleyTileEntity pulley = (PulleyTileEntity) te;
|
|
||||||
pulley.offset = 0;
|
|
||||||
pulley.sendData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RopeBlockBase extends Block {
|
@Override
|
||||||
|
public Class<PulleyTileEntity> getTileEntityClass() {
|
||||||
|
return PulleyTileEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
public RopeBlockBase(Properties properties) {
|
private static class RopeBlockBase extends Block implements IWaterLoggable {
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public RopeBlockBase(Properties properties) {
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
super(properties);
|
||||||
return PushReaction.BLOCK;
|
setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
|
public PushReaction getPushReaction(BlockState state) {
|
||||||
PlayerEntity player) {
|
return PushReaction.BLOCK;
|
||||||
return AllBlocks.ROPE_PULLEY.asStack();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
|
||||||
if (!isMoving) {
|
PlayerEntity player) {
|
||||||
onRopeBroken(worldIn, pos.up());
|
return AllBlocks.ROPE_PULLEY.asStack();
|
||||||
if (!worldIn.isRemote) {
|
}
|
||||||
BlockState above = worldIn.getBlockState(pos.up());
|
|
||||||
BlockState below = worldIn.getBlockState(pos.down());
|
|
||||||
if (above.getBlock() instanceof RopeBlockBase)
|
|
||||||
worldIn.destroyBlock(pos.up(), true);
|
|
||||||
if (below.getBlock() instanceof RopeBlockBase)
|
|
||||||
worldIn.destroyBlock(pos.down(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
|
||||||
worldIn.removeTileEntity(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
|
if (!isMoving && (!state.has(BlockStateProperties.WATERLOGGED) || !newState.has(BlockStateProperties.WATERLOGGED) || state.get(BlockStateProperties.WATERLOGGED) == newState.get(BlockStateProperties.WATERLOGGED))) {
|
||||||
|
onRopeBroken(worldIn, pos.up());
|
||||||
|
if (!worldIn.isRemote) {
|
||||||
|
BlockState above = worldIn.getBlockState(pos.up());
|
||||||
|
BlockState below = worldIn.getBlockState(pos.down());
|
||||||
|
if (above.getBlock() instanceof RopeBlockBase)
|
||||||
|
worldIn.destroyBlock(pos.up(), true);
|
||||||
|
if (below.getBlock() instanceof RopeBlockBase)
|
||||||
|
worldIn.destroyBlock(pos.down(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||||
|
worldIn.removeTileEntity(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MagnetBlock extends RopeBlockBase {
|
|
||||||
|
|
||||||
public MagnetBlock(Properties properties) {
|
@Override
|
||||||
super(properties);
|
public IFluidState getFluidState(BlockState state) {
|
||||||
}
|
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
return AllShapes.PULLEY_MAGNET;
|
builder.add(BlockStateProperties.WATERLOGGED);
|
||||||
}
|
super.fillStateContainer(builder);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState,
|
||||||
|
IWorld world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
|
if (state.get(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
public static class RopeBlock extends RopeBlockBase {
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
|
||||||
|
return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
}
|
||||||
|
|
||||||
public RopeBlock(Properties properties) {
|
}
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public static class MagnetBlock extends RopeBlockBase {
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
|
||||||
return AllShapes.FOUR_VOXEL_POLE.get(Direction.UP);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
public MagnetBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<PulleyTileEntity> getTileEntityClass() {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return PulleyTileEntity.class;
|
return AllShapes.PULLEY_MAGNET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RopeBlock extends RopeBlockBase {
|
||||||
|
|
||||||
|
public RopeBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
|
return AllShapes.FOUR_VOXEL_POLE.get(Direction.UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,13 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pis
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
|
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform;
|
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.IWaterLoggable;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
@ -19,170 +23,180 @@ import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class PulleyTileEntity extends LinearActuatorTileEntity {
|
public class PulleyTileEntity extends LinearActuatorTileEntity {
|
||||||
|
|
||||||
protected int initialOffset;
|
protected int initialOffset;
|
||||||
|
|
||||||
public PulleyTileEntity(TileEntityType<? extends PulleyTileEntity> type) {
|
public PulleyTileEntity(TileEntityType<? extends PulleyTileEntity> type) {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
return super.getRenderBoundingBox().expand(0, -offset, 0);
|
return super.getRenderBoundingBox().expand(0, -offset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
return super.getMaxRenderDistanceSquared() + offset * offset;
|
return super.getMaxRenderDistanceSquared() + offset * offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assemble() {
|
protected void assemble() {
|
||||||
if (!(world.getBlockState(pos)
|
if (!(world.getBlockState(pos)
|
||||||
.getBlock() instanceof PulleyBlock))
|
.getBlock() instanceof PulleyBlock))
|
||||||
return;
|
return;
|
||||||
if (speed == 0)
|
if (speed == 0)
|
||||||
return;
|
return;
|
||||||
if (offset >= getExtensionRange() && getSpeed() > 0)
|
if (offset >= getExtensionRange() && getSpeed() > 0)
|
||||||
return;
|
return;
|
||||||
if (offset <= 0 && getSpeed() < 0)
|
if (offset <= 0 && getSpeed() < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Collect Construct
|
// Collect Construct
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
BlockPos anchor = pos.down((int) (offset + 1));
|
BlockPos anchor = pos.down((int) (offset + 1));
|
||||||
initialOffset = (int) (offset);
|
initialOffset = (int) (offset);
|
||||||
PulleyContraption contraption = PulleyContraption.assemblePulleyAt(world, anchor, (int) offset);
|
PulleyContraption contraption = PulleyContraption.assemblePulleyAt(world, anchor, (int) offset);
|
||||||
|
|
||||||
if (contraption != null) {
|
if (contraption != null) {
|
||||||
Direction movementDirection = getSpeed() > 0 ? Direction.DOWN : Direction.UP;
|
Direction movementDirection = getSpeed() > 0 ? Direction.DOWN : Direction.UP;
|
||||||
if (ContraptionCollider.isCollidingWithWorld(world, contraption, anchor.offset(movementDirection),
|
if (ContraptionCollider.isCollidingWithWorld(world, contraption, anchor.offset(movementDirection),
|
||||||
movementDirection))
|
movementDirection))
|
||||||
contraption = null;
|
contraption = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contraption == null && getSpeed() > 0)
|
if (contraption == null && getSpeed() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = ((int) offset); i > 0; i--) {
|
for (int i = ((int) offset); i > 0; i--) {
|
||||||
BlockPos offset = pos.down(i);
|
BlockPos offset = pos.down(i);
|
||||||
world.setBlockState(offset, Blocks.AIR.getDefaultState(), 66);
|
BlockState oldState = world.getBlockState(offset);
|
||||||
}
|
if (oldState.getBlock() instanceof IWaterLoggable && oldState.has(BlockStateProperties.WATERLOGGED) && oldState.get(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
world.setBlockState(offset, Blocks.WATER.getDefaultState(), 66);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
world.setBlockState(offset, Blocks.AIR.getDefaultState(), 66);
|
||||||
|
}
|
||||||
|
|
||||||
if (contraption != null && !contraption.blocks.isEmpty()) {
|
if (contraption != null && !contraption.blocks.isEmpty()) {
|
||||||
contraption.removeBlocksFromWorld(world, BlockPos.ZERO);
|
contraption.removeBlocksFromWorld(world, BlockPos.ZERO);
|
||||||
movedContraption = ContraptionEntity.createStationary(world, contraption)
|
movedContraption = ContraptionEntity.createStationary(world, contraption)
|
||||||
.controlledBy(this);
|
.controlledBy(this);
|
||||||
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
|
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());
|
||||||
world.addEntity(movedContraption);
|
world.addEntity(movedContraption);
|
||||||
forceMove = true;
|
forceMove = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clientOffsetDiff = 0;
|
clientOffsetDiff = 0;
|
||||||
running = true;
|
running = true;
|
||||||
sendData();
|
sendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disassemble() {
|
public void disassemble() {
|
||||||
if (!running && movedContraption == null)
|
if (!running && movedContraption == null)
|
||||||
return;
|
return;
|
||||||
offset = getGridOffset(offset);
|
offset = getGridOffset(offset);
|
||||||
if (movedContraption != null)
|
if (movedContraption != null)
|
||||||
applyContraptionPosition();
|
applyContraptionPosition();
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
BlockPos magnetPos = pos.down((int) offset);
|
BlockPos magnetPos = pos.down((int) offset);
|
||||||
world.destroyBlock(magnetPos, world.getBlockState(magnetPos)
|
IFluidState ifluidstate = world.getFluidState(magnetPos);
|
||||||
.getCollisionShape(world, magnetPos)
|
world.destroyBlock(magnetPos, world.getBlockState(magnetPos)
|
||||||
.isEmpty());
|
.getCollisionShape(world, magnetPos)
|
||||||
world.setBlockState(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState(), 66);
|
.isEmpty());
|
||||||
}
|
world.setBlockState(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState().with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER)), 66);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 1; i <= ((int) offset) - 1; i++) {
|
boolean[] waterlog = new boolean[(int) offset];
|
||||||
BlockPos ropePos = pos.down(i);
|
|
||||||
world.destroyBlock(ropePos, world.getBlockState(ropePos)
|
|
||||||
.getCollisionShape(world, ropePos)
|
|
||||||
.isEmpty());
|
|
||||||
}
|
|
||||||
for (int i = 1; i <= ((int) offset) - 1; i++)
|
|
||||||
world.setBlockState(pos.down(i), AllBlocks.ROPE.getDefaultState(), 66);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (movedContraption != null)
|
for (int i = 1; i <= ((int) offset) - 1; i++) {
|
||||||
movedContraption.disassemble();
|
BlockPos ropePos = pos.down(i);
|
||||||
}
|
IFluidState ifluidstate = world.getFluidState(ropePos);
|
||||||
|
waterlog[i] = ifluidstate.getFluid() == Fluids.WATER;
|
||||||
|
world.destroyBlock(ropePos, world.getBlockState(ropePos)
|
||||||
|
.getCollisionShape(world, ropePos)
|
||||||
|
.isEmpty());
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= ((int) offset) - 1; i++)
|
||||||
|
world.setBlockState(pos.down(i), AllBlocks.ROPE.getDefaultState().with(BlockStateProperties.WATERLOGGED, waterlog[i]), 66);
|
||||||
|
}
|
||||||
|
|
||||||
if (movedContraption != null)
|
if (movedContraption != null)
|
||||||
movedContraption.remove();
|
movedContraption.disassemble();
|
||||||
movedContraption = null;
|
}
|
||||||
initialOffset = 0;
|
|
||||||
running = false;
|
|
||||||
sendData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (movedContraption != null)
|
||||||
protected Vec3d toPosition(float offset) {
|
movedContraption.remove();
|
||||||
if (movedContraption.getContraption() instanceof PulleyContraption) {
|
movedContraption = null;
|
||||||
PulleyContraption contraption = (PulleyContraption) movedContraption.getContraption();
|
initialOffset = 0;
|
||||||
return new Vec3d(contraption.getAnchor()).add(0, contraption.initialOffset - offset, 0);
|
running = false;
|
||||||
|
sendData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
return Vec3d.ZERO;
|
protected Vec3d toPosition(float offset) {
|
||||||
}
|
if (movedContraption.getContraption() instanceof PulleyContraption) {
|
||||||
|
PulleyContraption contraption = (PulleyContraption) movedContraption.getContraption();
|
||||||
|
return new Vec3d(contraption.getAnchor()).add(0, contraption.initialOffset - offset, 0);
|
||||||
|
|
||||||
@Override
|
}
|
||||||
protected void visitNewPosition() {
|
return Vec3d.ZERO;
|
||||||
super.visitNewPosition();
|
}
|
||||||
if (world.isRemote)
|
|
||||||
return;
|
|
||||||
if (movedContraption != null)
|
|
||||||
return;
|
|
||||||
if (getSpeed() <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockPos posBelow = pos.down((int) (offset + getMovementSpeed()) + 1);
|
@Override
|
||||||
if (!BlockMovementTraits.movementNecessary(world, posBelow))
|
protected void visitNewPosition() {
|
||||||
return;
|
super.visitNewPosition();
|
||||||
if (BlockMovementTraits.isBrittle(world.getBlockState(posBelow)))
|
if (world.isRemote)
|
||||||
return;
|
return;
|
||||||
|
if (movedContraption != null)
|
||||||
|
return;
|
||||||
|
if (getSpeed() <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
disassemble();
|
BlockPos posBelow = pos.down((int) (offset + getMovementSpeed()) + 1);
|
||||||
assembleNextTick = true;
|
if (!BlockMovementTraits.movementNecessary(world, posBelow))
|
||||||
}
|
return;
|
||||||
|
if (BlockMovementTraits.isBrittle(world.getBlockState(posBelow)))
|
||||||
|
return;
|
||||||
|
|
||||||
@Override
|
disassemble();
|
||||||
public void read(CompoundNBT tag) {
|
assembleNextTick = true;
|
||||||
initialOffset = tag.getInt("InitialOffset");
|
}
|
||||||
super.read(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT write(CompoundNBT tag) {
|
public void read(CompoundNBT tag) {
|
||||||
tag.putInt("InitialOffset", initialOffset);
|
initialOffset = tag.getInt("InitialOffset");
|
||||||
return super.write(tag);
|
super.read(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getExtensionRange() {
|
public CompoundNBT write(CompoundNBT tag) {
|
||||||
return Math.max(0, Math.min(AllConfigs.SERVER.kinetics.maxRopeLength.get(), pos.getY() - 1));
|
tag.putInt("InitialOffset", initialOffset);
|
||||||
}
|
return super.write(tag);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInitialOffset() {
|
protected int getExtensionRange() {
|
||||||
return initialOffset;
|
return Math.max(0, Math.min(AllConfigs.SERVER.kinetics.maxRopeLength.get(), pos.getY() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Vec3d toMotionVector(float speed) {
|
protected int getInitialOffset() {
|
||||||
return new Vec3d(0, -speed, 0);
|
return initialOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ValueBoxTransform getMovementModeSlot() {
|
protected Vec3d toMotionVector(float speed) {
|
||||||
return new CenteredSideValueBoxTransform((state, d) -> d == Direction.UP);
|
return new Vec3d(0, -speed, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ValueBoxTransform getMovementModeSlot() {
|
||||||
|
return new CenteredSideValueBoxTransform((state, d) -> d == Direction.UP);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable {
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN, BlockStateProperties.WATERLOGGED);
|
builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN, BlockStateProperties.WATERLOGGED);
|
||||||
|
super.fillStateContainer(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,8 +3,14 @@ package com.simibubi.create.content.contraptions.fluids;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.IWaterLoggable;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -12,45 +18,73 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
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.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
|
|
||||||
public class PumpBlock extends DirectionalKineticBlock {
|
public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable {
|
||||||
|
|
||||||
public PumpBlock(Properties p_i48415_1_) {
|
public PumpBlock(Properties p_i48415_1_) {
|
||||||
super(p_i48415_1_);
|
super(p_i48415_1_);
|
||||||
}
|
setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTileEntity(BlockState state) {
|
public boolean hasTileEntity(BlockState state) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return AllTileEntities.MECHANICAL_PUMP.create();
|
return AllTileEntities.MECHANICAL_PUMP.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) {
|
public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) {
|
||||||
return originalState.with(FACING, originalState.get(FACING)
|
return originalState.with(FACING, originalState.get(FACING)
|
||||||
.getOpposite());
|
.getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Axis getRotationAxis(BlockState state) {
|
public Axis getRotationAxis(BlockState state) {
|
||||||
return state.get(FACING)
|
return state.get(FACING)
|
||||||
.getAxis();
|
.getAxis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_,
|
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_,
|
||||||
ISelectionContext p_220053_4_) {
|
ISelectionContext p_220053_4_) {
|
||||||
return AllShapes.PUMP.get(state.get(FACING));
|
return AllShapes.PUMP.get(state.get(FACING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasIntegratedCogwheel(IWorldReader world, BlockPos pos, BlockState state) {
|
public boolean hasIntegratedCogwheel(IWorldReader world, BlockPos pos, BlockState state) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidState getFluidState(BlockState state) {
|
||||||
|
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(BlockStateProperties.WATERLOGGED);
|
||||||
|
super.fillStateContainer(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState,
|
||||||
|
IWorld world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
|
if (state.get(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
|
||||||
|
return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@ import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||||
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock;
|
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
@ -22,95 +24,96 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CogWheelBlock extends ShaftBlock {
|
public class CogWheelBlock extends ShaftBlock {
|
||||||
|
|
||||||
boolean isLarge;
|
boolean isLarge;
|
||||||
|
|
||||||
public static CogWheelBlock small(Properties properties) {
|
private CogWheelBlock(boolean large, Properties properties) {
|
||||||
return new CogWheelBlock(false, properties);
|
super(properties);
|
||||||
}
|
isLarge = large;
|
||||||
|
}
|
||||||
|
|
||||||
public static CogWheelBlock large(Properties properties) {
|
public static CogWheelBlock small(Properties properties) {
|
||||||
return new CogWheelBlock(true, properties);
|
return new CogWheelBlock(false, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CogWheelBlock(boolean large, Properties properties) {
|
public static CogWheelBlock large(Properties properties) {
|
||||||
super(properties);
|
return new CogWheelBlock(true, properties);
|
||||||
isLarge = large;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public static boolean isSmallCog(BlockState state) {
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
return AllBlocks.COGWHEEL.has(state);
|
||||||
return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.get(AXIS));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public static boolean isLargeCog(BlockState state) {
|
||||||
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
return AllBlocks.LARGE_COGWHEEL.has(state);
|
||||||
for (Direction facing : Direction.values()) {
|
}
|
||||||
if (facing.getAxis() == state.get(AXIS))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BlockState blockState = worldIn.getBlockState(pos.offset(facing));
|
@Override
|
||||||
if (isLargeCog(blockState) || isLarge && isSmallCog(blockState))
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return false;
|
return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.get(AXIS));
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
||||||
BlockPos placedOnPos = context.getPos()
|
for (Direction facing : Direction.values()) {
|
||||||
.offset(context.getFace()
|
if (facing.getAxis() == state.get(AXIS))
|
||||||
.getOpposite());
|
continue;
|
||||||
World world = context.getWorld();
|
|
||||||
BlockState placedAgainst = world.getBlockState(placedOnPos);
|
|
||||||
Block block = placedAgainst.getBlock();
|
|
||||||
|
|
||||||
BlockState stateBelow = world.getBlockState(context.getPos()
|
BlockState blockState = worldIn.getBlockState(pos.offset(facing));
|
||||||
.down());
|
if (isLargeCog(blockState) || isLarge && isSmallCog(blockState))
|
||||||
if (AllBlocks.ROTATION_SPEED_CONTROLLER.has(stateBelow) && isLarge) {
|
return false;
|
||||||
return this.getDefaultState()
|
}
|
||||||
.with(AXIS, stateBelow.get(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(block instanceof IRotate)
|
@Override
|
||||||
|| !(((IRotate) block).hasIntegratedCogwheel(world, placedOnPos, placedAgainst))) {
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
Axis preferredAxis = getPreferredAxis(context);
|
BlockPos placedOnPos = context.getPos()
|
||||||
if (preferredAxis != null)
|
.offset(context.getFace()
|
||||||
return this.getDefaultState()
|
.getOpposite());
|
||||||
.with(AXIS, preferredAxis);
|
World world = context.getWorld();
|
||||||
return this.getDefaultState()
|
BlockState placedAgainst = world.getBlockState(placedOnPos);
|
||||||
.with(AXIS, context.getFace()
|
Block block = placedAgainst.getBlock();
|
||||||
.getAxis());
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDefaultState().with(AXIS, ((IRotate) block).getRotationAxis(placedAgainst));
|
BlockState stateBelow = world.getBlockState(context.getPos()
|
||||||
}
|
.down());
|
||||||
|
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
|
||||||
|
if (AllBlocks.ROTATION_SPEED_CONTROLLER.has(stateBelow) && isLarge) {
|
||||||
|
return this.getDefaultState().with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER))
|
||||||
|
.with(AXIS, stateBelow.get(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
if (!(block instanceof IRotate)
|
||||||
public float getParticleTargetRadius() {
|
|| !(((IRotate) block).hasIntegratedCogwheel(world, placedOnPos, placedAgainst))) {
|
||||||
return isLarge ? 1.125f : .65f;
|
Axis preferredAxis = getPreferredAxis(context);
|
||||||
}
|
if (preferredAxis != null)
|
||||||
|
return this.getDefaultState()
|
||||||
|
.with(AXIS, preferredAxis).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
return this.getDefaultState()
|
||||||
|
.with(AXIS, context.getFace()
|
||||||
|
.getAxis()).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
return getDefaultState().with(AXIS, ((IRotate) block).getRotationAxis(placedAgainst));
|
||||||
public float getParticleInitialRadius() {
|
}
|
||||||
return isLarge ? 1f : .75f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSmallCog(BlockState state) {
|
@Override
|
||||||
return AllBlocks.COGWHEEL.has(state);
|
public float getParticleTargetRadius() {
|
||||||
}
|
return isLarge ? 1.125f : .65f;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLargeCog(BlockState state) {
|
@Override
|
||||||
return AllBlocks.LARGE_COGWHEEL.has(state);
|
public float getParticleInitialRadius() {
|
||||||
}
|
return isLarge ? 1f : .75f;
|
||||||
|
}
|
||||||
|
|
||||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
items.add(new ItemStack(this));
|
items.add(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// IRotate
|
// IRotate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasIntegratedCogwheel(IWorldReader world, BlockPos pos, BlockState state) {
|
public boolean hasIntegratedCogwheel(IWorldReader world, BlockPos pos, BlockState state) {
|
||||||
return !isLarge;
|
return !isLarge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,18 @@ import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
|
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.IWaterLoggable;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -18,63 +24,90 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
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.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
|
|
||||||
public class ShaftBlock extends RotatedPillarKineticBlock {
|
public class ShaftBlock extends RotatedPillarKineticBlock implements IWaterLoggable {
|
||||||
|
|
||||||
public ShaftBlock(Properties properties) {
|
public ShaftBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public static boolean isShaft(BlockState state) {
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
return AllBlocks.SHAFT.has(state);
|
||||||
return PushReaction.NORMAL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockRenderType getRenderType(BlockState state) {
|
public PushReaction getPushReaction(BlockState state) {
|
||||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
return PushReaction.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public BlockRenderType getRenderType(BlockState state) {
|
||||||
return AllTileEntities.SIMPLE_KINETIC.create();
|
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return AllShapes.SIX_VOXEL_POLE.get(state.get(AXIS));
|
return AllTileEntities.SIMPLE_KINETIC.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getParticleTargetRadius() {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return .25f;
|
return AllShapes.SIX_VOXEL_POLE.get(state.get(AXIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getParticleInitialRadius() {
|
public float getParticleTargetRadius() {
|
||||||
return 0f;
|
return .25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
public float getParticleInitialRadius() {
|
||||||
super.fillItemGroup(group, items);
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShaft(BlockState state) {
|
@Override
|
||||||
return AllBlocks.SHAFT.has(state);
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
}
|
super.fillItemGroup(group, items);
|
||||||
|
}
|
||||||
|
|
||||||
// IRotate:
|
// IRotate:
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
|
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
|
||||||
return face.getAxis() == state.get(AXIS);
|
return face.getAxis() == state.get(AXIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Axis getRotationAxis(BlockState state) {
|
public Axis getRotationAxis(BlockState state) {
|
||||||
return state.get(AXIS);
|
return state.get(AXIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidState getFluidState(BlockState state) {
|
||||||
|
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(BlockStateProperties.WATERLOGGED);
|
||||||
|
super.fillStateContainer(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState,
|
||||||
|
IWorld world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
|
if (state.get(BlockStateProperties.WATERLOGGED)) {
|
||||||
|
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
IFluidState ifluidstate = context.getWorld().getFluidState(context.getPos());
|
||||||
|
return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue