private void writeToStream( final ByteBuf buffer ) throws IOException { final byte[] name = this.fluid.getName().getBytes( "UTF-8" ); buffer.writeByte( (byte) name.length ); buffer.writeBytes( name ); if( this.hasTagCompound() ) { final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final DataOutputStream data = new DataOutputStream( bytes ); CompressedStreamTools.write( this.tagCompound, data ); final byte[] tagBytes = bytes.toByteArray(); final int size = tagBytes.length; buffer.writeInt( size ); buffer.writeBytes( tagBytes ); } } }
@Override public int compareTo( final AEFluidStack other ) { if( this.fluid != other.fluid ) { return this.fluid.getName().compareTo( other.fluid.getName() ); } if( Platform.itemComparisons().isNbtTagEqual( this.tagCompound, other.tagCompound ) ) { return 0; } return this.tagCompound.hashCode() - other.tagCompound.hashCode(); }
public FluidStateMapper(Fluid fluid) { this.fluid = fluid; // have each block hold its fluid per nbt? hm this.location = new ModelResourceLocation(Util.getResource("fluid_block"), fluid.getName()); }
/** Registers a hot lava-based block for the fluid, prefix with molten_ */ public static BlockMolten registerMoltenBlock(IForgeRegistry<Block> registry, Fluid fluid) { return registerBlock(registry, new BlockMolten(fluid), "molten_" + fluid.getName()); // molten_foobar prefix } }
/** Registers a non-burning water based block for the fluid */ public static BlockFluidBase registerClassicBlock(IForgeRegistry<Block> registry, Fluid fluid) { return registerBlock(registry, new BlockTinkerFluid(fluid, net.minecraft.block.material.Material.WATER), fluid.getName()); }
public static boolean isIntegrated(Fluid fluid) { String name = FluidRegistry.getFluidName(fluid); if(name != null) { for(MaterialIntegration integration : TinkerRegistry.getMaterialIntegrations()) { if(integration.isIntegrated() && integration.fluid != null && name.equals(integration.fluid.getName())) { return true; } } } return false; }
@Override public String toString() { return this.getStackSize() + "x" + this.getFluidStack().getFluid().getName() + " " + this.tagCompound; }
protected static <T extends Fluid> T registerFluid(T fluid) { fluid.setUnlocalizedName(Util.prefix(fluid.getName())); FluidRegistry.registerFluid(fluid); return fluid; }
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of(output, amount), fluid)); log.trace("Added automatic melting recipe for {} ({} {})", irecipe.getRecipeOutput().toString(), amount, fluid .getName());
/** * 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 isNew = true; for(MaterialIntegration mi : TinkerRegistry.getMaterialIntegrations()) { if(mi.fluid != null && mi.fluid.getName().equals(fluidName)) { isNew = false;
Fluid registeredFluid = FluidRegistry.getFluid(fluid.getName());
@Override public void writeToNBT( final NBTTagCompound data ) { data.setString( "FluidName", this.fluid.getName() ); data.setByte( "Count", (byte) 0 ); data.setLong( "Cnt", this.getStackSize() ); data.setLong( "Req", this.getCountRequestable() ); data.setBoolean( "Craft", this.isCraftable() ); if( this.hasTagCompound() ) { data.setTag( "Tag", this.tagCompound ); } else { data.removeTag( "Tag" ); } }
@Override public void addFuel(@Nonnull Fluid fluid, int powerPerCycleRF, int totalBurnTime) { fuels.put(fluid.getName(), new FuelImpl(fluid, powerPerCycleRF, totalBurnTime)); for (IFluidRegister reg : otherRegisters) { reg.addFuel(fluid, powerPerCycleRF, totalBurnTime); } }
@Override public void addCoolant(@Nonnull Fluid fluid, float degreesCoolingPerMB) { coolants.put(fluid.getName(), new CoolantImpl(fluid, degreesCoolingPerMB)); for (IFluidRegister reg : otherRegisters) { reg.addCoolant(fluid, degreesCoolingPerMB); } }
@Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setString(CoreProps.FLUID, fluid.getName()); }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if (!this.isInCreativeTab(tab)) return; for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { ItemStack itemStack = new ItemStack(this); setFluidName(itemStack, fluid.getName()); subItems.add(itemStack); } }
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 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; }