Search in sources :

Example 11 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project Gaia-Dimension by Andromander.

the class GDLiquidBismuth method mixFluids.

@Override
public void mixFluids(World world, BlockPos pos) {
    for (EnumFacing side : EnumFacing.VALUES) {
        if (side != EnumFacing.DOWN) {
            IBlockState offset = world.getBlockState(pos.offset(side));
            if (offset.getMaterial().isLiquid()) {
                if (offset.getBlock() == GDBlocks.sweet_muck_block || offset.getBlock() == GDBlocks.superhot_magma_block) {
                    world.setBlockState(pos, GDBlocks.active_rock.getDefaultState());
                    this.playSound(world, pos);
                    break;
                } else if (offset.getBlock() instanceof BlockFluidBase || offset.getBlock() instanceof BlockLiquid) {
                    if (offset.getMaterial() == Material.WATER) {
                        world.setBlockState(pos, GDBlocks.impure_rock.getDefaultState());
                        this.playSound(world, pos);
                        break;
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) EnumFacing(net.minecraft.util.EnumFacing)

Example 12 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project Wurst-MC-1.12 by Wurst-Imperium.

the class GlideMod method onUpdate.

@Override
public void onUpdate() {
    EntityPlayerSP player = WMinecraft.getPlayer();
    if (!player.isAirBorne || player.isInWater() || player.isInLava() || player.isOnLadder() || player.motionY >= 0)
        return;
    if (minHeight.getValue() > 0) {
        AxisAlignedBB box = player.getEntityBoundingBox();
        box = box.expand(0, -minHeight.getValue(), 0);
        if (WWorld.collidesWithAnyBlock(box))
            return;
        BlockPos min = new BlockPos(new Vec3d(box.minX, box.minY, box.minZ));
        BlockPos max = new BlockPos(new Vec3d(box.maxX, box.maxY, box.maxZ));
        Stream<BlockPos> stream = StreamSupport.stream(BlockPos.getAllInBox(min, max).spliterator(), true);
        // manual collision check, since liquids don't have bounding boxes
        if (stream.map(WBlock::getBlock).anyMatch(b -> b instanceof BlockLiquid))
            return;
    }
    player.motionY = Math.max(player.motionY, -fallSpeed.getValue());
    player.jumpMovementFactor *= moveSpeed.getValueF();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockLiquid(net.minecraft.block.BlockLiquid) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Vec3d(net.minecraft.util.math.Vec3d)

Example 13 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project RFTools by McJty.

the class SensorTileEntity method checkFluid.

private boolean checkFluid(BlockPos newpos) {
    IBlockState state = getWorld().getBlockState(newpos);
    ItemStack matcher = inventoryHelper.getStackInSlot(0);
    Block block = state.getBlock();
    if (matcher.isEmpty()) {
        if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
            return !block.isAir(state, getWorld(), newpos);
        }
        return false;
    }
    ItemStack stack = block.getItem(getWorld(), newpos, state);
    Item matcherItem = matcher.getItem();
    FluidStack matcherFluidStack = null;
    // }
    if (matcherItem instanceof ItemBucket || matcherItem instanceof UniversalBucket) {
        matcherFluidStack = new FluidBucketWrapper(matcher).getFluid();
        return checkFluid(block, matcherFluidStack, state, newpos);
    }
    return false;
}
Also used : UniversalBucket(net.minecraftforge.fluids.UniversalBucket) FluidBucketWrapper(net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) ItemStack(net.minecraft.item.ItemStack) ItemBucket(net.minecraft.item.ItemBucket)

Example 14 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project RFTools by McJty.

the class ScannerTileEntity method mapState.

private IBlockState mapState(List<ModifierEntry> modifiers, Map<IBlockState, IBlockState> modifierMapping, BlockPos pos, IBlockState inState) {
    if (modifiers.isEmpty()) {
        return inState;
    }
    if (!modifierMapping.containsKey(inState)) {
        IBlockState outState = inState;
        boolean stop = false;
        for (ModifierEntry modifier : modifiers) {
            if (stop) {
                break;
            }
            switch(modifier.getType()) {
                case FILTER_SLOT:
                    {
                        ItemStack inputItem = inState.getBlock().getItem(getWorld(), pos, inState);
                        if (!modifier.getIn().isEmpty() && modifier.getIn().getItem() == ModularStorageSetup.storageFilterItem) {
                            StorageFilterCache filter = StorageFilterItem.getCache(modifier.getIn());
                            if (filter.match(inputItem)) {
                                outState = getOutput(inState, modifier);
                                stop = true;
                            }
                        } else {
                            // Empty input stack in modifier also matches
                            if (modifier.getIn().isEmpty() || ItemStack.areItemsEqual(inputItem, modifier.getIn())) {
                                outState = getOutput(inState, modifier);
                                stop = true;
                            }
                        }
                        break;
                    }
                case FILTER_ORE:
                    {
                        ItemStack inputItem = inState.getBlock().getItem(getWorld(), pos, inState);
                        if (!inputItem.isEmpty()) {
                            int[] oreIDs = OreDictionary.getOreIDs(inputItem);
                            for (int id : oreIDs) {
                                if (OreDictionary.getOreName(id).startsWith("ore")) {
                                    outState = getOutput(inState, modifier);
                                    stop = true;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                case FILTER_LIQUID:
                    if (inState.getBlock() instanceof BlockLiquid) {
                        outState = getOutput(inState, modifier);
                        stop = true;
                    }
                    break;
                case FILTER_TILEENTITY:
                    if (getWorld().getTileEntity(pos) != null) {
                        outState = getOutput(inState, modifier);
                        stop = true;
                    }
                    break;
            }
        }
        modifierMapping.put(inState, outState);
    }
    return modifierMapping.get(inState);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) StorageFilterCache(mcjty.rftools.items.storage.StorageFilterCache) ModifierEntry(mcjty.rftools.items.modifier.ModifierEntry) ItemStack(net.minecraft.item.ItemStack)

Example 15 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project Galacticraft by micdoodle8.

the class EntityBacterialDripFX method onUpdate.

@Override
public void onUpdate() {
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.particleRed = 0.0F;
    this.particleGreen = 0.2F;
    this.particleBlue = 0.1F;
    this.motionY -= this.particleGravity;
    if (this.bobTimer-- > 0) {
        this.motionX *= 0.02D;
        this.motionY *= 0.02D;
        this.motionZ *= 0.02D;
        this.setParticleTextureIndex(113);
    } else {
        this.setParticleTextureIndex(112);
    }
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;
    if (this.particleMaxAge-- <= 0) {
        this.setDead();
    }
    if (this.onGround) {
        this.setDead();
        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }
    BlockPos pos = new BlockPos(this);
    IBlockState state = this.worldObj.getBlockState(pos);
    Material material = state.getBlock().getMaterial();
    if (material.isLiquid() || material.isSolid()) {
        double d0 = 0.0D;
        if (state.getBlock() instanceof BlockLiquid) {
            d0 = BlockLiquid.getLiquidHeightPercent(((Integer) state.getValue(BlockLiquid.LEVEL)).intValue());
        }
        double d1 = MathHelper.floor_double(this.posY) + 1 - d0;
        if (this.posY < d1) {
            this.setDead();
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockPos(net.minecraft.util.BlockPos) Material(net.minecraft.block.material.Material)

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