本文整理汇总了Java中net.minecraft.item.ItemFirework类的典型用法代码示例。如果您正苦于以下问题:Java ItemFirework类的具体用法?Java ItemFirework怎么用?Java ItemFirework使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemFirework类属于net.minecraft.item包,在下文中一共展示了ItemFirework类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onUpdate
import net.minecraft.item.ItemFirework; //导入依赖的package包/类
@Inject(method = "update", at = @At("RETURN"))
private void onUpdate(CallbackInfo callbackInfo) {
if (!this.world.isRemote) {
if (this.isBurning()) {
ItemStack itemStack = this.furnaceItemStacks[0];
if (itemStack != null) {
if (itemStack.getItem() instanceof ItemBlock) {
Block block = ((ItemBlock) itemStack.getItem()).block;
if (block.getMaterial(block.getStateFromMeta(itemStack.getMetadata())) == Material.TNT) {
this.doExplosion();
}
} else if (itemStack.getItem() == Items.GUNPOWDER) {
this.doExplosion();
} else if (itemStack.getItem() instanceof ItemFirework || itemStack.getItem()
instanceof ItemFireworkCharge) {
this.doExplosion();
}
}
}
}
}
开发者ID:GoodTimeStudio,项目名称:Production-Line,代码行数:22,代码来源:MixinTileEntityFurnace.java
示例2: onTick
import net.minecraft.item.ItemFirework; //导入依赖的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;
}
}
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:AutoTaunt.java
示例3: execute
import net.minecraft.item.ItemFirework; //导入依赖的package包/类
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
Entity entity = params.length > 2 ? null :
isSenderOfEntityType(sender.getMinecraftISender(), Entity.class) ?
getSenderAsEntity(sender.getMinecraftISender(), Entity.class) : null;
BlockPos spawn = null;
if (params.length > 2)
spawn = getCoordFromParams(sender.getMinecraftISender(), params, 0);
else
spawn = entity == null ? sender.getPosition() : EntityUtils.traceBlock(entity, 128.0D);
if (spawn == null)
throw new CommandException("command.firework.notFound", sender);
Random rand = new Random();
RecipeFireworks recipe = (RecipeFireworks) CraftingManager.REGISTRY.getObject(new ResourceLocation("fireworks"));
if (recipe != null) {
InventoryCrafting inv = new InventoryCrafting(new Container()
{
public boolean canInteractWith(EntityPlayer playerIn) {return false;}
}, 3, 3);
ItemStack dye;
ItemStack output;
do {
for (int i = 0; i < inv.getSizeInventory(); ++i) inv.setInventorySlotContents(i, null);
dye = new ItemStack(Items.DYE, 1, rand.nextInt(MAX_DYE_TYPES));
inv.setInventorySlotContents(0, dye);
inv.setInventorySlotContents(1, new ItemStack(Items.GUNPOWDER));
if (rand.nextBoolean())
inv.setInventorySlotContents(2, new ItemStack(shapeModifiers.get(rand.nextInt(shapeModifiers.size()))));
if (rand.nextBoolean())
inv.setInventorySlotContents(3, new ItemStack(effectModifiers.get(rand.nextInt(effectModifiers.size()))));
}
while (!recipe.matches(inv, sender.getMinecraftISender().getEntityWorld()));
output = recipe.getRecipeOutput();
if (output.getItem() instanceof ItemFireworkCharge) {
do {
for (int i = 0; i < inv.getSizeInventory(); ++i) inv.setInventorySlotContents(i, null);
inv.setInventorySlotContents(0, output);
inv.setInventorySlotContents(1, new ItemStack(Items.PAPER));
int gunpowder = rand.nextInt(MAX_GUNPOWDER);
for (int i = 0; i < gunpowder; i++) inv.setInventorySlotContents(2 + i, new ItemStack(Items.GUNPOWDER));
}
while (!recipe.matches(inv, sender.getMinecraftISender().getEntityWorld()));
output = recipe.getRecipeOutput();
if (output.getItem() instanceof ItemFirework) {
ItemFirework firework = (ItemFirework) output.getItem();
EntityFireworkRocket rocket = new EntityFireworkRocket(sender.getWorld(), spawn.getX(), spawn.getY(), spawn.getZ(), output);;
sender.getWorld().spawnEntity(rocket);
}
}
}
return null;
}
开发者ID:MrNobody98,项目名称:morecommands,代码行数:71,代码来源:CommandFirework.java
示例4: onMessage
import net.minecraft.item.ItemFirework; //导入依赖的package包/类
@Override
public IMessage onMessage(NbtRequestMessage message, MessageContext ctx)
{
if (ctx.side.isClient())
{
switch (message.type)
{
case ENTITY:
callbackCustomEntityType.callback(message.response);
break;
case FIREWORK:
callbackFireworksType.callback(message.response);
break;
case ITEM:
callbackItemType.callback(message.response);
break;
case BLOCK:
callbackBlockType.callback(message.response);
break;
}
}
else
{
switch (message.type)
{
case ENTITY:
NBTTagCompound nbt = new NBTTagCompound();
Entity entity = ctx.getServerHandler().playerEntity.worldObj.getEntityByID(message.entityId);
entity.writeToNBT(nbt);
entity.writeToNBTOptional(nbt);
nbt.setString("id", EntityList.getEntityString(entity));
return new NbtRequestMessage(message.type, JsonNBTHelper.parseNBT(nbt).toString());
case FIREWORK:
ItemStack itemStack = ctx.getServerHandler().playerEntity.getHeldItem();
if (itemStack != null && itemStack.getItem() instanceof ItemFirework)
{
return new NbtRequestMessage(message.type, JsonNBTHelper.parseNBT(ctx.getServerHandler().playerEntity.getHeldItem().writeToNBT(new NBTTagCompound())).toString());
}
else
{
Helper.sendChatToPlayer(ctx.getServerHandler().playerEntity, "You are not holding an ItemFirework...", EnumChatFormatting.RED);
}
break;
case ITEM:
if (ctx.getServerHandler().playerEntity.getHeldItem() != null)
{
return new NbtRequestMessage(message.type, JsonNBTHelper.parseNBT(ctx.getServerHandler().playerEntity.getHeldItem().writeToNBT(new NBTTagCompound())).toString());
}
else
{
Helper.sendChatToPlayer(ctx.getServerHandler().playerEntity, "You are not holding an item...", EnumChatFormatting.RED);
}
break;
case BLOCK:
NBTTagCompound compound = new NBTTagCompound();
World world = DimensionManager.getWorld(message.dim);
compound.setInteger(StructureType.BLOCKID_KEY, Block.getIdFromBlock(world.getBlock(message.x, message.y, message.z)));
compound.setInteger(StructureType.META_KEY, world.getBlockMetadata(message.x, message.y, message.z));
TileEntity tileEntity = world.getTileEntity(message.x, message.y, message.z);
if (tileEntity != null)
{
NBTTagCompound te = new NBTTagCompound();
tileEntity.writeToNBT(te);
compound.setTag(StructureType.TEDATA_KEY, te);
}
return new NbtRequestMessage(message.type, JsonNBTHelper.parseNBT(compound).toString());
}
}
return null;
}
开发者ID:CCM-Modding,项目名称:Pay2Spawn,代码行数:71,代码来源:NbtRequestMessage.java
注:本文中的net.minecraft.item.ItemFirework类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论