@Override
 protected void readEntityFromNBT(NBTTagCompound nbt) {
   if (nbt.hasKey("Fluid")) {
     fluid = FluidRegistry.getFluid(nbt.getString("Fluid"));
     dataManager.set(COLOR, fluid.getColor());
     isFluid = true;
   } else if (nbt.hasKey("Potion")) {
     potion = PotionType.getPotionTypeForName(nbt.getString("Potion"));
     dataManager.set(COLOR, fluid.getColor());
     isFluid = false;
   } else setDead();
   dataManager.setDirty(COLOR);
 }
  public EntitySprayCloud(World world, @Nullable EntityLivingBase sprayer, ISpray spray) {
    super(world);
    if (spray.getFiller().isPotion()) {
      potion = spray.getPotion();
      custom.addAll(spray.getEffects());

      dataManager.set(COLOR, spray.getColor());
      isFluid = false;
    } else if (spray.getFiller().isFluid()) {
      fluid = spray.getFluid();
      dataManager.set(COLOR, fluid.getColor());
      isFluid = true;
    } else setDead();
    dataManager.setDirty(COLOR);
    user = sprayer;
  }
示例#3
0
 public IBakedModel bake(
     IModelState state,
     VertexFormat format,
     Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
   ImmutableMap<TransformType, TRSRTransformation> map =
       IPerspectiveAwareModel.MapWrapper.getTransforms(state);
   return new BakedFluid(
       state.apply(Optional.<IModelPart>absent()),
       map,
       format,
       fluid.getColor(),
       bakedTextureGetter.apply(fluid.getStill()),
       bakedTextureGetter.apply(fluid.getFlowing()),
       fluid.isGaseous(),
       Optional.<IExtendedBlockState>absent());
 }
  @Override
  public boolean renderWorldBlock(
      IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    if (modelId == RENDER_ID) {
      final BlockBrewKettle brewKettle = (BlockBrewKettle) block;
      final double d = 0.0625D;
      float f = 1.0F;
      renderer.renderStandardBlock(block, x, y, z);
      final Tessellator tes = Tessellator.instance;
      tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
      int color = block.colorMultiplier(world, x, y, z);
      float r = (float) (color >> 16 & 255) / 255.0F;
      float g = (float) (color >> 8 & 255) / 255.0F;
      float b = (float) (color & 255) / 255.0F;
      float f4;

      if (EntityRenderer.anaglyphEnable) {
        final float f5 = (r * 30.0F + g * 59.0F + b * 11.0F) / 100.0F;
        f4 = (r * 30.0F + g * 70.0F) / 100.0F;
        final float f6 = (r * 30.0F + b * 70.0F) / 100.0F;
        r = f5;
        g = f4;
        b = f6;
      }

      tes.setColorOpaque_F(f * r, f * g, f * b);
      f4 = 0.125F;
      renderer.renderFaceXPos(
          block, (double) (x - 1.0F + f4), (double) y, (double) z, brewKettle.getIconByIndex(2));
      renderer.renderFaceXNeg(
          block, (double) (x + 1.0F - f4), (double) y, (double) z, brewKettle.getIconByIndex(2));
      renderer.renderFaceZPos(
          block, (double) x, (double) y, (double) (z - 1.0F + f4), brewKettle.getIconByIndex(2));
      renderer.renderFaceZNeg(
          block, (double) x, (double) y, (double) (z + 1.0F - f4), brewKettle.getIconByIndex(2));
      renderer.renderFaceYPos(
          block, (double) x, (double) (y - 1.0F + 0.25F), (double) z, brewKettle.getIconByIndex(1));
      renderer.renderFaceYNeg(
          block, (double) x, (double) (y + 1.0F - 0.75F), (double) z, brewKettle.getIconByIndex(1));

      // Render Liquid
      final TileEntityBrewKettle te = (TileEntityBrewKettle) world.getTileEntity(x, y, z);
      if (te != null) {
        for (int i = 0; i < 2; ++i) {
          if (te.isFluidTankFilled(i)) {
            final Fluid fluid = te.getFluid(i);
            color = fluid.getColor();
            r = (float) (color >> 16 & 255) / 255.0F;
            g = (float) (color >> 8 & 255) / 255.0F;
            b = (float) (color & 255) / 255.0F;
            f = 1.0F;
            tes.setColorOpaque_F(f * r, f * g, f * b);
            f = te.getFluidAmount(i) * FLUID_HEIGHT / te.getFluidTank(i).getCapacity();
            renderer.setRenderBounds(2 * d, 0.0D, 2 * d, 14 * d, (double) (0.25F + f), 14 * d);
            renderer.renderFaceYPos(block, (double) x, (double) y, (double) z, fluid.getIcon());
          }
        }
      }

      renderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
    }
    return true;
  }