Java 类net.minecraftforge.fluids.BlockFluidClassic 实例源码

项目:EnderIOAddons    文件:EngineNiard.java   
public EngineNiard setFluid(Fluid fluid) {
  if (fluid.canBePlacedInWorld()) {
    this.radiusItr = radius >= 0 ? new RadiusIterator(owner.getLocation(), radius) : null;
    this.fluid = fluid;
    this.downflowDirection = fluid.getDensity() > 0 ? ForgeDirection.DOWN : ForgeDirection.UP;
    block = fluid.getBlock();
    if (block instanceof BlockFluidClassic) {
      type = FluidType.CLASSIC;
    } else if (block instanceof BlockFluidFinite) {
      type = FluidType.FINITE;
    } else if (block instanceof BlockLiquid) {
      type = FluidType.VANILLA;
    } else {
      this.fluid = null;
    }
  } else {
    this.fluid = null;
  }
  return this;
}
项目:EnderIOAddons    文件:EngineNiard.java   
private void setSourceBlock(BlockCoord bc) {
  Block blockToSet = block;
  int metaToSet = 0;
  final World world = owner.getWorldObj();
  switch (type) {
  case CLASSIC:
    metaToSet = ((BlockFluidClassic) block).getMaxRenderHeightMeta();
    break;
  case FINITE:
    metaToSet = ((BlockFluidFinite) block).getMaxRenderHeightMeta();
    break;
  case VANILLA:
    if (world.provider.isHellWorld && fluid == FluidRegistry.WATER && !niardAllowWaterInHell.getBoolean()) {
      world.playSoundEffect(bc.x + 0.5F, bc.y + 0.1F, bc.z + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
      for (int l = 0; l < 8; ++l) {
        spawnParticle(world, "largesmoke", bc.x - 1 + 3 * Math.random(), bc.y + Math.random(), bc.z - 1 + 3 * Math.random(), 0.0D, 0.0D, 0.0D);
      }
      setVerticalBlock(bc, false);
      return;
    }
    metaToSet = 0;
    break;
  }
  world.setBlock(bc.x, bc.y, bc.z, blockToSet, metaToSet, 3);
}
项目:EnderIOAddons    文件:FluidHelper.java   
private FluidHelper(@Nonnull World world, @Nonnull FluidStack stack, @Nullable BlockCoord startbc) throws Exception {
  this.world = world;
  this.stack = stack;
  this.fluid = notnullF(stack.getFluid(), "FluidStack.getFluid()");
  this.block = notnull(fluid.getBlock(), "Invalid Fluid (it has no source block)");
  this.downflowDirection = fluid.getDensity() > 0 ? ForgeDirection.DOWN : ForgeDirection.UP;
  this.upflowDirection = downflowDirection == ForgeDirection.UP ? ForgeDirection.DOWN : ForgeDirection.UP;
  if (this.block instanceof BlockFluidClassic) {
    this.type = FluidType.CLASSIC;
  } else if (this.block instanceof BlockFluidFinite) {
    this.type = FluidType.FINITE;
  } else if (this.block instanceof BlockLiquid) {
    this.type = FluidType.VANILLA;
  } else {
    throw new Exception();
  }
  this.startbc = startbc;
}
项目:Industrial-Foregoing    文件:BlockRegistry.java   
@Override
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) {
    if (state.getBlock() instanceof BlockFluidClassic && ((BlockFluidClassic) state.getBlock()).isSourceBlock(worldIn, pos)) {
        worldIn.setBlockToAir(pos);
        EntityPinkSlime pinkSlime = new EntityPinkSlime(worldIn);
        pinkSlime.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
        worldIn.spawnEntity(pinkSlime);
    }
}
项目:BetterThanWeagles    文件:CommonProxy.java   
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
    event.getRegistry().register(new BlockButter());
    event.getRegistry().register(new BlockMemeOre());

    event.getRegistry().register(new BlockFluidClassic(ModFluids.liquid_butter, MaterialLiquid.WATER).setRegistryName("liquid_butter").setUnlocalizedName("liquid_butter").setCreativeTab(BetterThanWeagles.tabBTWeagles));
}
项目:CrystalMod    文件:ItemBucketCrystalMod.java   
public static ItemBucketCrystalMod create(BlockFluidClassic block, Fluid fluid) {
    ItemBucketCrystalMod b = new ItemBucketCrystalMod(block != null ? block : Blocks.AIR, fluid.getName());
    b.init();
    //FluidContainerRegistry.registerFluidContainer(fluid, new ItemStack(b), new ItemStack(Items.BUCKET));
    /*if (block != null) {
      BucketHandler.instance.registerFluid(block, b);
    }*/

    return b;
}
项目:LightningCraft    文件:LCFluids.java   
/** Register a fluid block with the specified fluid */
private static BlockFluidClassic registerFluidBlock(Fluid fluid, String blockName) {
    BlockFluidClassic block = new BlockFluidLC(fluid);

    ResourceLocation location = new ResourceLocation(RefStrings.MODID, blockName);
    block.setRegistryName(location);
    block.setUnlocalizedName(location.toString());
    GameRegistry.register(block);

    fluidBlocks.put(fluid, block);
    fluidBlockNames.put(block, blockName);
    return block;
}
项目:EnderIOAddons    文件:EngineNiard.java   
private boolean isFlowingBlock(@Nonnull BlockCoord bc) {
  switch (type) {
  case CLASSIC:
    return !((BlockFluidClassic) block).isSourceBlock(owner.getWorldObj(), bc.x, bc.y, bc.z);
  case FINITE:
    return false;
  case VANILLA:
    return owner.getWorldObj().getBlockMetadata(bc.x, bc.y, bc.z) != 0;
  }
  throw new IllegalStateException("unreachable code");
}
项目:EnderIOAddons    文件:FluidHelper.java   
public static boolean isSourceBlock(@Nonnull World world, @Nonnull BlockCoord bc) {
  if (!world.blockExists(bc.x, bc.y, bc.z)) {
    return false;
  }
  Block block = bc.getBlock(world);
  if (block instanceof BlockFluidClassic) {
    return ((BlockFluidClassic) block).isSourceBlock(world, bc.x, bc.y, bc.z);
  } else if (block instanceof BlockFluidFinite) {
    return ((BlockFluidFinite)block).canDrain(world, bc.x, bc.y, bc.z);
  } else if (block instanceof BlockLiquid) {
    return world.getBlockMetadata(bc.x, bc.y, bc.z) == 0;
  } else {
    return false;
  }
}
项目:EnderIOAddons    文件:FluidHelper.java   
public boolean isSourceBlock(@Nonnull BlockCoord bc) {
  switch (type) {
  case CLASSIC:
    return ((BlockFluidClassic) block).isSourceBlock(world, bc.x, bc.y, bc.z);
  case FINITE:
    return false;
  case VANILLA:
    return world.getBlockMetadata(bc.x, bc.y, bc.z) == 0;
  }
  throw new IllegalStateException("unreachable code");
}
项目:EnderIOAddons    文件:FluidHelper.java   
public boolean isFlowingBlock(@Nonnull BlockCoord bc) {
  switch (type) {
  case CLASSIC:
    return !((BlockFluidClassic) block).isSourceBlock(world, bc.x, bc.y, bc.z);
  case FINITE:
    return false;
  case VANILLA:
    return world.getBlockMetadata(bc.x, bc.y, bc.z) != 0;
  }
  throw new IllegalStateException("unreachable code");
}
项目:OresPlus    文件:BucketHandler.java   
private ItemStack fillOreBucket(World world, MovingObjectPosition target) {
    Block targetBlock = world.getBlock(target.blockX, target.blockY, target.blockZ);
    if (!(targetBlock instanceof BlockFluidClassic)) {
        return null;
    }
    ItemStack filledBucket = FluidContainerRegistry.fillFluidContainer(new FluidStack(((BlockFluidClassic)targetBlock).getFluid(), 1000), new ItemStack(net.minecraft.init.Items.bucket));
    if (filledBucket != null && world.getBlockMetadata(target.blockX, target.blockY, target.blockZ) == 0) {
        world.setBlockToAir(target.blockX, target.blockY, target.blockZ);
        return filledBucket;
    }
    else {
        return null;
    }
}
项目:TechReborn3    文件:TechRebornClient.java   
private static void registerFluid(BlockFluidClassic fluid) {
    final ModelResourceLocation location = new ModelResourceLocation(TRConstants.MOD_ID + ":fluids", fluid.getFluid().getName().toLowerCase());
    ModelLoader.setCustomStateMapper(fluid, new StateMapperBase() {
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return location; }
    });
}
项目:TheStuffMod    文件:BerryBushGen.java   
@Override
public boolean generate (World world, Random random, int startX, int startY, int startZ)
{
    if (alterSize)
    {
        startY = world.getHeightValue(startX, startZ);
    }

    float f = random.nextFloat() * (float) Math.PI;
    int blockNumber = numberOfBlocks;
    if (alterSize)
        blockNumber = numberOfBlocks * 2 / 5 + random.nextInt(numberOfBlocks * 3 / 5);
    double d0 = (double) ((float) (startX + 8) + MathHelper.sin(f) * (float) blockNumber / 8.0F);
    double d1 = (double) ((float) (startX + 8) - MathHelper.sin(f) * (float) blockNumber / 8.0F);
    double d2 = (double) ((float) (startZ + 8) + MathHelper.cos(f) * (float) blockNumber / 8.0F);
    double d3 = (double) ((float) (startZ + 8) - MathHelper.cos(f) * (float) blockNumber / 8.0F);
    double d4 = (double) (startY + random.nextInt(3) - 2);
    double d5 = (double) (startY + random.nextInt(3) - 2);

    for (int l = 0; l <= blockNumber; ++l)
    {
        double d6 = d0 + (d1 - d0) * (double) l / (double) blockNumber;
        double d7 = d4 + (d5 - d4) * (double) l / (double) blockNumber;
        double d8 = d2 + (d3 - d2) * (double) l / (double) blockNumber;
        double d9 = random.nextDouble() * (double) blockNumber / 16.0D;
        double d10 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) blockNumber) + 1.0F) * d9 + 1.0D;
        double d11 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) blockNumber) + 1.0F) * d9 + 1.0D;
        int i1 = MathHelper.floor_double(d6 - d10 / 2.0D);
        int j1 = MathHelper.floor_double(d7 - d11 / 2.0D);
        int k1 = MathHelper.floor_double(d8 - d10 / 2.0D);
        int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);
        int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);
        int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);

        for (int k2 = i1; k2 <= l1; ++k2)
        {
            double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D);

            if (d12 * d12 < 1.0D)
            {
                for (int l2 = j1; l2 <= i2; ++l2)
                {
                    double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D);

                    if (d12 * d12 + d13 * d13 < 1.0D)
                    {
                        for (int i3 = k1; i3 <= j2; ++i3)
                        {
                            double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D);

                            Block block = world.getBlock(k2, l2, i3);
                            if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D)
                            {
                                if (block == null && world.getBlock(k2, l2-1, i3).isOpaqueCube() || !world.getBlock(k2, l2, i3).isOpaqueCube() && world.getBlock(k2, l2-1, i3).isOpaqueCube()) {
                                    if(minableBlock.canPlaceBlockAt(world, k2, l2, i3) && !(world.getBlock(k2, l2, i3) instanceof BlockLiquid) && !(world.getBlock(k2, l2, i3) instanceof BlockFluidClassic)) {
                                        if(minableBlock instanceof BlockBasicBush && !BlockBasicBush.isWaterNearby(world, k2, l2, i3)) {return false;}
                                        else {
                                            world.setBlock(k2, l2, i3, this.minableBlock, minableBlockMeta, 2);
                                            world.scheduleBlockUpdate(k2, l2, i3, world.getBlock(k2, l2, i3), 1);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return true;
}