diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-06-08 23:18:07 +0100 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-06-08 23:18:07 +0100 |
| commit | d17826bf67eec6de4561041832670d18074655e8 (patch) | |
| tree | db7f098e9f106cae008a03e0ad666e1c41abddbd /src/main/java/darkknight | |
| parent | 8d4cf31c5fa874876a3dcbefdc0826b08f8d807d (diff) | |
Improved Hearts and Added Spawn Eggs for them.
Diffstat (limited to 'src/main/java/darkknight')
10 files changed, 1097 insertions, 901 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java index e97ee07..5855466 100644 --- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java @@ -9,12 +9,11 @@ import java.io.File; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
+
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.WeightedRandomChestContent;
-import net.minecraftforge.common.ChestGenHooks;
+import net.minecraft.potion.Potion;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -63,6 +62,7 @@ public class JewelrycraftMod public static File liquidsConf;
public static SimpleNetworkWrapper netWrapper;
public static boolean fancyRender = false;
+ public static Potion alpacaPotion = null;
/**
* Pre initialization of mod stuff.
diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java index 108a1dc..cd688b7 100644 --- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -1,96 +1,96 @@ -package darkknight.jewelrycraft.config; - -import java.io.File; -import net.minecraftforge.common.config.Configuration; -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import darkknight.jewelrycraft.util.Variables; - -public class ConfigHandler -{ - public static Configuration config; - public static final ConfigHandler INSTANCE = new ConfigHandler(); - public static final String[] categories = {"Timers", "Village Generation", "Misc", "Curses"}; - - public static int INGOT_COOLING_TIME; - public static int INGOT_MELTING_TIME; - public static int GEM_PLACEMENT_TIME; - public static int RITUAL_TIME; - public static int HEART_DESPAWN_TIME; - - public static boolean GENERATE_VILLAGE_NETHERSTAR; - public static boolean CAN_FURNACE_GENERATE_INGOTS; - public static boolean CRYSTAL_GLOW; - public static int MAX_VILLAGE_JEWELERS; - public static int JEWELER_WEIGHT; - public static int INGOT_CHEST_MIN; - public static int INGOT_CHEST_MAX; - public static int INGOT_CHEST_MAX_STACK; - public static int GEM_CHEST_MIN; - public static int GEM_CHEST_MAX; - public static int FURNACE_MIN_INGOT_STACK; - public static int FURNACE_MAX_INGOT_STACK; - - public static boolean CURSES_ENABLED = true; - public static boolean CURSE_ROTTEN_HEART = true; - public static boolean CURSE_FLAMING_SOUL = true; - public static boolean CURSE_GREED = true; - public static boolean CURSE_BLIND = true; - public static boolean CURSE_INFAMY = true; - public static boolean CURSE_MIDAS_TOUCH = true; - public static boolean CURSE_RABBIT_PAW = true; - public static boolean CURSE_PENTAGRAM = true; - public static boolean CURSE_VAMPIRE_HUNGER = true; - public static boolean CURSE_HUMBLE_BUNDLE = true; - - public void loadConfig(FMLPreInitializationEvent event) - { - config = new Configuration(event.getSuggestedConfigurationFile(),true); - config.load(); - syncConfigs(); - } - - private void syncConfigs() - { - INGOT_COOLING_TIME = config.getInt("Molder Ingot Cooling Time", categories[0], 100, 5, Integer.MAX_VALUE, "This sets the number of ticks you need to wait before the mold is cooled."); - INGOT_MELTING_TIME = config.getInt("Ingot Melting Time", categories[0], 1500, 5, Integer.MAX_VALUE, "This sets the number of ticks you need to wait before an ingot is completely smelted."); - GEM_PLACEMENT_TIME = config.getInt( "Jewelry Crafting Time", categories[0], 200, 5, Integer.MAX_VALUE, "This sets the number of ticks it takes for a jewel to be modified."); - RITUAL_TIME = config.getInt( "Ritual Time", categories[0], 1000, 5, Integer.MAX_VALUE, "This sets the number of ticks it takes for the ritual to end."); - HEART_DESPAWN_TIME = config.getInt( "Hearts Despawn Time", categories[0], 600, 20, Integer.MAX_VALUE, "This sets the number of ticks it takes for hearts to despawn, 20=1 second"); - - GENERATE_VILLAGE_NETHERSTAR = config.getBoolean("Netherstar Generation", categories[1], false, "If set to true Nether Stars will be able to generate in Jewelers chests."); - CAN_FURNACE_GENERATE_INGOTS = config.getBoolean("Furnace Ingots Generation", categories[1], true, "If set to true jewelers will generate ingots in furnaces."); - - MAX_VILLAGE_JEWELERS = config.getInt("Maximum Jewelers", categories[1], 1, 0, Integer.MAX_VALUE, "Sets how many jewelers can be in a village."); - JEWELER_WEIGHT = config.getInt("Jewelers Weight", categories[1], 30, 0, Integer.MAX_VALUE, "Chance of getting a jeweler in a village. The higher the value, the higher the chance."); - INGOT_CHEST_MIN = config.getInt("Ingot Chest Min", categories[1], 1, 0, Integer.MAX_VALUE, "Minimum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)"); - INGOT_CHEST_MAX = config.getInt("Ingot Chest Max", categories[1], 4, 0, Integer.MAX_VALUE, "Maximum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)"); - INGOT_CHEST_MAX_STACK = config.getInt("Ingot Chest Max Stack", categories[1], 2, 0, Integer.MAX_VALUE, "Maximum number of the stack the ingots can be. For example: if set to 2 and ingots have a chance of generating, you have a chance of getting a stack of max 2 ingots in a chest."); - GEM_CHEST_MIN = config.getInt("Jewelers Chest Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler."); - GEM_CHEST_MAX = config.getInt("Jewelers Chest Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler."); - FURNACE_MIN_INGOT_STACK = config.getInt("Ingot Furnace Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum number of ingots that can generate in a furnace."); - FURNACE_MAX_INGOT_STACK = config.getInt("Ingot Furnace Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum number of ingots that can generate in a furnace."); - - CRYSTAL_GLOW = config.getBoolean("Crystal Glow", categories[2], false, "If true, then crystal will slowly glow (can cause lag)"); - -// CURSES_ENABLED = config.getBoolean("Curses", categories[3], true, "If set to false curses will be deactivated."); -// CURSE_ROTTEN_HEART = config.getBoolean("Rotten Heart", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_FLAMING_SOUL = config.getBoolean("Flaming Soul", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_GREED = config.getBoolean("Greed", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_BLIND = config.getBoolean("Blind", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_INFAMY = config.getBoolean("Infamy", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_MIDAS_TOUCH = config.getBoolean("Midas Touch", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_RABBIT_PAW = config.getBoolean("Rabbit's Paw", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_PENTAGRAM = config.getBoolean("Pentagram", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_VAMPIRE_HUNGER = config.getBoolean("Vampire Hunger", categories[3], true, "If set to false this curse will be deactivated."); -// CURSE_HUMBLE_BUNDLE = config.getBoolean("Humble Bundle", categories[3], true, "If set to false this curse will be deactivated."); - if (config.hasChanged()) config.save(); - } - - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) - { - if (event.modID.equals(Variables.MODID)) syncConfigs(); - } -} +package darkknight.jewelrycraft.config;
+
+import java.io.File;
+import net.minecraftforge.common.config.Configuration;
+import cpw.mods.fml.client.event.ConfigChangedEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import darkknight.jewelrycraft.util.Variables;
+
+public class ConfigHandler
+{
+ public static Configuration config;
+ public static final ConfigHandler INSTANCE = new ConfigHandler();
+ public static final String[] categories = {"Timers", "Village Generation", "Misc"};
+
+ public static int INGOT_COOLING_TIME;
+ public static int INGOT_MELTING_TIME;
+ public static int GEM_PLACEMENT_TIME;
+ public static int RITUAL_TIME;
+ public static int HEART_DESPAWN_TIME;
+
+ public static boolean GENERATE_VILLAGE_NETHERSTAR;
+ public static boolean CAN_FURNACE_GENERATE_INGOTS;
+ public static boolean CRYSTAL_GLOW;
+ public static int MAX_VILLAGE_JEWELERS;
+ public static int JEWELER_WEIGHT;
+ public static int INGOT_CHEST_MIN;
+ public static int INGOT_CHEST_MAX;
+ public static int INGOT_CHEST_MAX_STACK;
+ public static int GEM_CHEST_MIN;
+ public static int GEM_CHEST_MAX;
+ public static int FURNACE_MIN_INGOT_STACK;
+ public static int FURNACE_MAX_INGOT_STACK;
+
+ public static boolean CURSES_ENABLED = true;
+ public static boolean CURSE_ROTTEN_HEART = true;
+ public static boolean CURSE_FLAMING_SOUL = true;
+ public static boolean CURSE_GREED = true;
+ public static boolean CURSE_BLIND = true;
+ public static boolean CURSE_INFAMY = true;
+ public static boolean CURSE_MIDAS_TOUCH = true;
+ public static boolean CURSE_RABBIT_PAW = true;
+ public static boolean CURSE_PENTAGRAM = true;
+ public static boolean CURSE_VAMPIRE_HUNGER = true;
+ public static boolean CURSE_HUMBLE_BUNDLE = true;
+
+ public void loadConfig(FMLPreInitializationEvent event)
+ {
+ config = new Configuration(event.getSuggestedConfigurationFile(),true);
+ config.load();
+ syncConfigs();
+ }
+
+ private void syncConfigs()
+ {
+ INGOT_COOLING_TIME = config.getInt("Molder Ingot Cooling Time", categories[0], 100, 5, Integer.MAX_VALUE, "This sets the number of ticks you need to wait before the mold is cooled.");
+ INGOT_MELTING_TIME = config.getInt("Ingot Melting Time", categories[0], 1500, 5, Integer.MAX_VALUE, "This sets the number of ticks you need to wait before an ingot is completely smelted.");
+ GEM_PLACEMENT_TIME = config.getInt( "Jewelry Crafting Time", categories[0], 200, 5, Integer.MAX_VALUE, "This sets the number of ticks it takes for a jewel to be modified.");
+ RITUAL_TIME = config.getInt( "Ritual Time", categories[0], 1000, 5, Integer.MAX_VALUE, "This sets the number of ticks it takes for the ritual to end.");
+ HEART_DESPAWN_TIME = config.getInt( "Hearts Despawn Time", categories[0], 600, 20, Integer.MAX_VALUE, "This sets the number of ticks it takes for hearts to despawn, 20=1 second");
+
+ GENERATE_VILLAGE_NETHERSTAR = config.getBoolean("Netherstar Generation", categories[1], false, "If set to true Nether Stars will be able to generate in Jewelers chests.");
+ CAN_FURNACE_GENERATE_INGOTS = config.getBoolean("Furnace Ingots Generation", categories[1], true, "If set to true jewelers will generate ingots in furnaces.");
+
+ MAX_VILLAGE_JEWELERS = config.getInt("Maximum Jewelers", categories[1], 1, 0, Integer.MAX_VALUE, "Sets how many jewelers can be in a village.");
+ JEWELER_WEIGHT = config.getInt("Jewelers Weight", categories[1], 30, 0, Integer.MAX_VALUE, "Chance of getting a jeweler in a village. The higher the value, the higher the chance.");
+ INGOT_CHEST_MIN = config.getInt("Ingot Chest Min", categories[1], 1, 0, Integer.MAX_VALUE, "Minimum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)");
+ INGOT_CHEST_MAX = config.getInt("Ingot Chest Max", categories[1], 4, 0, Integer.MAX_VALUE, "Maximum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)");
+ INGOT_CHEST_MAX_STACK = config.getInt("Ingot Chest Max Stack", categories[1], 2, 0, Integer.MAX_VALUE, "Maximum number of the stack the ingots can be. For example: if set to 2 and ingots have a chance of generating, you have a chance of getting a stack of max 2 ingots in a chest.");
+ GEM_CHEST_MIN = config.getInt("Jewelers Chest Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler.");
+ GEM_CHEST_MAX = config.getInt("Jewelers Chest Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler.");
+ FURNACE_MIN_INGOT_STACK = config.getInt("Ingot Furnace Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum number of ingots that can generate in a furnace.");
+ FURNACE_MAX_INGOT_STACK = config.getInt("Ingot Furnace Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum number of ingots that can generate in a furnace.");
+
+ CRYSTAL_GLOW = config.getBoolean("Crystal Glow", categories[2], false, "If true, then crystal will slowly glow (can cause lag)");
+
+// CURSES_ENABLED = config.getBoolean("Curses", categories[3], true, "If set to false curses will be deactivated.");
+// CURSE_ROTTEN_HEART = config.getBoolean("Rotten Heart", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_FLAMING_SOUL = config.getBoolean("Flaming Soul", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_GREED = config.getBoolean("Greed", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_BLIND = config.getBoolean("Blind", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_INFAMY = config.getBoolean("Infamy", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_MIDAS_TOUCH = config.getBoolean("Midas Touch", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_RABBIT_PAW = config.getBoolean("Rabbit's Paw", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_PENTAGRAM = config.getBoolean("Pentagram", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_VAMPIRE_HUNGER = config.getBoolean("Vampire Hunger", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_HUMBLE_BUNDLE = config.getBoolean("Humble Bundle", categories[3], true, "If set to false this curse will be deactivated.");
+ if (config.hasChanged()) config.save();
+ }
+
+ @SubscribeEvent
+ public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
+ {
+ if (event.modID.equals(Variables.MODID)) syncConfigs();
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java index 831f3ca..952b3ba 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java @@ -1,16 +1,34 @@ package darkknight.jewelrycraft.entities;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.item.ItemSpawnEgg;
import darkknight.jewelrycraft.util.Variables;
public class EntityList
{
public static void preInit(FMLPreInitializationEvent e)
{
- EntityRegistry.registerModEntity(EntityHeart.class, "Heart", 1, JewelrycraftMod.instance, 40, 3, false);
- EntityRegistry.registerModEntity(EntityHalfHeart.class, "HalfHeart", 2, JewelrycraftMod.instance, 40, 3, false);
+ registerEntity(1, EntityHeart.class, "Heart", 0x000000, 0xFF0000); //Red
+ ItemSpawnEgg.registerSpawnEgg(EntityHeart.class, "Heart", 2, 0x000000, 0xFFFFFF); // White
+ ItemSpawnEgg.registerSpawnEgg(EntityHeart.class, "Heart", 3, 0x000000, 0x006BBD); // Blue
+ ItemSpawnEgg.registerSpawnEgg(EntityHeart.class, "Heart", 4, 0x000000, 0x404040); // Black
+
+ registerEntity(5, EntityHalfHeart.class, "HalfHeart", 0x000000, 0xFF0000); // Red
+ ItemSpawnEgg.registerSpawnEgg(EntityHalfHeart.class, "HalfHeart", 6, 0x000000, 0xFFFFFF); // White
+ ItemSpawnEgg.registerSpawnEgg(EntityHalfHeart.class, "HalfHeart", 7, 0x000000, 0x006BBD); // Blue
+ ItemSpawnEgg.registerSpawnEgg(EntityHalfHeart.class, "HalfHeart", 8, 0x000000, 0x404040); // Black
+
}
+ private static final void registerEntity(int id, Class<? extends Entity> entityClass, String name) {
+ EntityRegistry.registerModEntity(entityClass, name, id, JewelrycraftMod.instance, 256, 1, true);
+ }
+
+ private static final void registerEntity(int id, Class<? extends EntityLiving> entityClass, String name, int eggBackgroundColor, int eggForegroundColor) {
+ registerEntity(id, entityClass, name);
+ ItemSpawnEgg.registerSpawnEgg(entityClass, name, id, eggBackgroundColor, eggForegroundColor);
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java index 786a8ae..c27ba9d 100644 --- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -8,9 +8,11 @@ import java.io.IOException; import java.util.Iterator;
import java.util.List;
import java.util.Random;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -57,433 +59,423 @@ import darkknight.jewelrycraft.util.Variables; /**
* Code taken from OpenBlocks
*/
-public class EntityEventHandler
-{
- int updateTime = 0, totalUnavailableCurses = 0;
- boolean addedCurses = false;
- Random rand = new Random();
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onEntityJoinWorld(EntityJoinWorldEvent event)
- {
- if (event.entity instanceof EntityPlayerMP) JewelrycraftMod.netWrapper.sendTo(new PacketClearColorCache(), (EntityPlayerMP)event.entity);
- if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- final Entity entity = event.entity;
- if (!event.world.isRemote && entity instanceof EntityPlayer){
- EntityPlayer player = (EntityPlayer)entity;
- NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- boolean shouldGiveManual = ItemList.guide != null && !persistTag.getBoolean("givenGuide");
- if (shouldGiveManual){
- ItemStack manual = new ItemStack(ItemList.guide);
- if (!player.inventory.addItemStackToInventory(manual)) BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual);
- persistTag.setBoolean("givenGuide", true);
- }
- boolean render = persistTag.getBoolean("fancyRender");
- JewelrycraftMod.fancyRender = render;
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(event.world) && !persistTag.hasKey(curse.getName())) persistTag.setInteger(curse.getName(), 0);
- for(Curse curse: Curse.getCurseList())
- if (!curse.canCurseBeActivated(event.world)){
- Curse.availableCurses.remove(curse);
- persistTag.setInteger(curse.getName(), 0);
- totalUnavailableCurses++;
- }else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse);
- persistTag.setBoolean("sendInfo", true);
- }
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onEntityUpdate(LivingUpdateEvent event)
- {
- Entity entity = event.entity;
- EntityLivingBase entityLiving = event.entityLiving;
- if (entityLiving.isPotionActive(PotionList.stun)){
- entityLiving.motionX *= 0D;
- entityLiving.motionZ *= 0D;
- entityLiving.motionY *= 0D;
- entityLiving.isSwingInProgress = false;
- entityLiving.moveForward = 0F;
- entityLiving.moveStrafing = 0F;
- entityLiving.setAIMoveSpeed(0F);
- entityLiving.limbSwing = 0F;
- entityLiving.limbSwingAmount = 0F;
- entityLiving.swingProgressInt = 0;
- entityLiving.rotationPitch = entity.prevRotationPitch;
- entityLiving.rotationYaw = entity.prevRotationYaw;
- entityLiving.worldObj.spawnParticle("spell", entityLiving.posX, entityLiving.posY + entityLiving.getEyeHeight(), entityLiving.posZ, 0.0D, 0.3D, 0.0D);
- }
- if (entityLiving.isPotionActive(PotionList.stun) && entityLiving.getActivePotionEffect(PotionList.stun).getDuration() == 0) entityLiving.removePotionEffect(PotionList.stun.id);
- if (entity instanceof EntityPlayer){
- EntityPlayer player = (EntityPlayer)entity;
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- playerInfo.setBoolean("fancyRender", JewelrycraftMod.fancyRender);
- if (updateTime > 0) updateTime--;
- for(int i = 0; i < 18; i++)
- if (playerInfo.hasKey("ext" + i)){
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (item != null){
- if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).action(item, player);
- if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onWearAction(item, player);
- }
- }
- if (!player.worldObj.isRemote){
- if (playerInfo.hasKey("reselectCurses") && !playerInfo.getBoolean("reselectCurses")){
- playerInfo.setInteger("curseTime", playerInfo.getInteger("curseTime") - 10000);
- if (playerInfo.getInteger("curseTime") <= 0) playerInfo.setBoolean("reselectCurses", true);
- }
- if (playerInfo.hasKey("playerCursePointsChanged") && playerInfo.getBoolean("playerCursePointsChanged")){
- int points = playerInfo.getInteger("cursePoints");
- for(int i = 1; i <= Variables.MAX_CURSES; i++)
- if (points > (i - 1) * 1750) addCurse(player, playerInfo, i);
- if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")){
- playerInfo.setInteger("curseTime", 23000);
- playerInfo.setBoolean("reselectCurses", false);
- }
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- if (addedCurses){
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
- // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0);
- addedCurses = false;
- }
- }
- if (playerInfo.getBoolean("playerCursePointsChanged")) playerInfo.setBoolean("playerCursePointsChanged", false);
- if (updateTime == 0){
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
- updateTime = 200;
- }
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.action(player.worldObj, player);
- }
- }
- }
-
- @SubscribeEvent
- public void onEntityLivingDropItems(LivingDropsEvent event)
- {
- if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){
- EntityPlayer player = (EntityPlayer)event.source.getEntity();
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDropItems(player, event.entityLiving, event.drops);
- }
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onEntityAttacked(LivingAttackEvent event)
- {
- EntityLivingBase entity = event.entityLiving;
- if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase && ((EntityLivingBase)event.source.getEntity()).isPotionActive(PotionList.stun)) event.setCanceled(true);
- if (entity instanceof EntityPlayer && !(event.source.getEntity() instanceof EntityPlayer)){
- EntityPlayer player = (EntityPlayer)entity;
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (!player.worldObj.isRemote) for(int i = 0; i < 18; i++)
- if (playerInfo.hasKey("ext" + i)){
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry)item.getItem()).onPlayerAttackedCacellable(item, player, event.source, event.ammount)){
- event.setCanceled(true);
- break;
- }
- if (playerInfo.getBoolean("negateDamage")){
- playerInfo.setBoolean("negateDamage", false);
- event.setCanceled(true);
- break;
- }
- if (item != null){
- if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount);
- if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerAttackedAction(item, player, event.source, event.ammount);
- }
- }
- if (player.getHealth() != player.prevHealth){
- if (playerInfo.getFloat("WhiteHeart") > 0){
- playerInfo.setFloat("WhiteHeart", 0f);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- }
- if (playerInfo.getFloat("BlueHeart") > 0){
- float damage = playerInfo.getFloat("BlueHeart") - event.ammount;
- if (damage >= 0){
- playerInfo.setFloat("BlueHeart", damage);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- player.heal(event.ammount);
- }else{
- playerInfo.setFloat("BlueHeart", 0f);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- player.heal(Math.abs(damage));
- }
- }else if (playerInfo.getFloat("BlackHeart") > 0){
- AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 0.0D, 2.0D);
- List enemies = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, axisalignedbb);
- if (enemies != null && !enemies.isEmpty()){
- Iterator iterator = enemies.iterator();
- while (iterator.hasNext()){
- Entity enemy = (Entity)iterator.next();
- enemy.attackEntityFrom(DamageSourceList.blackHeart, 5f * event.ammount);
- }
- }
- float damage = playerInfo.getFloat("BlackHeart") - event.ammount;
- if (damage >= 0){
- playerInfo.setFloat("BlackHeart", damage);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- player.heal(event.ammount);
- }else{
- playerInfo.setFloat("BlackHeart", 0f);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- player.heal(Math.abs(damage));
- }
- }
- }
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player);
- }else if (event.source.getEntity() instanceof EntityPlayer){
- EntityPlayer player = (EntityPlayer)event.source.getEntity();
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- for(int i = 0; i < 18; i++)
- if (playerInfo.hasKey("ext" + i)){
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry)item.getItem()).onEntityAttackedCacellable(item, player, entity, event.ammount)){
- event.setCanceled(true);
- break;
- }
- if (playerInfo.getBoolean("weakDamage")){
- playerInfo.setBoolean("weakDamage", false);
- event.setCanceled(true);
- break;
- }
- if (item != null){
- if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onEntityAttacked(item, player, entity, event.ammount);
- if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onEntityAttackedByPlayer(item, player, entity, event.ammount);
- }
- }
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedByPlayerAction(entity.worldObj, player, entity);
- }
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onPlayerRespawn(PlayerEvent.Clone event)
- {
- EntityPlayer player = event.entityPlayer;
- if (!player.worldObj.isRemote){
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (playerInfo.hasKey("cursePoints")){
- int points = playerInfo.getInteger("cursePoints");
- for(int i = 1; i <= Variables.MAX_CURSES; i++)
- if (points > (i - 1) * 1750) addCurse(player, playerInfo, i);
- if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")){
- playerInfo.setInteger("curseTime", 23000);
- playerInfo.setBoolean("reselectCurses", false);
- }
- }
- playerInfo.setFloat("BlueHeart", 0f);
- playerInfo.setFloat("BlackHeart", 0f);
- playerInfo.setFloat("WhiteHeart", 0f);
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.respawnAction(player.worldObj, player);
- for(int i = 0; i < 18; i++)
- if (playerInfo.hasKey("ext" + i)){
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (item != null){
- if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerRespawn(item, event);
- if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerRespawnAction(item, event);
- }
- }
- }
- if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- if (!player.worldObj.isRemote){
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- if (addedCurses){
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
- // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0);
- addedCurses = false;
- }
- }
- }
-
- /**
- * @param player
- * @param playerInfo
- * @param curse
- */
- public void addCurse(EntityPlayer player, NBTTagCompound playerInfo, int curseNo)
- {
- if (ConfigHandler.CURSES_ENABLED && Curse.availableCurses.size() > 0 && curseNo > Curse.getCurseList().size() - Curse.availableCurses.size() - totalUnavailableCurses){
- Curse cur = ((WeightedRandomCurse)WeightedRandom.getRandomItem(rand, JewelrycraftUtil.getCurses(player.worldObj, player, rand))).getCurse(rand);
- playerInfo.setInteger(cur.getName(), 1);
- Curse.availableCurses.remove(cur);
- addedCurses = true;
- }
- }
-
- @SubscribeEvent
- public void itemToss(ItemTossEvent event)
- {
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(event.player, Variables.MODID);
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(event.player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && curse.itemToss()){
- EntityItem entityitem = new EntityItem(event.player.worldObj, event.player.posX + 0.5D, event.player.posY + 0.5D, event.player.posZ + 0.5D, event.entityItem.getEntityItem());
- entityitem.motionX = 0;
- entityitem.motionZ = 0;
- entityitem.motionY = 0.11000000298023224D;
- event.player.worldObj.spawnEntityInWorld(entityitem);
- MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText("<" + event.player.getDisplayName() + "> This is MY item! MINE! I will NEVER give it to you! Mine! Mine! MINE!"));
- event.setCanceled(true);
- }
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void playerFileSave(PlayerEvent.SaveToFile event)
- {
- if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onEntityDead(LivingDeathEvent event)
- {
- final Entity entity = event.entity;
- Random rand = new Random();
- String[] types = {"Red", "Blue", "White", "Black"};
- if (!entity.worldObj.isRemote && !(entity instanceof EntityPlayer) && entity instanceof EntityLiving){
- EntityLiving live = (EntityLiving)entity;
- String type = types[rand.nextInt(4)];
- if (rand.nextInt(6) == 0 && live.getCreatureAttribute() != JewelrycraftUtil.HEART){
- if (type == "White"){
- EntityHeart h = new EntityHalfHeart(live.worldObj);
- h.setType(type);
- h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F);
- live.worldObj.spawnEntityInWorld(h);
- }else{
- for(int i = 1; i <= 1 + rand.nextInt(1 + (int)(live.getMaxHealth() / 20)); i++){
- EntityHeart[] hearts = {new EntityHeart(live.worldObj), new EntityHalfHeart(entity.worldObj)};
- EntityHeart h = hearts[rand.nextInt(2)];
- h.setType(type);
- h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F);
- live.worldObj.spawnEntityInWorld(h);
- }
- }
- }
- if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){
- EntityPlayer player = (EntityPlayer)event.source.getEntity();
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDeathAction(player.worldObj, event.entityLiving, player);
- }
- }
- if (entity instanceof EntityPlayer){
- EntityPlayer player = (EntityPlayer)entity;
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- playerInfo.setFloat("BlueHeart", 0f);
- playerInfo.setFloat("BlackHeart", 0f);
- playerInfo.setFloat("WhiteHeart", 0f);
- if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")){
- if (ConfigHandler.CURSES_ENABLED) for(Curse l: Curse.getCurseList()){
- if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) == 1){
- playerInfo.setInteger(l.getName(), 0);
- if (!Curse.availableCurses.contains(l)) Curse.availableCurses.add(l);
- }else if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) >= 2) playerInfo.setInteger(l.getName(), 1);
- }
- if (entity.worldObj.isRemote) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- }
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.playerDeathAction(player.worldObj, player);
- for(int i = 0; i < 18; i++)
- if (playerInfo.hasKey("ext" + i)){
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (item != null){
- if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerDead(item, player, event.source);
- if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerDeadAction(item, player, event.source);
- }
- }
- }
- if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onWorldLoad(WorldEvent.Load event)
- {
- if (!event.world.isRemote){
- new File(JewelrycraftMod.dir + File.separator + Variables.MODID).mkdirs();
- JewelrycraftMod.liquidsConf = new File(JewelrycraftMod.dir + File.separator + Variables.MODID, "JLP" + event.world.getWorldInfo().getWorldName() + ".cfg");
- try{
- if (!JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.liquidsConf.createNewFile();
- }
- catch(IOException e){
- e.printStackTrace();
- }
- }
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try{
- if (JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.saveData = CompressedStreamTools.readCompressed(new FileInputStream(JewelrycraftMod.liquidsConf));
- }
- catch(EOFException e){
- e.printStackTrace();
- }
- catch(IOException e){
- e.printStackTrace();
- }
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- public void onWorldSave(WorldEvent.Save event)
- {
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try{
- if (JewelrycraftMod.liquidsConf.exists()) CompressedStreamTools.writeCompressed(JewelrycraftMod.saveData, new FileOutputStream(JewelrycraftMod.liquidsConf));
- }
- catch(EOFException e){
- e.printStackTrace();
- }
- catch(IOException e){
- e.printStackTrace();
- }
- }
-
- /**
- * @param event
- */
- @SubscribeEvent
- @SideOnly (Side.CLIENT)
- public void fogColors(EntityViewRenderEvent.FogColors event)
- {}
-
- /**
- * @param event
- */
- @SubscribeEvent
- @SideOnly (Side.CLIENT)
- public void fogDensity(EntityViewRenderEvent.FogDensity event)
- {}
-
- /**
- * @param event
- */
- @SubscribeEvent
- @SideOnly (Side.CLIENT)
- public void renderFog(EntityViewRenderEvent.RenderFogEvent event)
- {}
+public class EntityEventHandler {
+ int updateTime = 0, totalUnavailableCurses = 0;
+ boolean addedCurses = false;
+ Random rand = new Random();
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onEntityJoinWorld(EntityJoinWorldEvent event) {
+ if (event.entity instanceof EntityPlayerMP) JewelrycraftMod.netWrapper.sendTo(new PacketClearColorCache(), (EntityPlayerMP) event.entity);
+ if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ final Entity entity = event.entity;
+ if (!event.world.isRemote && entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) entity;
+ NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ boolean shouldGiveManual = ItemList.guide != null && !persistTag.getBoolean("givenGuide");
+ if (shouldGiveManual) {
+ ItemStack manual = new ItemStack(ItemList.guide);
+ if (!player.inventory.addItemStackToInventory(manual)) BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual);
+ persistTag.setBoolean("givenGuide", true);
+ }
+ boolean render = persistTag.getBoolean("fancyRender");
+ JewelrycraftMod.fancyRender = render;
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(event.world) && !persistTag.hasKey(curse.getName())) persistTag.setInteger(curse.getName(), 0);
+ for (Curse curse : Curse.getCurseList())
+ if (!curse.canCurseBeActivated(event.world)) {
+ Curse.availableCurses.remove(curse);
+ persistTag.setInteger(curse.getName(), 0);
+ totalUnavailableCurses++;
+ } else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse);
+ persistTag.setBoolean("sendInfo", true);
+ }
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onEntityUpdate(LivingUpdateEvent event) {
+ Entity entity = event.entity;
+ EntityLivingBase entityLiving = event.entityLiving;
+ if (entityLiving.isPotionActive(PotionList.stun)) {
+ entityLiving.motionX *= 0D;
+ entityLiving.motionZ *= 0D;
+ entityLiving.motionY *= 0D;
+ entityLiving.isSwingInProgress = false;
+ entityLiving.moveForward = 0F;
+ entityLiving.moveStrafing = 0F;
+ entityLiving.setAIMoveSpeed(0F);
+ entityLiving.limbSwing = 0F;
+ entityLiving.limbSwingAmount = 0F;
+ entityLiving.swingProgressInt = 0;
+ entityLiving.rotationPitch = entity.prevRotationPitch;
+ entityLiving.rotationYaw = entity.prevRotationYaw;
+ entityLiving.worldObj.spawnParticle("spell", entityLiving.posX, entityLiving.posY + entityLiving.getEyeHeight(), entityLiving.posZ, 0.0D, 0.3D, 0.0D);
+ }
+ if (entityLiving.isPotionActive(PotionList.stun) && entityLiving.getActivePotionEffect(PotionList.stun).getDuration() == 0) entityLiving.removePotionEffect(PotionList.stun.id);
+ if (entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) entity;
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ playerInfo.setBoolean("fancyRender", JewelrycraftMod.fancyRender);
+ if (updateTime > 0) updateTime--;
+ for (int i = 0; i < 18; i++)
+ if (playerInfo.hasKey("ext" + i)) {
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (item != null) {
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry) item.getItem()).action(item, player);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem) item.getItem()).onWearAction(item, player);
+ }
+ }
+ if (!player.worldObj.isRemote) {
+ if (playerInfo.hasKey("reselectCurses") && !playerInfo.getBoolean("reselectCurses")) {
+ playerInfo.setInteger("curseTime", playerInfo.getInteger("curseTime") - 10000);
+ if (playerInfo.getInteger("curseTime") <= 0) playerInfo.setBoolean("reselectCurses", true);
+ }
+ if (playerInfo.hasKey("playerCursePointsChanged") && playerInfo.getBoolean("playerCursePointsChanged")) {
+ int points = playerInfo.getInteger("cursePoints");
+ for (int i = 1; i <= Variables.MAX_CURSES; i++)
+ if (points > (i - 1) * 1750) addCurse(player, playerInfo, i);
+ if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")) {
+ playerInfo.setInteger("curseTime", 23000);
+ playerInfo.setBoolean("reselectCurses", false);
+ }
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ if (addedCurses) {
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ // player.openGui(JewelrycraftMod.instance, 4,
+ // player.worldObj, 0, 0, 0);
+ addedCurses = false;
+ }
+ }
+ if (playerInfo.getBoolean("playerCursePointsChanged")) playerInfo.setBoolean("playerCursePointsChanged", false);
+ if (updateTime == 0) {
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ updateTime = 200;
+ }
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.action(player.worldObj, player);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onEntityLivingDropItems(LivingDropsEvent event) {
+ if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.source.getEntity();
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDropItems(player, event.entityLiving, event.drops);
+ }
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onEntityAttacked(LivingAttackEvent event) {
+ EntityLivingBase entity = event.entityLiving;
+ if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase && ((EntityLivingBase) event.source.getEntity()).isPotionActive(PotionList.stun)) event.setCanceled(true);
+ if (entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) entity;
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (!(event.source.getEntity() instanceof EntityPlayer)) {
+ if (!player.worldObj.isRemote) for (int i = 0; i < 18; i++)
+ if (playerInfo.hasKey("ext" + i)) {
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry) item.getItem()).onPlayerAttackedCacellable(item, player, event.source, event.ammount)) {
+ event.setCanceled(true);
+ break;
+ }
+ if (playerInfo.getBoolean("negateDamage")) {
+ playerInfo.setBoolean("negateDamage", false);
+ event.setCanceled(true);
+ break;
+ }
+ if (item != null) {
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry) item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem) item.getItem()).onPlayerAttackedAction(item, player, event.source, event.ammount);
+ }
+ }
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player);
+
+ }
+ if (!player.worldObj.isRemote && (float) player.hurtResistantTime <= (float) player.maxHurtResistantTime / 2.0F) {
+ if (playerInfo.getFloat("WhiteHeart") > 0) {
+ playerInfo.setFloat("WhiteHeart", 0f);
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ }
+ if (playerInfo.getFloat("BlueHeart") > 0) {
+ float damage = playerInfo.getFloat("BlueHeart") - event.ammount;
+ if (damage >= 0) playerInfo.setFloat("BlueHeart", damage);
+ else playerInfo.setFloat("BlueHeart", 0f);
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ if(damage < 0){
+ System.out.println(damage);
+ player.attackEntityFrom(event.source, Math.abs(damage));
+ }
+ player.hurtResistantTime = player.maxHurtResistantTime;
+ player.hurtTime = player.maxHurtTime = 10;
+ player.worldObj.playSoundAtEntity(player, "game.player.hurt", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
+ event.setCanceled(true);
+ } else if (playerInfo.getFloat("BlackHeart") > 0) {
+ AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 0.0D, 2.0D);
+ List enemies = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, axisalignedbb);
+ if (enemies != null && !enemies.isEmpty()) {
+ Iterator iterator = enemies.iterator();
+ while (iterator.hasNext()) {
+ Entity enemy = (Entity) iterator.next();
+ enemy.attackEntityFrom(DamageSourceList.blackHeart, 5f * event.ammount);
+ }
+ }
+ float damage = playerInfo.getFloat("BlackHeart") - event.ammount;
+ if (damage >= 0) playerInfo.setFloat("BlackHeart", damage);
+ else playerInfo.setFloat("BlackHeart", 0f);
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ if(damage < 0) player.attackEntityFrom(event.source, Math.abs(damage));
+ player.hurtResistantTime = player.maxHurtResistantTime;
+ player.hurtTime = player.maxHurtTime = 10;
+ player.worldObj.playSoundAtEntity(player, "game.player.hurt", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
+ event.setCanceled(true);
+ }
+ }
+ }
+ if (event.source.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.source.getEntity();
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ for (int i = 0; i < 18; i++)
+ if (playerInfo.hasKey("ext" + i)) {
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry) item.getItem()).onEntityAttackedCacellable(item, player, entity, event.ammount)) {
+ event.setCanceled(true);
+ break;
+ }
+ if (playerInfo.getBoolean("weakDamage")) {
+ playerInfo.setBoolean("weakDamage", false);
+ event.setCanceled(true);
+ break;
+ }
+ if (item != null) {
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry) item.getItem()).onEntityAttacked(item, player, entity, event.ammount);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem) item.getItem()).onEntityAttackedByPlayer(item, player, entity, event.ammount);
+ }
+ }
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedByPlayerAction(entity.worldObj, player, entity);
+ }
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onPlayerRespawn(PlayerEvent.Clone event) {
+ EntityPlayer player = event.entityPlayer;
+ if (!player.worldObj.isRemote) {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (playerInfo.hasKey("cursePoints")) {
+ int points = playerInfo.getInteger("cursePoints");
+ for (int i = 1; i <= Variables.MAX_CURSES; i++)
+ if (points > (i - 1) * 1750) addCurse(player, playerInfo, i);
+ if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")) {
+ playerInfo.setInteger("curseTime", 23000);
+ playerInfo.setBoolean("reselectCurses", false);
+ }
+ }
+ playerInfo.setFloat("BlueHeart", 0f);
+ playerInfo.setFloat("BlackHeart", 0f);
+ playerInfo.setFloat("WhiteHeart", 0f);
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.respawnAction(player.worldObj, player);
+ for (int i = 0; i < 18; i++)
+ if (playerInfo.hasKey("ext" + i)) {
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (item != null) {
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry) item.getItem()).onPlayerRespawn(item, event);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem) item.getItem()).onPlayerRespawnAction(item, event);
+ }
+ }
+ }
+ if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ if (!player.worldObj.isRemote) {
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ if (addedCurses) {
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ // player.openGui(JewelrycraftMod.instance, 4, player.worldObj,
+ // 0, 0, 0);
+ addedCurses = false;
+ }
+ }
+ }
+
+ /**
+ * @param player
+ * @param playerInfo
+ * @param curse
+ */
+ public void addCurse(EntityPlayer player, NBTTagCompound playerInfo, int curseNo) {
+ if (ConfigHandler.CURSES_ENABLED && Curse.availableCurses.size() > 0 && curseNo > Curse.getCurseList().size() - Curse.availableCurses.size() - totalUnavailableCurses) {
+ Curse cur = ((WeightedRandomCurse) WeightedRandom.getRandomItem(rand, JewelrycraftUtil.getCurses(player.worldObj, player, rand))).getCurse(rand);
+ playerInfo.setInteger(cur.getName(), 1);
+ Curse.availableCurses.remove(cur);
+ addedCurses = true;
+ }
+ }
+
+ @SubscribeEvent
+ public void itemToss(ItemTossEvent event) {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(event.player, Variables.MODID);
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(event.player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && curse.itemToss()) {
+ EntityItem entityitem = new EntityItem(event.player.worldObj, event.player.posX + 0.5D, event.player.posY + 0.5D, event.player.posZ + 0.5D, event.entityItem.getEntityItem());
+ entityitem.motionX = 0;
+ entityitem.motionZ = 0;
+ entityitem.motionY = 0.11000000298023224D;
+ event.player.worldObj.spawnEntityInWorld(entityitem);
+ MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText("<" + event.player.getDisplayName() + "> This is MY item! MINE! I will NEVER give it to you! Mine! Mine! MINE!"));
+ event.setCanceled(true);
+ }
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void playerFileSave(PlayerEvent.SaveToFile event) {
+ if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onEntityDead(LivingDeathEvent event) {
+ final Entity entity = event.entity;
+ Random rand = new Random();
+ String[] types = { "Red", "Blue", "White", "Black" };
+ if (!entity.worldObj.isRemote && !(entity instanceof EntityPlayer) && entity instanceof EntityLiving) {
+ EntityLiving live = (EntityLiving) entity;
+ String type = types[rand.nextInt(4)];
+ if (live.getCreatureAttribute() != JewelrycraftUtil.HEART) {
+ if (type == "White") {
+ EntityHeart h = new EntityHalfHeart(live.worldObj);
+ h.setType(type);
+ h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F);
+ live.worldObj.spawnEntityInWorld(h);
+ } else {
+ for (int i = 1; i <= 1 + rand.nextInt(1 + (int) (live.getMaxHealth() / 2)); i++) {
+ EntityHeart[] hearts = { new EntityHeart(live.worldObj), new EntityHalfHeart(entity.worldObj) };
+ EntityHeart h = hearts[rand.nextInt(2)];
+ h.setType(type);
+ h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F);
+ live.worldObj.spawnEntityInWorld(h);
+ }
+ }
+ }
+ if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.source.getEntity();
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDeathAction(player.worldObj, event.entityLiving, player);
+ }
+ }
+ if (entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) entity;
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ playerInfo.setFloat("BlueHeart", 0f);
+ playerInfo.setFloat("BlackHeart", 0f);
+ playerInfo.setFloat("WhiteHeart", 0f);
+ if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")) {
+ if (ConfigHandler.CURSES_ENABLED) for (Curse l : Curse.getCurseList()) {
+ if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) == 1) {
+ playerInfo.setInteger(l.getName(), 0);
+ if (!Curse.availableCurses.contains(l)) Curse.availableCurses.add(l);
+ } else if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) >= 2) playerInfo.setInteger(l.getName(), 1);
+ }
+ if (entity.worldObj.isRemote) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ }
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.playerDeathAction(player.worldObj, player);
+ for (int i = 0; i < 18; i++)
+ if (playerInfo.hasKey("ext" + i)) {
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (item != null) {
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry) item.getItem()).onPlayerDead(item, player, event.source);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem) item.getItem()).onPlayerDeadAction(item, player, event.source);
+ }
+ }
+ }
+ if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Load event) {
+ if (!event.world.isRemote) {
+ new File(JewelrycraftMod.dir + File.separator + Variables.MODID).mkdirs();
+ JewelrycraftMod.liquidsConf = new File(JewelrycraftMod.dir + File.separator + Variables.MODID, "JLP" + event.world.getWorldInfo().getWorldName() + ".cfg");
+ try {
+ if (!JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.liquidsConf.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try {
+ if (JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.saveData = CompressedStreamTools.readCompressed(new FileInputStream(JewelrycraftMod.liquidsConf));
+ } catch (EOFException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ public void onWorldSave(WorldEvent.Save event) {
+ if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try {
+ if (JewelrycraftMod.liquidsConf.exists()) CompressedStreamTools.writeCompressed(JewelrycraftMod.saveData, new FileOutputStream(JewelrycraftMod.liquidsConf));
+ } catch (EOFException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ @SideOnly(Side.CLIENT)
+ public void fogColors(EntityViewRenderEvent.FogColors event) {
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ @SideOnly(Side.CLIENT)
+ public void fogDensity(EntityViewRenderEvent.FogDensity event) {
+ }
+
+ /**
+ * @param event
+ */
+ @SubscribeEvent
+ @SideOnly(Side.CLIENT)
+ public void renderFog(EntityViewRenderEvent.RenderFogEvent event) {
+ }
}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java index 5da4b7a..74c7072 100644 --- a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java @@ -2,6 +2,7 @@ package darkknight.jewelrycraft.events; import java.nio.FloatBuffer;
import java.util.Iterator;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.client.Minecraft;
@@ -10,13 +11,17 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
+
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
+
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.item.render.BraceletRender;
@@ -25,210 +30,203 @@ import darkknight.jewelrycraft.item.render.NecklaceRender; import darkknight.jewelrycraft.item.render.RingRender;
import darkknight.jewelrycraft.util.JewelryNBT;
-public class PlayerRenderHandler
-{
- EarringsRender earrings = new EarringsRender();
- BraceletRender bracelet = new BraceletRender();
- NecklaceRender necklace = new NecklaceRender();
- RingRender ring = new RingRender();
- public static NBTTagCompound playersInfo = new NBTTagCompound();
- float size = 0.055F;
-
- @SubscribeEvent
- public void renderScreen(RenderPlayerEvent.Specials.Post event)
- {
- GL11.glPushMatrix();
- ModelBiped main = event.renderer.modelBipedMain;
- ModelRenderer rightArm = event.renderer.modelBipedMain.bipedRightArm;
- ModelRenderer leftArm = event.renderer.modelBipedMain.bipedLeftArm;
- ModelRenderer head = event.renderer.modelBipedMain.bipedHead;
- ModelRenderer body = event.renderer.modelBipedMain.bipedBody;
- Iterator<EntityPlayer> players = event.entityPlayer.worldObj.playerEntities.iterator();
- float rotAngleX = 0F, rotAngleY = 0F, rotAngleZ = 0F;
- if (playersInfo != null){
- while (players.hasNext()){
- int[] gemColor = {-1, -1, -1, -1};
- int[] ingotColor = {-1, -1, -1, -1};
- int gem = -1;
- int ingot = -1;
- EntityPlayer player = players.next();
- NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName());
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event);
- int no = 0;
- ModelRenderer arm = rightArm;
- if (player.inventory.getCurrentItem() != null && Block.getBlockFromItem(player.inventory.getCurrentItem().getItem()) instanceof BlockAir){
- GL11.glDisable(GL11.GL_LIGHT1);
- FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(4);
- Vec3 lightPos = Vec3.createVectorHelper(0.0D, 2.0D, 1.0D).normalize();
- colorBuffer.clear();
- colorBuffer.put((float)lightPos.xCoord).put((float)lightPos.yCoord).put((float)lightPos.zCoord).put(-1F);
- colorBuffer.flip();
- GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, colorBuffer);
- colorBuffer.clear();
- colorBuffer.put(0.03f).put(0.03f).put(0.03f).put(1.0F);
- colorBuffer.flip();
- GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, colorBuffer);
- }
- for(int i = 0; i <= 9; i++)
- if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
- gem = -1;
- ingot = -1;
- if (no > 4) arm = leftArm;
- float s = 0.055F;
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (Loader.isModLoaded("alpaca")) arm = body;
- GL11.glPushMatrix();
- if (arm.rotateAngleX == 0.0F && arm.rotateAngleY == 0.0F && arm.rotateAngleZ == 0.0F){
- if ((arm.rotationPointX + rotAngleX) != 0.0F || (arm.rotationPointY + rotAngleY) != 0.0F || (arm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((arm.rotationPointX + rotAngleX) * s, (arm.rotationPointY + rotAngleY) * s, (arm.rotationPointZ + rotAngleZ) * s);
- }else if(!Loader.isModLoaded("alpaca")){
- GL11.glTranslatef((arm.rotationPointX + rotAngleX) * s, (arm.rotationPointY + rotAngleY) * s, (arm.rotationPointZ + rotAngleZ) * s);
- if (arm.rotateAngleZ != 0.0F) GL11.glRotatef(arm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- if (arm.rotateAngleY != 0.0F) GL11.glRotatef(arm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- if (arm.rotateAngleX != 0.0F) GL11.glRotatef(arm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- }
- if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
- if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
- float scale = 0.1f;
- if (Loader.isModLoaded("alpaca")){
- if (no <= 4){
- GL11.glTranslatef(0.35F, -4.35F, -2.8F + 0.15F * no);
- GL11.glRotatef(90f, 0F, 1F, 0F);
- }
- else{
- GL11.glTranslatef(-0.35F, -4.35F, 1.48F + 0.15F * no);
- GL11.glRotatef(-90f, 0F, 1F, 0F);
- }
- scale = 0.3F;
- }
- else{
- if (no <= 4) GL11.glTranslatef(0.64F + 0.05F * no, -1.15F, 0.07F);
- else GL11.glTranslatef(0.59F + 0.05F * no, -1.15F, 0.07F);
- }
- GL11.glScalef(scale, scale + scale/2, scale);
- ring.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F);
- GL11.glPopMatrix();
- no++;
- }
- for(int i = 10; i <= 13; i++)
- if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelryNBT.ingotColor(item);
- }
- if ((playerInfo.hasKey("ext10") || playerInfo.hasKey("ext11")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
- GL11.glPushMatrix();
- GL11.glColor4f(1, 1, 1, 1);
- if (Loader.isModLoaded("alpaca"))
- {
- rightArm = body;
- GL11.glTranslatef(0.0F, 0.05F, 0.0F);
- GL11.glRotatef(-30F, 0.0F, 1.0F, 0.0F);
- }
- if (rightArm.rotateAngleX == 0.0F && rightArm.rotateAngleY == 0.0F && rightArm.rotateAngleZ == 0.0F){
- if ((rightArm.rotationPointX + rotAngleX) != 0.0F || (rightArm.rotationPointY + rotAngleY) != 0.0F || (rightArm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((rightArm.rotationPointX + rotAngleX) * size, (rightArm.rotationPointY + rotAngleY) * size, (rightArm.rotationPointZ + rotAngleZ) * size);
- }else if(!Loader.isModLoaded("alpaca")){
- GL11.glTranslatef((rightArm.rotationPointX + rotAngleX) * size, (rightArm.rotationPointY + rotAngleY) * size, (rightArm.rotationPointZ + rotAngleZ) * size);
- if (rightArm.rotateAngleZ != 0.0F) GL11.glRotatef(rightArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- if (rightArm.rotateAngleY != 0.0F) GL11.glRotatef(rightArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- if (rightArm.rotateAngleX != 0.0F) GL11.glRotatef(rightArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- }
- GL11.glScalef(0.05f, 0.03f, 0.05f);
- bracelet.doRender(event.entityPlayer, (float)ingotColor[0], (float)gemColor[0], (float)ingotColor[1], (float)gemColor[1], 0.0F);
- GL11.glPopMatrix();
- }
- if ((playerInfo.hasKey("ext12") || playerInfo.hasKey("ext13")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
- GL11.glPushMatrix();
- GL11.glColor4f(1, 1, 1, 1);
- if (Loader.isModLoaded("alpaca"))
- {
- leftArm = body;
- GL11.glTranslatef(-0.1F, 0.0F, 0.1F);
- GL11.glRotatef(-140F, 0.0F, 1.0F, 0.0F);
- }
- if (leftArm.rotateAngleX == 0.0F && leftArm.rotateAngleY == 0.0F && leftArm.rotateAngleZ == 0.0F){
- if ((leftArm.rotationPointX + rotAngleX) != 0.0F || (leftArm.rotationPointY + rotAngleY) != 0.0F || (leftArm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((leftArm.rotationPointX + rotAngleX) * size, (leftArm.rotationPointY + rotAngleY) * size, (leftArm.rotationPointZ + rotAngleZ) * size);
- }else if(!Loader.isModLoaded("alpaca")){
- GL11.glTranslatef((leftArm.rotationPointX + rotAngleX) * size + 0.2F, (leftArm.rotationPointY + rotAngleY) * size, (leftArm.rotationPointZ + rotAngleZ) * size);
- if (leftArm.rotateAngleZ != 0.0F) GL11.glRotatef(leftArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- if (leftArm.rotateAngleY != 0.0F) GL11.glRotatef(leftArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- if (leftArm.rotateAngleX != 0.0F) GL11.glRotatef(leftArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- }
- GL11.glScalef(0.05f, 0.03f, 0.05f);
- bracelet.doRender(event.entityPlayer, (float)ingotColor[2], (float)gemColor[2], (float)ingotColor[3], (float)gemColor[3], 0F);
- GL11.glPopMatrix();
- }
- no = 0;
- for(int i = 14; i <= 16; i++)
- if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
- gem = -1;
- ingot = -1;
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- GL11.glPushMatrix();
- if (body.rotateAngleX == 0.0F && body.rotateAngleY == 0.0F && body.rotateAngleZ == 0.0F){
- if (body.rotationPointX != 0.0F || body.rotationPointY != 0.0F || body.rotationPointZ != 0.0F) GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size);
- }else if(!Loader.isModLoaded("alpaca")){
- GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size);
- if (body.rotateAngleZ != 0.0F) GL11.glRotatef(body.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- if (body.rotateAngleY != 0.0F) GL11.glRotatef(body.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- if (body.rotateAngleX != 0.0F) GL11.glRotatef(body.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- }
- if (Loader.isModLoaded("alpaca")) GL11.glTranslatef(0.0F, 0.55F, -0.28F);
- GL11.glScalef(0.0625f, 0.0625f, 0.0625f);
- if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
- if (no > 0){
- GL11.glRotatef(no == 1 ? 25f : -25f, 0F, 0f, 1f);
- GL11.glRotatef(no == 1 ? -5f : -10f, 1F, 0f, 0f);
- }
- necklace.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F);
- GL11.glPopMatrix();
- no++;
- }
- if (playerInfo.hasKey("ext17") && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
- gem = -1;
- ingot = -1;
- NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext17");
- ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- GL11.glPushMatrix();
- float s = 0.0625F;
- if (Loader.isModLoaded("alpaca")) head = body;
- if (head.rotateAngleX == 0.0F && head.rotateAngleY == 0.0F && head.rotateAngleZ == 0.0F){
- if (head.rotationPointX != 0.0F || head.rotationPointY != 0.0F || head.rotationPointZ != 0.0F) GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size);
- }else if(!Loader.isModLoaded("alpaca")){
- GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size);
- if (head.rotateAngleZ != 0.0F) GL11.glRotatef(head.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- if (head.rotateAngleY != 0.0F) GL11.glRotatef(head.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- if (head.rotateAngleX != 0.0F) GL11.glRotatef(head.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- }
- if (Loader.isModLoaded("alpaca")) GL11.glTranslatef(0.0F, 0.7F, -0.2F);
- GL11.glScalef(s, s, s);
- GL11.glTranslatef(0.0F, 1.0F, -2.0F);
- if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
- earrings.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F);
- GL11.glPopMatrix();
- }
- }
- }
- GL11.glPopMatrix();
- }
-
- float rot = 0F;
-
- @SubscribeEvent
- public void renderHand(RenderHandEvent event)
- {
- if (playersInfo != null){
- EntityPlayer player = Minecraft.getMinecraft().thePlayer;
- if (player != null){
- NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName());
- if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && curse != null && playerInfo != null && playerInfo.hasKey(curse.getName()) && playerInfo.getInteger(curse.getName()) > 0 && playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event);
- }
- }
- }
+public class PlayerRenderHandler {
+ EarringsRender earrings = new EarringsRender();
+ BraceletRender bracelet = new BraceletRender();
+ NecklaceRender necklace = new NecklaceRender();
+ RingRender ring = new RingRender();
+ public static NBTTagCompound playersInfo = new NBTTagCompound();
+ float size = 0.055F;
+
+ @SubscribeEvent
+ public void renderScreen(RenderPlayerEvent.Specials.Post event) {
+ GL11.glPushMatrix();
+ ModelBiped main = event.renderer.modelBipedMain;
+ ModelRenderer rightArm = event.renderer.modelBipedMain.bipedRightArm;
+ ModelRenderer leftArm = event.renderer.modelBipedMain.bipedLeftArm;
+ ModelRenderer head = event.renderer.modelBipedMain.bipedHead;
+ ModelRenderer body = event.renderer.modelBipedMain.bipedBody;
+ Iterator<EntityPlayer> players = event.entityPlayer.worldObj.playerEntities.iterator();
+ float rotAngleX = 0F, rotAngleY = 0F, rotAngleZ = 0F;
+ if (playersInfo != null) {
+ while (players.hasNext()) {
+ int[] gemColor = { -1, -1, -1, -1 };
+ int[] ingotColor = { -1, -1, -1, -1 };
+ int gem = -1;
+ int ingot = -1;
+ EntityPlayer player = players.next();
+ NBTTagCompound playerInfo = (NBTTagCompound) playersInfo.getTag(player.getDisplayName());
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event);
+ int no = 0;
+ ModelRenderer arm = rightArm;
+ if (player.inventory.getCurrentItem() != null && Block.getBlockFromItem(player.inventory.getCurrentItem().getItem()) instanceof BlockAir) {
+ GL11.glDisable(GL11.GL_LIGHT1);
+ FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(4);
+ Vec3 lightPos = Vec3.createVectorHelper(0.0D, 2.0D, 1.0D).normalize();
+ colorBuffer.clear();
+ colorBuffer.put((float) lightPos.xCoord).put((float) lightPos.yCoord).put((float) lightPos.zCoord).put(-1F);
+ colorBuffer.flip();
+ GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, colorBuffer);
+ colorBuffer.clear();
+ colorBuffer.put(0.03f).put(0.03f).put(0.03f).put(1.0F);
+ colorBuffer.flip();
+ GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, colorBuffer);
+ }
+ for (int i = 0; i <= 9; i++)
+ if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
+ gem = -1;
+ ingot = -1;
+ if (no > 4) arm = leftArm;
+ float s = 0.055F;
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) arm = body;
+ GL11.glPushMatrix();
+ if (arm.rotateAngleX == 0.0F && arm.rotateAngleY == 0.0F && arm.rotateAngleZ == 0.0F) {
+ if ((arm.rotationPointX + rotAngleX) != 0.0F || (arm.rotationPointY + rotAngleY) != 0.0F || (arm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((arm.rotationPointX + rotAngleX) * s, (arm.rotationPointY + rotAngleY) * s, (arm.rotationPointZ + rotAngleZ) * s);
+ } else if (!Loader.isModLoaded("alpaca") || (Loader.isModLoaded("alpaca") && !fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer))) {
+ GL11.glTranslatef((arm.rotationPointX + rotAngleX) * s, (arm.rotationPointY + rotAngleY) * s, (arm.rotationPointZ + rotAngleZ) * s);
+ if (arm.rotateAngleZ != 0.0F) GL11.glRotatef(arm.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
+ if (arm.rotateAngleY != 0.0F) GL11.glRotatef(arm.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
+ if (arm.rotateAngleX != 0.0F) GL11.glRotatef(arm.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
+ if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
+ float scale = 0.1f;
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) {
+ if (no <= 4) {
+ GL11.glTranslatef(0.35F, -4.35F, -2.8F + 0.15F * no);
+ GL11.glRotatef(90f, 0F, 1F, 0F);
+ } else {
+ GL11.glTranslatef(-0.35F, -4.35F, 1.48F + 0.15F * no);
+ GL11.glRotatef(-90f, 0F, 1F, 0F);
+ }
+ scale = 0.3F;
+ } else {
+ if (no <= 4) GL11.glTranslatef(0.64F + 0.05F * no, -1.15F, 0.07F);
+ else GL11.glTranslatef(0.59F + 0.05F * no, -1.15F, 0.07F);
+ }
+ GL11.glScalef(scale, scale + scale / 2, scale);
+ ring.doRender(event.entityPlayer, 0F, 0F, (float) ingot, (float) gem, 0F);
+ GL11.glPopMatrix();
+ no++;
+ }
+ for (int i = 10; i <= 13; i++)
+ if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelryNBT.gemColor(item);
+ if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelryNBT.ingotColor(item);
+ }
+ if ((playerInfo.hasKey("ext10") || playerInfo.hasKey("ext11")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
+ GL11.glPushMatrix();
+ GL11.glColor4f(1, 1, 1, 1);
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) {
+ rightArm = body;
+ GL11.glTranslatef(0.0F, 0.05F, 0.0F);
+ GL11.glRotatef(-30F, 0.0F, 1.0F, 0.0F);
+ }
+ if (rightArm.rotateAngleX == 0.0F && rightArm.rotateAngleY == 0.0F && rightArm.rotateAngleZ == 0.0F) {
+ if ((rightArm.rotationPointX + rotAngleX) != 0.0F || (rightArm.rotationPointY + rotAngleY) != 0.0F || (rightArm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((rightArm.rotationPointX + rotAngleX) * size, (rightArm.rotationPointY + rotAngleY) * size, (rightArm.rotationPointZ + rotAngleZ) * size);
+ } else if (!Loader.isModLoaded("alpaca") || (Loader.isModLoaded("alpaca") && !fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer))) {
+ GL11.glTranslatef((rightArm.rotationPointX + rotAngleX) * size, (rightArm.rotationPointY + rotAngleY) * size, (rightArm.rotationPointZ + rotAngleZ) * size);
+ if (rightArm.rotateAngleZ != 0.0F) GL11.glRotatef(rightArm.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
+ if (rightArm.rotateAngleY != 0.0F) GL11.glRotatef(rightArm.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
+ if (rightArm.rotateAngleX != 0.0F) GL11.glRotatef(rightArm.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ GL11.glScalef(0.05f, 0.03f, 0.05f);
+ bracelet.doRender(event.entityPlayer, (float) ingotColor[0], (float) gemColor[0], (float) ingotColor[1], (float) gemColor[1], 0.0F);
+ GL11.glPopMatrix();
+ }
+ if ((playerInfo.hasKey("ext12") || playerInfo.hasKey("ext13")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
+ GL11.glPushMatrix();
+ GL11.glColor4f(1, 1, 1, 1);
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) {
+ leftArm = body;
+ GL11.glTranslatef(-0.1F, 0.0F, 0.1F);
+ GL11.glRotatef(-140F, 0.0F, 1.0F, 0.0F);
+ }
+ if (leftArm.rotateAngleX == 0.0F && leftArm.rotateAngleY == 0.0F && leftArm.rotateAngleZ == 0.0F) {
+ if ((leftArm.rotationPointX + rotAngleX) != 0.0F || (leftArm.rotationPointY + rotAngleY) != 0.0F || (leftArm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((leftArm.rotationPointX + rotAngleX) * size, (leftArm.rotationPointY + rotAngleY) * size, (leftArm.rotationPointZ + rotAngleZ) * size);
+ } else if (!Loader.isModLoaded("alpaca") || (Loader.isModLoaded("alpaca") && !fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer))) {
+ GL11.glTranslatef((leftArm.rotationPointX + rotAngleX) * size + 0.2F, (leftArm.rotationPointY + rotAngleY) * size, (leftArm.rotationPointZ + rotAngleZ) * size);
+ if (leftArm.rotateAngleZ != 0.0F) GL11.glRotatef(leftArm.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
+ if (leftArm.rotateAngleY != 0.0F) GL11.glRotatef(leftArm.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
+ if (leftArm.rotateAngleX != 0.0F) GL11.glRotatef(leftArm.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ GL11.glScalef(0.05f, 0.03f, 0.05f);
+ bracelet.doRender(event.entityPlayer, (float) ingotColor[2], (float) gemColor[2], (float) ingotColor[3], (float) gemColor[3], 0F);
+ GL11.glPopMatrix();
+ }
+ no = 0;
+ for (int i = 14; i <= 16; i++)
+ if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
+ gem = -1;
+ ingot = -1;
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ GL11.glPushMatrix();
+ if (body.rotateAngleX == 0.0F && body.rotateAngleY == 0.0F && body.rotateAngleZ == 0.0F) {
+ if (body.rotationPointX != 0.0F || body.rotationPointY != 0.0F || body.rotationPointZ != 0.0F) GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size);
+ } else if (!Loader.isModLoaded("alpaca") || (Loader.isModLoaded("alpaca") && !fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer))) {
+ GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size);
+ if (body.rotateAngleZ != 0.0F) GL11.glRotatef(body.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
+ if (body.rotateAngleY != 0.0F) GL11.glRotatef(body.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
+ if (body.rotateAngleX != 0.0F) GL11.glRotatef(body.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) GL11.glTranslatef(0.0F, 0.55F, -0.28F);
+ GL11.glScalef(0.0625f, 0.0625f, 0.0625f);
+ if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
+ if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
+ if (no > 0) {
+ GL11.glRotatef(no == 1 ? 25f : -25f, 0F, 0f, 1f);
+ GL11.glRotatef(no == 1 ? -5f : -10f, 1F, 0f, 0f);
+ }
+ necklace.doRender(event.entityPlayer, 0F, 0F, (float) ingot, (float) gem, 0F);
+ GL11.glPopMatrix();
+ no++;
+ }
+ if (playerInfo.hasKey("ext17") && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
+ gem = -1;
+ ingot = -1;
+ NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext17");
+ ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
+ GL11.glPushMatrix();
+ float s = 0.0625F;
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) head = body;
+ if (head.rotateAngleX == 0.0F && head.rotateAngleY == 0.0F && head.rotateAngleZ == 0.0F) {
+ if (head.rotationPointX != 0.0F || head.rotationPointY != 0.0F || head.rotationPointZ != 0.0F) GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size);
+ } else if (!Loader.isModLoaded("alpaca") || (Loader.isModLoaded("alpaca") && !fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer))) {
+ GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size);
+ if (head.rotateAngleZ != 0.0F) GL11.glRotatef(head.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
+ if (head.rotateAngleY != 0.0F) GL11.glRotatef(head.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
+ if (head.rotateAngleX != 0.0F) GL11.glRotatef(head.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)) GL11.glTranslatef(0.0F, 0.7F, -0.2F);
+ GL11.glScalef(s, s, s);
+ GL11.glTranslatef(0.0F, 1.0F, -2.0F);
+ if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
+ if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
+ earrings.doRender(event.entityPlayer, 0F, 0F, (float) ingot, (float) gem, 0F);
+ GL11.glPopMatrix();
+ }
+ }
+ }
+ GL11.glPopMatrix();
+ }
+
+ float rot = 0F;
+
+ @SubscribeEvent
+ public void renderHand(RenderHandEvent event) {
+ if (playersInfo != null) {
+ EntityPlayer player = Minecraft.getMinecraft().thePlayer;
+ if (player != null) {
+ NBTTagCompound playerInfo = (NBTTagCompound) playersInfo.getTag(player.getDisplayName());
+ if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && curse != null && playerInfo != null && playerInfo.hasKey(curse.getName()) && playerInfo.getInteger(curse.getName()) > 0 && playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event);
+ }
+ }
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java index 68aace4..b8df767 100644 --- a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java @@ -1,98 +1,98 @@ -package darkknight.jewelrycraft.events; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; -import org.lwjgl.opengl.GL11; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; - -public class ScreenHandler extends Gui -{ - private Minecraft mc; - public static NBTTagCompound tagCache = null; - public static int cooldown; - - public ScreenHandler(Minecraft mc) - { - super(); - this.mc = mc; - } - - @SubscribeEvent - public void renderScreen(RenderGameOverlayEvent event) - { - if (event.isCancelable() || event.type != ElementType.ALL || tagCache == null) return; - if (!mc.gameSettings.showDebugInfo && !(mc.currentScreen instanceof GuiChat)){ - int count = 0; - int size = 32; - ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - if (tagCache.hasKey("cursePoints") && tagCache.getInteger("cursePoints") > 0){ - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()){ - if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){ - drawTexturedModalRect(-16, -16 + (size - 6) * count, 0, 32, 144, 60); - count++; - } - } - count = 0; - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){ - mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png")); - int tag = curse.getTextureID(); - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glScalef(0.45f, 0.45f, 0.0f); - drawTexturedModalRect(28, 18 + (size + 26) * count, tag % 8 * size, tag / 8 * size, size, size); - GL11.glPopMatrix(); - count++; - } - count = 0; - size = 16; - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){ - mc.fontRenderer.drawStringWithShadow(curse.getName().split(":")[1], 30, 11 + (size + 10) * count, 16777215); - if (tagCache.getInteger(curse.getName()) == 2){ - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1f, 1f, 1f, 0.5f); - drawTexturedModalRect(95, 7 + (size + 10) * count, 3 * size, 0, size, size); - GL11.glPopMatrix(); - } - count++; - } - } - GL11.glPushMatrix(); - GL11.glColor4f(1f, 1f, 1f, 1.0f); - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - count = 0; - size = 16; - if (tagCache.getFloat("BlueHeart") > 0){ - drawTexturedModalRect(5 + 35*count, resolution.getScaledHeight() - 20, 0 * size, 0 * size, size, size); - mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F), 15 + 35*count, resolution.getScaledHeight() - 16, 16777215); - } - count++; - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - if (tagCache.getFloat("BlackHeart") > 0){ - drawTexturedModalRect(5 + 35*count, resolution.getScaledHeight() - 20, 1 * size, 0 * size, size, size); - mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F), 15 + 35*count, resolution.getScaledHeight() - 16, 16777215); - } - count++; - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - if (tagCache.getFloat("WhiteHeart") > 0) - drawTexturedModalRect(5 + 35*count, resolution.getScaledHeight() - 20, 2 * size, 1 * size, size, size); - GL11.glPopMatrix(); - } - } +package darkknight.jewelrycraft.events;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiChat;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
+import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.Variables;
+
+public class ScreenHandler extends Gui
+{
+ private Minecraft mc;
+ public static NBTTagCompound tagCache = null;
+ public static int cooldown;
+
+ public ScreenHandler(Minecraft mc)
+ {
+ super();
+ this.mc = mc;
+ }
+
+ @SubscribeEvent
+ public void renderScreen(RenderGameOverlayEvent event)
+ {
+ if (event.isCancelable() || event.type != ElementType.ALL || tagCache == null) return;
+ if (!mc.gameSettings.showDebugInfo && !(mc.currentScreen instanceof GuiChat)){
+ int count = 0;
+ int size = 32;
+ ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
+ if (tagCache.hasKey("cursePoints") && tagCache.getInteger("cursePoints") > 0){
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()){
+ if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
+ drawTexturedModalRect(-16, -16 + (size - 6) * count, 0, 32, 144, 60);
+ count++;
+ }
+ }
+ count = 0;
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
+ mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png"));
+ int tag = curse.getTextureID();
+ GL11.glPushMatrix();
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glScalef(0.45f, 0.45f, 0.0f);
+ drawTexturedModalRect(28, 18 + (size + 26) * count, tag % 8 * size, tag / 8 * size, size, size);
+ GL11.glPopMatrix();
+ count++;
+ }
+ count = 0;
+ size = 16;
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
+ mc.fontRenderer.drawStringWithShadow(curse.getName().split(":")[1], 30, 11 + (size + 10) * count, 16777215);
+ if (tagCache.getInteger(curse.getName()) == 2){
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glColor4f(1f, 1f, 1f, 0.5f);
+ drawTexturedModalRect(95, 7 + (size + 10) * count, 3 * size, 0, size, size);
+ GL11.glPopMatrix();
+ }
+ count++;
+ }
+ }
+ GL11.glPushMatrix();
+ GL11.glColor4f(1f, 1f, 1f, 1.0f);
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
+ count = 0;
+ size = 16;
+ if (tagCache.getFloat("BlueHeart") > 0){
+ drawTexturedModalRect(resolution.getScaledWidth()/2 + 90 + 35*count, resolution.getScaledHeight() - 20, 0 * size, 0 * size, size, size);
+ mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F), resolution.getScaledWidth()/2 + 105 + 35*count, resolution.getScaledHeight() - 16, 16777215);
+ }
+ count++;
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
+ if (tagCache.getFloat("BlackHeart") > 0){
+ drawTexturedModalRect(resolution.getScaledWidth()/2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35*count, resolution.getScaledHeight() - 20, 1 * size, 0 * size, size, size);
+ mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F), resolution.getScaledWidth()/2 + 105 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35*count, resolution.getScaledHeight() - 16, 16777215);
+ }
+ count++;
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
+ if (tagCache.getFloat("WhiteHeart") > 0)
+ drawTexturedModalRect(resolution.getScaledWidth()/2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F))) - 14) + 35*count, resolution.getScaledHeight() - 20, 2 * size, 1 * size, size, size);
+ GL11.glPopMatrix();
+ }
+ }
}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemList.java b/src/main/java/darkknight/jewelrycraft/item/ItemList.java index 064ee58..49c6679 100644 --- a/src/main/java/darkknight/jewelrycraft/item/ItemList.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemList.java @@ -1,66 +1,69 @@ -package darkknight.jewelrycraft.item; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.util.Variables; - -public class ItemList -{ - public static Item thiefGloves; - public static Item shadowIngot; - public static Item molds; - public static Item clayMolds; - public static ItemRing ring; - public static ItemNecklace necklace; - public static ItemBracelet bracelet; - public static ItemEarrings earrings; - public static Item guide; - public static Item jewelryModifier; - public static ItemMoltenMetalBucket bucket; - public static ItemMoltenMetal metal; - public static Item goldObj; - public static Item structureGen; - private static boolean isInitialized = false; - - /** - * @param e - */ - public static void preInit(FMLPreInitializationEvent e) - { - thiefGloves = new ItemThiefGloves().setUnlocalizedName(Variables.MODID + ".thiefGloves").setTextureName(Variables.MODID + ":thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); - shadowIngot = new Item().setUnlocalizedName(Variables.MODID + ".ingotShadow").setTextureName(Variables.MODID + ":ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - molds = new ItemMolds().setUnlocalizedName(Variables.MODID + ".mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); - clayMolds = new ItemClayMolds().setUnlocalizedName(Variables.MODID + ".mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); - ring = (ItemRing)new ItemRing().setUnlocalizedName(Variables.MODID + ".ring").setTextureName(Variables.MODID + ":ring").setCreativeTab(JewelrycraftMod.jewelrycraft); - necklace = (ItemNecklace)new ItemNecklace().setUnlocalizedName(Variables.MODID + ".necklace").setTextureName(Variables.MODID + ":necklace").setCreativeTab(JewelrycraftMod.jewelrycraft); - bracelet = (ItemBracelet)new ItemBracelet().setUnlocalizedName(Variables.MODID + ".bracelet").setTextureName(Variables.MODID + ":bracelet").setCreativeTab(JewelrycraftMod.jewelrycraft); - earrings = (ItemEarrings)new ItemEarrings().setUnlocalizedName(Variables.MODID + ".earrings").setTextureName(Variables.MODID + ":earrings").setCreativeTab(JewelrycraftMod.jewelrycraft); - guide = new ItemGuide().setUnlocalizedName(Variables.MODID + ".guide").setTextureName(Variables.MODID + ":guide").setCreativeTab(JewelrycraftMod.jewelrycraft); - bucket = (ItemMoltenMetalBucket)new ItemMoltenMetalBucket().setUnlocalizedName(Variables.MODID + ".bucket"); - metal = (ItemMoltenMetal)new ItemMoltenMetal().setUnlocalizedName(Variables.MODID + ".bucket"); - jewelryModifier = new ItemJewelryModifier().setUnlocalizedName(Variables.MODID + ".jewelryModifier").setTextureName(Variables.MODID + ":jewelryModifier").setCreativeTab(JewelrycraftMod.jewelrycraft); - goldObj = new ItemGoldObj().setUnlocalizedName(Variables.MODID + ".goldObject"); - structureGen = new ItemStructureGen().setUnlocalizedName(Variables.MODID + ".structureGen").setTextureName(Variables.MODID + ":structureGen").setCreativeTab(JewelrycraftMod.jewelrycraft); - - GameRegistry.registerItem(thiefGloves, "thiefGloves"); - GameRegistry.registerItem(shadowIngot, "shadowIngot"); - GameRegistry.registerItem(molds, "molds"); - GameRegistry.registerItem(clayMolds, "clayMolds"); - GameRegistry.registerItem(ring, "ring"); - GameRegistry.registerItem(necklace, "necklace"); - GameRegistry.registerItem(bracelet, "bracelet"); - GameRegistry.registerItem(earrings, "earrings"); - GameRegistry.registerItem(guide, "guide"); - GameRegistry.registerItem(bucket, "moltenMetalBucket"); - GameRegistry.registerItem(metal, "moltenMetal"); - GameRegistry.registerItem(jewelryModifier, "jewelryModifier"); - GameRegistry.registerItem(goldObj, "goldObject"); - GameRegistry.registerItem(structureGen, "structureGen"); - - OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot)); - } -} +package darkknight.jewelrycraft.item;
+
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.GameRegistry;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.util.Variables;
+
+public class ItemList
+{
+ public static Item thiefGloves;
+ public static Item shadowIngot;
+ public static Item molds;
+ public static Item clayMolds;
+ public static ItemRing ring;
+ public static ItemNecklace necklace;
+ public static ItemBracelet bracelet;
+ public static ItemEarrings earrings;
+ public static Item guide;
+ public static Item jewelryModifier;
+ public static ItemMoltenMetalBucket bucket;
+ public static ItemMoltenMetal metal;
+ public static Item goldObj;
+ public static Item structureGen;
+ public static Item spawnEgg;
+ private static boolean isInitialized = false;
+
+ /**
+ * @param e
+ */
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ thiefGloves = new ItemThiefGloves().setUnlocalizedName(Variables.MODID + ".thiefGloves").setTextureName(Variables.MODID + ":thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ shadowIngot = new Item().setUnlocalizedName(Variables.MODID + ".ingotShadow").setTextureName(Variables.MODID + ":ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ molds = new ItemMolds().setUnlocalizedName(Variables.MODID + ".mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ clayMolds = new ItemClayMolds().setUnlocalizedName(Variables.MODID + ".mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ ring = (ItemRing)new ItemRing().setUnlocalizedName(Variables.MODID + ".ring").setTextureName(Variables.MODID + ":ring").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ necklace = (ItemNecklace)new ItemNecklace().setUnlocalizedName(Variables.MODID + ".necklace").setTextureName(Variables.MODID + ":necklace").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ bracelet = (ItemBracelet)new ItemBracelet().setUnlocalizedName(Variables.MODID + ".bracelet").setTextureName(Variables.MODID + ":bracelet").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ earrings = (ItemEarrings)new ItemEarrings().setUnlocalizedName(Variables.MODID + ".earrings").setTextureName(Variables.MODID + ":earrings").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ guide = new ItemGuide().setUnlocalizedName(Variables.MODID + ".guide").setTextureName(Variables.MODID + ":guide").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ bucket = (ItemMoltenMetalBucket)new ItemMoltenMetalBucket().setUnlocalizedName(Variables.MODID + ".bucket");
+ metal = (ItemMoltenMetal)new ItemMoltenMetal().setUnlocalizedName(Variables.MODID + ".bucket");
+ jewelryModifier = new ItemJewelryModifier().setUnlocalizedName(Variables.MODID + ".jewelryModifier").setTextureName(Variables.MODID + ":jewelryModifier").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ goldObj = new ItemGoldObj().setUnlocalizedName(Variables.MODID + ".goldObject");
+ structureGen = new ItemStructureGen().setUnlocalizedName(Variables.MODID + ".structureGen").setTextureName(Variables.MODID + ":structureGen").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ spawnEgg = new ItemSpawnEgg().setUnlocalizedName(Variables.MODID + ".monsterPlacer").setTextureName("spawn_egg");
+
+ GameRegistry.registerItem(thiefGloves, "thiefGloves");
+ GameRegistry.registerItem(shadowIngot, "shadowIngot");
+ GameRegistry.registerItem(molds, "molds");
+ GameRegistry.registerItem(clayMolds, "clayMolds");
+ GameRegistry.registerItem(ring, "ring");
+ GameRegistry.registerItem(necklace, "necklace");
+ GameRegistry.registerItem(bracelet, "bracelet");
+ GameRegistry.registerItem(earrings, "earrings");
+ GameRegistry.registerItem(guide, "guide");
+ GameRegistry.registerItem(bucket, "moltenMetalBucket");
+ GameRegistry.registerItem(metal, "moltenMetal");
+ GameRegistry.registerItem(jewelryModifier, "jewelryModifier");
+ GameRegistry.registerItem(goldObj, "goldObject");
+ GameRegistry.registerItem(structureGen, "structureGen");
+ GameRegistry.registerItem(spawnEgg, "spawnEgg");
+
+ OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot));
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemSpawnEgg.java b/src/main/java/darkknight/jewelrycraft/item/ItemSpawnEgg.java new file mode 100644 index 0000000..708c69c --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemSpawnEgg.java @@ -0,0 +1,177 @@ +package darkknight.jewelrycraft.item;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.IEntityLivingData;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemMonsterPlacer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Facing;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.MovingObjectPosition.MovingObjectType;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.entities.EntityHeart;
+import darkknight.jewelrycraft.util.Variables;
+
+/**
+ * @author Betweenlands
+ */
+public class ItemSpawnEgg extends ItemMonsterPlacer {
+ private static final Map<Short, EggData> eggTypes = new LinkedHashMap<Short, EggData>();
+
+ public static void registerSpawnEgg(Class<? extends EntityLiving> entity, String entityName, int id, int eggBackgroundColor, int eggForegroundColor) {
+ eggTypes.put((short) id, new EggData(id, entityName, entity, eggBackgroundColor, eggForegroundColor));
+ }
+
+ private static EggData getEggData(ItemStack is) {
+ return eggTypes.get((short) is.getItemDamage());
+ }
+
+ public ItemSpawnEgg() {
+ setHasSubtypes(true);
+ setCreativeTab(CreativeTabs.tabMisc);
+ }
+
+ @Override
+ public String getItemStackDisplayName(ItemStack is) {
+ String s = StatCollector.translateToLocal(getUnlocalizedName() + ".name").trim();
+ String mob = "";
+
+ EggData egg = getEggData(is);
+ if (egg != null) mob = StatCollector.translateToLocal("entity." + Variables.MODID + "." + egg.entityName + ".name");
+
+ return String.format(s, mob);
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
+ if (world.isRemote) return true;
+
+ Block block = world.getBlock(x, y, z);
+ x += Facing.offsetsXForSide[side];
+ y += Facing.offsetsYForSide[side];
+ z += Facing.offsetsZForSide[side];
+
+ EggData egg = getEggData(is);
+ if (egg != null) {
+ egg.spawnMob(world, x + 0.5D, y + (side == 1 && block != null && block.getRenderType() == 11 ? 0.5D : 0D), z + 0.5D, is);
+
+ if (!player.capabilities.isCreativeMode) --is.stackSize;
+ }
+
+ return true;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
+ if (world.isRemote) return is;
+
+ MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
+
+ if (mop != null && mop.typeOfHit == MovingObjectType.BLOCK) {
+ int x = mop.blockX, y = mop.blockY, z = mop.blockZ;
+
+ if (!world.canMineBlock(player, x, y, z) || !player.canPlayerEdit(x, y, z, mop.sideHit, is)) return is;
+
+ if (world.getBlock(x, y, z).getMaterial() == Material.water) {
+ EggData egg = getEggData(is);
+ if (egg != null) {
+ egg.spawnMob(world, x, y, z, is);
+
+ if (!player.capabilities.isCreativeMode) --is.stackSize;
+ }
+ }
+ }
+
+ return is;
+ }
+
+ public static EntityLiving getEntity(World world, double x, double y, double z, ItemStack is) {
+ EggData egg = getEggData(is);
+ return egg.spawnMob(world, x, y, z, is);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getColorFromItemStack(ItemStack is, int pass) {
+ EggData egg = getEggData(is);
+ return egg != null ? pass == 0 ? egg.primaryColor : egg.secondaryColor : 16777215;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item id, CreativeTabs tab, List list) {
+ for (Short s : eggTypes.keySet())
+ list.add(new ItemStack(id, 1, s));
+ }
+
+ static class EggData {
+ private final short id;
+ String entityName;
+ private final Class<? extends EntityLiving> entityClass;
+ int primaryColor;
+ int secondaryColor;
+
+ EggData(int id, String entityName, Class<? extends EntityLiving> entityClass, int[] rgbPrimaryColor, int[] rgbSecondaryColor) {
+ this(id, entityName, entityClass, rgbPrimaryColor[0] << 16 | rgbPrimaryColor[1] << 8 | rgbPrimaryColor[2], rgbSecondaryColor[0] << 16 | rgbSecondaryColor[1] << 8 | rgbSecondaryColor[2]);
+ }
+
+ EggData(int id, String entityName, Class<? extends EntityLiving> entityClass, int primaryColor, int secondaryColor) {
+ this.id = (short) id;
+ this.entityName = entityName;
+ this.entityClass = entityClass;
+ this.primaryColor = primaryColor;
+ this.secondaryColor = secondaryColor;
+ }
+
+ public EntityLiving spawnMob(World world, double x, double y, double z, ItemStack is) {
+ EntityLiving e = null;
+
+ try {
+ e = entityClass.getConstructor(World.class).newInstance(world);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return null;
+ }
+
+ if (e == null) return null;
+
+ if (e instanceof EntityHeart) {
+ if (id == 2) ((EntityHeart) e).setType("White");
+ else if (id == 3) ((EntityHeart) e).setType("Blue");
+ else if (id == 4) ((EntityHeart) e).setType("Black");
+ else if (id == 6) ((EntityHeart) e).setType("White");
+ else if (id == 7) ((EntityHeart) e).setType("Blue");
+ else if (id == 8) ((EntityHeart) e).setType("Black");
+ else ((EntityHeart) e).setType("Red");
+ }
+ e.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360F), 0F);
+ e.rotationYawHead = e.rotationYaw;
+ e.renderYawOffset = e.rotationYaw;
+ e.onSpawnWithEgg((IEntityLivingData) null);
+ world.spawnEntityInWorld(e);
+ e.playLivingSound();
+
+ if (is.hasDisplayName()) e.setCustomNameTag(is.getDisplayName());
+
+ return e;
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java b/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java index 047cd93..bdec55d 100644 --- a/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java +++ b/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java @@ -3,9 +3,12 @@ package darkknight.jewelrycraft.item.render; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
+
import org.lwjgl.opengl.GL11;
+
import cpw.mods.fml.common.Loader;
import darkknight.jewelrycraft.model.ModelBracelet;
import darkknight.jewelrycraft.util.Variables;
@@ -25,7 +28,7 @@ public class BraceletRender extends TileEntitySpecialRenderer GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
if ((float)z != -1) bracelet.render(entity, 0F, 0F, 0F, (float)z, f, 1.0F);
- if (Loader.isModLoaded("alpaca")){
+ if (Loader.isModLoaded("alpaca") && fiskfille.alpaca.AlpacaAPI.isAlpacaClient((EntityPlayer)entity)){
GL11.glTranslatef(1F, 0F, -9F);
GL11.glRotatef(25F, 1F, 0F, 0F);
GL11.glRotatef(-25F, 0F, 1F, 0F);
diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java b/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java index 09f96b3..548004e 100644 --- a/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java +++ b/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java @@ -1,5 +1,8 @@ package darkknight.jewelrycraft.thirdparty;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import fiskfille.alpaca.common.potion.AlpacaPotions;
+
/**
* @author Sorin
*/
@@ -15,7 +18,9 @@ public class Alpaca implements IThirdParty @Override
public void postInit()
- {}
+ {
+ JewelrycraftMod.alpacaPotion = AlpacaPotions.potionAlpaca;
+ }
@Override
public void clientSide()
|
