本文整理匯總了Java中net.minecraftforge.fluids.IFluidBlock類的典型用法代碼示例。如果您正苦於以下問題:Java IFluidBlock類的具體用法?Java IFluidBlock怎麽用?Java IFluidBlock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IFluidBlock類屬於net.minecraftforge.fluids包,在下文中一共展示了IFluidBlock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFillBucket
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event) {
RayTraceResult rtr = event.getTarget();
if (rtr != null) {
Block b = event.getWorld().getBlockState(rtr.getBlockPos()).getBlock();
if (b instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) b).getFluid();
ItemStack filled = FluidUtil.getFilledBucket(new FluidStack(fluid, 1000));
if (!filled.isEmpty()) {
event.setFilledBucket(FluidUtil.getFilledBucket(new FluidStack(fluid, 1000)));
event.getWorld().setBlockToAir(rtr.getBlockPos());
event.setResult(Result.ALLOW);
if (TileEntityRefinery.isInputFluidValid(fluid, 4) && event.getEntityPlayer() instanceof EntityPlayerMP) {
AdvancementTriggers.OIL_BUCKET.trigger((EntityPlayerMP) event.getEntityPlayer());
}
}
}
}
}
示例2: createFluid
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
private static <T extends Block & IFluidBlock> Fluid createFluid(String name, boolean hasFlowIcon, Consumer<Fluid> fluidPropertyApplier, Function<Fluid, T> blockFactory, boolean hasBucket) {
final ResourceLocation still = new ResourceLocation(LibMod.MOD_ID + ":blocks/fluid/" + name + "_still");
final ResourceLocation flowing = hasFlowIcon ? new ResourceLocation(LibMod.MOD_ID + ":blocks/fluid/" + name + "_flow") : still;
Fluid fluid = new Fluid(name, still, flowing);
final boolean useOwnFluid = FluidRegistry.registerFluid(fluid);
if (useOwnFluid) {
fluidPropertyApplier.accept(fluid);
MOD_FLUID_BLOCKS.add(blockFactory.apply(fluid));
if (hasBucket)
FluidRegistry.addBucketForFluid(fluid);
} else {
fluid = FluidRegistry.getFluid(name);
}
return fluid;
}
示例3: tryBlockClient
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
private boolean tryBlockClient(int x, int y, int z)
{
BlockVec3 bv = new BlockVec3(x, y, z);
if (this.laserBlocks.contains(bv)) return false;
//Add minable blocks to the laser fx list
Block b = this.worldObj.getBlock(x, y, z);
if (b.getMaterial() == Material.air) return false;
if (noMineList.contains(b)) return true;
if (b instanceof BlockLiquid) return false;
if (b instanceof IFluidBlock) return false;
if (b instanceof IPlantable) return true;
int meta = this.worldObj.getBlockMetadata(x, y, z);
if (b.hasTileEntity(meta) || b.getBlockHardness(this.worldObj, x, y, z) < 0) return true;
if (this.tryBlockLimit == 0) return false;
this.tryBlockLimit--;
this.laserBlocks.add(bv);
this.laserTimes.add(this.ticksExisted);
return false;
}
示例4: isInsideOfFluid
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
public static boolean isInsideOfFluid(Entity entity, Fluid fluid)
{
double d0 = entity.posY + entity.getEyeHeight();
int i = MathHelper.floor_double(entity.posX);
int j = MathHelper.floor_float(MathHelper.floor_double(d0));
int k = MathHelper.floor_double(entity.posZ);
Block block = entity.worldObj.getBlock(i, j, k);
if (block != null && block instanceof IFluidBlock && ((IFluidBlock) block).getFluid() != null && ((IFluidBlock) block).getFluid().getName().equals(fluid.getName()))
{
double filled = ((IFluidBlock) block).getFilledPercentage(entity.worldObj, i, j, k);
if (filled < 0)
{
filled *= -1;
return d0 > j + (1 - filled);
}
else
{
return d0 < j + filled;
}
}
else
{
return false;
}
}
示例5: waterOverlay
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
@SubscribeEvent
public void waterOverlay(RenderBlockOverlayEvent event){
if(event.getOverlayType() == OverlayType.WATER){
EntityPlayer player = event.getPlayer();
IBlockState state = player.getEntityWorld().getBlockState(event.getBlockPos());
if(state.getBlock() instanceof IFluidBlock){
Fluid fluid = ((IFluidBlock)state.getBlock()).getFluid();
if(fluid !=null){
ResourceLocation res = ModFluids.getOverlayTexture(fluid);
if(res !=null){
event.setCanceled(true);
renderWaterOverlayTexture(event.getRenderPartialTicks(), res);
}
}
}
}
}
示例6: getFluidTypeFromItem
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
public static FluidStack getFluidTypeFromItem(ItemStack stack) {
if (ItemStackTools.isNullStack(stack)) {
return null;
}
stack = stack.copy();
ItemStackTools.setStackSize(stack, 1);
IFluidHandler handler = getFluidHandlerCapability(stack);
if (handler != null) {
return handler.drain(Fluid.BUCKET_VOLUME, false);
}
if (Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
if (fluid != null) {
return new FluidStack(fluid, 1000);
}
}
return null;
}
示例7: createFluid
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
/**
* Create a {@link Fluid} and its {@link IFluidBlock}, or use the existing ones if a fluid has already been registered with the same name.
*
* @param name The name of the fluid
* @param hasFlowIcon Does the fluid have a flow icon?
* @param fluidPropertyApplier A function that sets the properties of the {@link Fluid}
* @param blockFactory A function that creates the {@link IFluidBlock}
* @return The fluid and block
*/
private static <T extends Block & IFluidBlock> Fluid createFluid(String name, boolean hasFlowIcon, Consumer<Fluid> fluidPropertyApplier, Function<Fluid, T> blockFactory) {
final String texturePrefix = Constants.RESOURCE_PREFIX + "blocks/fluids/";
final ResourceLocation still = new ResourceLocation(texturePrefix + name + "_still");
final ResourceLocation flowing = hasFlowIcon ? new ResourceLocation(texturePrefix + name + "_flow") : still;
Fluid fluid = new Fluid(name, still, flowing);
final boolean useOwnFluid = FluidRegistry.registerFluid(fluid);
if (useOwnFluid) {
fluidPropertyApplier.accept(fluid);
registerFluidBlock(blockFactory.apply(fluid));
} else {
fluid = FluidRegistry.getFluid(name);
}
FLUIDS.add(fluid);
return fluid;
}
示例8: createFluidAcid
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
private static <T extends Block & IFluidBlock> Fluid createFluidAcid(String name, boolean hasFlowIcon, int color, Consumer<Fluid> fluidPropertyApplier, Function<Fluid, T> blockFactory) {
final String texturePrefix = Constants.RESOURCE_PREFIX + "blocks/fluids/";
final ResourceLocation still = new ResourceLocation(texturePrefix + "acid_still");
final ResourceLocation flowing = hasFlowIcon ? new ResourceLocation(texturePrefix + "acid_flow") : still;
FluidAcid fluid = new FluidAcid(name, color, still, flowing);
final boolean useOwnFluid = FluidRegistry.registerFluid(fluid);
if (useOwnFluid) {
fluidPropertyApplier.accept(fluid);
registerFluidBlock(blockFactory.apply(fluid));
} else {
// fluid = FluidRegistry.getFluid(name);
//TODO: deal with this case
}
FLUIDS.add(fluid);
return fluid;
}
示例9: registerFluidModel
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
private void registerFluidModel(IFluidBlock fluidBlock) {
final Item item = Item.getItemFromBlock((Block) fluidBlock);
assert item != null;
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(FLUID_MODEL_PATH, fluidBlock.getFluid().getName());
ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelResourceLocation));
ModelLoader.setCustomStateMapper((Block) fluidBlock, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_) {
return modelResourceLocation;
}
});
itemsRegistered.add(item);
}
示例10: registerRenderer
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
public void registerRenderer() {
IFluidBlock block = BlocksRegistry.liquidXpBlock;
Item item = Item.getItemFromBlock((Block)block);
assert (item == Items.AIR);
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(MekfarmMod.MODID + ":fluids", this.getName());
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return modelResourceLocation;
}
});
ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelResourceLocation;
}
});
}
示例11: registerRenderer
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
public void registerRenderer() {
IFluidBlock block = BlocksRegistry.sewageBlock;
Item item = Item.getItemFromBlock((Block)block);
assert (item == Items.AIR);
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(MekfarmMod.MODID + ":fluids", this.getName());
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return modelResourceLocation;
}
});
ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelResourceLocation;
}
});
}
示例12: createFluid
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
/**
* Create a {@link Fluid} and its {@link IFluidBlock}, or use the existing ones if a fluid has already been registered with the same name.
*
* @param name The name of the fluid
* @param hasFlowIcon Does the fluid have a flow icon?
* @param fluidPropertyApplier A function that sets the properties of the {@link Fluid}
* @param blockFactory A function that creates the {@link IFluidBlock}
* @return The fluid and block
*/
private static <T extends Block & IFluidBlock> Fluid createFluid(final String name, final boolean hasFlowIcon, final Consumer<Fluid> fluidPropertyApplier, final Function<Fluid, T> blockFactory) {
final String texturePrefix = GlobalNames.Domain + ":" + "blocks/fluid_";
final ResourceLocation still = new ResourceLocation(texturePrefix + name + "_still");
final ResourceLocation flowing = hasFlowIcon ? new ResourceLocation(texturePrefix + name + "_flow") : still;
Fluid fluid = new Fluid(name, still, flowing);
final boolean useOwnFluid = FluidRegistry.registerFluid(fluid);
if (useOwnFluid) {
fluidPropertyApplier.accept(fluid);
MOD_FLUID_BLOCKS.add(blockFactory.apply(fluid));
} else {
fluid = FluidRegistry.getFluid(name);
}
FLUIDS.add(fluid);
return fluid;
}
示例13: registerItems
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
/**
* Register this mod's fluid {@link ItemBlock}s.
*
* @param event The event
*/
// Use EventPriority.LOWEST so this is called after the RegistryEvent.Register<Item> handler in ModBlocks where
// the ItemBlock for ModBlocks.FLUID_TANK is registered.
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void registerItems(final RegistryEvent.Register<Item> event) {
final IForgeRegistry<Item> registry = event.getRegistry();
for (final IFluidBlock fluidBlock : MOD_FLUID_BLOCKS) {
final Block block = (Block) fluidBlock;
final ItemBlock itemBlock = new ItemBlock(block);
final ResourceLocation registryName = Preconditions.checkNotNull(block.getRegistryName());
itemBlock.setRegistryName(registryName);
registry.register(itemBlock);
}
registerFluidContainers();
}
示例14: registerFluidModel
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
private void registerFluidModel(final IFluidBlock fluidBlock) {
final Item item = Item.getItemFromBlock((Block) fluidBlock);
assert item != Items.AIR;
ModelBakery.registerItemVariants(item);
final ModelResourceLocation modelResourceLocation = new ModelResourceLocation(FLUID_MODEL_PATH, fluidBlock.getFluid().getName());
ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelResourceLocation));
ModelLoader.setCustomStateMapper((Block) fluidBlock, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(final IBlockState p_178132_1_) {
return modelResourceLocation;
}
});
}
示例15: getFluidFromItem
import net.minecraftforge.fluids.IFluidBlock; //導入依賴的package包/類
public static FluidStack getFluidFromItem(ItemStack stack) {
if (stack != null) {
FluidStack fluidStack = null;
if (stack.getItem() instanceof IFluidContainerItem) {
fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
}
if (fluidStack == null) {
fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
}
if (fluidStack == null && Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
if (fluid != null) {
return new FluidStack(fluid, 1000);
}
}
return fluidStack;
}
return null;
}