本文整理汇总了Java中net.minecraft.network.play.client.C08PacketPlayerBlockPlacement类的典型用法代码示例。如果您正苦于以下问题:Java C08PacketPlayerBlockPlacement类的具体用法?Java C08PacketPlayerBlockPlacement怎么用?Java C08PacketPlayerBlockPlacement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
C08PacketPlayerBlockPlacement类属于net.minecraft.network.play.client包,在下文中一共展示了C08PacketPlayerBlockPlacement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPostUpdate
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@EventTarget
private void onPostUpdate(UpdateEvent event) {
if (event.state == Event.State.POST) {
int soupSlot = this.getSoupFromInventory();
if ((double)this.mc.thePlayer.getHealth() < this.health * 2.0 && this.time.delay((float)this.delay) && soupSlot != -1) {
int prevSlot = this.mc.thePlayer.inventory.currentItem;
if (soupSlot < 9) {
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(soupSlot));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(this.mc.thePlayer.inventory.getCurrentItem()));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(prevSlot));
this.mc.playerController.syncCurrentPlayItem();
this.mc.thePlayer.inventory.currentItem = prevSlot;
} else {
this.swap(soupSlot, this.mc.thePlayer.inventory.currentItem + (this.mc.thePlayer.inventory.currentItem < 8 ? 1 : -1));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(this.mc.thePlayer.inventory.currentItem + (this.mc.thePlayer.inventory.currentItem < 8 ? 1 : -1)));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(this.mc.thePlayer.inventory.getCurrentItem()));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(prevSlot));
}
this.time.reset();
}
}
}
示例2: sendUseItem
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
public boolean sendUseItem(EntityPlayer p_78769_1_, World p_78769_2_, ItemStack p_78769_3_)
{
syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, p_78769_1_.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
int i = p_78769_3_.stackSize;
ItemStack itemstack1 = p_78769_3_.useItemRightClick(p_78769_2_, p_78769_1_);
if ((itemstack1 == p_78769_3_) && ((itemstack1 == null) || (itemstack1.stackSize == i))) {
return false;
}
p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = itemstack1;
if (itemstack1.stackSize <= 0)
{
p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = null;
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78769_1_, itemstack1));
}
return true;
}
示例3: onOutwardPacket
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@Override
public void onOutwardPacket(EventOnOutwardPacket event){
if(!invoker.isOnGround()) return;
Packet packet = event.getPacket();
if (packet instanceof C08PacketPlayerBlockPlacement) {
if(Item.getIdFromItem(invoker.getCurrentItem().getItem()) != 261) return;
C08PacketPlayerBlockPlacement packetBlockPlacement = (C08PacketPlayerBlockPlacement) packet;
if (packetBlockPlacement.func_149576_c() != -1 || packetBlockPlacement.func_149571_d() != -1 || packetBlockPlacement.func_149570_e() != -1 || packetBlockPlacement.func_149568_f() != 255) {
return;
}
event.addPacketToList(new C09PacketHeldItemChange(Minecraft.getMinecraft().thePlayer.inventory.currentItem));
for (int i = 0; i < 40; i++) {
event.addPacketToList(new C03PacketPlayer(false));
}
event.addPacketToList(new C07PacketPlayerDigging(5, 0, 0, 0, 255));
}
}
示例4: onOutwardPacket
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@Override
public void onOutwardPacket(EventOnOutwardPacket event){
if(!invoker.isOnGround()) return;
Packet packet = event.getPacket();
if (packet instanceof C08PacketPlayerBlockPlacement) {
if(!(invoker.getCurrentItem().getItem() instanceof ItemFood)) return;
C08PacketPlayerBlockPlacement packetBlockPlacement = (C08PacketPlayerBlockPlacement) packet;
if (packetBlockPlacement.func_149576_c() != -1 || packetBlockPlacement.func_149571_d() != -1 || packetBlockPlacement.func_149570_e() != -1 || packetBlockPlacement.func_149568_f() != 255) {
return;
}
event.addPacketToList(new C09PacketHeldItemChange(Minecraft.getMinecraft().thePlayer.inventory.currentItem));
for (int i = 0; i < 40; i++) {
event.addPacketToList(new C03PacketPlayer(false));
}
event.addPacketToList(new C07PacketPlayerDigging(5, 0, 0, 0, 255));
}
}
示例5: sendUseItem
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
/**
* Notifies the server of things like consuming food, etc...
*/
public boolean sendUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, par1EntityPlayer.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
int var4 = par3ItemStack.stackSize;
ItemStack var5 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer);
if (var5 == par3ItemStack && (var5 == null || var5.stackSize == var4))
{
return false;
}
else
{
par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = var5;
if (var5.stackSize == 0)
{
par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null;
}
return true;
}
}
示例6: sendUseItem
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
public boolean sendUseItem(EntityPlayer p_78769_1_, World p_78769_2_, ItemStack p_78769_3_)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, p_78769_1_.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
int i = p_78769_3_.stackSize;
ItemStack itemstack1 = p_78769_3_.useItemRightClick(p_78769_2_, p_78769_1_);
if (itemstack1 == p_78769_3_ && (itemstack1 == null || itemstack1.stackSize == i))
{
return false;
}
else
{
p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = itemstack1;
if (itemstack1.stackSize <= 0)
{
p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = null;
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78769_1_, itemstack1));
}
return true;
}
}
示例7: sendUseItem
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
/**
* Notifies the server of things like consuming food, etc...
*/
public boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn)
{
if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
{
return false;
}
else
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(playerIn.inventory.getCurrentItem()));
int i = itemStackIn.stackSize;
ItemStack itemstack = itemStackIn.useItemRightClick(worldIn, playerIn);
if (itemstack != itemStackIn || itemstack != null && itemstack.stackSize != i)
{
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = itemstack;
if (itemstack.stackSize == 0)
{
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
}
return true;
}
else
{
return false;
}
}
}
示例8: onUpdate
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@EventTarget
private void onUpdate(UpdateEvent event) {
int foodSlot;
if (event.state == Event.State.PRE && (foodSlot = this.getFoodSlotInHotbar()) != -1 && (double)this.mc.thePlayer.getFoodStats().getFoodLevel() < this.hunger * 2.0 && this.mc.thePlayer.isCollidedVertically) {
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(foodSlot));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(this.mc.thePlayer.inventory.mainInventory[foodSlot]));
int i = 0;
while (i < 32) {
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C03PacketPlayer(false));
++i;
}
this.mc.thePlayer.stopUsingItem();
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(this.mc.thePlayer.inventory.currentItem));
}
}
示例9: onPacketSend
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@EventTarget
private void onPacketSend(PacketSendEvent event) {
if (event.packet instanceof C0BPacketEntityAction || event.packet instanceof C03PacketPlayer || event.packet instanceof C02PacketUseEntity || event.packet instanceof C0APacketAnimation || event.packet instanceof C08PacketPlayerBlockPlacement) {
this.packetList.add(event.packet);
event.setCancelled(true);
}
}
示例10: onUpdate
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@EventTarget(value=4)
private void onUpdate(UpdateEvent event) {
if (this.mc.thePlayer.isBlocking() && (this.mc.thePlayer.motionX != 0.0 || this.mc.thePlayer.motionZ != 0.0)) {
if (event.state == Event.State.PRE) {
this.mc.getNetHandler().getNetworkManager().dispatchPacket((Packet)new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN), null);
} else if (event.state == Event.State.POST) {
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(this.mc.thePlayer.inventory.getCurrentItem()));
}
}
}
示例11: onTick
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@EventTarget
private void onTick(TickEvent event) {
int i = 0;
while (i < 8) {
Item item;
if (this.mc.thePlayer.inventory.mainInventory[i] != null && ((item = this.mc.thePlayer.inventory.mainInventory[i].getItem()) instanceof ItemRedstone || Item.getIdFromItem((Item)item) == 353 || item instanceof ItemFirework)) {
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(i));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(this.mc.thePlayer.inventory.mainInventory[i]));
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C09PacketHeldItemChange(this.mc.thePlayer.inventory.currentItem));
}
++i;
}
}
示例12: sendUsePacket
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
@Override
public void sendUsePacket(final PlayerInteractEvent event) {
if (event.world.isRemote) {
final Vec3 hitVec = Minecraft.getMinecraft().objectMouseOver.hitVec;
final float f = (float)hitVec.xCoord - event.x;
final float f2 = (float)hitVec.yCoord - event.y;
final float f3 = (float)hitVec.zCoord - event.z;
Minecraft.getMinecraft().getNetHandler().addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(event.x, event.y, event.z, event.face, event.entityPlayer.inventory.getCurrentItem(), f, f2, f3));
}
}
示例13: processPlayerBlockPlacement
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
/**
* Processes block placement and block activation (anvil, furnace, etc.)
*/
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
boolean flag = false;
BlockPos blockpos = packetIn.getPosition();
EnumFacing enumfacing = EnumFacing.getFront(packetIn.getPlacedBlockDirection());
this.playerEntity.markPlayerActive();
if (packetIn.getPlacedBlockDirection() == 255)
{
if (itemstack == null)
{
return;
}
this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
}
else if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
{
if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
{
this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ());
}
flag = true;
}
else
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
this.playerEntity.playerNetServerHandler.sendPacket(new S02PacketChat(chatcomponenttranslation));
flag = true;
}
if (flag)
{
this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos));
this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
itemstack = this.playerEntity.inventory.getCurrentItem();
if (itemstack != null && itemstack.stackSize == 0)
{
this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = null;
itemstack = null;
}
if (itemstack == null || itemstack.getMaxItemUseDuration() == 0)
{
this.playerEntity.isChangingQuantityOnly = true;
this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.isChangingQuantityOnly = false;
if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()))
{
this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
}
}
}
示例14: onPlayerRightClick
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
public boolean onPlayerRightClick(EntityPlayerSP player, WorldClient worldIn, ItemStack heldStack, BlockPos hitPos, EnumFacing side, Vec3 hitVec)
{
this.syncCurrentPlayItem();
float f = (float)(hitVec.xCoord - (double)hitPos.getX());
float f1 = (float)(hitVec.yCoord - (double)hitPos.getY());
float f2 = (float)(hitVec.zCoord - (double)hitPos.getZ());
boolean flag = false;
if (!this.mc.theWorld.getWorldBorder().contains(hitPos))
{
return false;
}
else
{
if (this.currentGameType != WorldSettings.GameType.SPECTATOR)
{
IBlockState iblockstate = worldIn.getBlockState(hitPos);
if ((!player.isSneaking() || player.getHeldItem() == null) && iblockstate.getBlock().onBlockActivated(worldIn, hitPos, iblockstate, player, side, f, f1, f2))
{
flag = true;
}
if (!flag && heldStack != null && heldStack.getItem() instanceof ItemBlock)
{
ItemBlock itemblock = (ItemBlock)heldStack.getItem();
if (!itemblock.canPlaceBlockOnSide(worldIn, hitPos, side, player, heldStack))
{
return false;
}
}
}
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(hitPos, side.getIndex(), player.inventory.getCurrentItem(), f, f1, f2));
if (!flag && this.currentGameType != WorldSettings.GameType.SPECTATOR)
{
if (heldStack == null)
{
return false;
}
else if (this.currentGameType.isCreative())
{
int i = heldStack.getMetadata();
int j = heldStack.stackSize;
boolean flag1 = heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
heldStack.setItemDamage(i);
heldStack.stackSize = j;
return flag1;
}
else
{
return heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
}
}
else
{
return true;
}
}
}
示例15: onPlayerRightClick
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入依赖的package包/类
public boolean onPlayerRightClick(EntityPlayer p_78760_1_, World p_78760_2_, ItemStack p_78760_3_, int p_78760_4_, int p_78760_5_, int p_78760_6_, int p_78760_7_, Vec3 p_78760_8_)
{
syncCurrentPlayItem();
float f = (float)p_78760_8_.xCoord - p_78760_4_;
float f1 = (float)p_78760_8_.yCoord - p_78760_5_;
float f2 = (float)p_78760_8_.zCoord - p_78760_6_;
boolean flag = false;
if ((p_78760_3_ != null) && (p_78760_3_.getItem() != null) && (p_78760_3_.getItem().onItemUseFirst(p_78760_3_, p_78760_1_, p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, f, f1, f2))) {
return true;
}
if ((!p_78760_1_.isSneaking()) || (p_78760_1_.getHeldItem() == null) || (p_78760_1_.getHeldItem().getItem().doesSneakBypassUse(p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_1_))) {
flag = p_78760_2_.getBlock(p_78760_4_, p_78760_5_, p_78760_6_).onBlockActivated(p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_1_, p_78760_7_, f, f1, f2);
}
if ((!flag) && (p_78760_3_ != null) && ((p_78760_3_.getItem() instanceof ItemBlock)))
{
ItemBlock itemblock = (ItemBlock)p_78760_3_.getItem();
if (!itemblock.func_150936_a(p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, p_78760_1_, p_78760_3_)) {
return false;
}
}
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, p_78760_1_.inventory.getCurrentItem(), f, f1, f2));
if (flag) {
return true;
}
if (p_78760_3_ == null) {
return false;
}
if (this.currentGameType.isCreative())
{
int j1 = p_78760_3_.getItemDamage();
int i1 = p_78760_3_.stackSize;
boolean flag1 = p_78760_3_.tryPlaceItemIntoWorld(p_78760_1_, p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, f, f1, f2);
p_78760_3_.setItemDamage(j1);
p_78760_3_.stackSize = i1;
return flag1;
}
if (!p_78760_3_.tryPlaceItemIntoWorld(p_78760_1_, p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, f, f1, f2)) {
return false;
}
if (p_78760_3_.stackSize <= 0) {
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78760_1_, p_78760_3_));
}
return true;
}