use of am2.utility.DummyEntityPlayer in project ArsMagica2 by Mithion.
the class FlickerOperatorFlatLands method DoOperation.
@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
int searchesPerLoop = 12;
int radius = 6;
int diameter = radius * 2 + 1;
if (!worldObj.isRemote) {
boolean actionPerformed = false;
for (int i = 0; i < searchesPerLoop && !actionPerformed; ++i) {
int effectX = ((TileEntity) habitat).xCoord - radius + (worldObj.rand.nextInt(diameter));
int effectZ = ((TileEntity) habitat).zCoord - radius + (worldObj.rand.nextInt(diameter));
int effectY = ((TileEntity) habitat).yCoord + worldObj.rand.nextInt(radius);
if (effectX == ((TileEntity) habitat).xCoord && effectY == ((TileEntity) habitat).yCoord && effectZ == ((TileEntity) habitat).zCoord)
return false;
Block block = worldObj.getBlock(effectX, effectY, effectZ);
int meta = worldObj.getBlockMetadata(effectX, effectY, effectZ);
if (block != null && !worldObj.isAirBlock(effectX, effectY, effectZ) && block.isOpaqueCube() && block != BlocksCommonProxy.invisibleUtility) {
if (ForgeEventFactory.doPlayerHarvestCheck(new DummyEntityPlayer(worldObj), block, true)) {
if (block.removedByPlayer(worldObj, new DummyEntityPlayer(worldObj), effectX, effectY, effectZ)) {
block.onBlockDestroyedByPlayer(worldObj, effectX, effectY, effectZ, meta);
block.dropBlockAsItem(worldObj, effectX, effectY, effectZ, meta, 0);
if (!worldObj.isRemote)
worldObj.playAuxSFX(2001, effectX, effectY, effectZ, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(effectX, effectY, effectZ) << 12));
worldObj.func_147478_e(effectX, effectY, effectZ, true);
actionPerformed = true;
}
}
}
}
return actionPerformed;
} else {
return false;
}
}
use of am2.utility.DummyEntityPlayer in project ArsMagica2 by Mithion.
the class TileEntitySummoner method summonCreature.
private void summonCreature() {
if (worldObj.isRemote || this.summonEntityID != -1)
return;
if (dummyCaster == null) {
dummyCaster = new DummyEntityPlayer(worldObj);
}
EntityLiving summon = ((Summon) SkillManager.instance.getSkill("Summon")).summonCreature(inventory[SUMMON_SLOT], dummyCaster, dummyCaster, worldObj, xCoord, yCoord, zCoord);
if (summon != null) {
if (summon instanceof EntityCreature)
EntityUtilities.setGuardSpawnLocation((EntityCreature) summon, xCoord, yCoord, zCoord);
this.summonEntityID = summon.getEntityId();
PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(this.worldObj).getHighestPowerType(this), summonCost);
this.summonCooldown = this.maxSummonCooldown;
EntityUtilities.setTileSpawned(summon, this);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
use of am2.utility.DummyEntityPlayer in project ArsMagica2 by Mithion.
the class FlickerOperatorFelledOak method DoOperation.
@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
int radius = 6;
dummyPlayer = new DummyEntityPlayer(worldObj);
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
Block block = worldObj.getBlock(((TileEntity) habitat).xCoord + i, ((TileEntity) habitat).yCoord, ((TileEntity) habitat).zCoord + j);
if (block == Blocks.air)
continue;
if (block.isWood(worldObj, ((TileEntity) habitat).xCoord + i, ((TileEntity) habitat).yCoord, ((TileEntity) habitat).zCoord + j)) {
if (!worldObj.isRemote)
beginTreeFelling(worldObj, ((TileEntity) habitat).xCoord + i, ((TileEntity) habitat).yCoord, ((TileEntity) habitat).zCoord + j);
return true;
}
}
}
return false;
}
Aggregations