use of net.minecraft.block.BlockLiquid in project RFToolsDimensions by McJty.
the class KnownDimletConfiguration method initMaterialDimlet.
private static void initMaterialDimlet(Block block) {
if (block instanceof BlockLiquid) {
return;
}
Set<Filter.Feature> features = getBlockFeatures(block);
ResourceLocation nameForObject = Block.blockRegistry.getNameForObject(block);
String mod = nameForObject.getResourceDomain();
for (IBlockState state : block.getBlockState().getValidStates()) {
int meta = state.getBlock().getMetaFromState(state);
List<IProperty> propertyNames = new ArrayList<>(state.getPropertyNames());
propertyNames.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
ImmutableMap<IProperty, Comparable> properties = state.getProperties();
Map<String, String> props = new HashMap<>();
for (Map.Entry<IProperty, Comparable> entry : properties.entrySet()) {
props.put(entry.getKey().getName(), entry.getValue().toString());
}
DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
Settings settings = DimletRules.getSettings(key, mod, features, props);
if (!settings.isBlacklisted()) {
knownDimlets.put(key, settings);
}
}
}
use of net.minecraft.block.BlockLiquid in project MorePlanets by SteveKunG.
the class ParticleCustomRain method onUpdate.
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= this.particleGravity;
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (this.particleMaxAge-- <= 0) {
this.setExpired();
}
if (this.onGround) {
if (Math.random() < 0.5D) {
this.setExpired();
}
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
BlockPos pos = new BlockPos(this.posX, this.posY, this.posZ);
IBlockState state = this.world.getBlockState(pos);
Material material = state.getMaterial();
if (material.isLiquid() || material.isSolid()) {
double d0;
if (state.getBlock() instanceof BlockLiquid) {
d0 = 1.0F - BlockLiquid.getLiquidHeightPercent(state.getValue(BlockLiquid.LEVEL));
} else {
d0 = state.getBoundingBox(this.world, pos).maxY;
}
double d1 = MathHelper.floor(this.posY) + d0;
if (this.posY < d1) {
this.setExpired();
}
}
}
use of net.minecraft.block.BlockLiquid 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.minecraft.block.BlockLiquid in project GregTech by GregTechCE.
the class MetaTileEntityFisher method update.
@Override
public void update() {
super.update();
ItemStack baitStack = importItems.getStackInSlot(0);
if (!getWorld().isRemote && energyContainer.getEnergyStored() >= energyAmountPerFish && getOffsetTimer() % fishingTicks == 0L && !baitStack.isEmpty()) {
WorldServer world = (WorldServer) this.getWorld();
int waterCount = 0;
int edgeSize = (int) Math.sqrt(WATER_CHECK_SIZE);
for (int x = 0; x < edgeSize; x++) {
for (int z = 0; z < edgeSize; z++) {
BlockPos waterCheckPos = getPos().down().add(x - edgeSize / 2, 0, z - edgeSize / 2);
if (world.getBlockState(waterCheckPos).getBlock() instanceof BlockLiquid && world.getBlockState(waterCheckPos).getMaterial() == Material.WATER) {
waterCount++;
}
}
}
if (waterCount == WATER_CHECK_SIZE) {
LootTable table = world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING);
NonNullList<ItemStack> itemStacks = NonNullList.create();
itemStacks.addAll(table.generateLootForPools(world.rand, new LootContext.Builder(world).build()));
if (addItemsToItemHandler(exportItems, true, itemStacks)) {
addItemsToItemHandler(exportItems, false, itemStacks);
energyContainer.removeEnergy(energyAmountPerFish);
baitStack.shrink(1);
}
}
}
if (!getWorld().isRemote && getOffsetTimer() % 5 == 0) {
pushItemsIntoNearbyHandlers(getFrontFacing());
}
}
use of net.minecraft.block.BlockLiquid 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);
}
}
}
Aggregations