Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Item[][] armors;
- private String[] colorOrder = {"Red", "Orange", "Yellow", "Green", "Blue", "Purple"};
- // "Helmet" "Plate" "Legs" "Boots"
- @ load()
- {
- ....
- armors[0][0] = RedHelmet;
- armors[0][1] = RedPlate;
- armors[0][2] = RedLegs;
- armors[0][3] = RedBoots;
- armors[1][0] = OrangeHelmet;
- ....
- }
- public String getArmorColorIndex(String color)
- {
- for (int i = 0; i < colorOrder.length; i++)
- {
- if (colorOrder[i] == color) return i;
- }
- throw new IllegalArgumentException("Unknown color name!");
- }
- ================
- package net.minecraft.src;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.PrintStream;
- import java.util.List;
- import java.util.Random;
- import net.minecraft.src.forge.ISpawnHandler;
- public class PaintballEntityRefillers extends PaintballEntityObjects implements IMob, ISpawnHandler
- {
- public PaintballEntityRefillers(World world)
- {
- super(world);
- }
- public PaintballEntityRefillers(World world, String color, double d, double d1, double d2)
- {
- super(world);
- setSize(0.35F, 0.50F);
- setPosition(d, d1, d2);
- refiller_color = color;
- motionX = 0.0D;
- motionY = 0.0D;
- motionZ = 0.0D;
- prevPosX = d;
- prevPosY = d1;
- prevPosZ = d2;
- if(!world.isRemote)
- {
- EntityPlayer entity = findPlayer();
- if(entity != null)
- {
- faceEntity(entity, 180F, 180F);
- rotationYaw -= 90;
- renderYawOffset = rotationYaw;
- refiller_isRotated = false;
- }
- }
- refiller_color = color;
- }
- public void onUpdate()
- {
- super.onUpdate();
- if(!refiller_isRotated)
- {
- renderYawOffset = rotationYaw;
- refiller_isRotated = true;
- }
- if(refiller_cooldown > 0)
- refiller_cooldown--;
- if(refiller_cooldown >= 900)
- texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller5.png";
- else if(refiller_cooldown >= 600 && refiller_cooldown < 900)
- texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller4.png";
- else if(refiller_cooldown >= 300 && refiller_cooldown < 600)
- texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller3.png";
- else if(refiller_cooldown > 0 && refiller_cooldown < 300)
- texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller2.png";
- else
- texture = "/Paintball/" + refiller_color.toLowerCase() + "refiller1.png";
- }
- private boolean fullSuit(ItemStack[] armorinv, int colorindex)
- {
- boolean[] checklist = {false,false,false,false};
- short count = 0;
- for(short i=0; i<4; i++)
- {
- if (armorinv[i] == null)
- {
- System.out.println("DEBUG: armor piece "+i+" was null");
- return false;
- }
- checklist[i] = (armorinv[i] == mod_Paintball.armors[colorindex][i]);
- count++;
- }
- System.out.println("DEBUG: Armor array: "+checklist.toString()+"; armor count: "+count);
- return count == 3;
- }
- public boolean interact(EntityPlayer entityplayer)
- {
- World world = ModLoader.getMinecraftServerInstance().getWorldManager(entityplayer.dimension);
- if(!world.isRemote)
- {
- boolean SameTeam = fullSuit(entityplayer.inventory.armorInventory, mod_Paintball.getArmorColorIndex(refiller_color));
- System.out.println(SameTeam); //Always false == thinks you're on the team
- System.out.println("DEBUG: Refiller cooldown: "+refiller_cooldown);
- if(SameTeam && refiller_cooldown == 0)
- {
- System.out.println("Server Give"); //Doesn't print until the second time you right click on the entity while it should be counting down
- boolean add1 = entityplayer.inventory.addItemStackToInventory(new ItemStack(mod_Paintball.pelletMap.get(refiller_color), 64));
- boolean add2 = entityplayer.inventory.addItemStackToInventory(new ItemStack(mod_Paintball.pelletMap.get(refiller_color), 64));
- boolean add3 = entityplayer.inventory.addItemStackToInventory(new ItemStack(mod_Paintball.pelletMap.get(refiller_color), 64));
- if(add1 || add2 || add3)
- {
- refiller_cooldown = 1200;
- world.playSoundAtEntity(entityplayer, "random.pop", 1.0F, 1.0F / (mod_Paintball.pelletMap.get(refiller_color).itemRand.nextFloat() * 0.4F + 0.8F));
- }
- }
- return true;
- }
- else
- {
- return false;
- }
- }
- protected EntityPlayer findPlayer()
- {
- EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, 16D);
- if(entityplayer != null && canEntityBeSeen(entityplayer))
- return entityplayer;
- else
- return null;
- }
- public void writeEntityToNBT(NBTTagCompound nbttagcompound)
- {
- super.writeEntityToNBT(nbttagcompound);
- nbttagcompound.setString("Color", refiller_color);
- nbttagcompound.setInteger("Cooldown", refiller_cooldown);
- }
- public void readEntityFromNBT(NBTTagCompound nbttagcompound)
- {
- super.readEntityFromNBT(nbttagcompound);
- refiller_color = nbttagcompound.getString("Color");
- refiller_cooldown = nbttagcompound.getInteger("Cooldown");
- }
- public void writeSpawnData(DataOutputStream data) throws IOException
- {
- data.writeUTF(refiller_color);
- }
- public void readSpawnData(DataInputStream data) throws IOException
- {
- }
- protected int getDropItemId()
- {
- if(refiller_color == "Red")
- entityDropItem(new ItemStack(mod_Paintball.RedRefiller), 0.0F);
- else if(refiller_color == "Orange")
- entityDropItem(new ItemStack(mod_Paintball.OrangeRefiller), 0.0F);
- else if(refiller_color == "Yellow")
- entityDropItem(new ItemStack(mod_Paintball.YellowRefiller), 0.0F);
- else if(refiller_color == "Green")
- entityDropItem(new ItemStack(mod_Paintball.GreenRefiller), 0.0F);
- else if(refiller_color == "Blue")
- entityDropItem(new ItemStack(mod_Paintball.BlueRefiller), 0.0F);
- else if(refiller_color == "Purple")
- entityDropItem(new ItemStack(mod_Paintball.PurpleRefiller), 0.0F);
- return 0;
- }
- public String refiller_color;
- private boolean refiller_isRotated;
- private int refiller_cooldown;
- private Entity currentTarget;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement