本文整理汇总了Java中net.minecraft.entity.item.EntityFireworkRocket类的典型用法代码示例。如果您正苦于以下问题:Java EntityFireworkRocket类的具体用法?Java EntityFireworkRocket怎么用?Java EntityFireworkRocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityFireworkRocket类属于net.minecraft.entity.item包,在下文中一共展示了EntityFireworkRocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spawnFirework
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public static void spawnFirework(World world, double x, double y, double z) {
ItemStack rocket = new ItemStack(Items.FIREWORKS);
ItemStack itemstack1 = getFireworkCharge();
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTTagList nbttaglist = new NBTTagList();
if (itemstack1 != null && itemstack1.getItem() == Items.FIREWORK_CHARGE && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
}
nbttagcompound1.setTag("Explosions", nbttaglist);
nbttagcompound1.setByte("Flight", (byte) 2);
nbttagcompound.setTag("Fireworks", nbttagcompound1);
rocket.setTagCompound(nbttagcompound);
EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
world.spawnEntity(entity);
}
示例2: onItemUse
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!worldIn.isRemote)
{
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(worldIn, (double)((float)pos.getX() + hitX), (double)((float)pos.getY() + hitY), (double)((float)pos.getZ() + hitZ), stack);
worldIn.spawnEntityInWorld(entityfireworkrocket);
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
return true;
}
else
{
return false;
}
}
示例3: onItemUse
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
if (!playerIn.isRemote)
{
ItemStack itemstack = stack.getHeldItem(pos);
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(playerIn, (double)((float)worldIn.getX() + facing), (double)((float)worldIn.getY() + hitX), (double)((float)worldIn.getZ() + hitY), itemstack);
playerIn.spawnEntityInWorld(entityfireworkrocket);
if (!stack.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
}
return EnumActionResult.SUCCESS;
}
示例4: onItemRightClick
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
if (worldIn.isElytraFlying())
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (!itemStackIn.isRemote)
{
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(itemStackIn, itemstack, worldIn);
itemStackIn.spawnEntityInWorld(entityfireworkrocket);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
}
return new ActionResult(EnumActionResult.SUCCESS, worldIn.getHeldItem(playerIn));
}
else
{
return new ActionResult(EnumActionResult.PASS, worldIn.getHeldItem(playerIn));
}
}
示例5: onItemUse
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (!worldIn.isRemote)
{
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(worldIn, (double)((float)pos.getX() + hitX), (double)((float)pos.getY() + hitY), (double)((float)pos.getZ() + hitZ), stack);
worldIn.spawnEntityInWorld(entityfireworkrocket);
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
}
return EnumActionResult.SUCCESS;
}
示例6: startFireworks
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public static void startFireworks(Entity entity)
{
//ItemStack stack = new ItemStack(Items.firework_charge); // Used to give fireworks something to blow up with, it seems
//stack.setTagCompound(new NBTTagCompound());
//NBTTagCompound nbttagcompound = stack.getTagCompound();
//nbttagcompound.setTag("Fireworks", new NBTTagCompound());
//nbttagcompound.getCompoundTag("Fireworks").setByte("Flight", (byte) 15);
// SFX
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(entity.worldObj, entity.posX, entity.posY, entity.posZ, null);
entity.worldObj.spawnEntityInWorld(entityfireworkrocket);
// Sound
entity.worldObj.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, entity.posX, entity.posY - 0.3D, entity.posZ, new Random().nextGaussian() * 0.05D, -entity.motionY * 0.5D, new Random().nextGaussian() * 0.05D, new int[0]);
}
示例7: afterAttack
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
@Override
public void afterAttack(EntityLivingBase attacker, List<EntityLivingBase> entities, float damage, ItemStack stack, AttackData attackData, UpgradeData value) {
NBTTagCompound batData = BatHelper.getBatData(stack);
if(batData.hasKey(NBT_FIREWORK)){
ItemStack fireW = new ItemStack(Items.FIREWORKS);
fireW.setTagCompound(batData.getCompoundTag(NBT_FIREWORK));
for(Entity entity : entities){
EntityFireworkRocket rocket = new EntityFireworkRocket(attacker.getEntityWorld(), (entity.posX), (entity.posY)+entity.height/2, (entity.posZ), fireW);
if(!attacker.getEntityWorld().isRemote){
attacker.getEntityWorld().spawnEntity(rocket);
attacker.getEntityWorld().setEntityState(rocket, (byte)17);
rocket.setDead();
}
}
}
}
示例8: CraftFirework
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public CraftFirework(CraftServer server, EntityFireworkRocket entity) {
super(server, entity);
ItemStack item = getHandle().getDataWatcher().getWatchableObjectItemStack(FIREWORK_ITEM_INDEX);
if (item == null) {
item = new ItemStack(Items.fireworks);
getHandle().getDataWatcher().updateObject(FIREWORK_ITEM_INDEX, item);
}
this.item = CraftItemStack.asCraftMirror(item);
// Ensure the item is a firework...
if (this.item.getType() != Material.FIREWORK) {
this.item.setType(Material.FIREWORK);
}
}
示例9: handleStatusUpdate
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
@Patch.Exception
@Hook("net.minecraft.entity.item.EntityFireworkRocket#func_70103_a")
public static Hook.Result handleStatusUpdate(EntityFireworkRocket rocket, byte id) {
if (id == 17 && rocket.world.isRemote) {
ItemStack item = rocket.getDataManager().get(EntityFireworkRocket.FIREWORK_ITEM);
NBTTagCompound nbt = null;
if (item != null && item.hasTagCompound()) {
nbt = item.getTagCompound().getCompoundTag("Fireworks");
if (item.getTagCompound().hasKey("display", NBT.TAG_COMPOUND))
nbt.setTag("display", item.getTagCompound().getTag("display"));
}
rocket.world.makeFireworks(rocket.posX, rocket.posY, rocket.posZ, rocket.motionX, rocket.motionY, rocket.motionZ, nbt);
}
return Hook.Result.NULL;
}
示例10: prepare
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
/**
* Create and initialize an {@link EntityFireworkRocket} from this object
*
* @return <tt>this</tt>
*/
public Firework prepare() {
NBTTagCompound rocketEntityTag = new NBTTagCompound();
NBTTagCompound rocketStackTag = new NBTTagCompound();
NBTTagCompound explosionNBT = this.toNBT();
ItemStack rocketStack = new ItemStack(Items.fireworks);
rocketStack.writeToNBT(rocketStackTag);
rocketStackTag.setTag("tag", explosionNBT);
rocketStack.readFromNBT(rocketStackTag);
EntityFireworkRocket rocketEntity = new EntityFireworkRocket(world, posX, posY, posZ, rocketStack);
rocketEntity.writeToNBT(rocketEntityTag);
rocketEntityTag.setInteger("LifeTime", this.lifetime);
rocketEntity.readFromNBT(rocketEntityTag);
rocket = rocketEntity;
return this;
}
示例11: onItemUse
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (!par3World.isClient)
{
EntityFireworkRocket var11 = new EntityFireworkRocket(par3World, (double)((float)par4 + par8), (double)((float)par5 + par9), (double)((float)par6 + par10), par1ItemStack);
par3World.spawnEntityInWorld(var11);
if (!par2EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
return true;
}
else
{
return false;
}
}
示例12: launch
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public Object[] launch(final World world, double x, double y, double z) {
final ItemStack firework = rocketBuffer.getNextItemStack();
if (firework != null) {
final EntityFireworkRocket rocket = new EntityFireworkRocket(world, x + xOffset, y + yOffset, z + zOffset, firework);
TickHandler.addTickCallback(world, new Callable<Object>() {
@Override
public Object call() throws Exception {
world.spawnEntityInWorld(rocket);
coolDownActive = true;
return null;
}
});
return new Object[]{true};
}
return new Object[]{false, "no firework to launch"};
}
示例13: onItemUse
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
if (!p_77648_3_.isRemote)
{
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(p_77648_3_, (double)((float)p_77648_4_ + p_77648_8_), (double)((float)p_77648_5_ + p_77648_9_), (double)((float)p_77648_6_ + p_77648_10_), p_77648_1_);
p_77648_3_.spawnEntityInWorld(entityfireworkrocket);
if (!p_77648_2_.capabilities.isCreativeMode)
{
--p_77648_1_.stackSize;
}
return true;
}
else
{
return false;
}
}
示例14: onItemUse
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (!par3World.isRemote)
{
EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(par3World, (double)((float)par4 + par8), (double)((float)par5 + par9), (double)((float)par6 + par10), par1ItemStack);
par3World.spawnEntityInWorld(entityfireworkrocket);
if (!par2EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
return true;
}
else
{
return false;
}
}
示例15: spawnFirework
import net.minecraft.entity.item.EntityFireworkRocket; //导入依赖的package包/类
public static void spawnFirework(World world, double x, double y, double z){
ItemStack rocket = new ItemStack(Items.fireworks);
ItemStack itemstack1 = getFireworkCharge();
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTTagList nbttaglist = new NBTTagList();
if(itemstack1 != null && itemstack1.getItem() == Items.firework_charge && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
}
nbttagcompound1.setTag("Explosions", nbttaglist);
nbttagcompound1.setByte("Flight", (byte)2);
nbttagcompound.setTag("Fireworks", nbttagcompound1);
rocket.setTagCompound(nbttagcompound);
EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
world.spawnEntityInWorld(entity);
}