Guest User

Untitled

a guest
Oct 6th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. package mymod.entity.EntityRifleBolt;
  2.  
  3. import net.minecraft.client.model.ModelBase;
  4. import net.minecraft.client.renderer.entity.Render;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.util.ResourceLocation;
  8.  
  9. import org.lwjgl.opengl.GL11;
  10.  
  11. import cpw.mods.fml.relauncher.Side;
  12. import cpw.mods.fml.relauncher.SideOnly;
  13.  
  14. @SideOnly(Side.CLIENT)
  15. public class RenderRifleBolt extends Render
  16. {
  17.  
  18. // ResourceLocations are typically static and final, but that is not an absolute requirement
  19. private static final ResourceLocation texture = new ResourceLocation("mymod", "textures/entity/RifleBolt.png");
  20.  
  21. // if you want a model, be sure to add it here:
  22. private ModelBase model;
  23.  
  24. public RenderRifleBolt(Item pulseRifle) {
  25. // we could have initialized it above, but here is fine as well:
  26. model = new ModelRifleBolt();
  27. }
  28.  
  29. @Override
  30. protected ResourceLocation getEntityTexture(Entity entity) {
  31. // this method should return your texture, which may be different based
  32. // on certain characteristics of your custom entity; if that is the case,
  33. // you may want to make a second method that takes your class:
  34. return getCustomTexture((EntityRifleBolt) entity);
  35. }
  36.  
  37. private ResourceLocation getCustomTexture(EntityRifleBolt entity) {
  38. // now you have access to your custom entity fields and methods, if any,
  39. // and can base the texture to return upon those
  40. return texture;
  41. }
  42.  
  43. // in whatever render method you are using; this one is from Render class:
  44. @Override
  45. public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTick) {
  46. // again, if you need some information from your custom entity class, you can cast to your
  47. // custom class, either passing off to another method, or just doing it here
  48. // in this example, it is not necessary
  49.  
  50. // if you are going to do any openGL matrix transformations, be sure to always Push and Pop
  51. GL11.glPushMatrix();
  52.  
  53. // bind your texture:
  54. bindTexture(texture);
  55.  
  56. // do whatever transformations you need, then render
  57.  
  58. // typically you will at least want to translate for x/y/z position:
  59. GL11.glTranslated(x, y, z);
  60.  
  61. // if you are using a model, you can do so like this:
  62. model.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
  63.  
  64. // note all the values are 0 except the final argument, which is scale
  65. // vanilla Minecraft almost excusively uses 0.0625F, but you can change it to whatever works
  66.  
  67. GL11.glPopMatrix();
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment