i should probably pull and merge the old updates before merging twice.... oops

This commit is contained in:
grimmauld 2020-12-05 12:58:35 +01:00
commit dfdba40c45
4 changed files with 122 additions and 110 deletions

View file

@ -207,8 +207,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "true", "axis": "x",
"axis": "x" "sticky_east": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -217,8 +217,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "true", "axis": "y",
"axis": "y" "sticky_east": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky", "model": "create:block/radial_chassis_side_y_sticky",
@ -227,8 +227,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "true", "axis": "z",
"axis": "z" "sticky_east": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_z_sticky" "model": "create:block/radial_chassis_side_z_sticky"
@ -236,8 +236,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "false", "axis": "x",
"axis": "x" "sticky_east": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",
@ -246,8 +246,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "false", "axis": "y",
"axis": "y" "sticky_east": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y", "model": "create:block/radial_chassis_side_y",
@ -256,8 +256,8 @@
}, },
{ {
"when": { "when": {
"sticky_east": "false", "axis": "z",
"axis": "z" "sticky_east": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_z" "model": "create:block/radial_chassis_side_z"

View file

@ -36,119 +36,129 @@ import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable { public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable {
public PistonExtensionPoleBlock(Properties properties) { public PistonExtensionPoleBlock(Properties properties) {
super(properties); super(properties);
setDefaultState(getDefaultState().with(FACING, Direction.UP).with(BlockStateProperties.WATERLOGGED, false)); setDefaultState(getDefaultState().with(FACING, Direction.UP)
} .with(BlockStateProperties.WATERLOGGED, false));
}
@Override @Override
public PushReaction getPushReaction(BlockState state) { public PushReaction getPushReaction(BlockState state) {
return PushReaction.NORMAL; return PushReaction.NORMAL;
} }
@Override @Override
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
Axis axis = state.get(FACING) Axis axis = state.get(FACING)
.getAxis(); .getAxis();
Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
BlockPos pistonHead = null; BlockPos pistonHead = null;
BlockPos pistonBase = null; BlockPos pistonBase = null;
for (int modifier : new int[]{1, -1}) { for (int modifier : new int[] { 1, -1 }) {
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset += for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
modifier) { modifier) {
BlockPos currentPos = pos.offset(direction, offset); BlockPos currentPos = pos.offset(direction, offset);
BlockState block = worldIn.getBlockState(currentPos); BlockState block = worldIn.getBlockState(currentPos);
if (isExtensionPole(block) && axis == block.get(FACING) if (isExtensionPole(block) && axis == block.get(FACING)
.getAxis()) .getAxis())
continue; continue;
if (isPiston(block) && block.get(BlockStateProperties.FACING) if (isPiston(block) && block.get(BlockStateProperties.FACING)
.getAxis() == axis) .getAxis() == axis)
pistonBase = currentPos; pistonBase = currentPos;
if (isPistonHead(block) && block.get(BlockStateProperties.FACING) if (isPistonHead(block) && block.get(BlockStateProperties.FACING)
.getAxis() == axis) .getAxis() == axis)
pistonHead = currentPos; pistonHead = currentPos;
break; break;
} }
} }
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead) if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead)
.get(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase) .get(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase)
.get(BlockStateProperties.FACING)) { .get(BlockStateProperties.FACING)) {
final BlockPos basePos = pistonBase; final BlockPos basePos = pistonBase;
BlockPos.getAllInBox(pistonBase, pistonHead) BlockPos.getAllInBox(pistonBase, pistonHead)
.filter(p -> !p.equals(pos) && !p.equals(basePos)) .filter(p -> !p.equals(pos) && !p.equals(basePos))
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative())); .forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
worldIn.setBlockState(basePos, worldIn.getBlockState(basePos) worldIn.setBlockState(basePos, worldIn.getBlockState(basePos)
.with(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); .with(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
} }
super.onBlockHarvested(worldIn, pos, state, player); super.onBlockHarvested(worldIn, pos, state, player);
} }
@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.FOUR_VOXEL_POLE.get(state.get(FACING) return AllShapes.FOUR_VOXEL_POLE.get(state.get(FACING)
.getAxis()); .getAxis());
} }
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
FluidState ifluidstate = context.getWorld().getFluidState(context.getPos()); FluidState FluidState = context.getWorld()
return getDefaultState().with(FACING, context.getFace().getOpposite()) .getFluidState(context.getPos());
.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER)); return getDefaultState().with(FACING, context.getFace()
} .getOpposite())
.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getFluid() == Fluids.WATER));
}
@Override @Override
public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
ItemStack heldItem = player.getHeldItem(hand); BlockRayTraceResult ray) {
ItemStack heldItem = player.getHeldItem(hand);
if (AllBlocks.PISTON_EXTENSION_POLE.isIn(heldItem) && !player.isSneaking()) { if (AllBlocks.PISTON_EXTENSION_POLE.isIn(heldItem) && !player.isSneaking()) {
Pair<Direction, Integer> offset = PistonPolePlacementHelper.getPlacementOffset(world, state.get(FACING).getAxis(), pos, ray.getHitVec()); Pair<Direction, Integer> offset = PistonPolePlacementHelper.getPlacementOffset(world, state.get(FACING)
.getAxis(), pos, ray.getHitVec());
if (offset == null || offset.getSecond() == 0) if (offset == null || offset.getSecond() == 0)
return ActionResultType.PASS; return ActionResultType.PASS;
BlockPos newPos = pos.offset(offset.getFirst(), offset.getSecond()); BlockPos newPos = pos.offset(offset.getFirst(), offset.getSecond());
if (!world.getBlockState(newPos).getMaterial().isReplaceable()) if (!world.getBlockState(newPos)
return ActionResultType.PASS; .getMaterial()
.isReplaceable())
return ActionResultType.PASS;
if (world.isRemote) if (world.isRemote)
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
world.setBlockState(newPos, AllBlocks.PISTON_EXTENSION_POLE.getDefaultState().with(FACING, state.get(FACING))); world.setBlockState(newPos, AllBlocks.PISTON_EXTENSION_POLE.getDefaultState()
if (!player.isCreative()) .with(FACING, state.get(FACING)));
heldItem.shrink(1); if (!player.isCreative())
heldItem.shrink(1);
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }
return ActionResultType.PASS; return ActionResultType.PASS;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState(); return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false)
} : Fluids.EMPTY.getDefaultState();
}
@Override @Override
protected void fillStateContainer(Builder<Block, BlockState> builder) { protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.WATERLOGGED); builder.add(BlockStateProperties.WATERLOGGED);
super.fillStateContainer(builder); super.fillStateContainer(builder);
} }
@Override @Override
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState,
IWorld world, BlockPos pos, BlockPos neighbourPos) { IWorld world, BlockPos pos, BlockPos neighbourPos) {
if (state.get(BlockStateProperties.WATERLOGGED)) { if (state.get(BlockStateProperties.WATERLOGGED)) {
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); world.getPendingFluidTicks()
} .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
return state; }
} return state;
}
} }

View file

@ -19,7 +19,11 @@ import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.state.*; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.Property;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.RailShape; import net.minecraft.state.properties.RailShape;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;

View file

@ -13,6 +13,7 @@ import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
@ -32,11 +33,6 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import java.util.ArrayList;
import java.util.List;
import static com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation.spacing;
@EventBusSubscriber(value = Dist.CLIENT) @EventBusSubscriber(value = Dist.CLIENT)
public class GoggleOverlayRenderer { public class GoggleOverlayRenderer {
@ -105,7 +101,9 @@ public class GoggleOverlayRenderer {
if (!tooltip.isEmpty()) if (!tooltip.isEmpty())
tooltip.add(StringTextComponent.EMPTY); tooltip.add(StringTextComponent.EMPTY);
tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(Lang.translate("gui.goggles.pole_length")).append(" " + poles)); tooltip.add(IHaveGoggleInformation.componentSpacing.copy()
.append(Lang.translate("gui.goggles.pole_length"))
.append(new StringTextComponent(" " + poles)));
} }
if (tooltip.isEmpty()) if (tooltip.isEmpty())