use of net.minecraftforge.fluids.IFluidBlock in project Wizardry by TeamWizardry.
the class BlockFluidMana method run.
public static void run(World world, BlockPos pos, Block block, Entity entity, Predicate<Entity> test, Consumer<Entity> process) {
if (!(block instanceof IFluidBlock))
return;
float height;
IBlockState up = world.getBlockState(pos.up());
if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock)
height = 1f;
else
height = ((IFluidBlock) block).getFilledPercentage(world, pos) * 0.875f;
AxisAlignedBB bb = new AxisAlignedBB(pos).contract(0, 1 - height, 0);
AxisAlignedBB entityBox = entity.getCollisionBoundingBox();
if ((entityBox == null || entityBox.intersects(bb)) && test.test(entity))
process.accept(entity);
}
use of net.minecraftforge.fluids.IFluidBlock in project Wizardry by TeamWizardry.
the class BlockFluidLethe method run.
public static void run(World world, BlockPos pos, Block block, Entity entity, Predicate<Entity> test, Consumer<Entity> process) {
if (!(block instanceof IFluidBlock))
return;
float height;
IBlockState up = world.getBlockState(pos.up());
if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock)
height = 1f;
else
height = ((IFluidBlock) block).getFilledPercentage(world, pos) * 0.875f;
AxisAlignedBB bb = new AxisAlignedBB(pos).contract(0, 1 - height, 0);
AxisAlignedBB entityBox = entity.getCollisionBoundingBox();
if ((entityBox == null || entityBox.intersects(bb)) && test.test(entity))
process.accept(entity);
}
use of net.minecraftforge.fluids.IFluidBlock in project TechReborn by TechReborn.
the class DynamicCell method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (!worldIn.isRemote) {
RayTraceResult result = rayTrace(worldIn, playerIn, true);
if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos pos = result.getBlockPos();
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock) block;
if (fluidBlock.canDrain(worldIn, pos)) {
FluidStack fluid = fluidBlock.drain(worldIn, pos, false);
if (fluid != null && fluid.amount == DynamicCell.CAPACITY) {
if (tryAddCellToInventory(playerIn, stack, fluid.getFluid())) {
fluidBlock.drain(worldIn, pos, true);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
}
} else if (block instanceof BlockStaticLiquid) {
Fluid fluid = block.getMaterial(state) == Material.LAVA ? FluidRegistry.LAVA : FluidRegistry.WATER;
if (tryAddCellToInventory(playerIn, stack, fluid)) {
if (fluid != FluidRegistry.WATER)
worldIn.setBlockToAir(pos);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
}
}
return ActionResult.newResult(EnumActionResult.FAIL, stack);
}
use of net.minecraftforge.fluids.IFluidBlock in project NetherEx by LogicTechCorp.
the class NetherExModels method registerModel.
private static void registerModel(IFluidBlock block) {
Item item = Item.getItemFromBlock((Block) block);
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelLocation = new ModelResourceLocation(NetherEx.MOD_ID + ":fluid", block.getFluid().getName());
ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelLocation));
ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelLocation;
}
});
}
use of net.minecraftforge.fluids.IFluidBlock in project Witchworks by Um-Mitternacht.
the class CommonRegistration method registerBlocks.
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
final IForgeRegistry<Block> registry = event.getRegistry();
ModTiles.registerAll();
registry.registerAll(//Crops
new BlockCrop(LibBlockName.CROP_ACONITUM), new BlockCrop(LibBlockName.CROP_ASPHODEL), new BlockCrop(LibBlockName.CROP_GINGER), new CropMint(), new BlockCrop(LibBlockName.CROP_WHITE_SAGE), new BlockCrop(LibBlockName.CROP_MANDRAKE), new BlockCrop(LibBlockName.CROP_LAVENDER), new CropSilphium(), new CropThistle(), new BlockCrop(LibBlockName.CROP_TULSI), new CropKenaf(), new BlockCrop(LibBlockName.CROP_GARLIC), new CropWormwood(), new CropKelp(), new CropBelladonna(), new BlockBeehive(), //Ore
new BlockMod(LibBlockName.SILVER_BLOCK, Material.IRON).setSound(SoundType.METAL).setHardness(5.0F), new BlockMod(LibBlockName.SILVER_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(2.0F), new BlockMod(LibBlockName.MOLDAVITE_BLOCK, Material.ROCK).setSound(SoundType.GLASS).setHardness(5.0F), new BlockMod(LibBlockName.MOLDAVITE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.TOURMALINE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.MALACHITE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.TOURMALINE_BLOCK, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.JASPER_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.BLOODSTONE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.TIGERS_EYE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.NUUMMITE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.GARNET_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.SALT_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.ALEXANDRITE_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.COQUINA, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.CHALK, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.AMETHYST_ORE, Material.ROCK).setSound(SoundType.STONE).setHardness(7.0F), //Normal Blocks
new BlockMod(LibBlockName.BLOODSTONE_BLOCK, Material.ROCK).setSound(SoundType.STONE).setHardness(5.0F), new BlockMod(LibBlockName.NETHERSTEEL, Material.IRON).setSound(SoundType.METAL).setHardness(5.0F), //Tool Blocks
new BlockKettle(), new BlockCandleLarge(), new BlockCandleMedium(), new BlockCandleSmall(), new BlockSaltBarrier(), new BlockApiary(), new BlockAltar());
for (final IFluidBlock fluidBlock : Fluids.MOD_FLUID_BLOCKS) {
registry.register((Block) fluidBlock);
}
}
Aggregations