Search in sources :

Example 26 with BlockLiquid

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);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IProperty(net.minecraft.block.properties.IProperty) ResourceLocation(net.minecraft.util.ResourceLocation) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 27 with BlockLiquid

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();
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockPos(net.minecraft.util.math.BlockPos) Material(net.minecraft.block.material.Material)

Example 28 with BlockLiquid

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;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block)

Example 29 with BlockLiquid

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());
    }
}
Also used : LootTable(net.minecraft.world.storage.loot.LootTable) BlockLiquid(net.minecraft.block.BlockLiquid) LootContext(net.minecraft.world.storage.loot.LootContext) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 30 with BlockLiquid

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);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockLiquid (net.minecraft.block.BlockLiquid)57 IBlockState (net.minecraft.block.state.IBlockState)44 Block (net.minecraft.block.Block)27 BlockPos (net.minecraft.util.math.BlockPos)22 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)20 Material (net.minecraft.block.material.Material)11 ItemStack (net.minecraft.item.ItemStack)8 EnumFacing (net.minecraft.util.EnumFacing)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 BlockPos (net.minecraft.util.BlockPos)4 BlockFluidBase (net.minecraftforge.fluids.BlockFluidBase)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)4 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3 Entity (net.minecraft.entity.Entity)3 World (net.minecraft.world.World)3 IPlantable (net.minecraftforge.common.IPlantable)3 Location (com.builtbroken.mc.imp.transform.vector.Location)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2