diff --git a/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java b/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java index 4f444d6d9..6ef43c17c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java @@ -18,6 +18,7 @@ import com.simibubi.create.content.contraptions.relays.encased.EncasedBeltBlock; import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -431,7 +432,7 @@ public class RotationPropagator { .isAreaLoaded(te.getPos(), 1)) return neighbours; - for (Direction facing : Direction.values()) + for (Direction facing : Iterate.directions) neighbours.add(te.getPos() .offset(facing)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java index a2bc9e6f4..d6b43ef65 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.base; +import com.simibubi.create.foundation.utility.Iterate; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; @@ -26,7 +28,7 @@ public abstract class DirectionalKineticBlock extends KineticBlock { public Direction getPreferredFacing(BlockItemUseContext context) { Direction prefferedSide = null; - for (Direction side : Direction.values()) { + for (Direction side : Iterate.directions) { BlockState blockState = context.getWorld() .getBlockState(context.getPos() .offset(side)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java index dc6e004a9..70e674d69 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.base; +import com.simibubi.create.foundation.utility.Iterate; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; @@ -38,9 +40,7 @@ public abstract class HorizontalAxisKineticBlock extends KineticBlock { public static Axis getPreferredHorizontalAxis(BlockItemUseContext context) { Direction prefferedSide = null; - for (Direction side : Direction.values()) { - if (side.getAxis().isVertical()) - continue; + for (Direction side : Iterate.horizontalDirections) { BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side)); if (blockState.getBlock() instanceof IRotate) { if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos().offset(side), diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java index dda1b90f4..2e86a897a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.base; +import com.simibubi.create.foundation.utility.Iterate; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; @@ -40,7 +42,7 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { public static Axis getPreferredAxis(BlockItemUseContext context) { Axis prefferedAxis = null; - for (Direction side : Direction.values()) { + for (Direction side : Iterate.directions) { BlockState blockState = context.getWorld() .getBlockState(context.getPos() .offset(side)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java index cee93393c..7d5941dda 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java @@ -14,6 +14,7 @@ import java.util.stream.Collectors; import com.google.common.base.Predicates; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; @@ -74,7 +75,7 @@ public class ConnectedInputHandler { positions.remove(pos); while (!frontier.isEmpty()) { BlockPos current = frontier.remove(0); - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { BlockPos next = current.offset(direction); if (!positions.remove(next)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java index 6ee0720c8..a8de2ec50 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java @@ -9,6 +9,7 @@ import com.simibubi.create.content.contraptions.components.crafter.ConnectedInpu import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.AngleHelper; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.VecHelper; @@ -109,7 +110,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT crafter.ejectWholeGrid(); } - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { if (direction.getAxis() == state.get(HORIZONTAL_FACING) .getAxis()) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java index 20de1a509..3f32854de 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java @@ -16,6 +16,7 @@ import com.google.common.base.Predicates; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pointing; import net.minecraft.block.BlockState; @@ -109,7 +110,7 @@ public class RecipeGridHandler { Direction blockFacing = blockState.get(HORIZONTAL_FACING); Direction blockPointing = MechanicalCrafterBlock.getTargetDirection(blockState); - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { if (blockFacing.getAxis() == facing.getAxis()) continue; if (blockPointing == facing) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java index cd9c17187..548b4c6f8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java @@ -7,6 +7,7 @@ import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; @@ -52,9 +53,8 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE @Override public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - for (Direction d : Direction.values()) { - if (d.getAxis() == state.get(AXIS) || d.getAxis() - .isVertical()) + for (Direction d : Iterate.horizontalDirections) { + if (d.getAxis() == state.get(AXIS)) continue; if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(worldIn.getBlockState(pos.offset(d)))) worldIn.setBlockState(pos.offset(d), Blocks.AIR.getDefaultState()); @@ -153,7 +153,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE @Override public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { BlockPos neighbourPos = pos.offset(direction); BlockState neighbourState = worldIn.getBlockState(neighbourPos); Axis stateAxis = state.get(AXIS); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java index 94d6eccf6..d85549b7f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java @@ -7,6 +7,7 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.item.ItemHelper; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -127,9 +128,7 @@ public class CrushingWheelControllerBlock extends Block return; } - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) - continue; + for (Direction d : Iterate.horizontalDirections) { BlockState neighbour = world.getBlockState(pos.offset(d)); if (!AllBlocks.CRUSHING_WHEEL.has(neighbour)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java index 6a50b7366..d14531a6c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.contraptions.components.crusher; import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.DamageSource; @@ -29,7 +30,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity { } public void fixControllers() { - for (Direction d : Direction.values()) + for (Direction d : Iterate.directions) ((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getWorld(), getPos(), d); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java index 091b2c8e5..268aa65cc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java @@ -4,6 +4,7 @@ import javax.annotation.Nullable; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -75,9 +76,7 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable BlockPos baseBlockPos = getBaseBlockPos(state, pos); if (!isValidBaseBlock(world.getBlockState(baseBlockPos), world, pos)) return false; - for (Direction otherFacing : Direction.values()) { - if (otherFacing.getAxis().isVertical()) - continue; + for (Direction otherFacing : Iterate.horizontalDirections) { if (otherFacing == facing) continue; BlockPos otherPos = baseBlockPos.offset(otherFacing); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index c71acc94f..1900365ef 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -296,7 +296,7 @@ public abstract class Contraption { // Slime blocks and super glue drag adjacent blocks if possible boolean isSlimeBlock = state.getBlock() instanceof SlimeBlock; - for (Direction offset : Direction.values()) { + for (Direction offset : Iterate.directions) { BlockPos offsetPos = pos.offset(offset); BlockState blockState = world.getBlockState(offsetPos); if (isAnchoringBlockAt(offsetPos)) @@ -755,7 +755,7 @@ public abstract class Contraption { continue; if (nonBrittles) - for (Direction face : Direction.values()) + for (Direction face : Iterate.directions) state = state.updatePostPlacement(face, world.getBlockState(targetPos.offset(face)), world, targetPos, targetPos.offset(face)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java index 85adf5e0d..39cadf017 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java @@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.cha import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; import com.simibubi.create.foundation.utility.DirectionHelper; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BellBlock; @@ -310,13 +311,13 @@ public class StructureTransform { BlockState rotated = state.with(AXIS, transformAxis(state.get(AXIS))); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = block.getGlueableSide(rotated, face); if (glueableSide != null) rotated = rotated.with(glueableSide, false); } - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = block.getGlueableSide(state, face); if (glueableSide == null || !state.get(glueableSide)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java index 65c31d2b5..b9cae7e36 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java @@ -4,6 +4,7 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.BlockState; import net.minecraft.block.RotatedPillarBlock; @@ -56,7 +57,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements return ActionResultType.PASS; if (isSlimeBall && state.get(affectedSide)) { - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); if (glueableSide != null && !state.get(glueableSide)) { if (worldIn.isRemote) { @@ -95,13 +96,13 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements return state; BlockState rotated = super.rotate(state, rotation); - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(rotated, face); if (glueableSide != null) rotated = rotated.with(glueableSide, false); } - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); if (glueableSide == null || !state.get(glueableSide)) continue; @@ -120,13 +121,13 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements return state; BlockState mirrored = state; - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(mirrored, face); if (glueableSide != null) mirrored = mirrored.with(glueableSide, false); } - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); if (glueableSide == null || !state.get(glueableSide)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java index c7efc5d12..832b656da 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java @@ -17,6 +17,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.BlockState; @@ -122,7 +123,7 @@ public class ChassisTileEntity extends SmartTileEntity { } // Collect group of connected linear chassis - for (Direction offset : Direction.values()) { + for (Direction offset : Iterate.directions) { if (offset.getAxis() == axis) continue; BlockPos current = pos.offset(offset); @@ -187,7 +188,7 @@ public class ChassisTileEntity extends SmartTileEntity { AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); int chassisRange = visualize ? range.scrollableValue : getRange(); - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { if (facing.getAxis() == axis) continue; if (!state.get(block.getGlueableSide(state, facing))) @@ -215,7 +216,7 @@ public class ChassisTileEntity extends SmartTileEntity { if (!searchPos.equals(pos)) positions.add(searchPos); - for (Direction offset : Direction.values()) { + for (Direction offset : Iterate.directions) { if (offset.getAxis() == axis) continue; if (searchPos.equals(pos) && offset != facing) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java index 850051626..306a442a3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java @@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.block.BlockRenderType; @@ -42,7 +43,7 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE type) { super(type); flows = new HashMap<>(); - for (Direction d : Direction.values()) + for (Direction d : Iterate.directions) setFlow(d, 0); setLazyTickRate(20); } @@ -28,7 +29,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { protected void read(CompoundNBT compound, boolean clientPacket) { super.read(compound, clientPacket); if (compound.contains("Flows")) { - for (Direction d : Direction.values()) + for (Direction d : Iterate.directions) setFlow(d, compound.getCompound("Flows") .getFloat(d.getName())); } @@ -42,7 +43,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { @Override public void write(CompoundNBT compound, boolean clientPacket) { CompoundNBT flows = new CompoundNBT(); - for (Direction d : Direction.values()) + for (Direction d : Iterate.directions) flows.putFloat(d.getName(), this.flows.get(d)); compound.put("Flows", flows); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java index 4b9eb3af8..8e2d906c3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java @@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -55,7 +56,7 @@ public class CogWheelBlock extends AbstractShaftBlock { @Override public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { if (facing.getAxis() == state.get(AXIS)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java index 46d0891c0..1749f455e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java @@ -4,6 +4,7 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.Block; @@ -62,7 +63,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { axis = placedAxis; BlockState state = getDefaultState().with(AXIS, axis); - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { if (facing.getAxis() == axis) continue; BlockPos pos = context.getPos(); @@ -130,7 +131,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { .updateNeighbors(context.getWorld(), context.getPos(), 1); Axis axis = newState.get(AXIS); newState = getDefaultState().with(AXIS, axis); - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { if (facing.getAxis() == axis) continue; BlockPos pos = context.getPos(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index f2f4a7bfa..96186728f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.block.Block; @@ -30,7 +31,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { final BlockPos pos = te.getPos(); float time = AnimationTickHolder.getRenderTick(); - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { Axis axis = direction.getAxis(); if (boxAxis != axis) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java index b9d4378f1..1580b553e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java @@ -6,6 +6,7 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.foundation.utility.ColorHelper; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; @@ -143,7 +144,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { return; int color = gaugeTE.color; - for (Direction face : Direction.values()) { + for (Direction face : Iterate.directions) { if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index ce652d4c4..8c24f63b4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.block.BlockState; @@ -46,7 +47,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer { .renderOn(gaugeState); SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState); - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState, facing)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index e1a9211ea..7462e355c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -28,7 +29,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { final BlockPos pos = te.getPos(); float time = AnimationTickHolder.getRenderTick(); - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { final Axis axis = direction.getAxis(); if (boxAxis == axis) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java index d2346ab30..153b85154 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java @@ -4,6 +4,7 @@ import java.util.Map; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.IRotate; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -41,10 +42,7 @@ public class VerticalGearboxItem extends BlockItem { @Override protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity player, ItemStack stack, BlockState state) { Axis prefferedAxis = null; - for (Direction side : Direction.values()) { - if (side.getAxis() - .isVertical()) - continue; + for (Direction side : Iterate.horizontalDirections) { BlockState blockState = world.getBlockState(pos.offset(side)); if (blockState.getBlock() instanceof IRotate) { if (((IRotate) blockState.getBlock()).hasShaftTowards(world, pos.offset(side), blockState, diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java index 28edd0ef8..da65a069d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java @@ -15,6 +15,7 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.BlockHelper; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -207,7 +208,7 @@ public class SymmetryWandItem extends Item { if (world.canPlace(block, position, ISelectionContext.forEntity(player))) { BlockState blockState = blockSet.get(position); - for (Direction face : Direction.values()) + for (Direction face : Iterate.directions) blockState = blockState.updatePostPlacement(face, world.getBlockState(position.offset(face)), world, position, position.offset(face)); diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java index 25f32bb99..37253ceea 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java @@ -137,11 +137,11 @@ public abstract class ZapperItem extends Item { player.setActiveHand(hand); // Check if can be used - String msg = validateUsage(item); + ITextComponent msg = validateUsage(item); if (msg != null) { world.playSound(player, player.getPosition(), AllSoundEvents.BLOCKZAPPER_DENY.get(), SoundCategory.BLOCKS, 1f, 0.5f); - player.sendStatusMessage(new StringTextComponent(TextFormatting.RED + msg), true); + player.sendStatusMessage(msg.applyTextStyle(TextFormatting.RED), true); return new ActionResult(ActionResultType.FAIL, item); } @@ -192,10 +192,10 @@ public abstract class ZapperItem extends Item { return new ActionResult(ActionResultType.SUCCESS, item); } - public String validateUsage(ItemStack item) { + public ITextComponent validateUsage(ItemStack item) { CompoundNBT tag = item.getOrCreateTag(); if (!canActivateWithoutSelectedBlock(item) && !tag.contains("BlockUsed")) - return Lang.translate("blockzapper.leftClickToSet"); + return Lang.createTranslationTextComponent("blockzapper.leftClickToSet"); return null; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java index c5528de7d..bd0c520b6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java @@ -15,6 +15,7 @@ import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.item.ItemDescription.Palette; import com.simibubi.create.foundation.utility.BlockHelper; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; @@ -47,6 +48,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.BlockSnapshot; +import net.minecraftforge.common.util.Constants.BlockFlags; import net.minecraftforge.event.ForgeEventFactory; public class BlockzapperItem extends ZapperItem { @@ -92,6 +94,7 @@ public class BlockzapperItem extends ZapperItem { items.add(gunWithPurpurStuff); } + @Override protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState selectedState, BlockRayTraceResult raytrace) { CompoundNBT nbt = stack.getOrCreateTag(); @@ -119,13 +122,13 @@ public class BlockzapperItem extends ZapperItem { if (!player.isCreative() && replace) dropBlocks(world, player, stack, face, placed); - for (Direction updateDirection : Direction.values()) + for (Direction updateDirection : Iterate.directions) selectedState = selectedState.updatePostPlacement(updateDirection, world.getBlockState(placed.offset(updateDirection)), world, placed, placed.offset(updateDirection)); BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, placed); IFluidState ifluidstate = world.getFluidState(placed); - world.setBlockState(placed, ifluidstate.getBlockState(), 18); + world.setBlockState(placed, ifluidstate.getBlockState(), BlockFlags.UPDATE_NEIGHBORS); world.setBlockState(placed, selectedState); if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) { blocksnapshot.restore(true, false); diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java index 5a2117eb0..7c7b91e72 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -43,10 +44,10 @@ public class WorldshaperItem extends ZapperItem { } @Override - public String validateUsage(ItemStack item) { + public ITextComponent validateUsage(ItemStack item) { if (!item.getOrCreateTag() .contains("BrushParams")) - return Lang.translate("terrainzapper.shiftRightClickToSet"); + return Lang.createTranslationTextComponent("terrainzapper.shiftRightClickToSet"); return super.validateUsage(item); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index 943837c91..5b3bd9dbc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.VecHelper; @@ -32,7 +33,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer read(PacketBuffer buffer) { int i = buffer.readVarInt(); - return i == 0 ? Optional.empty() : Optional.of(Direction.values()[i - 1]); + return i == 0 ? Optional.empty() : Optional.of(Iterate.directions[i - 1]); } public Optional copyValue(Optional opt) { diff --git a/src/main/java/com/simibubi/create/foundation/item/PartialItemModelRenderer.java b/src/main/java/com/simibubi/create/foundation/item/PartialItemModelRenderer.java index 2478c6d34..bdfaf418a 100644 --- a/src/main/java/com/simibubi/create/foundation/item/PartialItemModelRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/item/PartialItemModelRenderer.java @@ -5,6 +5,7 @@ import java.util.Random; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.renderState.RenderTypes; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -81,7 +82,7 @@ public class PartialItemModelRenderer { Random random = new Random(); IModelData data = EmptyModelData.INSTANCE; - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { random.setSeed(42L); ir.renderBakedItemQuads(ms, p_229114_6_, model.getQuads((BlockState) null, direction, random, data), stack, light, overlay); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java index 972623a74..3c7c90323 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.RaycastHelper; import net.minecraft.block.Block; @@ -64,7 +65,7 @@ public class EdgeInteractionHandler { if (Block.hasSolidSide(world.getBlockState(pos.offset(face)), world, pos.offset(face), face.getOpposite())) return sides; - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { if (direction.getAxis() == face.getAxis()) continue; BlockPos neighbourPos = pos.offset(direction); diff --git a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java index 5849c8625..32923920b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -124,7 +124,7 @@ public class TreeCutter { leaves.add(currentPos); int distance = isLog ? 0 : blockState.get(LeavesBlock.DISTANCE); - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { BlockPos offset = currentPos.offset(direction); if (visited.contains(offset)) continue; @@ -182,7 +182,7 @@ public class TreeCutter { if (!lowerLayer && !pos.equals(currentPos.down()) && isLog(reader.getBlockState(currentPos.down()))) return false; - for (Direction direction : Direction.values()) { + for (Direction direction : Iterate.directions) { if (direction == Direction.DOWN) continue; if (direction == Direction.UP && !lowerLayer) diff --git a/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java b/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java index ad40422ef..3538923c3 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java @@ -36,7 +36,7 @@ public class VoxelShaper { } public static VoxelShaper forDirectional(VoxelShape shape, Direction facing){ - return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.values()), new DefaultRotationValues()); + return forDirectionsWithRotation(shape, facing, Arrays.asList(Iterate.directions), new DefaultRotationValues()); } public static VoxelShaper forAxis(VoxelShape shape, Axis along){ diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java index c7b975c9b..d3ec1fbd9 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java @@ -6,6 +6,7 @@ import java.util.Random; import com.simibubi.create.content.curiosities.tools.SandPaperItem; import com.simibubi.create.content.palettes.MetalBlock; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -54,7 +55,7 @@ public class OxidizingBlock extends MetalBlock { int currentState = state.get(OXIDIZATION); boolean canIncrease = false; LinkedList neighbors = new LinkedList<>(); - for (Direction facing : Direction.values()) { + for (Direction facing : Iterate.directions) { BlockPos neighbourPos = pos.offset(facing); if (!worldIn.isAreaLoaded(neighbourPos, 0)) continue;