Merge branch 'mc1.15/dev' of https://github.com/Creators-of-Create/Create into mc1.15/dev

This commit is contained in:
simibubi 2020-12-11 13:02:07 +01:00
commit 1433bcb4ef
47 changed files with 150 additions and 91 deletions

View file

@ -42,7 +42,7 @@ public class CreateClient {
public static SchematicHandler schematicHandler; public static SchematicHandler schematicHandler;
public static SchematicAndQuillHandler schematicAndQuillHandler; public static SchematicAndQuillHandler schematicAndQuillHandler;
public static SuperByteBufferCache bufferCache; public static SuperByteBufferCache bufferCache;
public static Outliner outliner; public static final Outliner outliner = new Outliner();
private static CustomBlockModels customBlockModels; private static CustomBlockModels customBlockModels;
private static CustomItemModels customItemModels; private static CustomItemModels customItemModels;
@ -62,7 +62,6 @@ public class CreateClient {
schematicSender = new ClientSchematicLoader(); schematicSender = new ClientSchematicLoader();
schematicHandler = new SchematicHandler(); schematicHandler = new SchematicHandler();
schematicAndQuillHandler = new SchematicAndQuillHandler(); schematicAndQuillHandler = new SchematicAndQuillHandler();
outliner = new Outliner();
bufferCache = new SuperByteBufferCache(); bufferCache = new SuperByteBufferCache();
bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);

View file

@ -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.encased.SplitShaftTileEntity;
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
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;
@ -431,7 +432,7 @@ public class RotationPropagator {
.isAreaLoaded(te.getPos(), 1)) .isAreaLoaded(te.getPos(), 1))
return neighbours; return neighbours;
for (Direction facing : Direction.values()) for (Direction facing : Iterate.directions)
neighbours.add(te.getPos() neighbours.add(te.getPos()
.offset(facing)); .offset(facing));

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
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.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -26,7 +28,7 @@ public abstract class DirectionalKineticBlock extends KineticBlock {
public Direction getPreferredFacing(BlockItemUseContext context) { public Direction getPreferredFacing(BlockItemUseContext context) {
Direction prefferedSide = null; Direction prefferedSide = null;
for (Direction side : Direction.values()) { for (Direction side : Iterate.directions) {
BlockState blockState = context.getWorld() BlockState blockState = context.getWorld()
.getBlockState(context.getPos() .getBlockState(context.getPos()
.offset(side)); .offset(side));

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
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.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -38,9 +40,7 @@ public abstract class HorizontalAxisKineticBlock extends KineticBlock {
public static Axis getPreferredHorizontalAxis(BlockItemUseContext context) { public static Axis getPreferredHorizontalAxis(BlockItemUseContext context) {
Direction prefferedSide = null; Direction prefferedSide = null;
for (Direction side : Direction.values()) { for (Direction side : Iterate.horizontalDirections) {
if (side.getAxis().isVertical())
continue;
BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side)); BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side));
if (blockState.getBlock() instanceof IRotate) { if (blockState.getBlock() instanceof IRotate) {
if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos().offset(side), if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos().offset(side),

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
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.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -40,7 +42,7 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock {
public static Axis getPreferredAxis(BlockItemUseContext context) { public static Axis getPreferredAxis(BlockItemUseContext context) {
Axis prefferedAxis = null; Axis prefferedAxis = null;
for (Direction side : Direction.values()) { for (Direction side : Iterate.directions) {
BlockState blockState = context.getWorld() BlockState blockState = context.getWorld()
.getBlockState(context.getPos() .getBlockState(context.getPos()
.offset(side)); .offset(side));

View file

@ -14,6 +14,7 @@ import java.util.stream.Collectors;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -74,7 +75,7 @@ public class ConnectedInputHandler {
positions.remove(pos); positions.remove(pos);
while (!frontier.isEmpty()) { while (!frontier.isEmpty()) {
BlockPos current = frontier.remove(0); BlockPos current = frontier.remove(0);
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
BlockPos next = current.offset(direction); BlockPos next = current.offset(direction);
if (!positions.remove(next)) if (!positions.remove(next))
continue; continue;

View file

@ -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.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.AngleHelper; 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.Pointing;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -109,7 +110,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
crafter.ejectWholeGrid(); crafter.ejectWholeGrid();
} }
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
if (direction.getAxis() == state.get(HORIZONTAL_FACING) if (direction.getAxis() == state.get(HORIZONTAL_FACING)
.getAxis()) .getAxis())
continue; continue;

View file

@ -16,6 +16,7 @@ import com.google.common.base.Predicates;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.Pointing;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -109,7 +110,7 @@ public class RecipeGridHandler {
Direction blockFacing = blockState.get(HORIZONTAL_FACING); Direction blockFacing = blockState.get(HORIZONTAL_FACING);
Direction blockPointing = MechanicalCrafterBlock.getTargetDirection(blockState); Direction blockPointing = MechanicalCrafterBlock.getTargetDirection(blockState);
for (Direction facing : Direction.values()) { for (Direction facing : Iterate.directions) {
if (blockFacing.getAxis() == facing.getAxis()) if (blockFacing.getAxis() == facing.getAxis())
continue; continue;
if (blockPointing == facing) if (blockPointing == facing)

View file

@ -7,6 +7,7 @@ import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -52,9 +53,8 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
@Override @Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
for (Direction d : Direction.values()) { for (Direction d : Iterate.horizontalDirections) {
if (d.getAxis() == state.get(AXIS) || d.getAxis() if (d.getAxis() == state.get(AXIS))
.isVertical())
continue; continue;
if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(worldIn.getBlockState(pos.offset(d)))) if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(worldIn.getBlockState(pos.offset(d))))
worldIn.setBlockState(pos.offset(d), Blocks.AIR.getDefaultState()); worldIn.setBlockState(pos.offset(d), Blocks.AIR.getDefaultState());
@ -153,7 +153,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
@Override @Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
BlockPos neighbourPos = pos.offset(direction); BlockPos neighbourPos = pos.offset(direction);
BlockState neighbourState = worldIn.getBlockState(neighbourPos); BlockState neighbourState = worldIn.getBlockState(neighbourPos);
Axis stateAxis = state.get(AXIS); Axis stateAxis = state.get(AXIS);

View file

@ -7,6 +7,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.item.ItemHelper;
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;
@ -127,9 +128,7 @@ public class CrushingWheelControllerBlock extends Block
return; return;
} }
for (Direction d : Direction.values()) { for (Direction d : Iterate.horizontalDirections) {
if (d.getAxis().isVertical())
continue;
BlockState neighbour = world.getBlockState(pos.offset(d)); BlockState neighbour = world.getBlockState(pos.offset(d));
if (!AllBlocks.CRUSHING_WHEEL.has(neighbour)) if (!AllBlocks.CRUSHING_WHEEL.has(neighbour))
continue; continue;

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.components.crusher; package com.simibubi.create.content.contraptions.components.crusher;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
@ -29,7 +30,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity {
} }
public void fixControllers() { public void fixControllers() {
for (Direction d : Direction.values()) for (Direction d : Iterate.directions)
((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getWorld(), getPos(), ((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getWorld(), getPos(),
d); d);
} }

View file

@ -4,6 +4,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.contraptions.wrench.IWrenchable;
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;
@ -75,9 +76,7 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable
BlockPos baseBlockPos = getBaseBlockPos(state, pos); BlockPos baseBlockPos = getBaseBlockPos(state, pos);
if (!isValidBaseBlock(world.getBlockState(baseBlockPos), world, pos)) if (!isValidBaseBlock(world.getBlockState(baseBlockPos), world, pos))
return false; return false;
for (Direction otherFacing : Direction.values()) { for (Direction otherFacing : Iterate.horizontalDirections) {
if (otherFacing.getAxis().isVertical())
continue;
if (otherFacing == facing) if (otherFacing == facing)
continue; continue;
BlockPos otherPos = baseBlockPos.offset(otherFacing); BlockPos otherPos = baseBlockPos.offset(otherFacing);

View file

@ -296,7 +296,7 @@ public abstract class Contraption {
// Slime blocks and super glue drag adjacent blocks if possible // Slime blocks and super glue drag adjacent blocks if possible
boolean isSlimeBlock = state.getBlock() instanceof SlimeBlock; boolean isSlimeBlock = state.getBlock() instanceof SlimeBlock;
for (Direction offset : Direction.values()) { for (Direction offset : Iterate.directions) {
BlockPos offsetPos = pos.offset(offset); BlockPos offsetPos = pos.offset(offset);
BlockState blockState = world.getBlockState(offsetPos); BlockState blockState = world.getBlockState(offsetPos);
if (isAnchoringBlockAt(offsetPos)) if (isAnchoringBlockAt(offsetPos))
@ -755,7 +755,7 @@ public abstract class Contraption {
continue; continue;
if (nonBrittles) if (nonBrittles)
for (Direction face : Direction.values()) for (Direction face : Iterate.directions)
state = state.updatePostPlacement(face, world.getBlockState(targetPos.offset(face)), world, state = state.updatePostPlacement(face, world.getBlockState(targetPos.offset(face)), world,
targetPos, targetPos.offset(face)); targetPos, targetPos.offset(face));

View file

@ -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.BeltBlock;
import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope;
import com.simibubi.create.foundation.utility.DirectionHelper; import com.simibubi.create.foundation.utility.DirectionHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BellBlock; import net.minecraft.block.BellBlock;
@ -310,13 +311,13 @@ public class StructureTransform {
BlockState rotated = state.with(AXIS, transformAxis(state.get(AXIS))); BlockState rotated = state.with(AXIS, transformAxis(state.get(AXIS)));
AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock();
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = block.getGlueableSide(rotated, face); BooleanProperty glueableSide = block.getGlueableSide(rotated, face);
if (glueableSide != null) if (glueableSide != null)
rotated = rotated.with(glueableSide, false); rotated = rotated.with(glueableSide, false);
} }
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = block.getGlueableSide(state, face); BooleanProperty glueableSide = block.getGlueableSide(state, face);
if (glueableSide == null || !state.get(glueableSide)) if (glueableSide == null || !state.get(glueableSide))
continue; continue;

View file

@ -7,6 +7,7 @@ import java.util.Set;
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 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;
@ -38,6 +39,15 @@ public abstract class TranslatingContraption extends Contraption {
return cachedColliders; return cachedColliders;
} }
@Override
public void removeBlocksFromWorld(IWorld world, BlockPos offset) {
int count = blocks.size();
super.removeBlocksFromWorld(world, offset);
if (count != blocks.size()) {
cachedColliders = null;
}
}
@Override @Override
protected boolean canAxisBeStabilized(Axis axis) { protected boolean canAxisBeStabilized(Axis axis) {
return false; return false;

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.RotatedPillarBlock; import net.minecraft.block.RotatedPillarBlock;
@ -56,7 +57,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
return ActionResultType.PASS; return ActionResultType.PASS;
if (isSlimeBall && state.get(affectedSide)) { if (isSlimeBall && state.get(affectedSide)) {
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = getGlueableSide(state, face); BooleanProperty glueableSide = getGlueableSide(state, face);
if (glueableSide != null && !state.get(glueableSide)) { if (glueableSide != null && !state.get(glueableSide)) {
if (worldIn.isRemote) { if (worldIn.isRemote) {
@ -95,13 +96,13 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
return state; return state;
BlockState rotated = super.rotate(state, rotation); BlockState rotated = super.rotate(state, rotation);
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = getGlueableSide(rotated, face); BooleanProperty glueableSide = getGlueableSide(rotated, face);
if (glueableSide != null) if (glueableSide != null)
rotated = rotated.with(glueableSide, false); rotated = rotated.with(glueableSide, false);
} }
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = getGlueableSide(state, face); BooleanProperty glueableSide = getGlueableSide(state, face);
if (glueableSide == null || !state.get(glueableSide)) if (glueableSide == null || !state.get(glueableSide))
continue; continue;
@ -120,13 +121,13 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
return state; return state;
BlockState mirrored = state; BlockState mirrored = state;
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = getGlueableSide(mirrored, face); BooleanProperty glueableSide = getGlueableSide(mirrored, face);
if (glueableSide != null) if (glueableSide != null)
mirrored = mirrored.with(glueableSide, false); mirrored = mirrored.with(glueableSide, false);
} }
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
BooleanProperty glueableSide = getGlueableSide(state, face); BooleanProperty glueableSide = getGlueableSide(state, face);
if (glueableSide == null || !state.get(glueableSide)) if (glueableSide == null || !state.get(glueableSide))
continue; continue;

View file

@ -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.CenteredSideValueBoxTransform;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
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;
@ -122,7 +123,7 @@ public class ChassisTileEntity extends SmartTileEntity {
} }
// Collect group of connected linear chassis // Collect group of connected linear chassis
for (Direction offset : Direction.values()) { for (Direction offset : Iterate.directions) {
if (offset.getAxis() == axis) if (offset.getAxis() == axis)
continue; continue;
BlockPos current = pos.offset(offset); BlockPos current = pos.offset(offset);
@ -187,7 +188,7 @@ public class ChassisTileEntity extends SmartTileEntity {
AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock();
int chassisRange = visualize ? range.scrollableValue : getRange(); int chassisRange = visualize ? range.scrollableValue : getRange();
for (Direction facing : Direction.values()) { for (Direction facing : Iterate.directions) {
if (facing.getAxis() == axis) if (facing.getAxis() == axis)
continue; continue;
if (!state.get(block.getGlueableSide(state, facing))) if (!state.get(block.getGlueableSide(state, facing)))
@ -215,7 +216,7 @@ public class ChassisTileEntity extends SmartTileEntity {
if (!searchPos.equals(pos)) if (!searchPos.equals(pos))
positions.add(searchPos); positions.add(searchPos);
for (Direction offset : Direction.values()) { for (Direction offset : Iterate.directions) {
if (offset.getAxis() == axis) if (offset.getAxis() == axis)
continue; continue;
if (searchPos.equals(pos) && offset != facing) if (searchPos.equals(pos) && offset != facing)

View file

@ -81,8 +81,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
world.setBlockState(offset, Blocks.AIR.getDefaultState(), 66); world.setBlockState(offset, Blocks.AIR.getDefaultState(), 66);
} }
if (contraption != null && !contraption.getBlocks() if (!contraption.getBlocks().isEmpty()) {
.isEmpty()) {
contraption.removeBlocksFromWorld(world, BlockPos.ZERO); contraption.removeBlocksFromWorld(world, BlockPos.ZERO);
movedContraption = ControlledContraptionEntity.create(world, this, contraption); movedContraption = ControlledContraptionEntity.create(world, this, contraption);
movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());

View file

@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockRenderType;
@ -44,7 +45,7 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
@Override @Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
BlockPos neighbourPos = pos.offset(direction); BlockPos neighbourPos = pos.offset(direction);
BlockState neighbourState = worldIn.getBlockState(neighbourPos); BlockState neighbourState = worldIn.getBlockState(neighbourPos);
if (!AllBlocks.WATER_WHEEL.has(neighbourState)) if (!AllBlocks.WATER_WHEEL.has(neighbourState))
@ -77,7 +78,7 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
} }
public void updateAllSides(BlockState state, World worldIn, BlockPos pos) { public void updateAllSides(BlockState state, World worldIn, BlockPos pos) {
for (Direction d : Direction.values()) for (Direction d : Iterate.directions)
updateFlowAt(state, worldIn, pos, d); updateFlowAt(state, worldIn, pos, d);
updateWheelSpeed(worldIn, pos); updateWheelSpeed(worldIn, pos);
} }

View file

@ -6,6 +6,7 @@ import java.util.Map;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
@ -19,7 +20,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity {
public WaterWheelTileEntity(TileEntityType<? extends WaterWheelTileEntity> type) { public WaterWheelTileEntity(TileEntityType<? extends WaterWheelTileEntity> type) {
super(type); super(type);
flows = new HashMap<>(); flows = new HashMap<>();
for (Direction d : Direction.values()) for (Direction d : Iterate.directions)
setFlow(d, 0); setFlow(d, 0);
setLazyTickRate(20); setLazyTickRate(20);
} }
@ -28,7 +29,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity {
protected void read(CompoundNBT compound, boolean clientPacket) { protected void read(CompoundNBT compound, boolean clientPacket) {
super.read(compound, clientPacket); super.read(compound, clientPacket);
if (compound.contains("Flows")) { if (compound.contains("Flows")) {
for (Direction d : Direction.values()) for (Direction d : Iterate.directions)
setFlow(d, compound.getCompound("Flows") setFlow(d, compound.getCompound("Flows")
.getFloat(d.getName())); .getFloat(d.getName()));
} }
@ -42,7 +43,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity {
@Override @Override
public void write(CompoundNBT compound, boolean clientPacket) { public void write(CompoundNBT compound, boolean clientPacket) {
CompoundNBT flows = new CompoundNBT(); CompoundNBT flows = new CompoundNBT();
for (Direction d : Direction.values()) for (Direction d : Iterate.directions)
flows.putFloat(d.getName(), this.flows.get(d)); flows.putFloat(d.getName(), this.flows.get(d));
compound.put("Flows", flows); compound.put("Flows", flows);

View file

@ -3,13 +3,18 @@ package com.simibubi.create.content.contraptions.goggles;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock; import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonPolePlacementHelper; 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.tileEntity.behaviour.ValueBox;
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 com.simibubi.create.foundation.utility.outliner.Outline;
import com.simibubi.create.foundation.utility.outliner.Outliner.OutlineEntry;
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;
@ -30,12 +35,15 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import static com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation.spacing; import static com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation.spacing;
@EventBusSubscriber(value = Dist.CLIENT) @EventBusSubscriber(value = Dist.CLIENT)
public class GoggleOverlayRenderer { public class GoggleOverlayRenderer {
private static final Map<Object, OutlineEntry> outlines = CreateClient.outliner.getOutlines();
@SubscribeEvent @SubscribeEvent
public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) {
if (event.getType() != ElementType.HOTBAR) if (event.getType() != ElementType.HOTBAR)
@ -45,6 +53,15 @@ public class GoggleOverlayRenderer {
if (!(objectMouseOver instanceof BlockRayTraceResult)) if (!(objectMouseOver instanceof BlockRayTraceResult))
return; return;
for (OutlineEntry entry : outlines.values()) {
if (!entry.isAlive())
continue;
Outline outline = entry.getOutline();
if (outline instanceof ValueBox && !((ValueBox) outline).isPassive) {
return;
}
}
BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver;
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
ClientWorld world = mc.world; ClientWorld world = mc.world;

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock;
import 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;
@ -55,7 +56,7 @@ public class CogWheelBlock extends AbstractShaftBlock {
@Override @Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { 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)) if (facing.getAxis() == state.get(AXIS))
continue; continue;

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
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.Block; import net.minecraft.block.Block;
@ -62,7 +63,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock {
axis = placedAxis; axis = placedAxis;
BlockState state = getDefaultState().with(AXIS, axis); BlockState state = getDefaultState().with(AXIS, axis);
for (Direction facing : Direction.values()) { for (Direction facing : Iterate.directions) {
if (facing.getAxis() == axis) if (facing.getAxis() == axis)
continue; continue;
BlockPos pos = context.getPos(); BlockPos pos = context.getPos();
@ -130,7 +131,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock {
.updateNeighbors(context.getWorld(), context.getPos(), 1); .updateNeighbors(context.getWorld(), context.getPos(), 1);
Axis axis = newState.get(AXIS); Axis axis = newState.get(AXIS);
newState = getDefaultState().with(AXIS, axis); newState = getDefaultState().with(AXIS, axis);
for (Direction facing : Direction.values()) { for (Direction facing : Iterate.directions) {
if (facing.getAxis() == axis) if (facing.getAxis() == axis)
continue; continue;
BlockPos pos = context.getPos(); BlockPos pos = context.getPos();

View file

@ -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.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -30,7 +31,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
final BlockPos pos = te.getPos(); final BlockPos pos = te.getPos();
float time = AnimationTickHolder.getRenderTick(); float time = AnimationTickHolder.getRenderTick();
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
Axis axis = direction.getAxis(); Axis axis = direction.getAxis();
if (boxAxis != axis) if (boxAxis != axis)
continue; continue;

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.foundation.utility.ColorHelper; 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.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
@ -143,7 +144,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
return; return;
int color = gaugeTE.color; int color = gaugeTE.color;
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face)) if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face))
continue; continue;

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type; 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 com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -46,7 +47,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
.renderOn(gaugeState); .renderOn(gaugeState);
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.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, if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState,
facing)) facing))
continue; continue;

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -28,7 +29,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
final BlockPos pos = te.getPos(); final BlockPos pos = te.getPos();
float time = AnimationTickHolder.getRenderTick(); float time = AnimationTickHolder.getRenderTick();
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
final Axis axis = direction.getAxis(); final Axis axis = direction.getAxis();
if (boxAxis == axis) if (boxAxis == axis)
continue; continue;

View file

@ -4,6 +4,7 @@ import java.util.Map;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.IRotate;
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;
@ -41,10 +42,7 @@ public class VerticalGearboxItem extends BlockItem {
@Override @Override
protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity player, ItemStack stack, BlockState state) { protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity player, ItemStack stack, BlockState state) {
Axis prefferedAxis = null; Axis prefferedAxis = null;
for (Direction side : Direction.values()) { for (Direction side : Iterate.horizontalDirections) {
if (side.getAxis()
.isVertical())
continue;
BlockState blockState = world.getBlockState(pos.offset(side)); BlockState blockState = world.getBlockState(pos.offset(side));
if (blockState.getBlock() instanceof IRotate) { if (blockState.getBlock() instanceof IRotate) {
if (((IRotate) blockState.getBlock()).hasShaftTowards(world, pos.offset(side), blockState, if (((IRotate) blockState.getBlock()).hasShaftTowards(world, pos.offset(side), blockState,

View file

@ -15,6 +15,7 @@ import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
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;
@ -207,7 +208,7 @@ public class SymmetryWandItem extends Item {
if (world.canPlace(block, position, ISelectionContext.forEntity(player))) { if (world.canPlace(block, position, ISelectionContext.forEntity(player))) {
BlockState blockState = blockSet.get(position); 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, blockState = blockState.updatePostPlacement(face, world.getBlockState(position.offset(face)), world,
position, position.offset(face)); position, position.offset(face));

View file

@ -137,11 +137,11 @@ public abstract class ZapperItem extends Item {
player.setActiveHand(hand); player.setActiveHand(hand);
// Check if can be used // Check if can be used
String msg = validateUsage(item); ITextComponent msg = validateUsage(item);
if (msg != null) { if (msg != null) {
world.playSound(player, player.getPosition(), AllSoundEvents.BLOCKZAPPER_DENY.get(), SoundCategory.BLOCKS, world.playSound(player, player.getPosition(), AllSoundEvents.BLOCKZAPPER_DENY.get(), SoundCategory.BLOCKS,
1f, 0.5f); 1f, 0.5f);
player.sendStatusMessage(new StringTextComponent(TextFormatting.RED + msg), true); player.sendStatusMessage(msg.applyTextStyle(TextFormatting.RED), true);
return new ActionResult<ItemStack>(ActionResultType.FAIL, item); return new ActionResult<ItemStack>(ActionResultType.FAIL, item);
} }
@ -192,10 +192,10 @@ public abstract class ZapperItem extends Item {
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, item); return new ActionResult<ItemStack>(ActionResultType.SUCCESS, item);
} }
public String validateUsage(ItemStack item) { public ITextComponent validateUsage(ItemStack item) {
CompoundNBT tag = item.getOrCreateTag(); CompoundNBT tag = item.getOrCreateTag();
if (!canActivateWithoutSelectedBlock(item) && !tag.contains("BlockUsed")) if (!canActivateWithoutSelectedBlock(item) && !tag.contains("BlockUsed"))
return Lang.translate("blockzapper.leftClickToSet"); return Lang.createTranslationTextComponent("blockzapper.leftClickToSet");
return null; return null;
} }

View file

@ -15,12 +15,14 @@ import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.item.ItemDescription.Palette; import com.simibubi.create.foundation.item.ItemDescription.Palette;
import com.simibubi.create.foundation.utility.BlockHelper; 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.Lang;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneLampBlock;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -47,6 +49,7 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.Constants.BlockFlags;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
public class BlockzapperItem extends ZapperItem { public class BlockzapperItem extends ZapperItem {
@ -92,6 +95,7 @@ public class BlockzapperItem extends ZapperItem {
items.add(gunWithPurpurStuff); items.add(gunWithPurpurStuff);
} }
@Override
protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState selectedState, protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState selectedState,
BlockRayTraceResult raytrace) { BlockRayTraceResult raytrace) {
CompoundNBT nbt = stack.getOrCreateTag(); CompoundNBT nbt = stack.getOrCreateTag();
@ -119,14 +123,15 @@ public class BlockzapperItem extends ZapperItem {
if (!player.isCreative() && replace) if (!player.isCreative() && replace)
dropBlocks(world, player, stack, face, placed); dropBlocks(world, player, stack, face, placed);
for (Direction updateDirection : Direction.values()) BlockState state = selectedState;
selectedState = selectedState.updatePostPlacement(updateDirection, for (Direction updateDirection : Iterate.directions)
state = state.updatePostPlacement(updateDirection,
world.getBlockState(placed.offset(updateDirection)), world, placed, placed.offset(updateDirection)); world.getBlockState(placed.offset(updateDirection)), world, placed, placed.offset(updateDirection));
BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, placed); BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, placed);
IFluidState ifluidstate = world.getFluidState(placed); IFluidState ifluidstate = world.getFluidState(placed);
world.setBlockState(placed, ifluidstate.getBlockState(), 18); world.setBlockState(placed, ifluidstate.getBlockState(), BlockFlags.UPDATE_NEIGHBORS);
world.setBlockState(placed, selectedState); world.setBlockState(placed, state);
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) { if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) {
blocksnapshot.restore(true, false); blocksnapshot.restore(true, false);
return false; return false;
@ -134,7 +139,7 @@ public class BlockzapperItem extends ZapperItem {
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) { if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player; ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
CriteriaTriggers.PLACED_BLOCK.trigger(serverPlayer, placed, new ItemStack(selectedState.getBlock())); CriteriaTriggers.PLACED_BLOCK.trigger(serverPlayer, placed, new ItemStack(state.getBlock()));
boolean fullyUpgraded = true; boolean fullyUpgraded = true;
for (Components c : Components.values()) { for (Components c : Components.values()) {
@ -147,6 +152,9 @@ public class BlockzapperItem extends ZapperItem {
AllTriggers.UPGRADED_ZAPPER.trigger(serverPlayer); AllTriggers.UPGRADED_ZAPPER.trigger(serverPlayer);
} }
} }
for (BlockPos placed : selectedBlocks) {
world.neighborChanged(placed, selectedState.getBlock(), placed);
}
return true; return true;
} }

View file

@ -16,6 +16,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
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.text.ITextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -43,10 +44,10 @@ public class WorldshaperItem extends ZapperItem {
} }
@Override @Override
public String validateUsage(ItemStack item) { public ITextComponent validateUsage(ItemStack item) {
if (!item.getOrCreateTag() if (!item.getOrCreateTag()
.contains("BrushParams")) .contains("BrushParams"))
return Lang.translate("terrainzapper.shiftRightClickToSet"); return Lang.createTranslationTextComponent("terrainzapper.shiftRightClickToSet");
return super.validateUsage(item); return super.validateUsage(item);
} }

View file

@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; 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.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -32,7 +33,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
Vec3d pivot = VecHelper.voxelSpace(0, 10, 1f); Vec3d pivot = VecHelper.voxelSpace(0, 10, 1f);
MatrixStacker msr = MatrixStacker.of(ms); MatrixStacker msr = MatrixStacker.of(ms);
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
if (!te.flaps.containsKey(direction)) if (!te.flaps.containsKey(direction))
continue; continue;

View file

@ -109,10 +109,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
public void updateTunnelConnections() { public void updateTunnelConnections() {
flaps.clear(); flaps.clear();
BlockState tunnelState = getBlockState(); BlockState tunnelState = getBlockState();
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.horizontalDirections) {
if (direction.getAxis()
.isVertical())
continue;
BlockState blockState = world.getBlockState(pos.offset(direction)); BlockState blockState = world.getBlockState(pos.offset(direction));
if (blockState.getBlock() instanceof BeltTunnelBlock) if (blockState.getBlock() instanceof BeltTunnelBlock)
continue; continue;

View file

@ -3,6 +3,8 @@ 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 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.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -62,7 +64,7 @@ public class CrateBlock extends ProperDirectionalBlock implements IWrenchable {
if (context.getPlayer() == null || !context.getPlayer() if (context.getPlayer() == null || !context.getPlayer()
.isSneaking()) { .isSneaking()) {
for (Direction d : Direction.values()) { for (Direction d : Iterate.directions) {
BlockState state = world.getBlockState(pos.offset(d)); BlockState state = world.getBlockState(pos.offset(d));
if (state.getBlock() == this && !state.get(DOUBLE)) if (state.getBlock() == this && !state.get(DOUBLE))
return getDefaultState().with(FACING, d) return getDefaultState().with(FACING, d)

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
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;
@ -115,11 +116,7 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE<Stockpi
BlockState state = getDefaultState(); BlockState state = getDefaultState();
Direction preferredFacing = null; Direction preferredFacing = null;
for (Direction face : Direction.values()) { for (Direction face : Iterate.horizontalDirections) {
if (face.getAxis()
.isVertical())
continue;
TileEntity te = context.getWorld() TileEntity te = context.getWorld()
.getTileEntity(context.getPos() .getTileEntity(context.getPos()
.offset(face)); .offset(face));

View file

@ -327,15 +327,15 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
} }
if (hoveredSlot != null && !hoveredSlot.getHasStack()) { if (hoveredSlot != null && !hoveredSlot.getHasStack()) {
if (hoveredSlot.getSlotIndex() == 0) if (hoveredSlot.slotNumber == 0)
renderTooltip( renderTooltip(
TooltipHelper.cutString(Lang.translate(_slotSchematic), TextFormatting.GRAY, TextFormatting.BLUE), TooltipHelper.cutString(Lang.translate(_slotSchematic), TextFormatting.GRAY, TextFormatting.BLUE),
mouseX, mouseY); mouseX, mouseY);
if (hoveredSlot.getSlotIndex() == 2) if (hoveredSlot.slotNumber == 2)
renderTooltip( renderTooltip(
TooltipHelper.cutString(Lang.translate(_slotListPrinter), TextFormatting.GRAY, TextFormatting.BLUE), TooltipHelper.cutString(Lang.translate(_slotListPrinter), TextFormatting.GRAY, TextFormatting.BLUE),
mouseX, mouseY); mouseX, mouseY);
if (hoveredSlot.getSlotIndex() == 4) if (hoveredSlot.slotNumber == 4)
renderTooltip( renderTooltip(
TooltipHelper.cutString(Lang.translate(_slotGunpowder), TextFormatting.GRAY, TextFormatting.BLUE), TooltipHelper.cutString(Lang.translate(_slotGunpowder), TextFormatting.GRAY, TextFormatting.BLUE),
mouseX, mouseY); mouseX, mouseY);

View file

@ -23,6 +23,7 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
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.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -143,7 +144,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
public void findInventories() { public void findInventories() {
hasCreativeCrate = false; hasCreativeCrate = false;
attachedInventories.clear(); attachedInventories.clear();
for (Direction facing : Direction.values()) { for (Direction facing : Iterate.directions) {
if (!world.isBlockPresent(pos.offset(facing))) if (!world.isBlockPresent(pos.offset(facing)))
continue; continue;

View file

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext;
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;
@ -54,7 +55,7 @@ public class CTModel extends BakedModelWrapperWithData {
protected CTData createCTData(ILightReader world, BlockPos pos, BlockState state) { protected CTData createCTData(ILightReader world, BlockPos pos, BlockState state) {
CTData data = new CTData(); CTData data = new CTData();
for (Direction face : Direction.values()) { for (Direction face : Iterate.directions) {
if (!Block.shouldSideBeRendered(state, world, pos, face) && !behaviour.buildContextForOccludedDirections()) if (!Block.shouldSideBeRendered(state, world, pos, face) && !behaviour.buildContextForOccludedDirections())
continue; continue;
CTSpriteShiftEntry spriteShift = behaviour.get(state, face); CTSpriteShiftEntry spriteShift = behaviour.get(state, face);

View file

@ -2,6 +2,8 @@ package com.simibubi.create.foundation.entity;
import java.util.Optional; import java.util.Optional;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.IDataSerializer; import net.minecraft.network.datasync.IDataSerializer;
@ -19,7 +21,7 @@ public class CreateDataSerializers {
public Optional<Direction> read(PacketBuffer buffer) { public Optional<Direction> read(PacketBuffer buffer) {
int i = buffer.readVarInt(); 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<Direction> copyValue(Optional<Direction> opt) { public Optional<Direction> copyValue(Optional<Direction> opt) {

View file

@ -5,6 +5,7 @@ import java.util.Random;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.foundation.renderState.RenderTypes; import com.simibubi.create.foundation.renderState.RenderTypes;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -81,7 +82,7 @@ public class PartialItemModelRenderer {
Random random = new Random(); Random random = new Random();
IModelData data = EmptyModelData.INSTANCE; IModelData data = EmptyModelData.INSTANCE;
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
random.setSeed(42L); random.setSeed(42L);
ir.renderBakedItemQuads(ms, p_229114_6_, model.getQuads((BlockState) null, direction, random, data), stack, ir.renderBakedItemQuads(ms, p_229114_6_, model.getQuads((BlockState) null, direction, random, data), stack,
light, overlay); light, overlay);

View file

@ -28,7 +28,7 @@ public class ValueBox extends ChasingAABBOutline {
protected int passiveColor; protected int passiveColor;
protected int highlightColor; protected int highlightColor;
protected boolean isPassive; public boolean isPassive;
protected BlockPos pos; protected BlockPos pos;
protected ValueBoxTransform transform; protected ValueBoxTransform transform;

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper;
import net.minecraft.block.Block; 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())) if (Block.hasSolidSide(world.getBlockState(pos.offset(face)), world, pos.offset(face), face.getOpposite()))
return sides; return sides;
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
if (direction.getAxis() == face.getAxis()) if (direction.getAxis() == face.getAxis())
continue; continue;
BlockPos neighbourPos = pos.offset(direction); BlockPos neighbourPos = pos.offset(direction);

View file

@ -124,7 +124,7 @@ public class TreeCutter {
leaves.add(currentPos); leaves.add(currentPos);
int distance = isLog ? 0 : blockState.get(LeavesBlock.DISTANCE); int distance = isLog ? 0 : blockState.get(LeavesBlock.DISTANCE);
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
BlockPos offset = currentPos.offset(direction); BlockPos offset = currentPos.offset(direction);
if (visited.contains(offset)) if (visited.contains(offset))
continue; continue;
@ -182,7 +182,7 @@ public class TreeCutter {
if (!lowerLayer && !pos.equals(currentPos.down()) && isLog(reader.getBlockState(currentPos.down()))) if (!lowerLayer && !pos.equals(currentPos.down()) && isLog(reader.getBlockState(currentPos.down())))
return false; return false;
for (Direction direction : Direction.values()) { for (Direction direction : Iterate.directions) {
if (direction == Direction.DOWN) if (direction == Direction.DOWN)
continue; continue;
if (direction == Direction.UP && !lowerLayer) if (direction == Direction.UP && !lowerLayer)

View file

@ -36,7 +36,7 @@ public class VoxelShaper {
} }
public static VoxelShaper forDirectional(VoxelShape shape, Direction facing){ 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){ public static VoxelShaper forAxis(VoxelShape shape, Axis along){

View file

@ -21,7 +21,11 @@ import net.minecraft.util.math.Vec3d;
public class Outliner { public class Outliner {
Map<Object, OutlineEntry> outlines; final Map<Object, OutlineEntry> outlines;
public Map<Object, OutlineEntry> getOutlines() {
return Collections.unmodifiableMap(outlines);
}
// Facade // Facade
@ -136,7 +140,7 @@ public class Outliner {
if (entry.ticksTillRemoval < 0) { if (entry.ticksTillRemoval < 0) {
int prevTicks = entry.ticksTillRemoval + 1; int prevTicks = entry.ticksTillRemoval + 1;
float fadeticks = (float) OutlineEntry.fadeTicks; float fadeticks = OutlineEntry.fadeTicks;
float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks); float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks);
float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks); float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks);
float alpha = MathHelper.lerp(Minecraft.getInstance() float alpha = MathHelper.lerp(Minecraft.getInstance()
@ -150,7 +154,7 @@ public class Outliner {
}); });
} }
private class OutlineEntry { public static class OutlineEntry {
static final int fadeTicks = 8; static final int fadeTicks = 8;
private Outline outline; private Outline outline;

View file

@ -6,6 +6,7 @@ import java.util.Random;
import com.simibubi.create.content.curiosities.tools.SandPaperItem; import com.simibubi.create.content.curiosities.tools.SandPaperItem;
import com.simibubi.create.content.palettes.MetalBlock; import com.simibubi.create.content.palettes.MetalBlock;
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;
@ -54,7 +55,7 @@ public class OxidizingBlock extends MetalBlock {
int currentState = state.get(OXIDIZATION); int currentState = state.get(OXIDIZATION);
boolean canIncrease = false; boolean canIncrease = false;
LinkedList<Integer> neighbors = new LinkedList<>(); LinkedList<Integer> neighbors = new LinkedList<>();
for (Direction facing : Direction.values()) { for (Direction facing : Iterate.directions) {
BlockPos neighbourPos = pos.offset(facing); BlockPos neighbourPos = pos.offset(facing);
if (!worldIn.isAreaLoaded(neighbourPos, 0)) if (!worldIn.isAreaLoaded(neighbourPos, 0))
continue; continue;