From 7fe5dd337a92c11a5a33b3ffc685f0ea32606430 Mon Sep 17 00:00:00 2001 From: Grafe Date: Fri, 11 Jan 2013 03:08:45 +0100 Subject: [PATCH] Change: Removed all CraftBukkit and NMS Code --- src/com/dre/dungeonsxl/DMobType.java | 67 ++++++--------------------- src/com/dre/dungeonsxl/game/DMob.java | 9 +++- 2 files changed, 22 insertions(+), 54 deletions(-) diff --git a/src/com/dre/dungeonsxl/DMobType.java b/src/com/dre/dungeonsxl/DMobType.java index a820d445..4508d6a3 100644 --- a/src/com/dre/dungeonsxl/DMobType.java +++ b/src/com/dre/dungeonsxl/DMobType.java @@ -8,17 +8,11 @@ import java.util.Map; import java.util.Set; import java.util.logging.Level; -import net.minecraft.server.v1_4_6.Item; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.craftbukkit.v1_4_6.entity.CraftPigZombie; -import org.bukkit.craftbukkit.v1_4_6.entity.CraftSkeleton; -import org.bukkit.craftbukkit.v1_4_6.entity.CraftZombie; -import org.bukkit.craftbukkit.v1_4_6.inventory.CraftItemStack; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -39,11 +33,11 @@ public class DMobType { private int maxHealth; - private Item ItemHand; - private Item ItemHelmet; - private Item ItemChestplate; - private Item ItemLeggings; - private Item ItemBoots; + private ItemStack ItemHand; + private ItemStack ItemHelmet; + private ItemStack ItemChestplate; + private ItemStack ItemLeggings; + private ItemStack ItemBoots; private Map drops = new HashMap(); public Map getDrops() { return this.drops; } @@ -66,42 +60,11 @@ public class DMobType { LivingEntity entity=(LivingEntity)gWorld.world.spawnEntity(loc, type); /* Set the Items */ - - //Check if it's a Zombie - if(type==EntityType.ZOMBIE){ - CraftZombie entityC = (CraftZombie)entity; - net.minecraft.server.v1_4_6.EntityZombie entityMC = entityC.getHandle(); - - if(ItemHand!=null) entityMC.setEquipment(0, new net.minecraft.server.v1_4_6.ItemStack(ItemHand)); - if(ItemBoots!=null) entityMC.setEquipment(1, new net.minecraft.server.v1_4_6.ItemStack(ItemBoots)); - if(ItemLeggings!=null) entityMC.setEquipment(2, new net.minecraft.server.v1_4_6.ItemStack(ItemLeggings)); - if(ItemChestplate!=null) entityMC.setEquipment(3, new net.minecraft.server.v1_4_6.ItemStack(ItemChestplate)); - if(ItemHelmet!=null) entityMC.setEquipment(4, new net.minecraft.server.v1_4_6.ItemStack(ItemHelmet)); - } - - //Check if it's a Skeleton - if(type==EntityType.SKELETON){ - CraftSkeleton entityC = (CraftSkeleton)entity; - net.minecraft.server.v1_4_6.EntitySkeleton entityMC = entityC.getHandle(); - - if(ItemHand!=null) entityMC.setEquipment(0, new net.minecraft.server.v1_4_6.ItemStack(ItemHand)); - if(ItemBoots!=null) entityMC.setEquipment(1, new net.minecraft.server.v1_4_6.ItemStack(ItemBoots)); - if(ItemLeggings!=null) entityMC.setEquipment(2, new net.minecraft.server.v1_4_6.ItemStack(ItemLeggings)); - if(ItemChestplate!=null) entityMC.setEquipment(3, new net.minecraft.server.v1_4_6.ItemStack(ItemChestplate)); - if(ItemHelmet!=null) entityMC.setEquipment(4, new net.minecraft.server.v1_4_6.ItemStack(ItemHelmet)); - } - - //Check if it's a Zombie Pigman - if(type==EntityType.PIG_ZOMBIE){ - CraftPigZombie entityC = (CraftPigZombie)entity; - net.minecraft.server.v1_4_6.EntityPigZombie entityMC = entityC.getHandle(); - - if(ItemHand!=null) entityMC.setEquipment(0, new net.minecraft.server.v1_4_6.ItemStack(ItemHand)); - if(ItemBoots!=null) entityMC.setEquipment(1, new net.minecraft.server.v1_4_6.ItemStack(ItemBoots)); - if(ItemLeggings!=null) entityMC.setEquipment(2, new net.minecraft.server.v1_4_6.ItemStack(ItemLeggings)); - if(ItemChestplate!=null) entityMC.setEquipment(3, new net.minecraft.server.v1_4_6.ItemStack(ItemChestplate)); - if(ItemHelmet!=null) entityMC.setEquipment(4, new net.minecraft.server.v1_4_6.ItemStack(ItemHelmet)); - } + entity.getEquipment().setItemInHand(ItemHand); + entity.getEquipment().setHelmet(ItemHelmet); + entity.getEquipment().setChestplate(ItemChestplate); + entity.getEquipment().setLeggings(ItemLeggings); + entity.getEquipment().setBoots(ItemBoots); /* Check mob specified stuff */ if(type==EntityType.SKELETON){ @@ -152,23 +115,23 @@ public class DMobType { //Load Items if(configFile.contains(mobName+".ItemHelmet")){ - mobType.ItemHelmet=CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem(); + mobType.ItemHelmet = new ItemStack(configFile.getInt(mobName+".ItemHelmet"));//CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemHelmet"))).getItem(); } if(configFile.contains(mobName+".ItemChestplate")){ - mobType.ItemChestplate=CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem(); + mobType.ItemChestplate = new ItemStack(configFile.getInt(mobName+".ItemChestplate"));//CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemChestplate"))).getItem(); } if(configFile.contains(mobName+".ItemBoots")){ - mobType.ItemBoots=CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem(); + mobType.ItemBoots = new ItemStack(configFile.getInt(mobName+".ItemBoots"));//CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemBoots"))).getItem(); } if(configFile.contains(mobName+".ItemLeggings")){ - mobType.ItemLeggings=CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemLeggings"))).getItem(); + mobType.ItemLeggings = new ItemStack(configFile.getInt(mobName+".ItemLeggings"));//CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemLeggings"))).getItem(); } if(configFile.contains(mobName+".ItemHand")){ - mobType.ItemHand=CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemHand"))).getItem(); + mobType.ItemHand = new ItemStack(configFile.getInt(mobName+".ItemHand"));//CraftItemStack.asNMSCopy(new ItemStack(configFile.getInt(mobName+".ItemHand"))).getItem(); } //Load different Mob options diff --git a/src/com/dre/dungeonsxl/game/DMob.java b/src/com/dre/dungeonsxl/game/DMob.java index 035bf6ee..bd245e8a 100644 --- a/src/com/dre/dungeonsxl/game/DMob.java +++ b/src/com/dre/dungeonsxl/game/DMob.java @@ -13,15 +13,20 @@ public class DMob { //Variables public LivingEntity entity; public DMobType type; - public int live; public DMob(LivingEntity entity, int live, GameWorld gworld, DMobType type){ gworld.dmobs.add(this); this.entity = entity; - this.live = live; this.type = type; + /* Remove DropChance of equipment */ + this.entity.getEquipment().setHelmetDropChance(0); + this.entity.getEquipment().setChestplateDropChance(0); + this.entity.getEquipment().setLeggingsDropChance(0); + this.entity.getEquipment().setBootsDropChance(0); + this.entity.getEquipment().setItemInHandDropChance(0); + /* Max Health */ if(live>0){ this.entity.setMaxHealth(live);