use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class TileEntityArcaneDeconstructor method transferOrEjectItem.
private void transferOrEjectItem(ItemStack stack) {
if (worldObj.isRemote)
return;
boolean eject = false;
for (int i = -1; i <= 1; ++i) {
for (int j = -1; j <= 1; ++j) {
for (int k = -1; k <= 1; ++k) {
if (i == 0 && j == 0 && k == 0)
continue;
TileEntity te = worldObj.getTileEntity(xCoord + i, yCoord + j, zCoord + k);
if (te != null && te instanceof IInventory) {
for (int side = 0; side < 6; ++side) {
if (InventoryUtilities.mergeIntoInventory((IInventory) te, stack, stack.stackSize, side))
return;
}
}
}
}
}
//eject the remainder
EntityItem item = new EntityItem(worldObj);
item.setPosition(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5);
item.setEntityItemStack(stack);
worldObj.spawnEntityInWorld(item);
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class TileEntityCraftingAltar method checkForStartCondition.
private void checkForStartCondition() {
if (this.worldObj.isRemote || !structureValid || this.isCrafting)
return;
List<Entity> items = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord - 3, zCoord - 2, xCoord + 2, yCoord, zCoord + 2));
if (items.size() == 1) {
EntityItem item = (EntityItem) items.get(0);
if (item != null && !item.isDead && item.getEntityItem().getItem() == ItemsCommonProxy.rune && item.getEntityItem().getItemDamage() == ItemsCommonProxy.rune.META_BLANK) {
item.setDead();
setCrafting(true);
}
}
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class EntityFireElemental method onUpdate.
@Override
public void onUpdate() {
int cookTargetID = dataWatcher.getWatchableObjectInt(19);
if (cookTargetID != 0) {
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(cookRadius, cookRadius, cookRadius));
EntityItem inanimate = null;
for (EntityItem item : items) {
if (item.getEntityId() == cookTargetID) {
inanimate = item;
}
}
if (inanimate != null && worldObj.isRemote) {
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "fire", posX, posY + getEyeHeight(), posZ);
if (effect != null) {
effect.setIgnoreMaxAge(true);
effect.AddParticleController(new ParticleApproachPoint(effect, inanimate.posX + (rand.nextFloat() - 0.5), inanimate.posY + (rand.nextFloat() - 0.5), inanimate.posZ + (rand.nextFloat() - 0.5), 0.1f, 0.1f, 1, false).setKillParticleOnFinish(true));
}
}
}
if (worldObj.isRemote && rand.nextInt(100) > 75 && !isBurning())
for (int i = 0; i < AMCore.config.getGFXLevel(); i++) worldObj.spawnParticle("largesmoke", posX + (rand.nextDouble() - 0.5D) * width, posY + rand.nextDouble() * height, posZ + (rand.nextDouble() - 0.5D) * width, 0.0D, 0.0D, 0.0D);
super.onUpdate();
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class EntityAirSled method interact.
@Override
public boolean interact(EntityPlayer par1EntityPlayer) {
if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) {
return true;
} else {
if (!this.worldObj.isRemote) {
if (par1EntityPlayer.isSneaking()) {
this.setDead();
EntityItem item = new EntityItem(worldObj);
item.setPosition(posX, posY, posZ);
item.setEntityItemStack(ItemsCommonProxy.airSledEnchanted.copy());
worldObj.spawnEntityInWorld(item);
} else {
par1EntityPlayer.mountEntity(this);
}
}
return true;
}
}
use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.
the class LifeTap method applyEffectBlock.
@Override
public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster) {
if (world.getBlock(blockx, blocky, blockz) == Blocks.mob_spawner) {
ItemStack[] reagents = RitualShapeHelper.instance.checkForRitual(this, world, blockx, blocky, blockz);
if (reagents != null) {
if (!world.isRemote) {
world.setBlockToAir(blockx, blocky, blockz);
RitualShapeHelper.instance.consumeRitualReagents(this, world, blockx, blocky, blockz);
RitualShapeHelper.instance.consumeRitualShape(this, world, blockx, blocky, blockz);
EntityItem item = new EntityItem(world);
item.setPosition(blockx + 0.5, blocky + 0.5, blockz + 0.5);
item.setEntityItemStack(new ItemStack(BlocksCommonProxy.inertSpawner));
world.spawnEntityInWorld(item);
} else {
}
return true;
}
}
return false;
}
Aggregations