コード例 #1
0
 @SideOnly(Side.CLIENT)
 @SubscribeEvent
 public void textureStitch(TextureStitchEvent.Pre event) {
   blockIconInfoList.clear();
   blockIconList.clear();
   fluidIcons.clear();
   itemIcons.clear();
   TextureMap textureMap = event.map;
   for (Object object : jsonDestroyer.objectsToDestroy) {
     if (object instanceof Block && object instanceof ITexturedBlock) {
       ITexturedBlock blockTextureProvider = (ITexturedBlock) object;
       Block block = (Block) object;
       for (int i = 0; i < blockTextureProvider.amountOfStates(); i++) {
         for (EnumFacing side : EnumFacing.values()) {
           String name;
           name = blockTextureProvider.getTextureNameFromState(block.getStateFromMeta(i), side);
           TextureAtlasSprite texture = textureMap.getTextureExtry(name);
           if (texture == null) {
             texture = new CustomTexture(name);
             textureMap.setTextureEntry(name, texture);
           }
           BlockIconInfo iconInfo = new BlockIconInfo(block, i, side);
           blockIconList.put(iconInfo, texture);
           blockIconInfoList.add(iconInfo);
         }
       }
     } else if (object instanceof BlockFluidBase && object instanceof ITexturedFluid) {
       ITexturedFluid fluidTextureProvider = (ITexturedFluid) object;
       String name = fluidTextureProvider.getTextureName();
       TextureAtlasSprite texture = textureMap.getTextureExtry(name);
       if (texture == null) {
         texture = new CustomTexture(name);
         textureMap.setTextureEntry(name, texture);
       }
       fluidIcons.put((BlockFluidBase) object, texture);
     } else if (object instanceof Item && object instanceof ITexturedItem) {
       ITexturedItem itemTexture = (ITexturedItem) object;
       Item item = (Item) object;
       for (int i = 0; i < itemTexture.getMaxMeta(); i++) {
         String name = itemTexture.getTextureName(i);
         TextureAtlasSprite texture = textureMap.getTextureExtry(name);
         if (texture == null) {
           texture = new CustomTexture(name);
           textureMap.setTextureEntry(name, texture);
         }
         ItemIconInfo info = new ItemIconInfo((Item) object, i, texture, name);
         itemIcons.add(info);
       }
     } else if (object instanceof Item && object instanceof ITexturedBucket) {
       ITexturedBucket itemTexture = (ITexturedBucket) object;
       for (int i = 0; i < itemTexture.getMaxMeta(); i++) {
         String name = itemTexture.getFluid(i).getStill().toString();
         TextureAtlasSprite texture = textureMap.getTextureExtry(name);
         if (texture == null) {
           texture = new CustomTexture(name);
           textureMap.setTextureEntry(name, texture);
         }
         ItemIconInfo info = new ItemIconInfo((Item) object, i, texture, name);
         info.isBucket = true;
         itemIcons.add(info);
       }
     }
   }
 }