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); }
/** * 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; } }
/** * 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; }
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)); } }
/** * 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; }
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]); }
@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(); } } } }
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); } }
@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; }
/** * 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; }
/** * 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; } }
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"}; }
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; } }
/** * 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; } }
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); }
/** * These entities are excluded from Activation range checks. * * @param entity * @param world * @return boolean If it should always tick. */ public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config) { // Cauldron start - another fix for Proxy Worlds if (config == null && DimensionManager.getWorld(0) != null) { config = DimensionManager.getWorld(0).spigotConfig; } else { return true; } // Cauldron end if ( ( entity.activationType == 3 && config.miscActivationRange == 0 ) || ( entity.activationType == 2 && config.animalActivationRange == 0 ) || ( entity.activationType == 1 && config.monsterActivationRange == 0 ) || (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) // Cauldron || entity instanceof EntityThrowable || entity instanceof EntityDragon || entity instanceof EntityDragonPart || entity instanceof EntityWither || entity instanceof EntityFireball || entity instanceof EntityWeatherEffect || entity instanceof EntityTNTPrimed || entity instanceof EntityEnderCrystal || entity instanceof EntityFireworkRocket || entity instanceof EntityVillager // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false) && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false) && !entity.isCreatureType(EnumCreatureType.waterCreature, false))) { return true; } return false; }
public static void startFireworks(Entity entity) { // 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]); }
/** * These entities are excluded from Activation range checks. * * @param entity * @param world * @return boolean If it should always tick. */ public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config) { // Cauldron start - another fix for Proxy Worlds if (config == null && DimensionManager.getWorld(0) != null) { config = DimensionManager.getWorld(0).spigotConfig; } else { return true; } // Cauldron end if ( ( entity.activationType == 3 && config.miscActivationRange == 0 ) || ( entity.activationType == 2 && config.animalActivationRange == 0 ) || ( entity.activationType == 1 && config.monsterActivationRange == 0 ) || (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) // Cauldron || entity instanceof EntityThrowable || entity instanceof EntityDragon || entity instanceof EntityDragonPart || entity instanceof EntityWither || entity instanceof EntityFireball || entity instanceof EntityWeatherEffect || entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock // PaperSpigot - Always tick falling blocks || entity instanceof EntityEnderCrystal || entity instanceof EntityFireworkRocket || entity instanceof EntityVillager // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false) && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false) && !entity.isCreatureType(EnumCreatureType.waterCreature, false))) { return true; } return false; }
public static EntityFireworkRocket getRandomFirework(World world, BlockCoord pos) { ItemStack firework = new ItemStack(Items.fireworks); firework.stackTagCompound = new NBTTagCompound(); NBTTagCompound expl = new NBTTagCompound(); expl.setBoolean("Flicker", true); expl.setBoolean("Trail", true); int[] colors = new int[rand.nextInt(8) + 1]; for (int i = 0; i < colors.length; i++) { colors[i] = ItemDye.field_150922_c[rand.nextInt(16)]; } expl.setIntArray("Colors", colors); byte type = (byte) (rand.nextInt(3) + 1); type = type == 3 ? 4 : type; expl.setByte("Type", type); NBTTagList explosions = new NBTTagList(); explosions.appendTag(expl); NBTTagCompound fireworkTag = new NBTTagCompound(); fireworkTag.setTag("Explosions", explosions); fireworkTag.setByte("Flight", (byte) 1); firework.stackTagCompound.setTag("Fireworks", fireworkTag); EntityFireworkRocket e = new EntityFireworkRocket(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, firework); return e; }
/** * These entities are excluded from Activation range checks. * * @param entity * @param world * @return boolean If it should always tick. */ public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config) { // Cauldron start - another fix for Proxy Worlds if (config == null && DimensionManager.getWorld(0) != null) { config = DimensionManager.getWorld(0).spigotConfig; } else { return true; } // Cauldron end if ( ( entity.activationType == 3 && config.miscActivationRange == 0 ) || ( entity.activationType == 2 && config.animalActivationRange == 0 ) || ( entity.activationType == 1 && config.monsterActivationRange == 0 ) || (entity.getClass().equals(EntityPlayer.class) && !(entity.getClass().equals(FakePlayer.class))) // Cauldron || entity.getClass().equals(EntityThrowable.class) || entity.getClass().equals(EntityDragon.class) || entity.getClass().equals(EntityDragonPart.class) || entity.getClass().equals(EntityWither.class) || entity.getClass().equals(EntityFireball.class) || entity.getClass().equals(EntityWeatherEffect.class) || entity.getClass().equals(EntityTNTPrimed.class) || entity.getClass().equals(EntityFallingBlock.class) || entity.getClass().equals(EntityEnderCrystal.class) || entity.getClass().equals(EntityFireworkRocket.class) || entity.getClass().equals(EntityVillager.class) // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false) && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false) && !entity.isCreatureType(EnumCreatureType.waterCreature, false))) { return true; } return false; }
@Override public void flyUser(EntityLivingBase user, ItemStack stack, ItemPack item, boolean force) { if (this.isFired(stack)) { super.flyUser(user, stack, item, true); user.rotationYawHead += 37.5F; if (item.getFuelStored(stack) <= 0) { user.setCurrentItemOrArmor(3, null); if (!user.worldObj.isRemote) { user.worldObj.createExplosion(user, user.posX, user.posY, user.posZ, 4.0F, false); for (int i = 0; i <= MathHelper.RANDOM.nextInt(3) + 4; i++) { ItemStack firework = FireworksHelper.getRandomFireworks(0, 1, MathHelper.RANDOM.nextInt(6) + 1, 1); user.worldObj.spawnEntityInWorld(new EntityFireworkRocket(user.worldObj, user.posX + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, user.posY, user.posZ + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, firework)); } user.attackEntityFrom(new EntityDamageSource("jetpackpotato", user), 100.0F); if (user instanceof EntityPlayer) { user.dropItem(Items.baked_potato, 1); } } } } else { if (force || SyncHandler.isFlyKeyDown(user)) { if (this.isTimerSet(stack)) { this.decrementTimer(stack, user); } else { this.setTimer(stack, 50); } } } }