Search in sources :

Example 1 with PressurePlateBlock

use of net.minecraft.world.level.block.PressurePlateBlock in project Create by Creators-of-Create.

the class Contraption method capture.

protected Pair<StructureBlockInfo, BlockEntity> capture(Level world, BlockPos pos) {
    BlockState blockstate = world.getBlockState(pos);
    if (AllBlocks.REDSTONE_CONTACT.has(blockstate))
        blockstate = blockstate.setValue(RedstoneContactBlock.POWERED, true);
    if (blockstate.getBlock() instanceof ButtonBlock) {
        blockstate = blockstate.setValue(ButtonBlock.POWERED, false);
        world.scheduleTick(pos, blockstate.getBlock(), -1);
    }
    if (blockstate.getBlock() instanceof PressurePlateBlock) {
        blockstate = blockstate.setValue(PressurePlateBlock.POWERED, false);
        world.scheduleTick(pos, blockstate.getBlock(), -1);
    }
    CompoundTag compoundnbt = getTileEntityNBT(world, pos);
    BlockEntity tileentity = world.getBlockEntity(pos);
    return Pair.of(new StructureBlockInfo(pos, blockstate, compoundnbt), tileentity);
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) ButtonBlock(net.minecraft.world.level.block.ButtonBlock) PressurePlateBlock(net.minecraft.world.level.block.PressurePlateBlock) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) CompoundTag(net.minecraft.nbt.CompoundTag) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Aggregations

CompoundTag (net.minecraft.nbt.CompoundTag)1 ButtonBlock (net.minecraft.world.level.block.ButtonBlock)1 PressurePlateBlock (net.minecraft.world.level.block.PressurePlateBlock)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 StructureBlockInfo (net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo)1