Advertisement
riking

Untitled

Feb 13th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.87 KB | None | 0 0
  1. /** mod_KorriSPlayground.java **/
  2. package net.minecraft.src;
  3.  
  4. import java.util.Map;
  5.  
  6. import net.minecraft.src.korri.*;
  7.  
  8. public class mod_KorriSPlayground extends BaseMod {
  9.     public static final Item itemFly;
  10.     static {
  11.         itemFly = new ItemFly(2001).setItemName("fly");
  12.     }
  13.  
  14.     @Override
  15.     public String getVersion() {
  16.         return "0.01";
  17.     }
  18.  
  19.     @Override
  20.     public void load() {
  21.         ModLoader.RegisterEntityID(EntityFly.class, "Fly",
  22.                 ModLoader.getUniqueEntityId());
  23.         itemFly.iconIndex = ModLoader.addOverride("/gui/items.png",
  24.                 "/korri/rocket.png");
  25.         ModLoader.AddName(itemFly, "Fly baby fly !");
  26.         ModLoader.AddRecipe(new ItemStack(itemFly, 1),
  27.                 new Object[] { " X ", "X X", "YYY", Character.valueOf('X'),
  28.                         Item.stick, Character.valueOf('Y'), Block.planks });
  29.     }
  30.  
  31.     @Override
  32.     public void AddRenderer(Map map) {
  33.         map.put(EntityFly.class, new RenderFly());
  34.     }
  35.  
  36. }
  37.  
  38. /** ItemFly.java **/
  39. package net.minecraft.src.korri;
  40.  
  41. import net.minecraft.src.BlockRail;
  42. import net.minecraft.src.EntityMinecart;
  43. import net.minecraft.src.EntityPlayer;
  44. import net.minecraft.src.Item;
  45. import net.minecraft.src.ItemStack;
  46. import net.minecraft.src.World;
  47.  
  48. public class ItemFly extends Item {
  49.     public ItemFly(int i) {
  50.         super(i);
  51.         maxStackSize = 1;
  52.     }
  53.  
  54.     public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer,
  55.             World world, int i, int j, int k, int l) {
  56.         if (!world.isRemote) {
  57.             world.spawnEntityInWorld(new EntityFly(world, (float) i + 0.5F,
  58.                     (float) j + 0.5F, (float) k + 0.5F));
  59.             System.out.println("New Fly !");
  60.         }
  61.         itemstack.stackSize--;
  62.         return true;
  63.     }
  64. }
  65.  
  66. /** EntityFly.java **/
  67. package net.minecraft.src.korri;
  68.  
  69. import java.util.List;
  70.  
  71. import net.minecraft.src.*;
  72.  
  73. public class EntityFly extends Entity {
  74.  
  75.     public EntityFly(World world) {
  76.         super(world);
  77.         preventEntitySpawning = true;
  78.         setSize(1.0F, 0.3F);
  79.         yOffset = height / 2.0F;
  80.     }
  81.  
  82.     public EntityFly(World world, float x, float y, float z) {
  83.         this(world);
  84.         setPosition(x, y + (double) yOffset, z);
  85.     }
  86.  
  87.     protected boolean canTriggerWalking() {
  88.         return false;
  89.     }
  90.  
  91.     public boolean canBeCollidedWith() {
  92.         return true;
  93.     }
  94.  
  95.     public boolean canBePushed() {
  96.         return true;
  97.     }
  98.  
  99.     public double getMountedYOffset() {
  100.         return -0.3D;// (double)height * 0.0D - 0.30000001192092896D;
  101.     }
  102.  
  103.     public boolean interact(EntityPlayer entityplayer) {
  104.         if (riddenByEntity != null && (riddenByEntity instanceof EntityPlayer)
  105.                 && riddenByEntity != entityplayer) {
  106.             return true;
  107.         }
  108.         if (!worldObj.isRemote) {
  109.             entityplayer.mountEntity(this);
  110.         }
  111.         return true;
  112.     }
  113.  
  114.     public void onUpdate() {
  115.         super.onUpdate();
  116.  
  117.         if (riddenByEntity != null && riddenByEntity.isDead) {
  118.             riddenByEntity = null;
  119.         }
  120.     }
  121.  
  122.     @Override
  123.     protected void entityInit() {
  124.     }
  125.  
  126.     @Override
  127.     protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
  128.         // super.readFromNBT(nbttagcompound);
  129.     }
  130.  
  131.     @Override
  132.     protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {
  133.         // super.writeToNBT(nbttagcompound);
  134.     }
  135.  
  136. }
  137.  
  138. /** RenderFly.java **/
  139. package net.minecraft.src.korri;
  140.  
  141. import net.minecraft.src.Entity;
  142. import net.minecraft.src.EntityBoat;
  143. import net.minecraft.src.MathHelper;
  144. import net.minecraft.src.ModelBase;
  145. import net.minecraft.src.ModelBoat;
  146. import net.minecraft.src.Render;
  147.  
  148. import org.lwjgl.opengl.GL11;
  149.  
  150. public class RenderFly extends Render {
  151.     protected ModelFly modelFly;
  152.  
  153.     public RenderFly() {
  154.         shadowSize = 0.5F;
  155.         modelFly = new ModelFly();
  156.     }
  157.  
  158.     public void renderFly(EntityFly entityfly, double d, double d1, double d2,
  159.             float f, float f1) {
  160.         loadTexture("/korri/fly.png");
  161.         modelFly.render(entityfly, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  162.     }
  163.  
  164.     public void doRender(Entity entity, double d, double d1, double d2,
  165.             float f, float f1) {
  166.         renderFly((EntityFly) entity, d, d1, d2, f, f1);
  167.     }
  168. }
  169.  
  170. /** ModelFly.java **/
  171. package net.minecraft.src.korri;
  172.  
  173. import net.minecraft.src.*;
  174.  
  175. public class ModelFly extends ModelBase {
  176.     // fields
  177.     ModelRenderer Sit;
  178.  
  179.     public ModelFly() {
  180.         textureWidth = 52;
  181.         textureHeight = 15;
  182.  
  183.         Sit = new ModelRenderer(this, 0, 0);
  184.         Sit.addBox(0F, 0F, 0F, 16, 5, 10);
  185.         Sit.setRotationPoint(8F, 0F, 5F);
  186.         Sit.setTextureSize(textureWidth, textureHeight);
  187.         Sit.mirror = true;
  188.         setRotation(Sit, 0F, 0F, 0F);
  189.     }
  190.  
  191.     public void render(Entity entity, float f, float f1, float f2, float f3,
  192.             float f4, float f5) {
  193.     //  super.render(entity, f, f1, f2, f3, f4, f5);
  194.     GL11.glPushMatrix();
  195.         setRotationAngles(f, f1, f2, f3, f4, f5);
  196.         Sit.render(f5);
  197.     GL11.glPopMatrix();
  198.     }
  199.  
  200.     private void setRotation(ModelRenderer model, float x, float y, float z) {
  201.         model.rotateAngleX = x;
  202.         model.rotateAngleY = y;
  203.         model.rotateAngleZ = z;
  204.     }
  205.  
  206.     public void setRotationAngles(float f, float f1, float f2, float f3,
  207.             float f4, float f5) {
  208.         super.setRotationAngles(f, f1, f2, f3, f4, f5);
  209.     }
  210.  
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement