use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class Contraption method addBlock.
protected void addBlock(BlockPos pos, Pair<StructureBlockInfo, BlockEntity> pair) {
StructureBlockInfo captured = pair.getKey();
BlockPos localPos = pos.subtract(anchor);
StructureBlockInfo StructureBlockInfo = new StructureBlockInfo(localPos, captured.state, captured.nbt);
if (blocks.put(localPos, StructureBlockInfo) != null)
return;
bounds = bounds.minmax(new AABB(localPos));
BlockEntity te = pair.getValue();
if (te != null && MountedStorage.canUseAsStorage(te))
storage.put(localPos, new MountedStorage(te));
if (te != null && MountedFluidStorage.canUseAsStorage(te))
fluidStorage.put(localPos, new MountedFluidStorage(te));
if (AllMovementBehaviours.contains(captured.state.getBlock()))
actors.add(MutablePair.of(StructureBlockInfo, null));
if (AllInteractionBehaviours.contains(captured.state.getBlock()))
interactors.put(localPos, AllInteractionBehaviours.of(captured.state.getBlock()));
if (te instanceof CreativeCrateTileEntity && ((CreativeCrateTileEntity) te).getBehaviour(FilteringBehaviour.TYPE).getFilter().isEmpty())
hasUniversalCreativeCrate = true;
}
use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class ContraptionCollider method isCollidingWithWorld.
public static boolean isCollidingWithWorld(Level world, TranslatingContraption contraption, BlockPos anchor, Direction movementDirection) {
for (BlockPos pos : contraption.getColliders(world, movementDirection)) {
BlockPos colliderPos = pos.offset(anchor);
if (!world.isLoaded(colliderPos))
return true;
BlockState collidedState = world.getBlockState(colliderPos);
StructureBlockInfo blockInfo = contraption.getBlocks().get(pos);
boolean emptyCollider = collidedState.getCollisionShape(world, pos).isEmpty();
if (collidedState.getBlock() instanceof CocoaBlock)
continue;
if (AllMovementBehaviours.contains(blockInfo.state.getBlock())) {
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state.getBlock());
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour;
if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
if (movementBehaviour instanceof HarvesterMovementBehaviour) {
HarvesterMovementBehaviour harvesterMovementBehaviour = (HarvesterMovementBehaviour) movementBehaviour;
if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState) && !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
}
if (AllBlocks.PULLEY_MAGNET.has(collidedState) && pos.equals(BlockPos.ZERO) && movementDirection == Direction.UP)
continue;
if (!collidedState.getMaterial().isReplaceable() && !emptyCollider) {
return true;
}
}
return false;
}
use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class AbstractContraptionEntity method tickActors.
public void tickActors() {
boolean stalledPreviously = contraption.stalled;
if (!level.isClientSide)
contraption.stalled = false;
ticking = true;
for (MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors()) {
MovementContext context = pair.right;
StructureBlockInfo blockInfo = pair.left;
MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state);
Vec3 oldMotion = context.motion;
Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos).add(actor.getActiveAreaOffset(context)), 1);
BlockPos gridPosition = new BlockPos(actorPosition);
boolean newPosVisited = !context.stall && shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition);
context.rotation = v -> applyRotation(v, 1);
context.position = actorPosition;
if (!actor.isActive(context))
continue;
if (newPosVisited && !context.stall) {
actor.visitNewPosition(context, gridPosition);
if (!isAlive())
break;
context.firstMovement = false;
}
if (!oldMotion.equals(context.motion)) {
actor.onSpeedChanged(context, oldMotion, context.motion);
if (!isAlive())
break;
}
actor.tick(context);
if (!isAlive())
break;
contraption.stalled |= context.stall;
}
if (!isAlive()) {
contraption.stop(level);
return;
}
ticking = false;
for (Entity entity : getPassengers()) {
if (!(entity instanceof OrientedContraptionEntity))
continue;
if (!contraption.stabilizedSubContraptions.containsKey(entity.getUUID()))
continue;
OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity;
if (orientedCE.contraption != null && orientedCE.contraption.stalled) {
contraption.stalled = true;
break;
}
}
if (!level.isClientSide) {
if (!stalledPreviously && contraption.stalled)
onContraptionStalled();
entityData.set(STALLED, contraption.stalled);
return;
}
contraption.stalled = isStalled();
}
Aggregations