public class BlockTinkerFluid extends BlockFluidClassic { public BlockTinkerFluid(Fluid fluid, Material material) { super(fluid, material); setCreativeTab(TinkerRegistry.tabSmeltery); } @Nonnull @Override public String getUnlocalizedName() { Fluid fluid = FluidRegistry.getFluid(fluidName); if(fluid != null) { return fluid.getUnlocalizedName(); } return super.getUnlocalizedName(); } @Override public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } }
/** * Used to ensure that a fluidstack is valid. Basically when you return a fluidstack, * you should ALWAYS take the fluid from the FluidRegistry. This isn't possible in all cases for us * hence we replace the FluidStack with a FluidStack containing the correct fluid. * * Example: Entity X melts into a specific fluid with specific NBT. However in game Fluid X is not the default fluid * anymore. We change the returned stack to contain the default fluid instead of the fluid used during setup. * * @return A save FluidStack or null if there is no valid fluid for the fluidstack */ public static FluidStack getValidFluidStackOrNull(FluidStack possiblyInvalidFluidstack) { FluidStack fluidStack = possiblyInvalidFluidstack; if(!FluidRegistry.isFluidDefault(fluidStack.getFluid())) { Fluid fluid = FluidRegistry.getFluid(fluidStack.getFluid().getName()); if(fluid != null) { fluidStack = new FluidStack(fluid, fluidStack.amount, fluidStack.tag); } else { fluidStack = null; } } return fluidStack; } }
boolean toolforge = tag.getBoolean("toolforge"); Fluid fluid = FluidRegistry.getFluid(fluidName);
Fluid registeredFluid = FluidRegistry.getFluid(fluid.getName());
@Nullable protected Fluid getFluid(String fluidName) { Fluid fluid = FluidRegistry.getFluid(fluidName); if (fluid == null) { Log.debug("Could not find fluid {}", fluidName); } return fluid; }
@Deprecated protected void setFluid(int index, String fluidName) { Fluid f = FluidRegistry.getFluid(fluidName); setFluid(index, f); }
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { String fluidName = modelLocation.getResourcePath().replace("models/item/fluid/", ""); Fluid fluid = FluidRegistry.getFluid(fluidName); if (fluid == null) { fluid = FluidRegistry.WATER; } return new FluidItemModel(fluid); }
public static List<MagmaticFuelWrapper> getRecipes(IModRegistry registry, IGuiHelper guiHelper) { List<MagmaticFuelWrapper> recipes = new ArrayList<>(); for (String fluidName : MagmaticManager.getFuels()) { FluidStack fuelStack = new FluidStack(FluidRegistry.getFluid(fluidName), Fluid.BUCKET_VOLUME); recipes.add(new MagmaticFuelWrapper(guiHelper, fuelStack, MagmaticManager.getFuelEnergy(fuelStack))); } return recipes; }
public void setSaveData(NBTTagCompound nbtTagCompound) { this.multiBlockSaveData = nbtTagCompound; this.myTank = FluidStack.loadFluidStackFromNBT(nbtTagCompound.getCompoundTag("fluid")); this.lastSeenFluid = FluidRegistry.getFluid(nbtTagCompound.getString("lastSeenFluid")); }
public static List<CoolantWrapper> getRecipes(IModRegistry registry, IGuiHelper guiHelper) { List<CoolantWrapper> recipes = new ArrayList<>(); for (String fluidName : CoolantManager.getCoolantFluids()) { FluidStack coolantStack = new FluidStack(FluidRegistry.getFluid(fluidName), Fluid.BUCKET_VOLUME); recipes.add(new CoolantWrapper(guiHelper, coolantStack, CoolantManager.getCoolantRF(coolantStack), CoolantManager.getCoolantFactor(coolantStack))); } return recipes; }
public @Nonnull Fluid getFluidType() { Fluid fluid = null; String fluidname = InvpanelConfig.remoteInventoryFluidTypes.get(ordinal()).get(); fluid = FluidRegistry.getFluid(fluidname); if (fluid == null) { Log.warn("ItemRemoteInvAccessType: Could not find fluid '" + fluidname + "' using default fluid " + Fluids.NUTRIENT_DISTILLATION.getFluid()); fluid = NullHelper.notnull(Fluids.NUTRIENT_DISTILLATION.getFluid(), "Nutrient Distillation registration went AWOL"); } return fluid; }
private static Fluid registerFluid(String fluidName, String fluidTextureName, EnumRarity rarity){ Fluid fluid = new FluidAA(fluidName.toLowerCase(Locale.ROOT), fluidTextureName).setRarity(rarity); FluidRegistry.registerFluid(fluid); FluidRegistry.addBucketForFluid(fluid); return FluidRegistry.getFluid(fluid.getName()); }
@Override public FluidStack read(PacketBuffer buf) { try { if (buf.readBoolean()) { return new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), buf.readCompoundTag()); } } catch (IOException e) { // NO OP } return null; }
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if (stack.getTagCompound() != null) { NBTTagCompound tags = stack.getTagCompound(); int fluidAmt = tags.getInteger(NBT_FLUIDSIZE); String resourceStr = tags.getString(NBT_FLUIDTYPE); TileEntityHydrator container = (TileEntityHydrator) worldIn.getTileEntity(pos); Fluid fluidObj = FluidRegistry.getFluid(resourceStr);//should never be null if fluidAmt > 0 if (fluidObj != null) container.fill(new FluidStack(fluidObj, fluidAmt), true); } }
public static void registerRedstoneRecipes() { Fluid f = FluidRegistry.getFluid(TicProxy.REDSTONE_FLUID_NAME); if (f != null) { // Note: We match the old TE amounts TicRecipeHandler.instance.registerSmelterySmelting(new Things().add(Items.REDSTONE), f, 100); TicRecipeHandler.instance.registerSmelterySmelting(new Things().add(Blocks.REDSTONE_BLOCK), f, 900); TicRecipeHandler.instance.registerBasinCasting(new Things().add(Blocks.REDSTONE_BLOCK), new Things(), f, 900); } }
public static void registerGlowstoneRecipes() { Fluid f = FluidRegistry.getFluid(TicProxy.GLOWSTONE_FLUID_NAME); if (f != null) { // Note: We match the old TE amounts TicRecipeHandler.instance.registerSmelterySmelting(new Things().add(Items.GLOWSTONE_DUST), f, 250); TicRecipeHandler.instance.registerSmelterySmelting(new Things().add(Blocks.GLOWSTONE), f, 1000); TicRecipeHandler.instance.registerBasinCasting(new Things().add(Blocks.GLOWSTONE), new Things(), f, 1000); } }
public static Block createFluidBlock() { @SuppressWarnings("null") MoltenEnder block = new MoltenEnder(fluid, Material.WATER, 0x1b7b6b); block.setFluidStack(new FluidStack(FluidRegistry.getFluid(fluid.getName()), Fluid.BUCKET_VOLUME)); NBTTagCompound tag = new NBTTagCompound(); tag.setString("fluid", fluid.getName()); tag.setString("ore", "Ender"); tag.setBoolean("toolforge", true); FMLInterModComms.sendMessage("tconstruct", "integrateSmeltery", tag); return block; }
public static void registerEnderRecipes() { Fluid f = FluidRegistry.getFluid(TicProxy.ENDER_FLUID_NAME); if (f != null) { // Note: We match the old TE amounts TicRecipeHandler.instance.registerSmelterySmelting(new Things().add(Items.ENDER_PEARL), f, 250); // Need to do this late because of the cast Things cast = new Things("tconstruct:cast_custom:2"); TicRecipeHandler.instance.registerTableCast(new Things().add(Items.ENDER_PEARL), cast, f, 250, false); } TicRecipeHandler.instance.registerSmelterySmelting(new Things().add(POWDER_ENDER.getStack()), f, 250 / 9); }
public static Block createFluidBlock() { fluid.setLuminosity(Blocks.LIT_REDSTONE_ORE.getDefaultState().getLightValue() * 7 / 10); @SuppressWarnings("null") MoltenRedstone block = new MoltenRedstone(fluid, Material.WATER, 0xff0000); block.setFluidStack(new FluidStack(FluidRegistry.getFluid(fluid.getName()), Fluid.BUCKET_VOLUME)); NBTTagCompound tag = new NBTTagCompound(); tag.setString("fluid", fluid.getName()); tag.setString("ore", "Redstone"); tag.setBoolean("toolforge", true); FMLInterModComms.sendMessage("tconstruct", "integrateSmeltery", tag); return block; }
public static Block createFluidBlock() { fluid.setLuminosity(Blocks.GLOWSTONE.getDefaultState().getLightValue()); // sic! Create the block for our fluid but then set the current fluid @SuppressWarnings("null") MoltenGlowstone block = new MoltenGlowstone(fluid, Material.WATER, 0xffbc5e); block.setFluidStack(new FluidStack(FluidRegistry.getFluid(fluid.getName()), Fluid.BUCKET_VOLUME)); NBTTagCompound tag = new NBTTagCompound(); tag.setString("fluid", fluid.getName()); tag.setString("ore", "Glowstone"); tag.setBoolean("toolforge", true); FMLInterModComms.sendMessage("tconstruct", "integrateSmeltery", tag); return block; }