当前位置: 首页>>代码示例>>Java>>正文


Java TileEntity.getUpdatePacket方法代码示例

本文整理汇总了Java中net.minecraft.tileentity.TileEntity.getUpdatePacket方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntity.getUpdatePacket方法的具体用法?Java TileEntity.getUpdatePacket怎么用?Java TileEntity.getUpdatePacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.tileentity.TileEntity的用法示例。


在下文中一共展示了TileEntity.getUpdatePacket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendTileEntityUpdate

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
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);
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:13,代码来源:EntityPlayerMP.java

示例2: sendBlockEntity

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
private void sendBlockEntity(@Nullable TileEntity be)
{
    if (be != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = be.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.sendPacket(spacketupdatetileentity);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:PlayerChunkMapEntry.java

示例3: onBlockBreakEvent

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
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();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:54,代码来源:ForgeHooks.java


注:本文中的net.minecraft.tileentity.TileEntity.getUpdatePacket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。