use of net.minecraftforge.fluids.IFluidBlock in project MorePlanets by SteveKunG.
the class LiquidUtils method isInsideLiquid.
@Deprecated
private static boolean isInsideLiquid(EntityPlayer player, BlockPos pos) {
IBlockState state = player.world.getBlockState(pos);
Block block = state.getBlock();
double eyes = player.posY + player.getEyeHeight();
double filled = 1.0F;
if (block instanceof IFluidBlock) {
filled = ((IFluidBlock) block).getFilledPercentage(player.world, pos);
} else if (block instanceof BlockLiquid) {
filled = 1.0F - (BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state)) - 1.0F / 9.0F);
}
if (filled < 0.0F) {
return eyes > pos.getY() + (filled + 1.0F);
} else {
return eyes < pos.getY() + filled;
}
}
use of net.minecraftforge.fluids.IFluidBlock in project GregTech by GregTechCE.
the class SurfaceRockPopulator method findUndergroundMaterials.
private Set<Material> findUndergroundMaterials(Collection<IBlockState> generatedBlocks) {
HashSet<Material> result = new HashSet<>();
for (IBlockState blockState : generatedBlocks) {
Material resultMaterial;
if (blockState.getBlock() instanceof IFluidBlock || blockState.getBlock() instanceof BlockLiquid) {
Fluid fluid = FluidRegistry.lookupFluidForBlock(blockState.getBlock());
resultMaterial = fluid == null ? null : MetaFluids.getMaterialFromFluid(fluid);
} else {
ItemStack itemStack = new ItemStack(blockState.getBlock(), 1, blockState.getBlock().damageDropped(blockState));
UnificationEntry entry = OreDictUnifier.getUnificationEntry(itemStack);
resultMaterial = entry == null ? null : entry.material;
}
if (resultMaterial != null) {
result.add(resultMaterial);
}
}
return result;
}
use of net.minecraftforge.fluids.IFluidBlock in project GregTech by GregTechCE.
the class MetaTileEntityPump method updateQueueState.
private void updateQueueState(int blocksToCheckAmount) {
BlockPos selfPos = getPos().down(pumpHeadY);
for (int i = 0; i < blocksToCheckAmount; i++) {
BlockPos checkPos = null;
int amountIterated = 0;
do {
if (checkPos != null) {
blocksToCheck.push(checkPos);
amountIterated++;
}
checkPos = blocksToCheck.poll();
} while (checkPos != null && !getWorld().isBlockLoaded(checkPos) && amountIterated < blocksToCheck.size());
if (checkPos != null) {
checkFluidBlockAt(selfPos, checkPos);
} else
break;
}
if (fluidSourceBlocks.isEmpty()) {
if (getOffsetTimer() % 20 == 0) {
BlockPos downPos = selfPos.down(1);
if (downPos != null && downPos.getY() >= 0) {
IBlockState downBlock = getWorld().getBlockState(downPos);
if (downBlock.getBlock() instanceof BlockLiquid || downBlock.getBlock() instanceof IFluidBlock || !downBlock.isTopSolid()) {
this.pumpHeadY++;
}
}
// Always recheck next time
writeCustomData(200, b -> b.writeVarInt(pumpHeadY));
markDirty();
// schedule queue rebuild because we changed our position and no fluid is available
this.initializedQueue = false;
}
if (!initializedQueue || getOffsetTimer() % 6000 == 0 || getTimer() == 0) {
this.initializedQueue = true;
// just add ourselves to check list and see how this will go
this.blocksToCheck.add(selfPos);
}
}
}
use of net.minecraftforge.fluids.IFluidBlock in project Galacticraft by micdoodle8.
the class EntityAstroMiner method tryBlockClient.
private boolean tryBlockClient(BlockPos pos) {
BlockVec3 bv = new BlockVec3(pos.getX(), pos.getY(), pos.getZ());
if (this.laserBlocks.contains(bv)) {
return false;
}
// Add minable blocks to the laser fx list
IBlockState state = this.world.getBlockState(pos);
Block b = state.getBlock();
if (b.getMaterial(state) == Material.AIR) {
return false;
}
if (noMineList.contains(b)) {
return true;
}
if (b instanceof BlockLiquid) {
return false;
}
if (b instanceof IFluidBlock) {
return false;
}
if (b instanceof IPlantable) {
return true;
}
if (b.hasTileEntity(state) || b.getBlockHardness(state, this.world, pos) < 0) {
return true;
}
if (this.tryBlockLimit == 0) {
return false;
}
this.tryBlockLimit--;
this.laserBlocks.add(bv);
this.laserTimes.add(this.ticksExisted);
return false;
}
use of net.minecraftforge.fluids.IFluidBlock in project Galacticraft by micdoodle8.
the class EntityAstroMiner method tryMineBlock.
private boolean tryMineBlock(BlockPos pos) {
// Check things to avoid in front of it (see static list for list) including base type things
// Can move through liquids including flowing lava
IBlockState state = this.world.getBlockState(pos);
Block b = state.getBlock();
if (b.getMaterial(state) == Material.AIR) {
return false;
}
if (noMineList.contains(b)) {
blockingBlock.block = b;
blockingBlock.meta = b.getMetaFromState(state);
return true;
}
if (b instanceof BlockLiquid) {
if ((b == Blocks.LAVA || b == Blocks.FLOWING_LAVA) && state.getValue(BlockLiquid.LEVEL) == 0 && this.AIstate != AISTATE_RETURNING) {
blockingBlock.block = Blocks.LAVA;
blockingBlock.meta = 0;
return true;
}
return false;
}
if (b instanceof IFluidBlock) {
return false;
}
boolean gtFlag = false;
if (b != GCBlocks.fallenMeteor) {
if (b instanceof IPlantable && b != Blocks.TALLGRASS && b != Blocks.DEADBUSH && b != Blocks.DOUBLE_PLANT && b != Blocks.WATERLILY && !(b instanceof BlockFlower) && b != Blocks.REEDS) {
blockingBlock.block = b;
blockingBlock.meta = b.getMetaFromState(state);
return true;
}
int meta = b.getMetaFromState(state);
if (b.getBlockHardness(state, this.world, pos) < 0) {
blockingBlock.block = b;
blockingBlock.meta = meta;
return true;
}
if (b.hasTileEntity(state)) {
if (CompatibilityManager.isGTLoaded() && gregTechCheck(b)) {
gtFlag = true;
} else {
blockingBlock.block = b;
blockingBlock.meta = meta;
return true;
}
}
}
if (this.tryBlockLimit == 0) {
return false;
}
int result = ForgeHooks.onBlockBreakEvent(this.world, this.playerMP.interactionManager.getGameType(), this.playerMP, pos);
if (result < 0) {
blockingBlock.block = Blocks.STONE;
blockingBlock.meta = 0;
return true;
}
this.tryBlockLimit--;
// Collect the mined block - unless it's a plant or leaves in which case just break it
if (!((b instanceof IPlantable && !(b instanceof BlockReed)) || b instanceof BlockLeaves)) {
ItemStack drops = gtFlag ? getGTDrops(this.world, pos, b) : getPickBlock(this.world, pos, b);
if (drops != null && !this.addToInventory(drops)) {
// drop itemstack if AstroMiner can't hold it
dropStack(pos, drops);
}
}
this.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
return false;
}
Aggregations