use of net.minecraftforge.fluids.IFluidBlock in project ICBM-Classic by BuiltBrokenModding.
the class BlastSonic method doPreExplode.
@Override
public void doPreExplode() {
if (!this.world().isRemote) {
if (this.hasShockWave) {
for (int x = (int) (-this.getRadius() * 2); x < this.getRadius() * 2; ++x) {
for (int y = (int) (-this.getRadius() * 2); y < this.getRadius() * 2; ++y) {
for (int z = (int) (-this.getRadius() * 2); z < this.getRadius() * 2; ++z) {
Location targetPosition = position.add(new Pos(x, y, z));
Block blockID = world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
if (blockID != Blocks.air) {
Material material = blockID.getMaterial();
if (blockID != Blocks.bedrock && !(material.isLiquid()) && (blockID.getExplosionResistance(this.exploder, world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), position.xi(), position.yi(), position.zi()) > this.nengLiang || material == Material.glass)) {
targetPosition.setBlock(world(), Blocks.air);
}
}
}
}
}
}
this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.nengLiang, this.exploder, new IThreadCallBack() {
@Override
public float getResistance(World world, IPos3D explosionPosition, IPos3D targetPosition, Entity source, Block block) {
float resistance = 0;
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
resistance = 1f;
} else {
resistance = block.getExplosionResistance(source, world, (int) targetPosition.x(), (int) targetPosition.y(), (int) targetPosition.z(), explosionPosition.x(), explosionPosition.y(), explosionPosition.z());
}
return resistance;
}
});
this.thread.start();
}
if (this.hasShockWave) {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "hypersonic", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
} else {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "sonicwave", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
}
use of net.minecraftforge.fluids.IFluidBlock in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method doDestroyBlocks.
protected void doDestroyBlocks() {
// Try to find and grab some blocks to orbit
int blocksDestroyed = 0;
for (int currentRadius = 1; currentRadius < getRadius(); currentRadius++) {
for (int xr = -currentRadius; xr < currentRadius; xr++) {
for (int yr = -currentRadius; yr < currentRadius; yr++) {
for (int zr = -currentRadius; zr < currentRadius; zr++) {
final Location currentPos = position.add(xr, yr, zr);
final double dist = position.distance(currentPos);
//We are looping in a shell orbit around the center
if (dist < currentRadius && dist > currentRadius - 2) {
final Block block = currentPos.getBlock();
//Null if call was made on an unloaded chunk
if (block != null) {
int meta = currentPos.getBlockMetadata();
//Ignore air blocks and unbreakable blocks
if (!block.isAir(world(), currentPos.xi(), currentPos.yi(), currentPos.zi()) && block.getBlockHardness(this.world(), currentPos.xi(), currentPos.yi(), currentPos.zi()) >= 0) {
//TODO handle multi-blocks
final boolean isFluid = block instanceof BlockLiquid || block instanceof IFluidBlock;
currentPos.setBlock(Blocks.air, 0, isFluid ? 0 : 3);
//TODO: render fluid streams moving into hole
if (!isFluid && doFlyingBlocks) {
//Convert a random amount of destroyed blocks into flying blocks for visuals
if (this.world().rand.nextFloat() > 0.8) {
EntityFlyingBlock entity = new EntityFlyingBlock(this.world(), currentPos.add(0.5D), block, meta);
entity.yawChange = 50 * this.world().rand.nextFloat();
entity.pitchChange = 50 * this.world().rand.nextFloat();
this.world().spawnEntityInWorld(entity);
}
}
//Keep track of blocks removed to keep from lagging the game
blocksDestroyed++;
if (blocksDestroyed > this.MAX_BLOCKS_REMOVED_PER_TICK) {
return;
}
}
}
}
}
}
}
}
}
use of net.minecraftforge.fluids.IFluidBlock in project BluePower by Qmunity.
the class TileMachineBase method ejectItems.
private void ejectItems() {
for (Iterator<TubeStack> iterator = internalItemStackBuffer.iterator(); iterator.hasNext(); ) {
TubeStack tubeStack = iterator.next();
if (IOHelper.canInterfaceWith(getTileCache(getOutputDirection()), getFacingDirection())) {
ItemStack returnedStack = IOHelper.insert(getTileCache(getOutputDirection()), tubeStack.stack, getFacingDirection(), tubeStack.color, false);
if (returnedStack == null) {
iterator.remove();
markDirty();
if (!ejectionScheduled)
break;
} else if (returnedStack.stackSize != tubeStack.stack.stackSize) {
markDirty();
if (!ejectionScheduled)
break;
} else {
break;
}
} else if (spawnItemsInWorld) {
ForgeDirection direction = getFacingDirection().getOpposite();
if ((worldObj.getBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ).getBlocksMovement(worldObj, xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ)) || (worldObj.getBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ) instanceof BlockLiquid) || (worldObj.getBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ) instanceof IFluidBlock)) {
ejectItemInWorld(tubeStack.stack, direction);
iterator.remove();
markDirty();
} else {
break;
}
}
}
}
use of net.minecraftforge.fluids.IFluidBlock in project NetherEx by LogicTechCorp.
the class NetherExModels method registerModel.
private static void registerModel(IFluidBlock block) {
Item item = Item.getItemFromBlock((Block) block);
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelLocation = new ModelResourceLocation(NetherEx.MOD_ID + ":fluid", block.getFluid().getName());
ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelLocation));
ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelLocation;
}
});
}
use of net.minecraftforge.fluids.IFluidBlock in project NewHorizonsCoreMod by GTNewHorizons.
the class OilGeneratorFix method getTopBlock.
private int getTopBlock(World pWorld, int pLocX, int pLocZ) {
Chunk tChunk = pWorld.getChunkFromBlockCoords(pLocX, pLocZ);
int y = tChunk.getTopFilledSegment() + 15;
int trimmedX = pLocX & 0xF;
int trimmedZ = pLocZ & 0xF;
for (; y > 0; y--) {
Block tBlock = tChunk.getBlock(trimmedX, y, trimmedZ);
if (!tBlock.isAir(pWorld, pLocX, y, pLocZ)) {
if ((tBlock instanceof BlockStaticLiquid)) {
return y;
}
if ((tBlock instanceof BlockFluidBase)) {
return y;
}
if ((tBlock instanceof IFluidBlock)) {
return y;
}
if (tBlock.getMaterial().blocksMovement()) {
if (!(tBlock instanceof BlockFlower)) {
return y - 1;
}
}
}
}
return -1;
}
Aggregations