use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.
the class SimpleBlockRenderHandler method renderEverstoneBlock.
private void renderEverstoneBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (world == null)
return;
if (block == null)
return;
GL11.glColor4f(1, 1, 1, 1);
TileEntityEverstone te = (TileEntityEverstone) Minecraft.getMinecraft().theWorld.getTileEntity(x, y, z);
if (te != null) {
Block fBlock = te.getFacade();
if (fBlock != null) {
if (te.isSolid()) {
IBlockAccess old = renderer.blockAccess;
renderer.blockAccess = this.blockAccess;
this.blockAccess.setControllingTileEntity(te);
this.blockAccess.setFakeBlockAndMeta(te.getFacade(), te.getFacadeMeta());
this.blockAccess.setOuterBlockAccess(world);
this.blockAccess.setOverrideCoords(x, y, z);
renderer.renderStandardBlock(fBlock, x, y, z);
this.blockAccess.setOuterBlockAccess(null);
renderer.blockAccess = old;
} else {
Tessellator.instance.setColorRGBA(te.getFadeStrength(), te.getFadeStrength(), te.getFadeStrength(), te.getFadeStrength());
renderer.renderFaceYPos(block, x, y, z, fBlock.getIcon(1, te.getFacadeMeta()));
renderer.renderFaceYNeg(block, x, y, z, fBlock.getIcon(0, te.getFacadeMeta()));
renderer.renderFaceXPos(block, x, y, z, fBlock.getIcon(2, te.getFacadeMeta()));
renderer.renderFaceXNeg(block, x, y, z, fBlock.getIcon(3, te.getFacadeMeta()));
renderer.renderFaceZPos(block, x, y, z, fBlock.getIcon(4, te.getFacadeMeta()));
renderer.renderFaceZNeg(block, x, y, z, fBlock.getIcon(5, te.getFacadeMeta()));
}
} else {
renderer.renderStandardBlock(block, x, y, z);
}
}
}
use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.
the class TileEntityEverstone method propagatePoweredByEverstone.
private void propagatePoweredByEverstone(boolean powered, ArrayList<ChunkPosition> completedUpdates) {
ChunkPosition myPosition = new ChunkPosition(xCoord, yCoord, zCoord);
if (completedUpdates.contains(myPosition)) {
return;
}
completedUpdates.add(myPosition);
poweredFromEverstone = powered;
onBreak();
if (worldObj.isRemote) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "radiant", xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f);
if (particle != null) {
particle.setMaxAge(20);
particle.setDontRequireControllers();
particle.setIgnoreMaxAge(false);
}
}
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
ChunkPosition targetPosition = new ChunkPosition(xCoord + i, yCoord + j, zCoord + k);
Block blockID = worldObj.getBlock(targetPosition.chunkPosX, targetPosition.chunkPosY, targetPosition.chunkPosZ);
if (blockID == BlocksCommonProxy.everstone && !completedUpdates.contains(targetPosition)) {
TileEntityEverstone everstone = ((TileEntityEverstone) worldObj.getTileEntity(targetPosition.chunkPosX, targetPosition.chunkPosY, targetPosition.chunkPosZ));
if (everstone != null)
everstone.propagatePoweredByEverstone(powered, completedUpdates);
}
}
}
}
}
use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.
the class BlockEverstone method addHitEffects.
@Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
TileEntityEverstone everstone = getTE(worldObj, target.blockX, target.blockY, target.blockZ);
AMParticle particle;
Block block;
int blockMeta = 0;
if (everstone == null || everstone.getFacade() == null) {
block = this;
} else {
block = everstone.getFacade();
if (block == null)
block = this;
blockMeta = everstone.getFacadeMeta();
}
effectRenderer.addEffect(new EntityDiggingFX(worldObj, target.blockX + worldObj.rand.nextDouble(), target.blockY + worldObj.rand.nextDouble(), target.blockZ + worldObj.rand.nextDouble(), 0, 0, 0, block, blockMeta, 0));
return true;
}
use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.
the class BlockEverstone method getBlockHardness.
@Override
public float getBlockHardness(World world, int x, int y, int z) {
TileEntityEverstone everstone = getTE(world, x, y, z);
if (everstone == null)
return this.blockHardness;
Block block = everstone.getFacade();
if (block == null || block == this)
return this.blockHardness;
return block.getBlockHardness(world, x, y, z);
}
use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.
the class BlockEverstone method addDestroyEffects.
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
TileEntityEverstone everstone = getTE(world, x, y, z);
for (int i = 0; i < 5 * AMCore.config.getGFXLevel(); ++i) {
Block block = Blocks.air;
int blockMeta = 0;
if (everstone == null || everstone.getFacade() == null) {
block = this;
} else {
block = everstone.getFacade();
if (block == null)
block = this;
blockMeta = everstone.getFacadeMeta();
}
effectRenderer.addEffect(new EntityDiggingFX(world, x + world.rand.nextDouble(), y + world.rand.nextDouble(), z + world.rand.nextDouble(), 0, 0, 0, block, blockMeta, 0));
}
return true;
}
Aggregations