use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class MountedContraption method capture.
@Override
protected Pair<StructureBlockInfo, BlockEntity> capture(Level world, BlockPos pos) {
Pair<StructureBlockInfo, BlockEntity> pair = super.capture(world, pos);
StructureBlockInfo capture = pair.getKey();
if (!AllBlocks.CART_ASSEMBLER.has(capture.state))
return pair;
Pair<StructureBlockInfo, BlockEntity> anchorSwap = Pair.of(new StructureBlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state), null), pair.getValue());
if (pos.equals(anchor) || connectedCart != null)
return anchorSwap;
for (Axis axis : Iterate.axes) {
if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis))
continue;
for (AbstractMinecart abstractMinecartEntity : world.getEntitiesOfClass(AbstractMinecart.class, new AABB(pos))) {
if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity))
break;
connectedCart = abstractMinecartEntity;
connectedCart.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5f);
}
}
return anchorSwap;
}
use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class MountedContraption method assemble.
@Override
public boolean assemble(Level world, BlockPos pos) throws AssemblyException {
BlockState state = world.getBlockState(pos);
if (!state.hasProperty(RAIL_SHAPE))
return false;
if (!searchMovedStructure(world, pos, null))
return false;
Axis axis = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z;
addBlock(pos, Pair.of(new StructureBlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState().setValue(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null));
if (blocks.size() == 1)
return false;
return true;
}
use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class SimpleBlockMovingInteraction method handlePlayerInteraction.
@Override
public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos, AbstractContraptionEntity contraptionEntity) {
Contraption contraption = contraptionEntity.getContraption();
StructureBlockInfo info = contraption.getBlocks().get(localPos);
BlockState newState = handle(player, contraption, localPos, info.state);
if (info.state == newState)
return false;
setContraptionBlockData(contraptionEntity, localPos, new StructureBlockInfo(info.pos, newState, info.nbt));
if (updateColliders())
contraption.invalidateColliders();
return true;
}
use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class ContraptionInstanceManager method createActor.
@Nullable
public ActorInstance createActor(Pair<StructureBlockInfo, MovementContext> actor) {
StructureBlockInfo blockInfo = actor.getLeft();
MovementContext context = actor.getRight();
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) {
ActorInstance instance = movementBehaviour.createInstance(materialManager, renderWorld, context);
actors.add(instance);
return instance;
}
return null;
}
use of net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo in project Create by Creators-of-Create.
the class ZapperLog method record.
// private int redoIndex;
/*
* Undo and redo operations applied by tools what information is necessary?
*
* For survival mode: does undo have the required blocks
*
* For creative mode: what data did removed TEs have
*
* When undo: remove added blocks (added -> air) replace replaced blocks (added
* -> before) add removed blocks (air -> before)
*
*/
public void record(Level world, List<BlockPos> positions) {
// return;
if (world != activeWorld)
log.clear();
activeWorld = world;
List<StructureBlockInfo> blocks = positions.stream().map(pos -> {
BlockEntity tileEntity = world.getBlockEntity(pos);
return new StructureBlockInfo(pos, world.getBlockState(pos), tileEntity == null ? null : tileEntity.saveWithFullMetadata());
}).collect(Collectors.toList());
log.add(0, blocks);
// redoIndex = 0;
// if (maxLogLength() < log.size())
// log.remove(log.size() - 1);
}
Aggregations