mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 05:52:41 +01:00
Pole Vault
- add placement helper for piston extension poles - add piston pole length to goggle overlay - fix mechanical pistons being a little too generous with pole alignment - allow ProperDirectionalBlocks to be rotated with the wrench
This commit is contained in:
parent
ddf28cfcea
commit
c5163f0953
12 changed files with 285 additions and 87 deletions
|
@ -1,12 +1,5 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import static net.minecraft.util.text.TextFormatting.GOLD;
|
|
||||||
import static net.minecraft.util.text.TextFormatting.GRAY;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.contraptions.KineticNetwork;
|
import com.simibubi.create.content.contraptions.KineticNetwork;
|
||||||
import com.simibubi.create.content.contraptions.RotationPropagator;
|
import com.simibubi.create.content.contraptions.RotationPropagator;
|
||||||
|
@ -20,7 +13,6 @@ import com.simibubi.create.foundation.item.TooltipHelper;
|
||||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
@ -35,6 +27,12 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.minecraft.util.text.TextFormatting.GOLD;
|
||||||
|
import static net.minecraft.util.text.TextFormatting.GRAY;
|
||||||
|
|
||||||
public abstract class KineticTileEntity extends SmartTileEntity
|
public abstract class KineticTileEntity extends SmartTileEntity
|
||||||
implements ITickableTileEntity, IHaveGoggleInformation, IHaveHoveringInformation {
|
implements ITickableTileEntity, IHaveGoggleInformation, IHaveHoveringInformation {
|
||||||
|
|
||||||
|
@ -352,13 +350,12 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileEntity tileEntityIn = world.getTileEntity(pos);
|
TileEntity tileEntityIn = world.getTileEntity(pos);
|
||||||
|
BlockState currentState = world.getBlockState(pos);
|
||||||
boolean isKinetic = tileEntityIn instanceof KineticTileEntity;
|
boolean isKinetic = tileEntityIn instanceof KineticTileEntity;
|
||||||
|
|
||||||
if (tileEntityIn == null)
|
if (currentState == state)
|
||||||
return;
|
return;
|
||||||
if (tileEntityIn.getBlockState() == state)
|
if (tileEntityIn == null || !isKinetic) {
|
||||||
return;
|
|
||||||
if (!isKinetic) {
|
|
||||||
world.setBlockState(pos, state, 3);
|
world.setBlockState(pos, state, 3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@ package com.simibubi.create.content.contraptions.components.fan;
|
||||||
|
|
||||||
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.wrench.IWrenchable;
|
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
|
|
||||||
import mcp.MethodsReturnNonnullByDefault;
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -24,7 +22,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public class NozzleBlock extends ProperDirectionalBlock implements IWrenchable {
|
public class NozzleBlock extends ProperDirectionalBlock {
|
||||||
|
|
||||||
public NozzleBlock(Properties p_i48415_1_) {
|
public NozzleBlock(Properties p_i48415_1_) {
|
||||||
super(p_i48415_1_);
|
super(p_i48415_1_);
|
||||||
|
|
|
@ -1,25 +1,11 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
||||||
|
|
||||||
import static com.simibubi.create.AllBlocks.MECHANICAL_PISTON_HEAD;
|
|
||||||
import static com.simibubi.create.AllBlocks.PISTON_EXTENSION_POLE;
|
|
||||||
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 static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isStickyPiston;
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes;
|
import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits;
|
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption;
|
import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption;
|
||||||
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.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.CarpetBlock;
|
import net.minecraft.block.CarpetBlock;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
@ -32,6 +18,15 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.simibubi.create.AllBlocks.MECHANICAL_PISTON_HEAD;
|
||||||
|
import static com.simibubi.create.AllBlocks.PISTON_EXTENSION_POLE;
|
||||||
|
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.*;
|
||||||
|
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
public class PistonContraption extends TranslatingContraption {
|
public class PistonContraption extends TranslatingContraption {
|
||||||
|
|
||||||
|
@ -77,8 +72,7 @@ public class PistonContraption extends TranslatingContraption {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (blockState.get(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) {
|
if (blockState.get(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) {
|
||||||
while (isExtensionPole(nextBlock) && nextBlock.get(FACING)
|
while (PistonPolePlacementHelper.matchesAxis(nextBlock, direction.getAxis()) || isPistonHead(nextBlock) && nextBlock.get(FACING) == direction) {
|
||||||
.getAxis() == direction.getAxis() || isPistonHead(nextBlock) && nextBlock.get(FACING) == direction) {
|
|
||||||
|
|
||||||
actualStart = actualStart.offset(direction);
|
actualStart = actualStart.offset(direction);
|
||||||
poles.add(new BlockInfo(actualStart, nextBlock.with(FACING, direction), null));
|
poles.add(new BlockInfo(actualStart, nextBlock.with(FACING, direction), null));
|
||||||
|
@ -105,7 +99,7 @@ public class PistonContraption extends TranslatingContraption {
|
||||||
nextBlock = world.getBlockState(end.offset(direction.getOpposite()));
|
nextBlock = world.getBlockState(end.offset(direction.getOpposite()));
|
||||||
int extensionsInBack = 0;
|
int extensionsInBack = 0;
|
||||||
|
|
||||||
while (isExtensionPole(nextBlock)) {
|
while (PistonPolePlacementHelper.matchesAxis(nextBlock, direction.getAxis())) {
|
||||||
end = end.offset(direction.getOpposite());
|
end = end.offset(direction.getOpposite());
|
||||||
poles.add(new BlockInfo(end, nextBlock.with(FACING, direction), null));
|
poles.add(new BlockInfo(end, nextBlock.with(FACING, direction), null));
|
||||||
extensionsInBack++;
|
extensionsInBack++;
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
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 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 com.simibubi.create.foundation.utility.Pair;
|
||||||
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.IWaterLoggable;
|
||||||
|
@ -17,18 +14,24 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.fluid.IFluidState;
|
import net.minecraft.fluid.IFluidState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
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.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
|
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.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.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.*;
|
||||||
|
|
||||||
public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable {
|
public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable {
|
||||||
|
|
||||||
public PistonExtensionPoleBlock(Properties properties) {
|
public PistonExtensionPoleBlock(Properties properties) {
|
||||||
|
@ -99,6 +102,34 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements
|
||||||
.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) {
|
||||||
|
ItemStack heldItem = player.getHeldItem(hand);
|
||||||
|
|
||||||
|
if (AllBlocks.PISTON_EXTENSION_POLE.isIn(heldItem) && !player.isSneaking()) {
|
||||||
|
Pair<Direction, Integer> offset = PistonPolePlacementHelper.getPlacementOffset(world, state.get(FACING).getAxis(), pos, ray.getHitVec());
|
||||||
|
|
||||||
|
if (offset == null || offset.getSecond() == 0)
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
|
BlockPos newPos = pos.offset(offset.getFirst(), offset.getSecond());
|
||||||
|
|
||||||
|
if (!world.getBlockState(newPos).getMaterial().isReplaceable())
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
|
if (world.isRemote)
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
|
world.setBlockState(newPos, AllBlocks.PISTON_EXTENSION_POLE.getDefaultState().with(FACING, offset.getFirst()));
|
||||||
|
if (!player.isCreative())
|
||||||
|
heldItem.shrink(1);
|
||||||
|
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFluidState getFluidState(BlockState state) {
|
public IFluidState 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();
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.CreateClient;
|
||||||
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
|
import com.simibubi.create.foundation.utility.Pair;
|
||||||
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class PistonPolePlacementHelper {
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static void tick() {
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
ClientWorld world = mc.world;
|
||||||
|
|
||||||
|
if (!(mc.objectMouseOver instanceof BlockRayTraceResult))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BlockRayTraceResult ray = (BlockRayTraceResult) mc.objectMouseOver;
|
||||||
|
|
||||||
|
if (!isHoldingPole(mc.player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BlockPos pos = ray.getPos();
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
if (!(state.getBlock() instanceof PistonExtensionPoleBlock))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Pair<Direction, Integer> offset = getPlacementOffset(world, state.get(PistonExtensionPoleBlock.FACING).getAxis(), pos, ray.getHitVec());
|
||||||
|
if (offset == null || offset.getSecond() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Direction hitFace = ray.getFace();
|
||||||
|
|
||||||
|
if (hitFace.getAxis() == offset.getFirst().getAxis())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vec3d hitCenter = VecHelper.getCenterOf(pos).add(new Vec3d(hitFace.getDirectionVec()).scale(0.3));
|
||||||
|
|
||||||
|
//get the two perpendicular directions to form the arrow
|
||||||
|
Direction[] directions = Arrays.stream(Direction.Axis.values()).filter(axis -> axis != hitFace.getAxis() && axis != offset.getFirst().getAxis()).map(Iterate::directionsInAxis).findFirst().orElse(new Direction[]{});
|
||||||
|
Vec3d startOffset = new Vec3d(offset.getFirst().getDirectionVec());
|
||||||
|
Vec3d start = hitCenter.add(startOffset);
|
||||||
|
for (Direction dir : directions) {
|
||||||
|
Vec3d arrowOffset = new Vec3d(dir.getDirectionVec()).scale(.25);
|
||||||
|
Vec3d target = hitCenter.add(startOffset.scale(0.75)).add(arrowOffset);
|
||||||
|
CreateClient.outliner.showLine("poleHelp" + offset.getFirst() + dir, start, target).lineWidth(1/16f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// first indicates the direction that the position needs to be offset into
|
||||||
|
// second indicates by how many blocks the position needs to be offset by; is 0 if there was no valid position on either end of the pole
|
||||||
|
public static Pair<Direction, Integer> getPlacementOffset(World world, Direction.Axis poleAxis, BlockPos pos, Vec3d hit) {
|
||||||
|
Pair<Direction, Integer> offset = null;
|
||||||
|
double min = Double.MAX_VALUE;
|
||||||
|
Vec3d localPos = hit.subtract(VecHelper.getCenterOf(pos));
|
||||||
|
|
||||||
|
//find target direction
|
||||||
|
for (Direction dir : Iterate.directionsInAxis(poleAxis)) {
|
||||||
|
double distance = new Vec3d(dir.getDirectionVec()).distanceTo(localPos);
|
||||||
|
if (distance > min)
|
||||||
|
continue;
|
||||||
|
min = distance;
|
||||||
|
offset = Pair.of(dir, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset == null)//??
|
||||||
|
return null;
|
||||||
|
|
||||||
|
//check for space at the end of the pole
|
||||||
|
int poles = attachedPoles(world, pos, offset.getFirst());
|
||||||
|
BlockState state = world.getBlockState(pos.offset(offset.getFirst(), poles + 1));
|
||||||
|
|
||||||
|
if (state.getMaterial().isReplaceable()) {
|
||||||
|
offset.setSecond(poles + 1);
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check the other end of the pole
|
||||||
|
offset.setFirst(offset.getFirst().getOpposite());
|
||||||
|
poles = attachedPoles(world, pos, offset.getFirst());
|
||||||
|
state = world.getBlockState(pos.offset(offset.getFirst(), poles + 1));
|
||||||
|
|
||||||
|
if (state.getMaterial().isReplaceable()) {
|
||||||
|
offset.setSecond(poles + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int attachedPoles(World world, BlockPos pos, Direction direction) {
|
||||||
|
BlockPos checkPos = pos.offset(direction);
|
||||||
|
BlockState state = world.getBlockState(checkPos);
|
||||||
|
int count = 0;
|
||||||
|
while (matchesAxis(state, direction.getAxis())) {
|
||||||
|
count++;
|
||||||
|
checkPos = checkPos.offset(direction);
|
||||||
|
state = world.getBlockState(checkPos);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
//checks if the given state is a piston pole on the given axis
|
||||||
|
public static boolean matchesAxis(BlockState state, Direction.Axis axis) {
|
||||||
|
return AllBlocks.PISTON_EXTENSION_POLE.has(state) && state.get(PistonExtensionPoleBlock.FACING).getAxis() == axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHoldingPole(PlayerEntity player) {
|
||||||
|
return Arrays.stream(Hand.values()).anyMatch(hand -> AllBlocks.PISTON_EXTENSION_POLE.isIn(player.getHeldItem(hand)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,19 +1,21 @@
|
||||||
package com.simibubi.create.content.contraptions.goggles;
|
package com.simibubi.create.content.contraptions.goggles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonPolePlacementHelper;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
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 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;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
import net.minecraft.inventory.EquipmentSlotType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
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.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
@ -24,6 +26,11 @@ 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 {
|
||||||
|
|
||||||
|
@ -41,36 +48,52 @@ public class GoggleOverlayRenderer {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ClientWorld world = mc.world;
|
ClientWorld world = mc.world;
|
||||||
BlockPos pos = result.getPos();
|
BlockPos pos = result.getPos();
|
||||||
ItemStack goggles = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD);
|
ItemStack headSlot = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD);
|
||||||
TileEntity te = world.getTileEntity(pos);
|
TileEntity te = world.getTileEntity(pos);
|
||||||
|
|
||||||
boolean goggleInformation = te instanceof IHaveGoggleInformation;
|
boolean wearingGoggles = AllItems.GOGGLES.isIn(headSlot);
|
||||||
boolean hoveringInformation = te instanceof IHaveHoveringInformation;
|
|
||||||
|
|
||||||
if (!goggleInformation && !hoveringInformation)
|
boolean hasGoggleInformation = te instanceof IHaveGoggleInformation;
|
||||||
return;
|
boolean hasHoveringInformation = te instanceof IHaveHoveringInformation;
|
||||||
|
|
||||||
|
boolean goggleAddedInformation = false;
|
||||||
|
boolean hoverAddedInformation = false;
|
||||||
|
|
||||||
List<String> tooltip = new ArrayList<>();
|
List<String> tooltip = new ArrayList<>();
|
||||||
|
|
||||||
if (goggleInformation && AllItems.GOGGLES.isIn(goggles)) {
|
if (hasGoggleInformation && wearingGoggles) {
|
||||||
IHaveGoggleInformation gte = (IHaveGoggleInformation) te;
|
IHaveGoggleInformation gte = (IHaveGoggleInformation) te;
|
||||||
if (!gte.addToGoggleTooltip(tooltip, mc.player.isSneaking()))
|
goggleAddedInformation = gte.addToGoggleTooltip(tooltip, mc.player.isSneaking());
|
||||||
goggleInformation = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hoveringInformation) {
|
if (hasHoveringInformation) {
|
||||||
boolean goggleAddedInformation = !tooltip.isEmpty();
|
if (!tooltip.isEmpty())
|
||||||
if (goggleAddedInformation)
|
|
||||||
tooltip.add("");
|
tooltip.add("");
|
||||||
IHaveHoveringInformation hte = (IHaveHoveringInformation) te;
|
IHaveHoveringInformation hte = (IHaveHoveringInformation) te;
|
||||||
if (!hte.addToTooltip(tooltip, mc.player.isSneaking()))
|
hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isSneaking());
|
||||||
hoveringInformation = false;
|
|
||||||
if (goggleAddedInformation && !hoveringInformation)
|
if (goggleAddedInformation && !hoverAddedInformation)
|
||||||
tooltip.remove(tooltip.size() - 1);
|
tooltip.remove(tooltip.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!goggleInformation && !hoveringInformation)
|
//break early if goggle or hover returned false when present
|
||||||
|
if ((hasGoggleInformation && !goggleAddedInformation) && (hasHoveringInformation && !hoverAddedInformation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//check for piston poles if goggles are worn
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
if (wearingGoggles && AllBlocks.PISTON_EXTENSION_POLE.has(state)) {
|
||||||
|
Direction[] directions = Iterate.directionsInAxis(state.get(PistonExtensionPoleBlock.FACING).getAxis());
|
||||||
|
int poles = 1;
|
||||||
|
for (Direction dir : directions)
|
||||||
|
poles += PistonPolePlacementHelper.attachedPoles(world, pos, dir);
|
||||||
|
|
||||||
|
if (!tooltip.isEmpty())
|
||||||
|
tooltip.add("");
|
||||||
|
|
||||||
|
tooltip.add(spacing + "Pole length: " + poles);
|
||||||
|
}
|
||||||
|
|
||||||
if (tooltip.isEmpty())
|
if (tooltip.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -88,7 +111,6 @@ public class GoggleOverlayRenderer {
|
||||||
RenderSystem.popMatrix();
|
RenderSystem.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final class TooltipScreen extends Screen {
|
private static final class TooltipScreen extends Screen {
|
||||||
private TooltipScreen(ITextComponent p_i51108_1_) {
|
private TooltipScreen(ITextComponent p_i51108_1_) {
|
||||||
super(p_i51108_1_);
|
super(p_i51108_1_);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.logistics.block.inventories;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
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.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
@ -80,6 +79,11 @@ public class CrateBlock extends ProperDirectionalBlock implements IWrenchable {
|
||||||
return getDefaultState();
|
return getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) {
|
||||||
|
return originalState;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
super.fillStateContainer(builder.add(DOUBLE));
|
super.fillStateContainer(builder.add(DOUBLE));
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
package com.simibubi.create.content.logistics.block.redstone;
|
package com.simibubi.create.content.logistics.block.redstone;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
|
|
||||||
import mcp.MethodsReturnNonnullByDefault;
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -23,9 +16,13 @@ import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
public class RedstoneContactBlock extends ProperDirectionalBlock implements IWrenchable {
|
public class RedstoneContactBlock extends ProperDirectionalBlock {
|
||||||
|
|
||||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,10 @@ package com.simibubi.create.content.logistics.block.redstone;
|
||||||
|
|
||||||
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.wrench.IWrenchable;
|
|
||||||
import com.simibubi.create.content.logistics.block.funnel.FunnelBlock;
|
import com.simibubi.create.content.logistics.block.funnel.FunnelBlock;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
import com.simibubi.create.foundation.block.ITE;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
import com.simibubi.create.foundation.utility.Iterate;
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -28,7 +26,7 @@ import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE<RedstoneLinkTileEntity>, IWrenchable {
|
public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE<RedstoneLinkTileEntity> {
|
||||||
|
|
||||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||||
public static final BooleanProperty RECEIVER = BooleanProperty.create("receiver");
|
public static final BooleanProperty RECEIVER = BooleanProperty.create("receiver");
|
||||||
|
@ -152,7 +150,12 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE<Red
|
||||||
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
if (toggleMode(state, context.getWorld(), context.getPos()) == ActionResultType.SUCCESS)
|
if (toggleMode(state, context.getWorld(), context.getPos()) == ActionResultType.SUCCESS)
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
return IWrenchable.super.onWrenched(state, context);
|
return super.onWrenched(state, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getRotatedBlockState(BlockState originalState, Direction _targetedFace) {
|
||||||
|
return originalState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.simibubi.create.events;
|
package com.simibubi.create.events;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
|
@ -10,6 +7,7 @@ import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlockPlacementHelper;
|
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlockPlacementHelper;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay;
|
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonPolePlacementHelper;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingHandlerClient;
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingHandlerClient;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingPhysics;
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingPhysics;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingRenderer;
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingRenderer;
|
||||||
|
@ -31,7 +29,6 @@ import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkRenderer;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueRenderer;
|
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueRenderer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
@ -52,6 +49,9 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||||
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;
|
||||||
|
|
||||||
@EventBusSubscriber(value = Dist.CLIENT)
|
@EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ public class ClientEvents {
|
||||||
// CollisionDebugger.tick();
|
// CollisionDebugger.tick();
|
||||||
ArmInteractionPointHandler.tick();
|
ArmInteractionPointHandler.tick();
|
||||||
SailBlockPlacementHelper.tick();
|
SailBlockPlacementHelper.tick();
|
||||||
|
PistonPolePlacementHelper.tick();
|
||||||
CreateClient.outliner.tickOutlines();
|
CreateClient.outliner.tickOutlines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package com.simibubi.create.foundation.block;
|
package com.simibubi.create.foundation.block;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||||
|
import com.simibubi.create.foundation.utility.DirectionHelper;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.DirectionalBlock;
|
import net.minecraft.block.DirectionalBlock;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Mirror;
|
import net.minecraft.util.Mirror;
|
||||||
import net.minecraft.util.Rotation;
|
import net.minecraft.util.Rotation;
|
||||||
|
|
||||||
public class ProperDirectionalBlock extends DirectionalBlock {
|
public class ProperDirectionalBlock extends DirectionalBlock implements IWrenchable {
|
||||||
|
|
||||||
public ProperDirectionalBlock(Properties p_i48415_1_) {
|
public ProperDirectionalBlock(Properties p_i48415_1_) {
|
||||||
super(p_i48415_1_);
|
super(p_i48415_1_);
|
||||||
|
@ -20,6 +23,18 @@ public class ProperDirectionalBlock extends DirectionalBlock {
|
||||||
super.fillStateContainer(builder);
|
super.fillStateContainer(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) {
|
||||||
|
Direction facing = originalState.get(FACING);
|
||||||
|
|
||||||
|
if (facing.getAxis() == targetedFace.getAxis())
|
||||||
|
return originalState;
|
||||||
|
|
||||||
|
Direction newFacing = DirectionHelper.rotateAround(facing, targetedFace.getAxis());
|
||||||
|
|
||||||
|
return originalState.with(FACING, newFacing);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
return getDefaultState().with(FACING, context.getNearestLookingDirection());
|
return getDefaultState().with(FACING, context.getNearestLookingDirection());
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.simibubi.create.foundation.utility;
|
package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
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.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Iterate {
|
public class Iterate {
|
||||||
|
|
||||||
public static final boolean[] trueAndFalse = {true, false};
|
public static final boolean[] trueAndFalse = {true, false};
|
||||||
|
@ -23,9 +23,19 @@ public class Iterate {
|
||||||
return directions;
|
return directions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Direction[] directionsInAxis(Axis axis) {
|
||||||
|
switch (axis) {
|
||||||
|
case X:
|
||||||
|
return new Direction[]{Direction.EAST, Direction.WEST};
|
||||||
|
case Y:
|
||||||
|
return new Direction[]{Direction.UP, Direction.DOWN};
|
||||||
|
default:
|
||||||
|
case Z:
|
||||||
|
return new Direction[]{Direction.SOUTH, Direction.NORTH};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static List<BlockPos> hereAndBelow(BlockPos pos) {
|
public static List<BlockPos> hereAndBelow(BlockPos pos) {
|
||||||
return Arrays.asList(pos, pos.down());
|
return Arrays.asList(pos, pos.down());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue