net.minecraft.block.entity.BlockEntity Java Examples

The following examples show how to use net.minecraft.block.entity.BlockEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientPlayNetworkHandler_smoothClientAnimationsMixin.java    From fabric-carpet with MIT License 7 votes vote down vote up
@Inject( method = "onChunkData", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/client/world/ClientWorld;getBlockEntity(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/entity/BlockEntity;",
        shift = At.Shift.AFTER
))
private void recreateMovingPistons(ChunkDataS2CPacket packet, CallbackInfo ci,
                                   Iterator var5, CompoundTag tag, BlockPos blockPos)
{
    if (CarpetSettings.smoothClientAnimations)
    {
        BlockEntity blockEntity = world.getBlockEntity(blockPos);
        if (blockEntity == null && "minecraft:piston".equals(tag.getString("id")))
        {
            BlockState blockState = world.getBlockState(blockPos);
            if (blockState.getBlock() == Blocks.MOVING_PISTON) {
                tag.putFloat("progress", Math.min(tag.getFloat("progress") + 0.5F, 1.0F));
                blockEntity = new PistonBlockEntity();
                blockEntity.fromTag(tag);
                world.setBlockEntity(blockPos, blockEntity);
                blockEntity.resetBlock();
            }
        }
    }
}
 
Example #2
Source File: RefineryBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);

    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof RefineryBlockEntity) {
            RefineryBlockEntity refineryBlockEntity = (RefineryBlockEntity) blockEntity;

            for (int i = 0; i < refineryBlockEntity.getInventory().getSize(); i++) {
                ItemStack itemStack = refineryBlockEntity.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #3
Source File: CarpetProfiler.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static void end_current_entity_section(ProfilerToken tok)
{
    if (tick_health_requested == 0L || test_type != TYPE.ENTITY || current_tick_start == 0 || tok == null)
        return;
    long end_time = System.nanoTime();
    String section;
    if (tok.type == TYPE.ENTITY)
        section = getEntityString(tok.world, (Entity) tok.section);
    else if (tok.type == TYPE.TILEENTITY)
        section = getTEntityString(tok.world, (BlockEntity) tok.section);
    else
        return;
    String time_section = "t." + section;
    String count_section = "c." + section;
    time_repo.put(time_section, time_repo.getOrDefault(time_section, 0L) + end_time - tok.start);
    time_repo.put(count_section, time_repo.getOrDefault(count_section, 0L) + 1);
}
 
Example #4
Source File: DrawCommand.java    From fabric-carpet with MIT License 6 votes vote down vote up
private static int setBlock(
        ServerWorld world, BlockPos.Mutable mbpos, int x, int y, int z,
        BlockStateArgument block, Predicate<CachedBlockPosition> replacement,
        List<BlockPos> list
)
{
    mbpos.set(x, y, z);
    int success=0;
    if (replacement == null || replacement.test(new CachedBlockPosition(world, mbpos, true)))
    {
        BlockEntity tileentity = world.getBlockEntity(mbpos);
        if (tileentity instanceof Inventory)
        {
            ((Inventory) tileentity).clear();
        }
        if (block.setBlockState(world, mbpos, 2))
        {
            list.add(mbpos.toImmutable());
            ++success;
        }
    }

    return success;
}
 
Example #5
Source File: BlockValue.java    From fabric-carpet with MIT License 6 votes vote down vote up
public CompoundTag getData()
{
    if (data != null)
    {
        if (data.isEmpty())
            return null;
        return data;
    }
    if (world != null && pos != null)
    {
        BlockEntity be = getBlockEntity(world, pos);
        CompoundTag tag = new CompoundTag();
        if (be == null)
        {
            data = tag;
            return null;
        }
        data = be.toTag(tag);
        return data;
    }
    return null;
}
 
Example #6
Source File: CoalGeneratorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);

    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof CoalGeneratorBlockEntity) {
            CoalGeneratorBlockEntity coalGeneratorBlockEntity = (CoalGeneratorBlockEntity) blockEntity;

            for (int i = 0; i < coalGeneratorBlockEntity.getInventory().getSize(); i++) {
                ItemStack itemStack = coalGeneratorBlockEntity.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #7
Source File: EnergyStorageModuleBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);
    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof EnergyStorageModuleBlockEntity) {
            EnergyStorageModuleBlockEntity be = (EnergyStorageModuleBlockEntity) blockEntity;

            for (int i = 0; i < be.getInventory().getSize(); i++) {
                ItemStack itemStack = be.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #8
Source File: ElectricCompressorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);

    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof ElectricCompressorBlockEntity) {
            ElectricCompressorBlockEntity be = (ElectricCompressorBlockEntity) blockEntity;

            for (int i = 0; i < be.getInventory().getSize(); i++) {
                ItemStack itemStack = be.getInventory().getStack(i);

                if (!itemStack.isEmpty()) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack.copy()));
                }
            }
        }
    }
}
 
Example #9
Source File: CompressorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);

    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof CompressorBlockEntity) {
            CompressorBlockEntity be = (CompressorBlockEntity) blockEntity;

            for (int i = 0; i < be.getInventory().getSize(); i++) {
                ItemStack itemStack = be.getInventory().getStack(i);

                if (!itemStack.isEmpty()) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack.copy()));
                }
            }
        }
    }
}
 
Example #10
Source File: PistonBlockEntityRenderer_movableTEMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@Inject(method = "render", at = @At("RETURN"), locals = LocalCapture.NO_CAPTURE)
private void endMethod3576(PistonBlockEntity pistonBlockEntity_1, float partialTicks, MatrixStack matrixStack_1, VertexConsumerProvider layeredVertexConsumerStorage_1, int int_1, int init_2, CallbackInfo ci)
{
    if (((PistonBlockEntityInterface) pistonBlockEntity_1).getRenderCarriedBlockEntity())
    {
        BlockEntity carriedBlockEntity = ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity();
        if (carriedBlockEntity != null)
        {
            carriedBlockEntity.setPos(pistonBlockEntity_1.getPos());
            //((BlockEntityRenderDispatcherInterface) BlockEntityRenderDispatcher.INSTANCE).renderBlockEntityOffset(carriedBlockEntity, float_1, int_1, BlockRenderLayer.field_20799, bufferBuilder_1, pistonBlockEntity_1.getRenderOffsetX(float_1), pistonBlockEntity_1.getRenderOffsetY(float_1), pistonBlockEntity_1.getRenderOffsetZ(float_1));
            matrixStack_1.translate(
                    pistonBlockEntity_1.getRenderOffsetX(partialTicks),
                    pistonBlockEntity_1.getRenderOffsetY(partialTicks),
                    pistonBlockEntity_1.getRenderOffsetZ(partialTicks)
            );
            BlockEntityRenderDispatcher.INSTANCE.render(carriedBlockEntity, partialTicks, matrixStack_1, layeredVertexConsumerStorage_1);

        }
    }
}
 
Example #11
Source File: CircuitFabricatorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);

    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof CircuitFabricatorBlockEntity) {
            CircuitFabricatorBlockEntity circuitFabricatorBlockEntity = (CircuitFabricatorBlockEntity) blockEntity;

            for (int i = 0; i < circuitFabricatorBlockEntity.getInventory().getSize(); i++) {
                ItemStack itemStack = circuitFabricatorBlockEntity.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #12
Source File: BasicSolarPanelBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private void dropInventory(World world, BlockPos blockPos) {
    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof BasicSolarPanelBlockEntity) {
            BasicSolarPanelBlockEntity basicSolarPanelBlockEntity = (BasicSolarPanelBlockEntity) blockEntity;

            for (int i = 0; i < basicSolarPanelBlockEntity.getInventory().getSize(); i++) {
                ItemStack itemStack = basicSolarPanelBlockEntity.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #13
Source File: OxygenCollectorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void randomDisplayTick(BlockState blockState_1, World world, BlockPos pos, Random random_1) {
    BlockEntity blockEntity = world.getBlockEntity(pos);
    if (!(blockEntity instanceof OxygenCollectorBlockEntity)) {
        return;
    }

    OxygenCollectorBlockEntity collector = (OxygenCollectorBlockEntity) blockEntity;
    if (collector.collectionAmount > 0) {
        for (int particleCount = 0; particleCount < 10; particleCount++) {
            Random random = world.random;

            for (int int_1 = 0; int_1 < 32; ++int_1) {
                world.addParticle(
                        new DustParticleEffect(0.9f, 0.9f, 1.0f, 1.0F),
                        pos.getX() + 0.5D,
                        (random.nextFloat() - 0.5D) * 0.5D + /*random.nextDouble() * 2.0D*/ 0.5D,
                        pos.getZ() + 0.5D,
                        random.nextGaussian(),
                        0.0D,
                        random.nextGaussian());
            }
        }
    }
}
 
Example #14
Source File: OxygenCollectorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);
    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof OxygenCollectorBlockEntity) {
            OxygenCollectorBlockEntity be = (OxygenCollectorBlockEntity) blockEntity;

            for (int i = 0; i < be.getInventory().getSize(); i++) {
                ItemStack itemStack = be.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #15
Source File: FeatureUtils.java    From the-hallow with MIT License 5 votes vote down vote up
default void setLootChest(IWorld world, BlockPos pos, Identifier lootTable, Random rand) {
	world.setBlockState(pos, Blocks.CHEST.getDefaultState(), 2);
	
	BlockEntity entity = world.getBlockEntity(pos);
	if (entity instanceof ChestBlockEntity) {
		((ChestBlockEntity) entity).setLootTable(lootTable, rand.nextLong());
	}
}
 
Example #16
Source File: BlockEntityRenderDispatcherMixin.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Inject(at = {@At("HEAD")},
	method = {
		"render(Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V"},
	cancellable = true)
private <E extends BlockEntity> void onRender(E blockEntity_1,
	float float_1, MatrixStack matrixStack_1,
	VertexConsumerProvider vertexConsumerProvider_1, CallbackInfo ci)
{
	RenderBlockEntityEvent event =
		new RenderBlockEntityEvent(blockEntity_1);
	WurstClient.INSTANCE.getEventManager().fire(event);
	
	if(event.isCancelled())
		ci.cancel();
}
 
Example #17
Source File: MixinPlayerUpdateSign_NetworkHandler.java    From Galaxy with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject(method = "onSignUpdate", at = @At(
    value = "INVOKE",
    target = "Lnet/minecraft/block/entity/SignBlockEntity;isEditable()Z"
), cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT)
private void onSignUpdate(UpdateSignC2SPacket packet, CallbackInfo ci, ServerWorld serverWorld, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity, SignBlockEntity signBlockEntity) {
    Main main = Main.Companion.getMain();
    if (main == null) return;
    if (main.getEventManager().emit(new PlayerUpdateSignEvent(packet, player, signBlockEntity)).getCancel()) {
        ci.cancel();

        signBlockEntity.markDirty();
        serverWorld.updateListeners(blockPos, blockState, blockState, 3);
    }
}
 
Example #18
Source File: HopperMinecartEntity_transferItemsOutFeatureMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Inventory getOutputInventory() {
    Vec3d offsetToInventory = getBlockBelowCartOffset();
    //The visual rotation point of the minecart is roughly 0.5 above its feet (determined visually ingame)
    //Search 0.5 Blocks below the feet for an inventory
    Inventory inv =  HopperBlockEntity.getInventoryAt(this.world, this.getX() + offsetToInventory.x, this.getY() + 0.5 + offsetToInventory.y, this.getZ() + offsetToInventory.z);

    //There is probably a way nicer way to determine the access side of the target inventory
    if(inv instanceof BlockEntity){
        BlockPos pos = ((BlockEntity) inv).getPos();
        if(pos.getY() < MathHelper.floor(this.getY()))
            outputDirection = Direction.DOWN;
        else if(pos.getX() > MathHelper.floor(this.getX()))
            outputDirection = Direction.EAST;
        else if(pos.getX() < MathHelper.floor(this.getX()))
            outputDirection = Direction.WEST;
        else if(pos.getZ() > MathHelper.floor(this.getZ()))
            outputDirection = Direction.SOUTH;
        else if(pos.getZ() < MathHelper.floor(this.getZ()))
            outputDirection = Direction.NORTH;
        else outputDirection = Direction.DOWN;
    }else
        outputDirection = Direction.DOWN;



    return inv;
}
 
Example #19
Source File: SyncedGuiDescription.java    From LibGui with MIT License 5 votes vote down vote up
/**
 * Gets the property delegate at the context.
 *
 * <p>If no property delegate is found, returns an empty property delegate with no properties.
 *
 * <p>Searches for block entities implementing {@link PropertyDelegateHolder}.
 *
 * @param ctx the context
 * @return the found property delegate
 */
public static PropertyDelegate getBlockPropertyDelegate(ScreenHandlerContext ctx) {
	return ctx.run((world, pos) -> {
		BlockEntity be = world.getBlockEntity(pos);
		if (be!=null && be instanceof PropertyDelegateHolder) {
			return ((PropertyDelegateHolder)be).getPropertyDelegate();
		}
		
		return new ArrayPropertyDelegate(0);
	}).orElse(new ArrayPropertyDelegate(0));
}
 
Example #20
Source File: BlockValue.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static BlockEntity getBlockEntity(ServerWorld world, BlockPos pos)
{
    if (world.getServer().isOnThread())
        return world.getBlockEntity(pos);
    else
        return world.getWorldChunk(pos).getBlockEntity(pos, WorldChunk.CreationType.IMMEDIATE);
}
 
Example #21
Source File: CarpetExpression.java    From fabric-carpet with MIT License 5 votes vote down vote up
private boolean tryBreakBlock_copy_from_ServerPlayerInteractionManager(ServerPlayerEntity player, BlockPos blockPos_1)
{
    //this could be done little better, by hooking up event handling not in try_break_block but wherever its called
    // so we can safely call it here
    // but that woudl do for now.
    BlockState blockState_1 = player.world.getBlockState(blockPos_1);
    if (!player.getMainHandStack().getItem().canMine(blockState_1, player.world, blockPos_1, player)) {
        return false;
    } else {
        BlockEntity blockEntity_1 = player.world.getBlockEntity(blockPos_1);
        Block block_1 = blockState_1.getBlock();
        if ((block_1 instanceof CommandBlock || block_1 instanceof StructureBlock || block_1 instanceof JigsawBlock) && !player.isCreativeLevelTwoOp()) {
            player.world.updateListeners(blockPos_1, blockState_1, blockState_1, 3);
            return false;
        } else if (player.canMine(player.world, blockPos_1, player.interactionManager.getGameMode())) {
            return false;
        } else {
            block_1.onBreak(player.world, blockPos_1, blockState_1, player);
            boolean boolean_1 = player.world.removeBlock(blockPos_1, false);
            if (boolean_1) {
                block_1.onBroken(player.world, blockPos_1, blockState_1);
            }

            if (player.isCreative()) {
                return true;
            } else {
                ItemStack itemStack_1 = player.getMainHandStack();
                boolean boolean_2 = player.isUsingEffectiveTool(blockState_1);
                itemStack_1.postMine(player.world, blockState_1, blockPos_1, player);
                if (boolean_1 && boolean_2) {
                    ItemStack itemStack_2 = itemStack_1.isEmpty() ? ItemStack.EMPTY : itemStack_1.copy();
                    block_1.afterBreak(player.world, player, blockPos_1, blockState_1, blockEntity_1, itemStack_2);
                }

                return true;
            }
        }
    }
}
 
Example #22
Source File: CarpetProfiler.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static String getTEntityString(World world, BlockEntity be)
{
    return String.format("%s.%s%s",
            world.getDimension().getType().toString().replaceFirst("minecraft:", ""),
            Registry.BLOCK_ENTITY_TYPE.getId(be.getType()).toString().replaceFirst("minecraft:", ""),
            world.isClient ? " (Client)" : "");
}
 
Example #23
Source File: World_tickMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "tickBlockEntities", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/block/entity/BlockEntity;isRemoved()Z",
        shift = At.Shift.BEFORE,
        ordinal = 0
))
private void startTileEntitySection(CallbackInfo ci, Profiler profiler_1, Iterator i, BlockEntity blockEntity_2)
{
    entitySection = CarpetProfiler.start_entity_section((World)(Object)this, blockEntity_2, CarpetProfiler.TYPE.TILEENTITY);
}
 
Example #24
Source File: World_tickMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "tickBlockEntities", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/block/entity/BlockEntity;isRemoved()Z",
        ordinal = 0
))
private boolean checkProcessTEs(BlockEntity blockEntity)
{
    return blockEntity.isRemoved() || !TickSpeed.process_entities; // blockEntity can be NULL? happened once with fake player
}
 
Example #25
Source File: PistonBlock_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
                    CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1,
                    List<BlockPos> list_1, List<BlockState> list_2, List list_3, int int_2, BlockState[] blockStates_1,
                    Direction direction_2)
{
    //Get the blockEntities and remove them from the world before any magic starts to happen
    if (CarpetSettings.movableBlockEntities)
    {
        list1_BlockEntities.set(Lists.newArrayList());
        for (int i = 0; i < list_1.size(); ++i)
        {
            BlockPos blockpos = list_1.get(i);
            BlockEntity blockEntity = (list_2.get(i).getBlock().hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null;
            list1_BlockEntities.get().add(blockEntity);
            if (blockEntity != null)
            {
                //hopefully this call won't have any side effects in the future, such as dropping all the BlockEntity's items
                //we want to place this same(!) BlockEntity object into the world later when the movement stops again
                world_1.removeBlockEntity(blockpos);
                blockEntity.markDirty();
            }
        }
    }
}
 
Example #26
Source File: PistonBlock_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Lnet/minecraft/world/World;setBlockEntity(Lnet/minecraft/util/math/BlockPos;" +
                         "Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0),
        locals = LocalCapture.CAPTURE_FAILHARD)
private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
                                       CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1,
                                       List list_2, List list_3, int int_2, BlockState[] blockStates_1, Direction direction_2,
                                       int int_3, BlockPos blockPos_4, BlockState blockState_1)
{
    BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
            direction_1, boolean_1, false);
    if (CarpetSettings.movableBlockEntities)
        ((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3));
    world_1.setBlockEntity(blockPos_4, blockEntityPiston);
}
 
Example #27
Source File: PistonBlock_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "move", at = @At(value = "INVOKE",
        target = "Lnet/minecraft/world/World;setBlockEntity(Lnet/minecraft/util/math/BlockPos;" +
                         "Lnet/minecraft/block/entity/BlockEntity;)V",
        ordinal = 0))
private void dontDoAnything(World world, BlockPos blockPos_6, BlockEntity blockEntityPiston)
{
}
 
Example #28
Source File: PistonBlock_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "move", at = @At(value = "INVOKE",
        target = "Lnet/minecraft/block/PistonExtensionBlock;createBlockEntityPiston(Lnet/minecraft/block/BlockState;" +
                         "Lnet/minecraft/util/math/Direction;ZZ)Lnet/minecraft/block/entity/BlockEntity;",
        ordinal = 0))
private BlockEntity returnNull(BlockState blockState_1, Direction direction_1, boolean boolean_1, boolean boolean_2)
{
    return null;
}
 
Example #29
Source File: ServerPlayerInteractionManager_scarpetEventsMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILEXCEPTION, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/block/Block;onBroken(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V",
        shift = At.Shift.BEFORE
))
private void onBlockBroken(BlockPos blockPos_1, CallbackInfoReturnable<Boolean> cir, BlockState blockState_1, BlockEntity be, Block b, boolean boolean_1)
{
    PLAYER_BREAK_BLOCK.onBlockBroken(player, blockPos_1, blockState_1);
}
 
Example #30
Source File: WorldChunk_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "setBlockState", at = @At(value = "INVOKE", ordinal = 1,
        target = "Lnet/minecraft/world/chunk/WorldChunk;getBlockEntity(Lnet/minecraft/util/math/BlockPos;" + "Lnet/minecraft/world/chunk/WorldChunk$CreationType;)" + "Lnet/minecraft/block/entity/BlockEntity;"))
private BlockEntity ifGetBlockEntity(WorldChunk worldChunk, BlockPos blockPos_1,
        WorldChunk.CreationType worldChunk$CreationType_1)
{
    if (!CarpetSettings.movableBlockEntities)
    {
        return this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK);
    }
    else
    {
        return this.world.getBlockEntity(blockPos_1);
    }
}