Advertisement
Guest User

Riking

a guest
Apr 30th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.61 KB | None | 0 0
  1. public Item[][] armors;
  2. private String[] colorOrder = {"Red", "Orange", "Yellow", "Green", "Blue", "Purple"};
  3. // "Helmet" "Plate" "Legs" "Boots"
  4. @ load()
  5. {
  6. ....
  7. armors[0][0] = RedHelmet;
  8. armors[0][1] = RedPlate;
  9. armors[0][2] = RedLegs;
  10. armors[0][3] = RedBoots;
  11. armors[1][0] = OrangeHelmet;
  12. ....
  13. }
  14. ================
  15. package net.minecraft.src;
  16.  
  17. import java.io.DataInputStream;
  18. import java.io.DataOutputStream;
  19. import java.io.IOException;
  20. import java.io.PrintStream;
  21. import java.util.List;
  22. import java.util.Random;
  23.  
  24. import net.minecraft.src.forge.ISpawnHandler;
  25.  
  26. public class PaintballEntityRefillers extends PaintballEntityObjects implements IMob, ISpawnHandler
  27. {
  28.     public PaintballEntityRefillers(World world)
  29.     {
  30.         super(world);
  31.     }
  32.  
  33.     public PaintballEntityRefillers(World world, String color, double d, double d1, double d2)
  34.     {
  35.         super(world);
  36.         setSize(0.35F, 0.50F);
  37.         setPosition(d, d1, d2);
  38.         refiller_color = color;
  39.         motionX = 0.0D;
  40.         motionY = 0.0D;
  41.         motionZ = 0.0D;
  42.         prevPosX = d;
  43.         prevPosY = d1;
  44.         prevPosZ = d2;
  45.         if(!world.isRemote)
  46.         {
  47.             EntityPlayer entity = findPlayer();
  48.             if(entity != null)
  49.             {
  50.                 faceEntity(entity, 180F, 180F);
  51.                 rotationYaw -= 90;
  52.                 renderYawOffset = rotationYaw;
  53.                 refiller_isRotated = false;
  54.             }
  55.         }
  56.         refiller_color = color;
  57.     }
  58.  
  59.     public void onUpdate()
  60.     {
  61.         super.onUpdate();
  62.         if(!refiller_isRotated)
  63.         {
  64.             renderYawOffset = rotationYaw;
  65.             refiller_isRotated = true;
  66.         }
  67.         if(refiller_cooldown > 0)
  68.             refiller_cooldown--;
  69.         if(refiller_cooldown >= 900)
  70.             texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller5.png";
  71.         else if(refiller_cooldown >= 600 && refiller_cooldown < 900)
  72.             texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller4.png";
  73.         else if(refiller_cooldown >= 300 && refiller_cooldown < 600)
  74.             texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller3.png";
  75.         else if(refiller_cooldown > 0 && refiller_cooldown < 300)
  76.             texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller2.png";
  77.         else
  78.             texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller1.png";
  79.     }
  80.    
  81.     private boolean fullSuit(ItemStack[] armorinv, int colorindex)
  82.     {
  83.         boolean[] checklist = {false,false,false,false};
  84.         short count = 0;
  85.         for(short i=0; i<4; i++)
  86.         {
  87.             if (armorinv[i] == null)
  88.             {
  89.                 System.out.println("DEBUG: armor piece "+i+" was null");
  90.                 return false;
  91.             }
  92.             checklist[i] = (armorinv[i] == mod_Paintball.armors[colorindex][i]);
  93.             count++;
  94.         }
  95.         System.out.println("DEBUG: Armor array: "+checklist.toString()+"; armor count: "+count);
  96.         return count == 3;
  97.     }
  98.  
  99.     public boolean interact(EntityPlayer entityplayer)
  100.     {
  101.         World world = ModLoader.getMinecraftServerInstance().getWorldManager(entityplayer.dimension);
  102.         if(!world.isRemote)
  103.         {
  104.             boolean SameTeam = fullSuit(entityplayer.inventory.armorInventory, mod_Paintball.getArmorColorIndex(refiller_color));
  105.             System.out.println(SameTeam); //Always false == thinks you're on the team
  106.             System.out.println("DEBUG: Refiller cooldown: "+refiller_cooldown);
  107.             if(SameTeam && refiller_cooldown == 0)
  108.             {
  109.                 System.out.println("Server Give"); //Doesn't print until the second time you right click on the entity while it should be counting down
  110.                 boolean add1 = entityplayer.inventory.addItemStackToInventory(new ItemStack(mod_Paintball.pelletMap.get(refiller_color), 64));
  111.                 boolean add2 = entityplayer.inventory.addItemStackToInventory(new ItemStack(mod_Paintball.pelletMap.get(refiller_color), 64));
  112.                 boolean add3 = entityplayer.inventory.addItemStackToInventory(new ItemStack(mod_Paintball.pelletMap.get(refiller_color), 64));
  113.                 if(add1 || add2 || add3)
  114.                 {
  115.                     refiller_cooldown = 1200;
  116.                     world.playSoundAtEntity(entityplayer, "random.pop", 1.0F, 1.0F / (mod_Paintball.pelletMap.get(refiller_color).itemRand.nextFloat() * 0.4F + 0.8F));
  117.                 }
  118.             }
  119.             return true;
  120.         }
  121.         else
  122.         {
  123.             return false;
  124.         }
  125.     }
  126.  
  127.     protected EntityPlayer findPlayer()
  128.     {
  129.         EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, 16D);
  130.         if(entityplayer != null && canEntityBeSeen(entityplayer))
  131.             return entityplayer;
  132.         else
  133.             return null;
  134.     }
  135.  
  136.     public void writeEntityToNBT(NBTTagCompound nbttagcompound)
  137.     {
  138.         super.writeEntityToNBT(nbttagcompound);
  139.         nbttagcompound.setString("Color", refiller_color);
  140.         nbttagcompound.setInteger("Cooldown", refiller_cooldown);
  141.     }
  142.  
  143.     public void readEntityFromNBT(NBTTagCompound nbttagcompound)
  144.     {
  145.         super.readEntityFromNBT(nbttagcompound);
  146.         refiller_color = nbttagcompound.getString("Color");
  147.         refiller_cooldown = nbttagcompound.getInteger("Cooldown");
  148.     }
  149.    
  150.     public void writeSpawnData(DataOutputStream data) throws IOException
  151.     {
  152.         data.writeUTF(refiller_color);
  153.     }
  154.  
  155.     public void readSpawnData(DataInputStream data) throws IOException
  156.     {
  157.     }
  158.  
  159.     protected int getDropItemId()
  160.     {
  161.         if(refiller_color == "Red")
  162.             entityDropItem(new ItemStack(mod_Paintball.RedRefiller), 0.0F);
  163.         else if(refiller_color == "Orange")
  164.             entityDropItem(new ItemStack(mod_Paintball.OrangeRefiller), 0.0F);
  165.         else if(refiller_color == "Yellow")
  166.             entityDropItem(new ItemStack(mod_Paintball.YellowRefiller), 0.0F);
  167.         else if(refiller_color == "Green")
  168.             entityDropItem(new ItemStack(mod_Paintball.GreenRefiller), 0.0F);
  169.         else if(refiller_color == "Blue")
  170.             entityDropItem(new ItemStack(mod_Paintball.BlueRefiller), 0.0F);
  171.         else if(refiller_color == "Purple")
  172.             entityDropItem(new ItemStack(mod_Paintball.PurpleRefiller), 0.0F);
  173.         return 0;
  174.     }
  175.  
  176.     public String refiller_color;
  177.     private boolean refiller_isRotated;
  178.     private int refiller_cooldown;
  179.     private Entity currentTarget;
  180.  
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement