Advertisement
akSource

IItemRendererでの剣の描画処理

Jul 26th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.98 KB | None | 0 0
  1. package ak.EnchantChanger.Client.renderer;
  2.  
  3. import ak.EnchantChanger.Client.models.*;
  4. import ak.EnchantChanger.EnchantChanger;
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.entity.EntityLivingBase;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.util.ResourceLocation;
  9. import net.minecraftforge.client.IItemRenderer;
  10. import ak.EnchantChanger.item.EcItemCloudSword;
  11. import ak.EnchantChanger.item.EcItemCloudSwordCore;
  12. import ak.EnchantChanger.item.EcItemSephirothSword;
  13. import ak.EnchantChanger.item.EcItemSephirothSwordImit;
  14. import ak.EnchantChanger.item.EcItemUltimateWeapon;
  15. import ak.EnchantChanger.item.EcItemZackSword;
  16. import cpw.mods.fml.relauncher.Side;
  17. import cpw.mods.fml.relauncher.SideOnly;
  18. import net.minecraftforge.client.model.AdvancedModelLoader;
  19. import net.minecraftforge.client.model.IModelCustom;
  20. import org.lwjgl.opengl.GL11;
  21.  
  22. @SideOnly(Side.CLIENT)
  23. public class EcRenderSwordModel implements IItemRenderer
  24. {
  25.     private static final EcModelUltimateWeapon UModel = new EcModelUltimateWeapon();
  26.     private static final EcModelCloudSwordCore2 CCModel = new EcModelCloudSwordCore2();
  27.     private static final EcModelCloudSword2 CModel = new EcModelCloudSword2();
  28.     private static final EcModelSephirothSword SModel = new EcModelSephirothSword();
  29.     private static final EcModelZackSword ZModel = new EcModelZackSword();
  30.  
  31.     private static final ResourceLocation zackSwordObj = new ResourceLocation(EnchantChanger.EcAssetsDomain, "models/bustersword.obj");
  32.     private final IModelCustom zackSwordModel;
  33.     private static final ResourceLocation zackSwordEdge = new ResourceLocation(EnchantChanger.EcAssetsDomain, "textures/item/bustersword256-edge.png");
  34.     private static final ResourceLocation zackSwordBox = new ResourceLocation(EnchantChanger.EcAssetsDomain, "textures/item/bustersword256-box.png");
  35.     private static final ResourceLocation zackSwordCylinder = new ResourceLocation(EnchantChanger.EcAssetsDomain, "textures/item/bustersword256-cylinder.png");
  36.  
  37.     private Minecraft mc;
  38.  
  39.     public EcRenderSwordModel() {
  40.         mc = Minecraft.getMinecraft();
  41.         zackSwordModel = AdvancedModelLoader.loadModel(zackSwordObj);
  42.     }
  43.  
  44.     @Override
  45.     public boolean handleRenderType(ItemStack item, ItemRenderType type) {
  46.         return type == ItemRenderType.EQUIPPED
  47.                 || type == ItemRenderType.EQUIPPED_FIRST_PERSON;
  48.     }
  49.  
  50.     @Override
  51.     public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
  52.             ItemRendererHelper helper) {
  53.         return false;
  54.     }
  55.  
  56.     @Override
  57.     public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
  58.         if (item.getItem() instanceof EcItemZackSword) {
  59. //            ZModel.renderItem(item, (EntityLivingBase) data[1]);
  60.             renderSwordModel(item, (EntityLivingBase) data[1], type);
  61.         }
  62.         if (item.getItem() instanceof EcItemCloudSword) {
  63.             CModel.renderItem(item, (EntityLivingBase) data[1]);
  64.         }
  65.         if (item.getItem() instanceof EcItemCloudSwordCore) {
  66.             CCModel.renderItem(item, (EntityLivingBase) data[1],
  67.                     ((EcItemCloudSwordCore) item.getItem()).isActive(item));
  68.         }
  69.         if (item.getItem() instanceof EcItemSephirothSword
  70.                 || item.getItem() instanceof EcItemSephirothSwordImit) {
  71.             SModel.renderItem(item, (EntityLivingBase) data[1]);
  72.         }
  73.         if (item.getItem() instanceof EcItemUltimateWeapon) {
  74.             UModel.renderItem(item, (EntityLivingBase) data[1]);
  75.         }
  76.     }
  77.  
  78.     //Obj仕様renderメソッド
  79.     private void renderSwordModel(ItemStack item, EntityLivingBase entityLivingBase, ItemRenderType type) {
  80.         GL11.glPushMatrix();
  81.         GL11.glTranslatef(0.7F, 0.38F, 0.0F);
  82.         GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
  83. //        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) GL11.glTranslatef(0.3f, 0.2f, 0);
  84.         if (item.getItem() instanceof EcItemZackSword)
  85.             renderZackSwordModel(item, 0.12F);
  86.         if (item.getItem() instanceof EcItemCloudSword)
  87. //            CModel.renderItem(item, (EntityLivingBase) data[1]);
  88.         if (item.getItem() instanceof EcItemCloudSwordCore)
  89. //            CCModel.renderItem(item, (EntityLivingBase) data[1],
  90. //                    ((EcItemCloudSwordCore) item.getItem()).isActive(item));
  91.         if (item.getItem() instanceof EcItemSephirothSword
  92.                 || item.getItem() instanceof EcItemSephirothSwordImit)
  93. //            SModel.renderItem(item, (EntityLivingBase) data[1]);
  94.         if (item.getItem() instanceof EcItemUltimateWeapon)
  95. //            UModel.renderItem(item, (EntityLivingBase) data[1]);
  96.         GL11.glPopMatrix();
  97.     }
  98.  
  99.     private void renderZackSwordModel(ItemStack item, float size) {
  100.         GL11.glScalef(size, size, size);
  101.         mc.renderEngine.bindTexture(zackSwordEdge);
  102.         zackSwordModel.renderPart("Sword_sword");
  103.         mc.renderEngine.bindTexture(zackSwordBox);
  104.         zackSwordModel.renderPart("box");
  105.         mc.renderEngine.bindTexture(zackSwordCylinder);
  106.         zackSwordModel.renderPart("Cylinder");
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement