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


Java CPacketCreativeInventoryAction类代码示例

本文整理汇总了Java中net.minecraft.network.play.client.CPacketCreativeInventoryAction的典型用法代码示例。如果您正苦于以下问题:Java CPacketCreativeInventoryAction类的具体用法?Java CPacketCreativeInventoryAction怎么用?Java CPacketCreativeInventoryAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CPacketCreativeInventoryAction类属于net.minecraft.network.play.client包,在下文中一共展示了CPacketCreativeInventoryAction类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
@Override
public void call(String[] args) throws CmdException
{
	if(args.length > 0)
		throw new CmdSyntaxError();
	
	// check for creative mode
	EntityPlayerSP player = WMinecraft.getPlayer();
	if(!player.capabilities.isCreativeMode)
		throw new CmdError("Creative mode only.");
	
	// validate item
	ItemStack item = player.inventory.getCurrentItem();
	if(item == null)
		throw new CmdError("You need an item in your hand.");
	if(!item.isItemStackDamageable())
		throw new CmdError("This item can't take damage.");
	if(!item.isItemDamaged())
		throw new CmdError("This item is not damaged.");
	
	// repair item
	item.setItemDamage(0);
	WConnection.sendPacket(new CPacketCreativeInventoryAction(
		36 + player.inventory.currentItem, item));
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:26,代码来源:RepairCmd.java

示例2: placeStackInHotbar

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
public static boolean placeStackInHotbar(ItemStack stack)
{
	for(int i = 0; i < 9; i++)
		if(isSlotEmpty(i))
		{
			WConnection.sendPacket(
				new CPacketCreativeInventoryAction(36 + i, stack));
			return true;
		}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12-OF,代码行数:13,代码来源:InventoryUtils.java

示例3: onUpdate

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
@Override
public void onUpdate()
{
	if(infinite)
	{
		Item item = null;
		while(item == null)
			item = Item.getItemById(new Random().nextInt(431));
		WConnection.sendPacket(new CPacketCreativeInventoryAction(-1,
			new ItemStack(item, 64)));
		return;
	}
	if(wurst.special.yesCheatSpf.getProfile().ordinal() >= Profile.OLDER_NCP
		.ordinal())
	{
		timer++;
		if(timer >= 5)
		{
			WPlayerController.windowClick_THROW(counter);
			counter++;
			timer = 0;
			if(counter >= 45)
				wurst.events.remove(UpdateListener.class, this);
		}
	}else
	{
		for(int i = 9; i < 45; i++)
			WPlayerController.windowClick_THROW(i);
		wurst.events.remove(UpdateListener.class, this);
	}
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:32,代码来源:DropCmd.java

示例4: sendSlotPacket

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
/**
 * Used in PlayerControllerMP to update the server with an ItemStack in a slot.
 */
public void sendSlotPacket(ItemStack itemStackIn, int slotId)
{
    if (this.currentGameType.isCreative())
    {
        this.connection.sendPacket(new CPacketCreativeInventoryAction(slotId, itemStackIn));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:11,代码来源:PlayerControllerMP.java

示例5: sendPacketDropItem

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
/**
 * Sends a Packet107 to the server to drop the item on the ground
 */
public void sendPacketDropItem(ItemStack itemStackIn)
{
    if (this.currentGameType.isCreative() && !itemStackIn.func_190926_b())
    {
        this.connection.sendPacket(new CPacketCreativeInventoryAction(-1, itemStackIn));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:11,代码来源:PlayerControllerMP.java

示例6: placeStackInHotbar

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
public static boolean placeStackInHotbar(IItemStack stack) {
	for (int i = 0; i < 9; i++)
		if (getStackInSlot(i).isEmpty()) {
			Minecraft.getMinecraft().player.connection
					.sendPacket(new CPacketCreativeInventoryAction(36 + i, stack.getStack()));
			return true;
		}

	return false;
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:11,代码来源:IInventoryWrapper.java

示例7: sendPacketDropItem

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
/**
 * Sends a Packet107 to the server to drop the item on the ground
 */
public void sendPacketDropItem(ItemStack itemStackIn)
{
    if (this.currentGameType.isCreative() && itemStackIn != null)
    {
        this.connection.sendPacket(new CPacketCreativeInventoryAction(-1, itemStackIn));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:PlayerControllerMP.java

示例8: processCreativeInventoryAction

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.interactionManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.world.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
        boolean flag2 = itemstack.func_190926_b() || itemstack.getMetadata() >= 0 && itemstack.func_190916_E() <= 64 && !itemstack.func_190926_b();

        if (flag1 && flag2)
        {
            if (itemstack.func_190926_b())
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), ItemStack.field_190927_a);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:61,代码来源:NetHandlerPlayServer.java

示例9: processCreativeInventoryAction

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.interactionManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
        boolean flag2 = itemstack == null || itemstack.getItem() != null;
        boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;

        if (flag1 && flag2 && flag3)
        {
            if (itemstack == null)
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:62,代码来源:NetHandlerPlayServer.java

示例10: processCreativeInventoryAction

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
@Override
public void processCreativeInventoryAction(CPacketCreativeInventoryAction p_147344_1_) {
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:4,代码来源:FakeNetHandlerPlayServer.java

示例11: processCreativeInventoryAction

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
@Override
public void processCreativeInventoryAction(@Nonnull CPacketCreativeInventoryAction p_147344_1_) {
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:4,代码来源:FakeNetHandlerPlayServer.java

示例12: processCreativeInventoryAction

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
@Override
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) {

}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:5,代码来源:NetServerHandlerFake.java

示例13: processCreativeInventoryAction

import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入依赖的package包/类
/**
 * Update the server with an ItemStack in a slot.
 */
void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn);
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:INetHandlerPlayServer.java


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