net.minecraft.entity.item.EntityItem Java Examples

The following examples show how to use net.minecraft.entity.item.EntityItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockPneumaticPlantBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void dropBlockAsItem(World world, int x, int y, int z, ItemStack stack){
    if(!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
        if(captureDrops.get()) {
            capturedDrops.get().add(stack);
            return;
        }
        float f = 0.7F;
        double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, stack);
        entityitem.delayBeforeCanPickup = 10;
        world.spawnEntityInWorld(entityitem);
        ItemPlasticPlants.markInactive(entityitem);
    }
}
 
Example #2
Source File: TrackingRange.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the range an entity should be 'tracked' by players and visible in
 * the client.
 *
 * @param entity
 * @param defaultRange Default range defined by Mojang
 * @return
 */
public static int getEntityTrackingRange(Entity entity, int defaultRange) {
    SpigotWorldConfig config = entity.world.spigotConfig;
    if (entity instanceof EntityPlayer) {
        return config.playerTrackingRange;
    } else if (entity.activationType == 1) {
        return config.monsterTrackingRange;
    } else if (entity instanceof EntityGhast) {
        if (config.monsterTrackingRange > config.monsterActivationRange) {
            return config.monsterTrackingRange;
        } else {
            return config.monsterActivationRange;
        }
    } else if (entity.activationType == 2) {
        return config.animalTrackingRange;
    } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb) {
        return config.miscTrackingRange;
    } else {
        return config.otherTrackingRange;
    }
}
 
Example #3
Source File: BlockBurstPlant.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){
    if(!world.isRemote) {
        ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.BURST_PLANT_DAMAGE);
        EntityItem plant = new EntityItem(world, x + 0.5D, y + 0.8D, z + 0.5D, seed);
        plant.motionX = rand.nextFloat() - 0.5F;
        plant.motionY = 1.0F;
        plant.motionZ = rand.nextFloat() - 0.5F;
        plant.lifespan = 300;
        ItemPlasticPlants.markInactive(plant);
        world.spawnEntityInWorld(plant);
        plant.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);

        world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
    }
}
 
Example #4
Source File: RenderEntityChopperSeeds.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public void renderChopperSeeds(EntityChopperSeeds entity, double x, double y, double z, float var1, float partialTicks){
    float scaleFactor = 0.7F;
    GL11.glPushMatrix(); // start
    GL11.glTranslatef((float)x, (float)y, (float)z); // size
    // GL11.glScalef(1.0F, -1F, -1F);
    GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
    EntityItem ghostEntityItem = new EntityItem(entity.worldObj);
    ghostEntityItem.hoverStart = 0.0F;
    ghostEntityItem.setEntityItemStack(iStack);
    double radius = 0.25D;
    for(int i = 0; i < 4; i++) {
        GL11.glPushMatrix();
        GL11.glTranslated(Math.sin(0.5D * Math.PI * i + (entity.ticksExisted + partialTicks) * 0.4D) * radius, 0, Math.cos(0.5D * Math.PI * i + (entity.ticksExisted + partialTicks) * 0.4D) * radius);
        itemRenderer.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}
 
Example #5
Source File: ScoopBehaviour.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Method(modid = GTValues.MODID_FR)
private boolean processButterflyCatch(ItemStack itemStack, EntityPlayer player, Entity entity) {
    if (entity instanceof IEntityButterfly) {
        if (player.world.isRemote) {
            return true;
        }
        if (player.capabilities.isCreativeMode || GTUtility.doDamageItem(itemStack, this.cost, false)) {
            IEntityButterfly butterfly = (IEntityButterfly) entity;
            IAlleleButterflySpecies species = butterfly.getButterfly().getGenome().getPrimary();
            species.getRoot().getBreedingTracker(entity.world, player.getGameProfile()).registerCatch(butterfly.getButterfly());
            player.world.spawnEntity(new EntityItem(player.world, entity.posX, entity.posY, entity.posZ,
                species.getRoot().getMemberStack(butterfly.getButterfly().copy(), EnumFlutterType.BUTTERFLY)));
            entity.setDead();
        }
        return true;
    }
    return false;
}
 
Example #6
Source File: FarmLogicHelium.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Collection<ItemStack> collect(){
    List<ItemStack> col = new ArrayList<ItemStack>();
    int[] coords = housing.getCoords();
    int[] area = housing.getArea();
    int[] offset = housing.getOffset();

    AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(coords[0] + offset[0], coords[1] + offset[1], coords[2] + offset[2], coords[0] + offset[0] + area[0], coords[1] + offset[1] + area[1], coords[2] + offset[2] + area[2]);
    List<EntityItem> list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, harvestBox);

    for(EntityItem item : list) {
        if(!item.isDead) {
            ItemStack contained = item.getEntityItem();
            if(isAcceptedGermling(contained)) {
                col.add(contained.copy());
                item.setDead();
            }
        }
    }
    return col;
}
 
Example #7
Source File: TileAuraPylon.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void breakTile() {
    if(!isPartOfMultiblock || worldObj.isRemote) return;

    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    Block pylon = worldObj.getBlock(xCoord, yCoord, zCoord);
    if(pylon != null) {
        ArrayList<ItemStack> stacks = pylon.getDrops(worldObj, xCoord, yCoord, zCoord, meta, 0);
        for(ItemStack i : stacks) {
            EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, i);
            //ItemUtils.applyRandomDropOffset(item, worldObj.rand);
            worldObj.spawnEntityInWorld(item);
        }
    }
    worldObj.removeTileEntity(xCoord, yCoord, zCoord);
    worldObj.setBlockToAir(xCoord, yCoord, zCoord);
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
 
Example #8
Source File: BlockLogVertical.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void createFallingEntity(World world, BlockPos pos, IBlockState state)
{
	if(world.rand.nextFloat() < 0.4)
	{
		world.setBlockToAir(pos);
		EntityItem ei = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.STICK, 1+world.rand.nextInt(3)));
		world.spawnEntity(ei);
	}
	else
	{
		int x = 0;
		int z = 0;
		if(world.rand.nextFloat() < 0.25)
		{
			x = -1 + world.rand.nextInt(3);
			z = -1 + world.rand.nextInt(3);
		}
		world.setBlockToAir(pos);
		EntityFallingBlockTFC entityfallingblock = new EntityFallingBlockTFC(world, pos.getX() + 0.5D + x, pos.getY(), pos.getZ() + 0.5D + z, state);
		world.spawnEntity(entityfallingblock);
	}
}
 
Example #9
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public EntityItem getClosestEntityItem(Entity entity, double d)
{
	double d1 = -1D;
	EntityItem entityitem = null;
	List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(d, d, d));
	for (int k = 0; k < list.size(); k++)
	{
		Entity entity1 = (Entity) list.get(k);
		if (!(entity1 instanceof EntityItem))
		{
			continue;
		}
		EntityItem entityitem1 = (EntityItem) entity1;
		double d2 = entityitem1.getDistanceSq(entity.posX, entity.posY, entity.posZ);
		if (((d < 0.0D) || (d2 < (d * d))) && ((d1 == -1D) || (d2 < d1)))
		{
			d1 = d2;
			entityitem = entityitem1;
		}
	}

	return entityitem;
}
 
Example #10
Source File: ProjectileStone.java    From ExNihiloAdscensio with MIT License 6 votes vote down vote up
@Override
protected void onImpact(RayTraceResult result)
{
    if (result.entityHit != null)
    {
        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), (int) (Math.random() * (4.0F / 3.0F)));
    }
    else if (!world.isRemote)
    {
        setDead();
        
        if(stack != null)
        {
            world.spawnEntity(new EntityItem(world, posX, posY, posZ, stack));
        }
    }
    
    for (int j = 0; j < 8; ++j)
    {
        world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, posX, posY, posZ, 0.0D, 0.0D, 0.0D, new int[] { Block.getStateId(Blocks.STONE.getDefaultState()) });
    }
}
 
Example #11
Source File: ItemClipper.java    From AgriCraft with MIT License 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitx, float hity, float hitz) {
    if (world.isRemote) {
        return EnumActionResult.SUCCESS;
    }
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof IAgriCrop) {
        IAgriCrop crop = (IAgriCrop) te;
        if (crop.hasSeed() && crop.getGrowthStage() > 1) {
            crop.setGrowthStage(crop.getGrowthStage() - 1);
            AgriSeed seed = crop.getSeed();
            seed = seed.withStat(seed.getStat());
            world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), ItemClipping.getClipping(seed, 1)));
            return EnumActionResult.SUCCESS;
        }
        return EnumActionResult.FAIL;
    }
    return EnumActionResult.PASS;   //return PASS or else no other use methods will be called (for instance "onBlockActivated" on the crops block)
}
 
Example #12
Source File: PlatingReturnHandler.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent evt) {
    if (evt.player.worldObj.isRemote || !(evt.crafting.getItem() instanceof ItemPack)) {
        return;
    }
    
    PackBase outputPack = ((ItemPack) evt.crafting.getItem()).getPack(evt.crafting);
    if (outputPack.isArmored) {
        return;
    }
    
    for (int i = 0; i < evt.craftMatrix.getSizeInventory(); i++) {
        ItemStack input = evt.craftMatrix.getStackInSlot(i);
        if (input == null || !(input.getItem() instanceof ItemPack)) {
            continue;
        }
        PackBase inputPack = ((ItemPack) input.getItem()).getPack(input);
        if (inputPack != null && inputPack.isArmored && inputPack.platingMeta != null) {
            EntityItem item = evt.player.entityDropItem(new ItemStack(ModItems.armorPlatings, 1, inputPack.platingMeta), 0.0F);
            item.delayBeforeCanPickup = 0;
            break;
        }
    }
}
 
Example #13
Source File: BlockRepulsionPlant.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){
    if(!world.isRemote) {
        ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.REPULSION_PLANT_DAMAGE);
        EntityItem plant = new EntityItem(world, x + 0.5D, y + 0.8D, z + 0.5D, seed);
        plant.motionX = (rand.nextFloat() - 0.5F) / 2;
        plant.motionY = 0.7F;
        plant.motionZ = (rand.nextFloat() - 0.5F) / 2;
        plant.lifespan = 300;
        ItemPlasticPlants.markInactive(plant);
        world.spawnEntityInWorld(plant);
        plant.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);

        world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
    }
}
 
Example #14
Source File: BlockWrathCage.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void onBlockPreDestroy(World world, int x, int y, int z, int side) {
    TileEntityWrathCage spawner = (TileEntityWrathCage) world.getTileEntity(x, y, z);

    if (spawner != null && spawner.getSpawnerLogic().isMobSet()) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

        ItemStack crystal = new ItemStack(ForbiddenItems.mobCrystal);
        crystal.setTagCompound(new NBTTagCompound());
        String mob = spawner.getSpawnerLogic().getEntityNameToSpawn();
        crystal.stackTagCompound.setString("mob", mob);

        EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), crystal);

        entityitem.motionX = (double) ((float) world.rand.nextGaussian() * 0.05F);
        entityitem.motionY = (double) ((float) world.rand.nextGaussian() * 0.05F + 0.2F);
        entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * 0.05F);
        world.spawnEntityInWorld(entityitem);

    }

    super.onBlockPreDestroy(world, x, y, z, side);
}
 
Example #15
Source File: TileEntityPressureChamberInterface.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void outputInChamber(){
    TileEntityPressureChamberValve valve = getCore();
    if(valve != null) {
        for(int i = 0; i < 6; i++) {
            int x = xCoord + Facing.offsetsXForSide[i];
            int y = yCoord + Facing.offsetsYForSide[i];
            int z = zCoord + Facing.offsetsZForSide[i];
            if(valve.isCoordWithinChamber(worldObj, x, y, z)) {
                enoughAir = Math.abs(valve.currentAir) > inventory[0].stackSize * PneumaticValues.USAGE_CHAMBER_INTERFACE;
                if(enoughAir) {
                    valve.addAir((valve.currentAir > 0 ? -1 : 1) * inventory[0].stackSize * PneumaticValues.USAGE_CHAMBER_INTERFACE, ForgeDirection.UNKNOWN);
                    EntityItem item = new EntityItem(worldObj, x + 0.5D, y + 0.5D, z + 0.5D, inventory[0].copy());
                    worldObj.spawnEntityInWorld(item);
                    setInventorySlotContents(0, null);
                    break;
                }
            }
        }
    }
}
 
Example #16
Source File: BlockElevatorBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
    super.onNeighborBlockChange(world, x, y, z, block);
    TileEntity te = world.getTileEntity(x, y, z);
    if(te instanceof TileEntityElevatorBase) {
        TileEntityElevatorBase thisTe = (TileEntityElevatorBase)te;
        if(thisTe.isCoreElevator()) {
            TileEntityElevatorBase teAbove = getCoreTileEntity(world, x, y, z);
            if(teAbove != null && teAbove != thisTe) {
                for(int i = 0; i < thisTe.getSizeInventory(); i++) {
                    ItemStack item = thisTe.getStackInSlot(i);
                    if(item != null) {
                        ItemStack leftover = TileEntityHopper.func_145889_a(teAbove, item, 0);
                        thisTe.setInventorySlotContents(i, null);
                        if(leftover != null) {
                            EntityItem entity = new EntityItem(world, teAbove.xCoord + 0.5, teAbove.yCoord + 1.5, teAbove.zCoord + 0.5, leftover);
                            world.spawnEntityInWorld(entity);
                        }
                    }
                }
            }
        }
    }
}
 
Example #17
Source File: MoCEntityKitty.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void attackEntity(Entity entity, float f)
{

    if ((f > 2.0F) && (f < 6F) && (rand.nextInt(30) == 0) && onGround)
    {
        double d = entity.posX - posX;
        double d1 = entity.posZ - posZ;
        float f1 = MathHelper.sqrt_double((d * d) + (d1 * d1));
        motionX = ((d / f1) * 0.5D * 0.8D) + (motionX * 0.2D);
        motionZ = ((d1 / f1) * 0.5D * 0.8D) + (motionZ * 0.2D);
        motionY = 0.4D;
    }
    if ((f < 2D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        if ((getKittyState() != 18) && (getKittyState() != 10))
        {
            swingArm();
        }
        if (((getKittyState() == 13) && (entity instanceof EntityPlayer)) || ((getKittyState() == 8) && (entity instanceof EntityItem)) || ((getKittyState() == 18) && (entity instanceof MoCEntityKitty)) || (getKittyState() == 10)) { return; }
        //if(worldObj.isRemote) 
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1);
    }
}
 
Example #18
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private void addDrop(ItemStack stack, EntityLivingBase entity, List<EntityItem> list) {
	if (stack.stackSize <= 0)
		return;

	EntityItem entityItem = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, stack);
	entityItem.delayBeforeCanPickup = 10;
	list.add(entityItem);
}
 
Example #19
Source File: ItemEspHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(WUpdateEvent event)
{
	World world = WPlayer.getWorld(event.getPlayer());
	
	items.clear();
	for(Entity entity : world.loadedEntityList)
		if(entity instanceof EntityItem)
			items.add((EntityItem)entity);
}
 
Example #20
Source File: SubTileEuclidaisy.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public void dropItem(World world, int x, int y, int z, ItemStack item){
    float f = 0.7F;
    double d0 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
    double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
    double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
    EntityItem entityitem = new EntityItem(world, (double)x + d0, (double)y + d1, (double)z + d2, item);
    entityitem.delayBeforeCanPickup = 10;
    world.spawnEntityInWorld(entityitem);
}
 
Example #21
Source File: PLEvent.java    From Production-Line with MIT License 5 votes vote down vote up
private void onImpact(EntityThrownItem entity, RayTraceResult movingObjectPosition, PotionEffect potionEffect) {
    if (movingObjectPosition.entityHit != null) {
        movingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(entity, entity.getThrower()), 3F);
        if (movingObjectPosition.entityHit instanceof EntityLivingBase && potionEffect != null) {
            ((EntityLivingBase) movingObjectPosition.entityHit).addPotionEffect(potionEffect);
        }
    }
    entity.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, entity.posX, entity.posY, entity.posZ, 0.1D, 0.1D,
            0.1D, Item.getIdFromItem(entity.getThrowItem().get().getItem()));
    if (!entity.world.isRemote) {
        entity.setDead();
        entity.world.spawnEntity(new EntityItem(entity.world, entity.posX, entity.posY, entity.posZ,
                entity.getThrowItem().get()));
    }
}
 
Example #22
Source File: TileEntityPressureChamberValve.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public double[] clearStacksInChamber(Object... stacksToClear){
    int[] stackSizes = new int[stacksToClear.length];
    for(int i = 0; i < stacksToClear.length; i++) {
        stackSizes[i] = PneumaticRecipeRegistry.getItemAmount(stacksToClear[i]);
    }
    // default the output position to the middle of the chamber.
    double[] outputPosition = new double[]{multiBlockX + multiBlockSize / 2D, multiBlockY + 1.2D, multiBlockZ + multiBlockSize / 2D};

    // get the in world EntityItems
    AxisAlignedBB bbBox = AxisAlignedBB.getBoundingBox(multiBlockX, multiBlockY, multiBlockZ, multiBlockX + multiBlockSize, multiBlockY + multiBlockSize, multiBlockZ + multiBlockSize);
    List<EntityItem> entities = worldObj.getEntitiesWithinAABB(EntityItem.class, bbBox);
    for(EntityItem entity : entities) {
        if(entity.isDead) continue;
        ItemStack entityStack = entity.getEntityItem();
        for(int l = 0; l < stacksToClear.length; l++) {
            if(PneumaticRecipeRegistry.isItemEqual(stacksToClear[l], entityStack) && stackSizes[l] > 0) {
                outputPosition[0] = entity.posX;
                outputPosition[1] = entity.posY;
                outputPosition[2] = entity.posZ;
                int removedItems = Math.min(stackSizes[l], entityStack.stackSize);
                stackSizes[l] -= removedItems;
                entityStack.stackSize -= removedItems;
                if(entityStack.stackSize <= 0) entity.setDead();
                break;
            }
        }
    }
    return outputPosition;
}
 
Example #23
Source File: TileEntityNewBrewingStand.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private void brewPotions() {
	if (ForgeEventFactory.onPotionAttemptBreaw(new ItemStack[] { inventory[0], inventory[1], inventory[2], inventory[3] }))
		return;
	if (canBrew()) {
		for (int i = 0; i < 3; i++)
			if (inventory[i] != null && inventory[i].getItem() instanceof ItemPotion) {
				int j = inventory[i].getItemDamage();
				if (ItemPotion.isSplash(j) && inventory[3].getItem() == ModItems.dragon_breath)
					inventory[i] = new ItemStack(ModItems.lingering_potion, inventory[i].stackSize, inventory[i].getItemDamage());
				else {
					int k = applyIngredient(j, inventory[3]);
					List<?> list = Items.potionitem.getEffects(j);
					List<?> list1 = Items.potionitem.getEffects(k);

					if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) {
						if (j != k)
							inventory[i].setItemDamage(k);
					} else if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
						inventory[i].setItemDamage(k);
				}
			}

		boolean hasContainerItem = inventory[3].getItem().hasContainerItem(inventory[3]);
		if (--inventory[3].stackSize <= 0)
			inventory[3] = hasContainerItem ? inventory[3].getItem().getContainerItem(inventory[3]) : null;
		else if (hasContainerItem && !worldObj.isRemote) {
			float f = 0.7F;
			double x = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
			double y = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
			double z = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
			EntityItem entityitem = new EntityItem(worldObj, xCoord + x, yCoord + y, zCoord + z, inventory[3].getItem().getContainerItem(inventory[3]));
			entityitem.delayBeforeCanPickup = 10;
			worldObj.spawnEntityInWorld(entityitem);
		}

		fuel--;
		ForgeEventFactory.onPotionBrewed(new ItemStack[] { inventory[0], inventory[1], inventory[2], inventory[3] });
		worldObj.playSound(xCoord, yCoord, zCoord, Reference.MOD_ID + ":block.brewing_stand.brew", 1.0F, 1.0F, true);
	}
}
 
Example #24
Source File: EntityFairy.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onDeath(@Nonnull DamageSource cause) {
	if (getIsInvulnerable()) return;

	if (!world.isRemote) {
		FairyData dataFairy = getDataFairy();
		if (dataFairy == null) return;

		if (dataFairy.isDepressed) {

			ItemStack stack = new ItemStack(ModItems.FAIRY_ITEM);
			NBTHelper.setTag(stack, "fairy", dataFairy.serializeNBT());

			world.removeEntity(this);

			EntityItem entityItem = new EntityItem(world);
			entityItem.setPosition(posX, posY, posZ);
			entityItem.setItem(stack);
			entityItem.setPickupDelay(20);
			entityItem.setNoDespawn();

			world.spawnEntity(entityItem);
			return;
		}

		super.onDeath(cause);

		if (getHealth() <= 0)
			PacketHandler.NETWORK.sendToAllAround(new PacketExplode(getPositionVector().add(0, 0.25, 0), dataFairy.primaryColor, dataFairy.secondaryColor, 0.5, 0.5, RandUtil.nextInt(100, 200), 75, 25, true),
					new NetworkRegistry.TargetPoint(world.provider.getDimension(), posX, posY, posZ, 256));
	}
}
 
Example #25
Source File: MoCTools.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Drops item
 */
public static void dropCustomItem(Entity entity, World worldObj, ItemStack itemstack)
{
    if (!MoCreatures.isServer()) { return; }

    EntityItem entityitem = new EntityItem(worldObj, entity.posX, entity.posY, entity.posZ, itemstack);
    float f3 = 0.05F;
    entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3;
    entityitem.motionY = ((float) worldObj.rand.nextGaussian() * f3) + 0.2F;
    entityitem.motionZ = (float) worldObj.rand.nextGaussian() * f3;
    worldObj.spawnEntityInWorld(entityitem);
}
 
Example #26
Source File: MoCEntityOstrich.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Drops a block of the color of the flag if carrying one
 */
private void dropFlag() 
{
    if (MoCreatures.isServer() && getFlagColor() != 0)
    {
        int color = getFlagColor();
        if (color == 16) color = 0;
        EntityItem entityitem = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Item.itemsList[Block.cloth.blockID], 1, color));
        entityitem.delayBeforeCanPickup = 10;
        worldObj.spawnEntityInWorld(entityitem);
        //ItemStack itemstack = new ItemStack(Item.itemsList[Block.cloth.blockID], 1, color);
        setFlagColor((byte)0);
    }
}
 
Example #27
Source File: DropCapture.java    From OpenModsLib with MIT License 5 votes vote down vote up
private boolean check(EntityItem item) {
	if (!item.isDead && aabb.intersects(item.getEntityBoundingBox())) {
		drops.add(item);
		return true;
	}

	return false;
}
 
Example #28
Source File: ItemPLTreetap.java    From Production-Line with MIT License 5 votes vote down vote up
private static void ejectResin(World world, BlockPos pos, EnumFacing side, int quantity) {
    double ejectBias = 0.3D;
    double ejectX = (double) pos.getX() + 0.5D + (double) side.getFrontOffsetX() * 0.3D;
    double ejectY = (double) pos.getY() + 0.5D + (double) side.getFrontOffsetY() * 0.3D;
    double ejectZ = (double) pos.getZ() + 0.5D + (double) side.getFrontOffsetZ() * 0.3D;

    for (int i = 0; i < quantity; ++i) {
        EntityItem entityitem = new EntityItem(world, ejectX, ejectY, ejectZ, ItemName.misc_resource.getItemStack(MiscResourceType.resin));
        entityitem.setDefaultPickupDelay();
        world.spawnEntity(entityitem);
    }

}
 
Example #29
Source File: MixinRenderEntityItem.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "doRender", at = @At("HEAD"), cancellable = true)
private void doRender(EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
    if (Settings.ITEM_PHYSIC_ENABLED) {
        ClientPhysic.doRender(entity, x, y, z);
        ci.cancel();
    }
}
 
Example #30
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * ItemDespawnEvent
 */
public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) {
    org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();

    ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation());

    entity.getServer().getPluginManager().callEvent(event);
    return event;
}