Search in sources :

Example 6 with StructureBlockInfo

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;
}
Also used : AbstractMinecart(net.minecraft.world.entity.vehicle.AbstractMinecart) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) Axis(net.minecraft.core.Direction.Axis) AABB(net.minecraft.world.phys.AABB) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 7 with StructureBlockInfo

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;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) Axis(net.minecraft.core.Direction.Axis)

Example 8 with StructureBlockInfo

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;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo)

Example 9 with StructureBlockInfo

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;
}
Also used : StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) MovementContext(com.simibubi.create.content.contraptions.components.structureMovement.MovementContext) MovementBehaviour(com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour) Nullable(javax.annotation.Nullable)

Example 10 with StructureBlockInfo

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);
}
Also used : List(java.util.List) BlockPos(net.minecraft.core.BlockPos) LinkedList(java.util.LinkedList) Level(net.minecraft.world.level.Level) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) Collectors(java.util.stream.Collectors) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Aggregations

StructureBlockInfo (net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo)23 BlockPos (net.minecraft.core.BlockPos)16 BlockState (net.minecraft.world.level.block.state.BlockState)13 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)9 AABB (net.minecraft.world.phys.AABB)8 SuperGlueEntity (com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity)7 Axis (net.minecraft.core.Direction.Axis)7 MagnetBlock (com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock.MagnetBlock)6 RopeBlock (com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock.RopeBlock)6 Direction (net.minecraft.core.Direction)6 SeatBlock (com.simibubi.create.content.contraptions.components.actors.SeatBlock)5 SeatEntity (com.simibubi.create.content.contraptions.components.actors.SeatEntity)5 MechanicalBearingBlock (com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingBlock)5 WindmillBearingBlock (com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingBlock)5 AbstractChassisBlock (com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock)5 StickerBlock (com.simibubi.create.content.contraptions.components.structureMovement.chassis.StickerBlock)5 GantryCarriageBlock (com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryCarriageBlock)5 MechanicalPistonBlock (com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock)5 MechanicalPistonHeadBlock (com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonHeadBlock)5 PistonExtensionPoleBlock (com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock)5