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 ); } } }
/** Renders block with offset x/y/z from x1/y1/z1 to x2/y2/z2 inside the block local coordinates, so from 0-1 */ public static void renderFluidCuboid(FluidStack fluid, BlockPos pos, double x, double y, double z, double x1, double y1, double z1, double x2, double y2, double z2, int color) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder renderer = tessellator.getBuffer(); renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); //RenderUtil.setColorRGBA(color); int brightness = mc.world.getCombinedLight(pos, fluid.getFluid().getLuminosity()); boolean upsideDown = fluid.getFluid().isGaseous(fluid); pre(x, y, z); TextureAtlasSprite still = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getStill(fluid).toString()); TextureAtlasSprite flowing = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getFlowing(fluid).toString()); // x/y/z2 - x/y/z1 is because we need the width/height/depth putTexturedQuad(renderer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, false, upsideDown); putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, true, upsideDown); putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, true, upsideDown); putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness, true, upsideDown); putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, true, upsideDown); putTexturedQuad(renderer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness, false, upsideDown); tessellator.draw(); post(); }
@Override public void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks ) { final IAEFluidStack fs = this.getFluidStack(); if( fs != null ) { GlStateManager.disableLighting(); GlStateManager.disableBlend(); final Fluid fluid = fs.getFluid(); mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE ); final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() ); // Set color for dynamic fluids // Convert int color to RGB final float red = ( fluid.getColor() >> 16 & 255 ) / 255.0F; final float green = ( fluid.getColor() >> 8 & 255 ) / 255.0F; final float blue = ( fluid.getColor() & 255 ) / 255.0F; GlStateManager.color( red, green, blue ); this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() ); } }
protected static <T extends Fluid> T registerFluid(T fluid) { fluid.setUnlocalizedName(Util.prefix(fluid.getName())); FluidRegistry.registerFluid(fluid); return fluid; }
public static void renderTiledFluid(int x, int y, int width, int height, float depth, FluidStack fluidStack) { TextureAtlasSprite fluidSprite = mc.getTextureMapBlocks().getAtlasSprite(fluidStack.getFluid().getStill(fluidStack).toString()); RenderUtil.setColorRGBA(fluidStack.getFluid().getColor(fluidStack)); renderTiledTextureAtlas(x, y, width, height, depth, fluidSprite, fluidStack.getFluid().isGaseous(fluidStack)); }
private static IBakedModel getTexturedModel(IBakedModel original, ResourceLocation location, Fluid fluid) { try { IModel model = ModelLoaderRegistry.getModel(location); IModel retextured = model.retexture(ImmutableMap.of("fluid", fluid.getStill().toString())); return retextured.bake(retextured.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); } catch(Exception e) { e.printStackTrace(); return original; } }
@Override protected void queryMatches(Fluid fluid, String query, final ArrayDeque<FluidStack> results) { if(fluid == null || fluid.getName() == null) { return; } try { FluidStack stack = new FluidStack(fluid, 1000); if(fluid.getUnlocalizedName().toLowerCase().contains(query) || fluid.getLocalizedName(stack).toLowerCase().contains(query) || fluid.getName().toLowerCase().contains(query)) { results.add(stack); } } catch(Exception e) { BetterQuesting.logger.error("An error occured while searching fluid \"" + fluid.getName() + "\" (" + fluid.getClass().getName() + ")", e); } }
@Override public String getMessage() { final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot ); if( fluid != null && fluid.getStackSize() > 0 ) { String desc = fluid.getFluid().getLocalizedName( fluid.getFluidStack() ); String amountToText = fluid.getStackSize() + "mB"; return desc + "\n" + amountToText; } return null; }
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getTextureExtry(fluid.getStill().toString()); int brightness = world.getCombinedLight(tilePos.offset(face), fluid.getLuminosity(fluidStack)); int color = fluid.getColor(fluidStack);
/** * Called during the register blocks event to register fluid blocks. If no fluid is defined it does nothing for simplicity * @param registry Block Registry */ public void registerFluidBlock(IForgeRegistry<Block> registry) { // ensure the fluid block is not already registered if(fluid != null && fluid.getBlock() == null) { addedFluidBlock = true; TinkerFluids.registerMoltenBlock(registry, fluid); } }
public static void renderFluidCuboid(FluidStack fluid, BlockPos pos, double x, double y, double z, double x1, double y1, double z1, double x2, double y2, double z2) { int color = fluid.getFluid().getColor(fluid); renderFluidCuboid(fluid, pos, x, y, z, x1, y1, z1, x2, y2, z2, color); }
@Override public void apply(@Nonnull ItemStack stack) { if (Prep.isInvalid(stack)) { Log.error("The item " + item + " (" + item.getUnlocalizedName() + ") produces empty itemstacks in getSubItems(). This is a major bug in the mod '" + PaintUtil.block2Modname(item) + "'."); return; } if (stack.getItem() == Items.AIR) { Log.error("The item " + item + " (" + item.getUnlocalizedName() + ") produces itemstacks without item in getSubItems(). This is a major bug in the mod '" + PaintUtil.block2Modname(item) + "'."); return; } FluidStack fluidStack = FluidUtil.getFluidTypeFromItem(stack); if (fluidStack != null && fluidStack.getFluid() != null) { final Block block = fluidStack.getFluid().getBlock(); if (block != null && NullHelper.untrust(Block.REGISTRY.getNameForObject(block)) == null) { Log.error("Fluid " + fluidStack.getFluid() + " (" + fluidStack.getFluid().getName() + ", " + fluidStack.getFluid().getClass() + ") from item " + stack + " returned an unregistered block from getBlock(). This is a major bug in the mod that fluid belongs to."); return; } } list.add(stack); } }
public int getBrightness() { if(containsFluid()) { assert tank.getFluid() != null; return tank.getFluid().getFluid().getLuminosity(); } return 0; }
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); int color = te.drained.getFluid().getColor(te.drained); int brightness = te.getWorld().getCombinedLight(te.getPos(), te.drained.getFluid().getLuminosity()); TextureAtlasSprite flowing = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(te.drained.getFluid().getFlowing(te.drained).toString());
protected void setNames(Fluid fluid) { setUnlocalizedName(NullHelper.notnullF(fluid.getUnlocalizedName(), "encountered fluid without a name")); setRegistryName("block_fluid_" + fluid.getName().toLowerCase(Locale.ENGLISH)); }
@SideOnly(Side.CLIENT) @SubscribeEvent public static void onIconLoad(TextureStitchEvent.Pre event) { event.getMap().registerSprite(XP_JUICE.getFluid().getStill()); event.getMap().registerSprite(XP_JUICE.getFluid().getFlowing()); }
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 String getTranslatedFluidName(FluidStack fluidStack) { if (fluidStack == null) return ""; final Fluid fluid = fluidStack.getFluid(); String localizedName = fluid.getLocalizedName(fluidStack); if (!Strings.isNullOrEmpty(localizedName) && !localizedName.equals(fluid.getUnlocalizedName())) { return fluid.getRarity(fluidStack).rarityColor.toString() + localizedName; } else { return TextFormatting.OBFUSCATED + "LOLNOPE" + TextFormatting.RESET; } } }
public static void recalculateFluidBlocks() { fluidBlocks.clear(); for ( final Fluid o : FluidRegistry.getRegisteredFluids().values() ) { if ( o.canBePlacedInWorld() ) { BlockBitInfo.addFluidBlock( o.getBlock(), o ); } } }
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; } }