Exemple #1
0
 public static InputStream getResourceStream(ResourceLocation res) {
   try {
     String domain = res.getResourceDomain(), path = res.getResourcePath();
     return RegistryUtils.class.getResourceAsStream("/assets/" + domain + "/" + path);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
 /** (abstract) Protected helper method to write subclass entity data to NBT. */
 public void writeEntityToNBT(NBTTagCompound tagCompound) {
   tagCompound.setShort("xTile", (short) this.xTile);
   tagCompound.setShort("yTile", (short) this.yTile);
   tagCompound.setShort("zTile", (short) this.zTile);
   ResourceLocation resourcelocation =
       (ResourceLocation) Block.blockRegistry.getNameForObject(this.inTile);
   tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
   tagCompound.setByte("shake", (byte) this.shake);
   tagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
 }
  public List func_135056_b(ResourceLocation par1ResourceLocation) throws IOException {
    ResourceManager resourcemanager =
        (ResourceManager) this.field_110548_a.get(par1ResourceLocation.func_110624_b());

    if (resourcemanager != null) {
      return resourcemanager.func_135056_b(par1ResourceLocation);
    } else {
      throw new FileNotFoundException(par1ResourceLocation.toString());
    }
  }
Exemple #4
0
 public static void registerTransparentBlock(Block block, float transparency, int meta) {
   if (block != null) {
     NBTTagCompound tag = new NBTTagCompound();
     ResourceLocation b1 = block.delegate.name();
     tag.setString("blockName", b1.getResourcePath());
     tag.setString("modid", b1.getResourceDomain());
     tag.setFloat("t", transparency);
     tag.setInteger("m", meta);
     TomsModRecipeHelper.sendMessage(tag, "glass", 2);
   }
 }
Exemple #5
0
  public NBTTagCompound b(NBTTagCompound nbttagcompound) {
    ResourceLocation resourcelocation = (ResourceLocation) Item.e.c(this.d);

    nbttagcompound.a(
        "id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString());
    nbttagcompound.a("Count", (byte) this.b);
    nbttagcompound.a("Damage", (short) this.f);
    if (this.e != null) {
      nbttagcompound.a("tag", (NBTBase) this.e);
    }

    return nbttagcompound;
  }
Exemple #6
0
  public static String[] func_180141_c() {
    String[] var0 = new String[field_180150_I.size()];
    int var1 = 0;
    ResourceLocation var3;

    for (Iterator var2 = field_180150_I.keySet().iterator();
        var2.hasNext();
        var0[var1++] = var3.toString()) {
      var3 = (ResourceLocation) var2.next();
    }

    return var0;
  }
 private Object verify(Object obj) {
   if (obj instanceof String)
     AbyssalCraftAPI.getInternalNDHandler().verifyImageURL((String) obj);
   if (!(obj instanceof ResourceLocation)) return obj;
   if (FMLCommonHandler.instance().getSide().isServer()) return obj;
   ResourceLocation res = (ResourceLocation) obj;
   if (res.toString().equals("abyssalcraft:textures/gui/necronomicon/missing.png")) return obj;
   try {
     TextureUtil.readBufferedImage(
         Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream());
   } catch (IOException e) {
     return new ResourceLocation("abyssalcraft", "textures/gui/necronomicon/missing.png");
   }
   return res;
 }
 public ParticleMagicLine(
     World worldIn,
     double x,
     double y,
     double z,
     double vx,
     double vy,
     double vz,
     double r,
     double g,
     double b) {
   super(worldIn, x, y, z, 0, 0, 0);
   this.colorR = r;
   this.colorG = g;
   this.colorB = b;
   if (this.colorR > 1.0) {
     this.colorR = this.colorR / 255.0;
   }
   if (this.colorG > 1.0) {
     this.colorG = this.colorG / 255.0;
   }
   if (this.colorB > 1.0) {
     this.colorB = this.colorB / 255.0;
   }
   this.setRBGColorF(1, 1, 1);
   this.particleMaxAge = 8;
   this.particleGravity = 0.0f;
   this.motionX = (vx - x) / (double) this.particleMaxAge;
   this.motionY = (vy - y) / (double) this.particleMaxAge;
   this.motionZ = (vz - z) / (double) this.particleMaxAge;
   TextureAtlasSprite sprite =
       Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.toString());
   this.setParticleTexture(sprite);
 }
Exemple #9
0
  /** (abstract) Protected helper method to write subclass entity data to NBT. */
  protected void writeEntityToNBT(NBTTagCompound tagCompound) {
    if (this.hasDisplayTile()) {
      tagCompound.setBoolean("CustomDisplayTile", true);
      IBlockState iblockstate = this.getDisplayTile();
      ResourceLocation resourcelocation =
          (ResourceLocation) Block.blockRegistry.getNameForObject(iblockstate.getBlock());
      tagCompound.setString(
          "DisplayTile", resourcelocation == null ? "" : resourcelocation.toString());
      tagCompound.setInteger("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
      tagCompound.setInteger("DisplayOffset", this.getDisplayTileOffset());
    }

    if (this.entityName != null && this.entityName.length() > 0) {
      tagCompound.setString("CustomName", this.entityName);
    }
  }
 public ParticleMagicSparkle(
     World worldIn,
     double x,
     double y,
     double z,
     double vx,
     double vy,
     double vz,
     double r,
     double g,
     double b) {
   super(worldIn, x, y, z, 0, 0, 0);
   this.colorR = r;
   this.colorG = g;
   this.colorB = b;
   if (this.colorR > 1.0) {
     this.colorR = this.colorR / 255.0;
   }
   if (this.colorG > 1.0) {
     this.colorG = this.colorG / 255.0;
   }
   if (this.colorB > 1.0) {
     this.colorB = this.colorB / 255.0;
   }
   this.setRBGColorF(1, 1, 1);
   this.particleMaxAge = 10;
   this.motionX = vx;
   this.motionY = vy;
   this.motionZ = vz;
   this.particleScale = 5.0f;
   this.field_190014_F = random.nextFloat() * 2.0f * (float) Math.PI;
   TextureAtlasSprite sprite =
       Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.toString());
   this.setParticleTexture(sprite);
 }
 private File getRealPathBecauseMojangLiterallyCantEvenCodeOutsideTheirUsageScenario(
     ResourceLocation l) {
   String altPath = l.getResourcePath();
   altPath = altPath.substring(7); // omit the leading "sounds/"
   // System.out.println("Final path: "+new
   // File(mc_dir.getAbsolutePath(),altPath).getAbsolutePath());
   return new File(mc_dir.getAbsolutePath(), altPath);
 }
 private InputStream getResourceStream(ResourceLocation resourceLocation) {
   // TODO Check this
   return addon
       .getClass()
       .getResourceAsStream(
           String.format(
               "/assets/%s/%s",
               addon.getDescription().getIdentifier(), resourceLocation.getResourcePath()));
 }
Exemple #13
0
 @Inject(method = "<init>(ILnet/minecraft/util/ResourceLocation;ZI)V", at = @At("RETURN"))
 private void onConstruct(
     int potionID,
     ResourceLocation location,
     boolean badEffect,
     int potionColor,
     CallbackInfo callbackInfo) {
   this.spongeResourceID = location.toString();
 }
  public GenericStructureInfo structureInfoFromResource(ResourceLocation resourceLocation) {
    try {
      return structureInfoFromZip(
          new ZipInputStream(IvFileHelper.inputStreamFromResourceLocation(resourceLocation)));
    } catch (Exception ex) {
      RecurrentComplex.logger.error(
          "Could not read generic structure " + resourceLocation.toString(), ex);
    }

    return null;
  }
Exemple #15
0
  public static String getItemStackName(ItemStack itemStack) {

    if (itemStack == null) return null;

    Item item = itemStack.getItem();
    if (item == null) return null;

    ResourceLocation resourceLocation = getItemName(item);
    if (resourceLocation == null) return null;

    String ret;
    if (!itemStack.isItemStackDamageable()) {
      int dmg = itemStack.getItemDamage();
      if (dmg != OreDictionary.WILDCARD_VALUE)
        ret = String.format("%s:%d", resourceLocation.toString(), dmg);
      else ret = resourceLocation.toString();
    } else {
      ret = resourceLocation.toString();
    }

    return ret;
  }
  public InputStream getInputStream(ResourceLocation p_110590_1_) throws IOException {
    InputStream inputstream = this.getResourceStream(p_110590_1_);

    if (inputstream != null) {
      return inputstream;
    } else {
      InputStream inputstream1 = this.func_152780_c(p_110590_1_);

      if (inputstream1 != null) {
        return inputstream1;
      } else {
        throw new FileNotFoundException(p_110590_1_.getResourcePath());
      }
    }
  }
Exemple #17
0
  private static void renderMoon(
      float partialTickTime,
      WorldClient world,
      TextureManager renderEngine,
      Tessellator tessellator,
      float offset,
      float factor,
      float yangle,
      float size,
      ResourceLocation moon) {
    GL11.glTranslatef(0.0F, 0.0F, 0.0F);
    GL11.glRotatef(yangle, 0.0F, 1.0F, 0.0F);
    float angle =
        world.provider.calculateCelestialAngle(
            world.getWorldInfo().getWorldTime(), partialTickTime);
    angle = angle * factor + offset;
    GL11.glRotatef(angle * 360.0F, 1.0F, 0.0F, 0.0F);

    float f14, f15, f16, f17;
    renderEngine.bindTexture(moon);
    if (!moon.equals(locationMoonPhasesPng)) {
      f14 = 0.0f;
      f15 = 0.0f;
      f16 = 1.0f;
      f17 = 1.0f;
    } else {
      int k = world.getMoonPhase();
      int l = k % 4;
      int i1 = k / 4 % 2;
      f14 = (l + 0) / 4.0F;
      f15 = (i1 + 0) / 2.0F;
      f16 = (l + 1) / 4.0F;
      f17 = (i1 + 1) / 2.0F;
    }
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV((-size), -100.0D, size, f16, f17);
    tessellator.addVertexWithUV(size, -100.0D, size, f14, f17);
    tessellator.addVertexWithUV(size, -100.0D, (-size), f14, f15);
    tessellator.addVertexWithUV((-size), -100.0D, (-size), f16, f15);
    tessellator.draw();
  }
 protected White() {
   super(loc.toString());
 }
 public boolean resourceExists(ResourceLocation p_110589_1_) {
   return this.getResourceStream(p_110589_1_) != null
       || this.field_152781_b.containsKey(p_110589_1_.toString());
 }
 @Inject(method = "<init>", at = @At("RETURN"))
 public void onConstructed(
     int id, ResourceLocation resLoc, int weight, EnumEnchantmentType type, CallbackInfo ci) {
   this.id = resLoc.toString();
 }
 public BlockSource() {
   super(Material.IRON);
   setCreativeTab(CreativeTabs.MISC);
   setUnlocalizedName(name.toString());
   setRegistryName(name);
 }
 @Inject(method = "registerBlock", at = @At("RETURN"))
 private static void onRegisterBlock(
     int id, ResourceLocation location, Block block, CallbackInfo ci) {
   BlockTypeRegistryModule.getInstance()
       .registerFromGameData(location.toString(), (BlockType) block);
 }
 @Override
 protected ResourceLocation getModelLocation(ResourceLocation model) {
   return new ResourceLocation(model.getResourceDomain(), model.getResourcePath() + ".json");
 }
    public Collection<ResourceLocation> getTextures() {
      // setting parent here to make textures resolve properly
      if (model.getParentLocation() != null) {
        if (model.getParentLocation().getResourcePath().equals("builtin/generated")) {
          model.parent = MODEL_GENERATED;
        } else {
          try {
            IModel parent = getModel(model.getParentLocation());
            if (parent instanceof VanillaModelWrapper) {
              model.parent = ((VanillaModelWrapper) parent).model;
            } else {
              throw new IllegalStateException(
                  "vanilla model '" + model + "' can't have non-vanilla parent");
            }
          } catch (IOException e) {
            FMLLog.warning(
                "Could not load vanilla model parent '"
                    + model.getParentLocation()
                    + "' for '"
                    + model
                    + "': "
                    + e.toString());
            IModel missing = ModelLoader.this.getMissingModel();
            if (missing instanceof VanillaModelWrapper) {
              model.parent = ((VanillaModelWrapper) missing).model;
            } else {
              throw new IllegalStateException(
                  "vanilla model '"
                      + model
                      + "' has missing parent, and missing model is not a vanilla model");
            }
          }
        }
      }

      ImmutableSet.Builder<ResourceLocation> builder = ImmutableSet.builder();

      if (hasItemModel(model)) {
        for (String s : (List<String>) ItemModelGenerator.LAYERS) {
          String r = model.resolveTextureName(s);
          ResourceLocation loc = new ResourceLocation(r);
          if (!r.equals(s)) {
            builder.add(loc);
          }
          // mojang hardcode
          if (model.getRootModel() == MODEL_COMPASS
              && !loc.equals(TextureMap.LOCATION_MISSING_TEXTURE)) {
            TextureAtlasSprite.setLocationNameCompass(loc.toString());
          } else if (model.getRootModel() == MODEL_CLOCK
              && !loc.equals(TextureMap.LOCATION_MISSING_TEXTURE)) {
            TextureAtlasSprite.setLocationNameClock(loc.toString());
          }
        }
      }
      for (String s : (Iterable<String>) model.textures.values()) {
        if (!s.startsWith("#")) {
          builder.add(new ResourceLocation(s));
        }
      }
      return builder.build();
    }
 /** HELPERS */
 private boolean isResourceFromThisPack(ResourceLocation l) {
   return l.getResourceDomain().equals(getPackName());
 }
 public boolean resourceExists(ResourceLocation l) {
   return isResourceFromThisPack(l)
       && (l.getResourcePath().equals("sounds.json")
           || getRealPathBecauseMojangLiterallyCantEvenCodeOutsideTheirUsageScenario(l).exists());
 }
 public InputStream getInputStream(ResourceLocation l) throws IOException {
   if (l.getResourcePath().equals("sounds.json")) return generateSoundsJSON();
   return new FileInputStream(
       getRealPathBecauseMojangLiterallyCantEvenCodeOutsideTheirUsageScenario(l));
 }
 private InputStream getResourceStream(ResourceLocation p_110605_1_) {
   return DefaultResourcePack.class.getResourceAsStream(
       "/assets/" + p_110605_1_.getResourceDomain() + "/" + p_110605_1_.getResourcePath());
 }
Exemple #29
0
  private static void renderCelestialBodies(
      float partialTickTime,
      DimensionInformation information,
      WorldClient world,
      TextureManager renderEngine,
      Tessellator tessellator) {
    List<CelestialBodyDescriptor> celestialBodies = information.getCelestialBodyDescriptors();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.glBlendFunc(770, 1, 1, 0);
    GL11.glPushMatrix();

    float f6 = 1.0F - world.getRainStrength(partialTickTime);
    ResourceLocation sun = getSun(information);
    ResourceLocation moon = getMoon(information);

    if (celestialBodies.isEmpty()) {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
      GL11.glTranslatef(0.0F, 0.0F, 0.0F);
      GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(world.getCelestialAngle(partialTickTime) * 360.0F, 1.0F, 0.0F, 0.0F);
      float f10 = 30.0F;
      renderEngine.bindTexture(sun);
      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV((-f10), 100.0D, (-f10), 0.0D, 0.0D);
      tessellator.addVertexWithUV(f10, 100.0D, (-f10), 1.0D, 0.0D);
      tessellator.addVertexWithUV(f10, 100.0D, f10, 1.0D, 1.0D);
      tessellator.addVertexWithUV((-f10), 100.0D, f10, 0.0D, 1.0D);
      tessellator.draw();
      f10 = 20.0F;
      float f14, f15, f16, f17;
      renderEngine.bindTexture(moon);
      if (!moon.equals(locationMoonPhasesPng)) {
        f14 = 0.0f;
        f15 = 0.0f;
        f16 = 1.0f;
        f17 = 1.0f;
      } else {
        int k = world.getMoonPhase();
        int l = k % 4;
        int i1 = k / 4 % 2;
        f14 = (l + 0) / 4.0F;
        f15 = (i1 + 0) / 2.0F;
        f16 = (l + 1) / 4.0F;
        f17 = (i1 + 1) / 2.0F;
      }
      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV((-f10), -100.0D, f10, f16, f17);
      tessellator.addVertexWithUV(f10, -100.0D, f10, f14, f17);
      tessellator.addVertexWithUV(f10, -100.0D, (-f10), f14, f15);
      tessellator.addVertexWithUV((-f10), -100.0D, (-f10), f16, f15);
      tessellator.draw();
    } else {
      Random random = new Random(world.getSeed());
      for (CelestialBodyDescriptor body : celestialBodies) {
        float offset = 0.0f;
        float factor = 1.0f;
        float yangle = -90.0f;
        if (!body.isMain()) {
          offset = random.nextFloat() * 200.0f;
          factor = random.nextFloat() * 3.0f;
          yangle = random.nextFloat() * 180.0f;
        }
        switch (body.getType()) {
          case BODY_NONE:
            break;
          case BODY_SUN:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                30.0F,
                sun);
            break;
          case BODY_LARGESUN:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                80.0F,
                sun);
            break;
          case BODY_SMALLSUN:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                10.0F,
                sun);
            break;
          case BODY_REDSUN:
            GL11.glColor4f(1.0F, 0.0F, 0.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                30.0F,
                sun);
            break;
          case BODY_MOON:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                20.0F,
                moon);
            break;
          case BODY_LARGEMOON:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                60.0F,
                moon);
            break;
          case BODY_SMALLMOON:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                10.0F,
                moon);
            break;
          case BODY_REDMOON:
            GL11.glColor4f(1.0F, 0.0F, 0.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                20.0F,
                moon);
            break;
          case BODY_PLANET:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderPlanet(
                partialTickTime, world, renderEngine, tessellator, offset, factor, yangle, 10.0F);
            break;
          case BODY_LARGEPLANET:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderPlanet(
                partialTickTime, world, renderEngine, tessellator, offset, factor, yangle, 30.0F);
            break;
        }
      }
    }

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    float f18 = world.getStarBrightness(partialTickTime) * f6;

    if (f18 > 0.0F) {
      GL11.glColor4f(f18, f18, f18, f18);
      GL11.glCallList(starGLCallList);
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
  }
Exemple #30
0
 private static ResourceLocation completeResourceLocation(
     ResourceLocation location, String basePath) {
   return new ResourceLocation(
       location.getResourceDomain(),
       String.format("%s/%s%s", basePath, location.getResourcePath(), ".png"));
 }