Java Code Examples for net.minecraft.tileentity.TileEntity.getUpdatePacket()

The following are Jave code examples for showing how to use getUpdatePacket() of the net.minecraft.tileentity.TileEntity class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Zombe-Modpack   File: EntityPlayerMP.java   View Source Code Vote up 5 votes
private void sendTileEntityUpdate(TileEntity p_147097_1_)
{
    if (p_147097_1_ != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = p_147097_1_.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.connection.sendPacket(spacketupdatetileentity);
        }
    }
}
 
Example 2
Project: Backmemed   File: EntityPlayerMP.java   View Source Code Vote up 5 votes
private void sendTileEntityUpdate(TileEntity p_147097_1_)
{
    if (p_147097_1_ != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = p_147097_1_.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.connection.sendPacket(spacketupdatetileentity);
        }
    }
}
 
Example 3
Project: Backmemed   File: PlayerChunkMapEntry.java   View Source Code Vote up 5 votes
private void sendBlockEntity(@Nullable TileEntity be)
{
    if (be != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = be.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.sendPacket(spacketupdatetileentity);
        }
    }
}
 
Example 4
Project: CustomWorldGen   File: EntityPlayerMP.java   View Source Code Vote up 5 votes
private void sendTileEntityUpdate(TileEntity p_147097_1_)
{
    if (p_147097_1_ != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = p_147097_1_.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.connection.sendPacket(spacketupdatetileentity);
        }
    }
}
 
Example 5
Project: CustomWorldGen   File: PlayerChunkMapEntry.java   View Source Code Vote up 5 votes
private void sendBlockEntity(@Nullable TileEntity be)
{
    if (be != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = be.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.sendPacket(spacketupdatetileentity);
        }
    }
}
 
Example 6
Project: CustomWorldGen   File: ForgeHooks.java   View Source Code Vote up 4 votes
public static int onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, BlockPos pos)
{
    // Logic from tryHarvestBlock for pre-canceling the event
    boolean preCancelEvent = false;
    if (gameType.isCreative() && entityPlayer.getHeldItemMainhand() != null && entityPlayer.getHeldItemMainhand().getItem() instanceof ItemSword)
        preCancelEvent = true;

    if (gameType.isAdventure())
    {
        if (gameType == GameType.SPECTATOR)
            preCancelEvent = true;

        if (!entityPlayer.isAllowEdit())
        {
            ItemStack itemstack = entityPlayer.getHeldItemMainhand();
            if (itemstack == null || !itemstack.canDestroy(world.getBlockState(pos).getBlock()))
                preCancelEvent = true;
        }
    }

    // Tell client the block is gone immediately then process events
    if (world.getTileEntity(pos) == null)
    {
        SPacketBlockChange packet = new SPacketBlockChange(world, pos);
        packet.blockState = Blocks.AIR.getDefaultState();
        entityPlayer.connection.sendPacket(packet);
    }

    // Post the block break event
    IBlockState state = world.getBlockState(pos);
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, entityPlayer);
    event.setCanceled(preCancelEvent);
    MinecraftForge.EVENT_BUS.post(event);

    // Handle if the event is canceled
    if (event.isCanceled())
    {
        // Let the client know the block still exists
        entityPlayer.connection.sendPacket(new SPacketBlockChange(world, pos));

        // Update any tile entity data for this block
        TileEntity tileentity = world.getTileEntity(pos);
        if (tileentity != null)
        {
            Packet<?> pkt = tileentity.getUpdatePacket();
            if (pkt != null)
            {
                entityPlayer.connection.sendPacket(pkt);
            }
        }
    }
    return event.isCanceled() ? -1 : event.getExpToDrop();
}