summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-08-13 21:12:11 +0100
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-08-13 21:12:11 +0100
commit0ef6a00aa79f022e5bd56b3f77e6861bbecf6d94 (patch)
tree03966c83cd16d1912ec1596d83f89f251cc35f83 /src/main/java/darkknight
parent921f1ba6f30e66c80c803618ebff496778e78970 (diff)
Added a new structure, a new curse, achievements, challenges, curses
entry in the guide; reworked liquids to be tile entities, cleaned the structures code, potion code and... you know what? I improved and changed so much stuff that I literally forgot what I did...
Diffstat (limited to 'src/main/java/darkknight')
-rw-r--r--src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java33
-rw-r--r--src/main/java/darkknight/jewelrycraft/achievements/AchievementsList.java26
-rw-r--r--src/main/java/darkknight/jewelrycraft/api/Curse.java39
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java350
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/BlockList.java150
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java411
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java428
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java294
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/Page.java364
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/TabCurses.java2
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java202
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiGuide.java424
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiTabBlocks.java84
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiTabCurses.java89
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiTabGemsAndIngots.java188
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiTabIntroduction.java114
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiTabItems.java28
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiTabModifiers.java184
-rw-r--r--src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java15
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseDeathsTouch.java49
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java9
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseList.java84
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java3
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java52
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java9
-rw-r--r--src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java109
-rw-r--r--src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java18
-rw-r--r--src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java16
-rw-r--r--src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java12
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/BucketHandler.java39
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java336
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java10
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java4
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemGuide.java56
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemJewelryModifier.java52
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemList.java9
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java95
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java18
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemTest.java54
-rw-r--r--src/main/java/darkknight/jewelrycraft/network/PacketClearColorCache.java44
-rw-r--r--src/main/java/darkknight/jewelrycraft/network/PacketHandler.java46
-rw-r--r--src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java81
-rw-r--r--src/main/java/darkknight/jewelrycraft/network/PacketSendClientPlayerInfo.java116
-rw-r--r--src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java96
-rw-r--r--src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java71
-rw-r--r--src/main/java/darkknight/jewelrycraft/potions/PotionBase.java20
-rw-r--r--src/main/java/darkknight/jewelrycraft/potions/PotionStun.java64
-rw-r--r--src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java5
-rw-r--r--src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java106
-rw-r--r--src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java16
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java87
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java348
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java378
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java66
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java6
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java379
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java526
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java277
-rw-r--r--src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java251
-rw-r--r--src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java147
-rw-r--r--src/main/java/darkknight/jewelrycraft/util/Variables.java4
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/Generation.java119
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java25
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java2
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java20
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java4
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java6
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java93
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java900
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java2
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java54
77 files changed, 4381 insertions, 4611 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
index 6c8ca44..1d57412 100644
--- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
+++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
@@ -7,13 +7,10 @@ package darkknight.jewelrycraft;
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.nbt.NBTTagCompound;
-import net.minecraft.potion.Potion;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -24,7 +21,16 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
+import darkknight.jewelrycraft.achievements.AchievementsList;
import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.client.gui.GuiTab;
+import darkknight.jewelrycraft.client.gui.GuiTabBlocks;
+import darkknight.jewelrycraft.client.gui.GuiTabGemsAndIngots;
+import darkknight.jewelrycraft.client.gui.GuiTabIntroduction;
+import darkknight.jewelrycraft.client.gui.GuiTabItems;
+import darkknight.jewelrycraft.client.gui.GuiTabModifiers;
+import darkknight.jewelrycraft.client.gui.GuiTabOresToIngots;
+import darkknight.jewelrycraft.client.gui.GuiTabRitual;
import darkknight.jewelrycraft.commands.JewelrycraftCommands;
import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.curses.CurseList;
@@ -39,6 +45,9 @@ import darkknight.jewelrycraft.thirdparty.ThirdPartyManager;
import darkknight.jewelrycraft.util.Variables;
import darkknight.jewelrycraft.worldGen.ChestGeneration;
import darkknight.jewelrycraft.worldGen.village.VillageHandler;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.nbt.NBTTagCompound;
@Mod (modid = Variables.MODID, name = Variables.MODNAME, version = Variables.VERSION, guiFactory = Variables.CONFIG_GUI, acceptedMinecraftVersions = "[1.7.10,1.8)")
public class JewelrycraftMod
@@ -47,7 +56,7 @@ public class JewelrycraftMod
public static JewelrycraftMod instance;
@SidedProxy (clientSide = Variables.CLIENT_PROXY, serverSide = Variables.SERVER_PROXY)
public static CommonProxy proxy;
- public static final Logger logger = Logger.getLogger(Variables.MODNAME);
+ public static Logger logger;
public static File dir;
public static CreativeTabs jewelrycraft = new CreativeTabs(Variables.MODID){
@Override
@@ -57,12 +66,13 @@ public class JewelrycraftMod
}
};
public static CreativeTabs liquids = new CreativeTabLiquids("Liquids").setBackgroundImageName("item_search.png");
- public static NBTTagCompound saveData = new NBTTagCompound();
- public static NBTTagCompound clientData = new NBTTagCompound();
- public static File liquidsConf;
public static SimpleNetworkWrapper netWrapper;
public static boolean fancyRender = false;
+ //GUIDE
+ public static GuiTab prevActive = new GuiTabIntroduction(0);
+ public static int prevPage = 1;
+
/**
* Pre initialization of mod stuff.
*
@@ -73,6 +83,7 @@ public class JewelrycraftMod
public void preInit(FMLPreInitializationEvent e) throws IOException
{
dir = e.getModConfigurationDirectory();
+ logger = e.getModLog();
ConfigHandler.INSTANCE.loadConfig(e);
ThirdPartyManager.instance().index();
logger.log(Level.INFO, "Registering Blocks");
@@ -119,6 +130,8 @@ public class JewelrycraftMod
EventList.postInit(e);
logger.log(Level.INFO, "Registering Potions");
PotionList.postInit(e);
+ logger.log(Level.INFO, "Registering Achievements");
+ AchievementsList.addAchievements();
}
@EventHandler
diff --git a/src/main/java/darkknight/jewelrycraft/achievements/AchievementsList.java b/src/main/java/darkknight/jewelrycraft/achievements/AchievementsList.java
new file mode 100644
index 0000000..c5b5179
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/achievements/AchievementsList.java
@@ -0,0 +1,26 @@
+package darkknight.jewelrycraft.achievements;
+
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.init.Items;
+import net.minecraft.stats.Achievement;
+import net.minecraftforge.common.AchievementPage;
+
+public class AchievementsList
+{
+ public static AchievementPage jewelrycraft;
+
+ //Achievements
+ public static final Achievement openGuide = new Achievement("achievement.jewelrycraft.openGuide", "jewelrycraft.openGuide", 0, 0, ItemList.guide, (Achievement)null).initIndependentStat();
+
+ //Challenges
+ public static final Achievement pentagram = new Achievement("achievement.jewelrycraft.pentagram", "jewelrycraft.pentagram", -3, -2, Items.ender_eye, (Achievement)null).initIndependentStat().setSpecial();
+
+ public static void addAchievements()
+ {
+ openGuide.registerStat();
+ pentagram.registerStat();
+ jewelrycraft = new AchievementPage("Jewelrycraft 2", openGuide, pentagram);
+ AchievementPage.registerAchievementPage(jewelrycraft);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/api/Curse.java b/src/main/java/darkknight/jewelrycraft/api/Curse.java
index c8c4d60..84e425f 100644
--- a/src/main/java/darkknight/jewelrycraft/api/Curse.java
+++ b/src/main/java/darkknight/jewelrycraft/api/Curse.java
@@ -2,8 +2,8 @@ package darkknight.jewelrycraft.api;
import java.util.ArrayList;
import java.util.Random;
-
-import net.minecraft.client.Minecraft;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
@@ -11,14 +11,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.world.BlockEvent;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
public abstract class Curse
{
- protected int textureID;
- protected String name, description, texturePackName;
+ protected int textureID, ticksActive;
+ protected String name, description, texturePackName;
protected Random rand = new Random();
private static ArrayList<Curse> curses = new ArrayList<Curse>();
public static ArrayList<Curse> availableCurses = new ArrayList<Curse>();
@@ -33,6 +32,7 @@ public abstract class Curse
this.name = name;
this.texturePackName = texturepack;
this.textureID = txtID;
+ this.ticksActive = 0;
curses.add(this);
availableCurses.add(this);
}
@@ -87,7 +87,19 @@ public abstract class Curse
* @param player The cursed player
*/
public void action(World world, EntityPlayer player)
- {}
+ {
+ ticksActive++;
+ }
+
+ public int getTicksActive()
+ {
+ return ticksActive;
+ }
+
+ public void setTicksActive(int ticksActive)
+ {
+ this.ticksActive = ticksActive;
+ }
/**
* This runs when the player dies
@@ -128,10 +140,21 @@ public abstract class Curse
* @param player The player that caused the damage
* @param target The entity damaged
*/
- public void attackedByPlayerAction(World world, EntityPlayer player, Entity target)
+ public void attackedByPlayerAction(LivingAttackEvent event, World world, EntityPlayer player, Entity target)
{}
/**
+ * This runs when an entity is attacked by a player (this includes other players). This can cancel the damaging event.
+ * @param world The world the player is in
+ * @param player The player that caused the damage
+ * @param target The entity damaged
+ */
+ public boolean attackedByPlayerActionCancelable(LivingAttackEvent event, World world, EntityPlayer player, Entity target)
+ {
+ return false;
+ }
+
+ /**
* This runs when an item is dropped by an entity
* @param player The cursed player
* @param target The entity that drops the item
diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
index a5d058b..7a6bf38 100644
--- a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
+++ b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
@@ -1,231 +1,119 @@
-package darkknight.jewelrycraft.block;
-
-import java.util.Random;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockContainer;
-import net.minecraft.block.material.Material;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.MathHelper;
-import net.minecraft.util.StatCollector;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.Variables;
-
-public class BlockJewelrsCraftingTable extends BlockContainer
-{
- Random rand = new Random();
-
- /**
- * @param par2Material
- */
- protected BlockJewelrsCraftingTable(Material par2Material)
- {
- super(par2Material);
- setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F);
- }
-
- /**
- * @param world
- * @param var2
- * @return
- */
- @Override
- public TileEntity createNewTileEntity(World world, int var2)
- {
- return new TileEntityJewelrsCraftingTable();
- }
-
- /**
- * @return
- */
- @Override
- public boolean renderAsNormalBlock()
- {
- return false;
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param entityPlayer
- * @param par6
- * @param par7
- * @param par8
- * @param par9
- * @return
- */
- @Override
- public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
- {
- TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable)world.getTileEntity(i, j, k);
- ItemStack item = entityPlayer.inventory.getCurrentItem();
- if (te != null && !world.isRemote){
- if (te.hasEndItem && item != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.hasenditem")));
- if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)){
- te.jewelry = item.copy();
- te.hasJewelry = true;
- if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
- te.isDirty = true;
- }
- if (!te.hasEndItem && !te.hasGem && item != null && JewelrycraftUtil.isGem(item)){
- te.gem = item.copy();
- te.gem.stackSize = 1;
- te.hasGem = true;
- if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
- te.isDirty = true;
- }
- if (!te.hasEndItem && te.hasJewelry && te.hasGem && !te.crafting){
- te.carving = ConfigHandler.GEM_PLACEMENT_TIME;
- te.angle = 0;
- te.crafting = true;
- te.isDirty = true;
- }
- }
- return true;
- }
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @param stack
- */
- public void dropItem(World world, double x, double y, double z, ItemStack stack)
- {
- EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack);
- entityitem.motionX = 0;
- entityitem.motionZ = 0;
- entityitem.motionY = 0.21000000298023224D;
- world.spawnEntityInWorld(entityitem);
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param par5
- * @param par6
- */
- @Override
- public void breakBlock(World world, int i, int j, int k, Block par5, int par6)
- {
- TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable)world.getTileEntity(i, j, k);
- if (te != null){
- if (te.hasJewelry) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.jewelry.copy());
- if (te.hasGem) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.gem.copy());
- if (te.hasEndItem) dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.endItem.copy());
- world.removeTileEntity(i, j, k);
- }
- super.breakBlock(world, i, j, k, par5, par6);
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param entityLiving
- * @param par6ItemStack
- */
- @Override
- public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack)
- {
- int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
- world.setBlockMetadataWithNotify(i, j, k, rotation, 2);
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param player
- */
- @Override
- public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player)
- {
- TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable)world.getTileEntity(i, j, k);
- if (te != null && !world.isRemote) if (player.isSneaking()){
- if (te.hasJewelry){
- dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.jewelry.copy());
- te.jewelry = new ItemStack(Item.getItemById(0), 0, 0);
- te.hasJewelry = false;
- te.carving = -1;
- te.crafting = false;
- te.angle = 0F;
- te.isDirty = true;
- }
- if (te.hasGem){
- dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.gem.copy());
- te.gem = new ItemStack(Item.getItemById(0), 0, 0);
- te.hasGem = false;
- te.carving = -1;
- te.crafting = false;
- te.angle = 0F;
- te.isDirty = true;
- }
- }else if (te.hasEndItem){
- dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.endItem.copy());
- te.endItem = new ItemStack(Item.getItemById(0), 0, 0);
- te.hasEndItem = false;
- te.isDirty = true;
- }else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".table.iscrafting", te.jewelry.getDisplayName()) + " (" + (ConfigHandler.GEM_PLACEMENT_TIME - te.carving) * 100 / ConfigHandler.GEM_PLACEMENT_TIME + "%)"));
- else if (!te.hasGem) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missinggem")));
- else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missingjewelry")));
- }
-
- /**
- * @param iblockaccess
- * @param i
- * @param j
- * @param k
- * @param l
- * @return
- */
- @Override
- public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
- {
- return false;
- }
-
- /**
- * @return
- */
- @Override
- public boolean isOpaqueCube()
- {
- return false;
- }
-
- /**
- * @return
- */
- @Override
- public int getRenderType()
- {
- return -1;
- }
-
- /**
- * @param icon
- */
- @Override
- public void registerBlockIcons(IIconRegister icon)
- {
- blockIcon = icon.registerIcon(Variables.MODID + ":jewelrsCraftingTable");
- }
-}
+package darkknight.jewelrycraft.block;
+
+import java.util.Random;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
+
+public class BlockJewelrsCraftingTable extends BlockContainer {
+ Random rand = new Random();
+
+ protected BlockJewelrsCraftingTable(Material par2Material) {
+ super(par2Material);
+ setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new TileEntityJewelrsCraftingTable();
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
+ TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k);
+ ItemStack item = entityPlayer.inventory.getCurrentItem();
+ if (te != null && !world.isRemote) {
+ if (te.hasEndItem && item != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.hasenditem")));
+ if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)) {
+ te.setJewelryItemStack(item);
+ if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
+ }
+ if (!te.hasEndItem && !te.hasGem && item != null && JewelrycraftUtil.isGem(item)) {
+ te.setGemItemStack(item);
+ if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
+ }
+ if (!te.hasEndItem && te.hasJewelry && te.hasGem && !te.crafting) te.setCrafting();
+ }
+ return true;
+ }
+
+ public void dropItem(World world, double x, double y, double z, ItemStack stack) {
+ EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack);
+ entityitem.motionX = 0;
+ entityitem.motionZ = 0;
+ entityitem.motionY = 0.21000000298023224D;
+ world.spawnEntityInWorld(entityitem);
+ }
+
+ @Override
+ public void breakBlock(World world, int i, int j, int k, Block par5, int par6) {
+ TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k);
+ if (te != null) {
+ if (te.hasJewelry) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.jewelry.copy());
+ if (te.hasGem) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.gem.copy());
+ if (te.hasEndItem) dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.endItem.copy());
+ world.removeTileEntity(i, j, k);
+ }
+ super.breakBlock(world, i, j, k, par5, par6);
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) {
+ int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ world.setBlockMetadataWithNotify(i, j, k, rotation, 2);
+ }
+
+ @Override
+ public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) {
+ TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k);
+ if (te != null && !world.isRemote) if (player.isSneaking()) {
+ if (te.hasJewelry) te.removeJewelry();
+ if (te.hasGem) te.removeGem();
+ }
+ else if (te.hasEndItem) te.removeResult();
+ else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".table.iscrafting", te.jewelry.getDisplayName()) + " (" + (ConfigHandler.GEM_PLACEMENT_TIME - te.carving) * 100 / ConfigHandler.GEM_PLACEMENT_TIME + "%)"));
+ else if (!te.hasGem) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missinggem")));
+ else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missingjewelry")));
+ }
+
+ @Override
+ public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ return false;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public int getRenderType() {
+ return -1;
+ }
+
+ @Override
+ public void registerBlockIcons(IIconRegister icon) {
+ blockIcon = icon.registerIcon(Variables.MODID + ":jewelrsCraftingTable");
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockList.java b/src/main/java/darkknight/jewelrycraft/block/BlockList.java
index 990a77f..032797c 100644
--- a/src/main/java/darkknight/jewelrycraft/block/BlockList.java
+++ b/src/main/java/darkknight/jewelrycraft/block/BlockList.java
@@ -1,74 +1,76 @@
-package darkknight.jewelrycraft.block;
-
-import net.minecraft.block.Block;
-import net.minecraft.block.material.Material;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidRegistry;
-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.tileentity.TileEntityBlockShadow;
-import darkknight.jewelrycraft.tileentity.TileEntityCrystal;
-import darkknight.jewelrycraft.tileentity.TileEntityDisplayer;
-import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal;
-import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable;
-import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch;
-import darkknight.jewelrycraft.tileentity.TileEntityMolder;
-import darkknight.jewelrycraft.tileentity.TileEntityShadowEye;
-import darkknight.jewelrycraft.tileentity.TileEntityShadowHand;
-import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
-import darkknight.jewelrycraft.util.Variables;
-
-public class BlockList
-{
- public static Block shadowOre, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, handPedestal, shadowHand, midasTouchBlock, crystal;
- public static BlockMoltenMetal moltenMetal;
- public static Fluid moltenMetalFluid;
- private static boolean isInitialized = false;
-
- public static void preInit(FMLPreInitializationEvent e)
- {
- shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockTextureName(Variables.MODID + ":oreShadow").setBlockName(Variables.MODID + ".oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
- smelter = new BlockSmelter().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".smelter").setCreativeTab(JewelrycraftMod.jewelrycraft);
- molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".molder").setCreativeTab(JewelrycraftMod.jewelrycraft);
- displayer = new BlockDisplayer(Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".displayer").setCreativeTab(JewelrycraftMod.jewelrycraft);
- jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft);
- shadowBlock = new BlockShadow().setHardness(5.0F).setResistance(7.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName(Variables.MODID + ":blockShadow").setBlockName(Variables.MODID + ".blockShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
- shadowEye = new BlockShadowEye().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowEye").setCreativeTab(JewelrycraftMod.jewelrycraft);
- handPedestal = new BlockHandPedestal(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".handPedestal").setCreativeTab(JewelrycraftMod.jewelrycraft);
- shadowHand = new BlockShadowHand(Material.rock).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowHand").setCreativeTab(JewelrycraftMod.jewelrycraft).setBlockUnbreakable();
- midasTouchBlock = new BlockMidasTouch(Material.iron).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".midasTouchBlock");
- moltenMetalFluid = new Fluid("metal.molten").setLuminosity(15).setDensity(3000).setTemperature(2000).setViscosity(6000);
- if (!FluidRegistry.registerFluid(moltenMetalFluid)) moltenMetalFluid = FluidRegistry.getFluid("metal.molten");
- moltenMetal = new BlockMoltenMetal(moltenMetalFluid, Material.lava);
- crystal = new BlockCrystal().setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeGlass).setBlockTextureName(Variables.MODID + ":blockCrystal").setBlockName(Variables.MODID + ".blockCrystal").setCreativeTab(JewelrycraftMod.jewelrycraft);
-
- GameRegistry.registerBlock(shadowOre, "shadowOre");
- GameRegistry.registerBlock(shadowBlock, "shadowBlock");
- GameRegistry.registerBlock(smelter, "Smelter");
- GameRegistry.registerBlock(molder, "Molder");
- GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable");
- GameRegistry.registerBlock(displayer, "Displayer");
- GameRegistry.registerBlock(shadowEye, "Shadow Eye");
- GameRegistry.registerBlock(handPedestal, "Stone Bricks Pedestal");
- GameRegistry.registerBlock(shadowHand, "Shadow Hand");
- GameRegistry.registerBlock(midasTouchBlock, "Midas Touch Block");
- GameRegistry.registerBlock(moltenMetal, "moltenMetalLiquid");
- GameRegistry.registerBlock(crystal, BlockItemCrystal.class, "crystalBlock");
-
- GameRegistry.registerTileEntity(TileEntitySmelter.class, Variables.MODID + ":smelter");
- GameRegistry.registerTileEntity(TileEntityMolder.class, Variables.MODID + ":molder");
- GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, Variables.MODID + ":table");
- GameRegistry.registerTileEntity(TileEntityDisplayer.class, Variables.MODID + ":displayer");
- GameRegistry.registerTileEntity(TileEntityBlockShadow.class, Variables.MODID + ":blockShadow");
- GameRegistry.registerTileEntity(TileEntityShadowEye.class, Variables.MODID + ":shadowEye");
- GameRegistry.registerTileEntity(TileEntityHandPedestal.class, Variables.MODID + ":handPedestal");
- GameRegistry.registerTileEntity(TileEntityShadowHand.class, Variables.MODID + ":shadowHand");
- GameRegistry.registerTileEntity(TileEntityMidasTouch.class, Variables.MODID + ":midsaTouch");
- GameRegistry.registerTileEntity(TileEntityCrystal.class, Variables.MODID + ":crystalBlock");
-
- OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre));
- }
-}
+package darkknight.jewelrycraft.block;
+
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.GameRegistry;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow;
+import darkknight.jewelrycraft.tileentity.TileEntityCrystal;
+import darkknight.jewelrycraft.tileentity.TileEntityDisplayer;
+import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal;
+import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable;
+import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch;
+import darkknight.jewelrycraft.tileentity.TileEntityMolder;
+import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal;
+import darkknight.jewelrycraft.tileentity.TileEntityShadowEye;
+import darkknight.jewelrycraft.tileentity.TileEntityShadowHand;
+import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
+import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class BlockList
+{
+ public static Block shadowOre, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, handPedestal, shadowHand, midasTouchBlock, crystal;
+ public static BlockMoltenMetal moltenMetal;
+ public static Fluid moltenMetalFluid;
+ private static boolean isInitialized = false;
+
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockTextureName(Variables.MODID + ":oreShadow").setBlockName(Variables.MODID + ".oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ smelter = new BlockSmelter().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".smelter").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".molder").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ displayer = new BlockDisplayer(Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".displayer").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ shadowBlock = new BlockShadow().setHardness(5.0F).setResistance(7.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName(Variables.MODID + ":blockShadow").setBlockName(Variables.MODID + ".blockShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ shadowEye = new BlockShadowEye().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowEye").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ handPedestal = new BlockHandPedestal(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".handPedestal").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ shadowHand = new BlockShadowHand(Material.rock).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowHand").setCreativeTab(JewelrycraftMod.jewelrycraft).setBlockUnbreakable();
+ midasTouchBlock = new BlockMidasTouch(Material.iron).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".midasTouchBlock");
+ moltenMetalFluid = new Fluid("metal.molten").setLuminosity(15).setDensity(3000).setTemperature(2000).setViscosity(6000);
+ if (!FluidRegistry.registerFluid(moltenMetalFluid)) moltenMetalFluid = FluidRegistry.getFluid("metal.molten");
+ moltenMetal = new BlockMoltenMetal(moltenMetalFluid, Material.lava);
+ crystal = new BlockCrystal().setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeGlass).setBlockTextureName(Variables.MODID + ":blockCrystal").setBlockName(Variables.MODID + ".blockCrystal").setCreativeTab(JewelrycraftMod.jewelrycraft);
+
+ GameRegistry.registerBlock(shadowOre, "shadowOre");
+ GameRegistry.registerBlock(shadowBlock, "shadowBlock");
+ GameRegistry.registerBlock(smelter, "Smelter");
+ GameRegistry.registerBlock(molder, "Molder");
+ GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable");
+ GameRegistry.registerBlock(displayer, "Displayer");
+ GameRegistry.registerBlock(shadowEye, "Shadow Eye");
+ GameRegistry.registerBlock(handPedestal, "Stone Bricks Pedestal");
+ GameRegistry.registerBlock(shadowHand, "Shadow Hand");
+ GameRegistry.registerBlock(midasTouchBlock, "Midas Touch Block");
+ GameRegistry.registerBlock(moltenMetal, "moltenMetalLiquid");
+ GameRegistry.registerBlock(crystal, BlockItemCrystal.class, "crystalBlock");
+
+ GameRegistry.registerTileEntity(TileEntitySmelter.class, Variables.MODID + ":smelter");
+ GameRegistry.registerTileEntity(TileEntityMolder.class, Variables.MODID + ":molder");
+ GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, Variables.MODID + ":table");
+ GameRegistry.registerTileEntity(TileEntityDisplayer.class, Variables.MODID + ":displayer");
+ GameRegistry.registerTileEntity(TileEntityBlockShadow.class, Variables.MODID + ":blockShadow");
+ GameRegistry.registerTileEntity(TileEntityShadowEye.class, Variables.MODID + ":shadowEye");
+ GameRegistry.registerTileEntity(TileEntityHandPedestal.class, Variables.MODID + ":handPedestal");
+ GameRegistry.registerTileEntity(TileEntityShadowHand.class, Variables.MODID + ":shadowHand");
+ GameRegistry.registerTileEntity(TileEntityMidasTouch.class, Variables.MODID + ":midsaTouch");
+ GameRegistry.registerTileEntity(TileEntityCrystal.class, Variables.MODID + ":crystalBlock");
+ GameRegistry.registerTileEntity(TileEntityMoltenMetal.class, Variables.MODID + ":moltenMetalTE");
+
+ OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre));
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
index 2525dd3..0995cc3 100644
--- a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
+++ b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
@@ -2,276 +2,167 @@ package darkknight.jewelrycraft.block;
import java.io.IOException;
import java.util.Random;
-
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.network.PacketRequestLiquidData;
-import darkknight.jewelrycraft.network.PacketSendLiquidData;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.Variables;
-public class BlockMoltenMetal extends BlockFluidClassic
-{
- @SideOnly (Side.CLIENT)
- protected IIcon stillIcon;
- @SideOnly (Side.CLIENT)
- protected IIcon flowingIcon;
-
- /**
- * @param fluid
- * @param material
- */
- public BlockMoltenMetal(Fluid fluid, Material material)
- {
- super(fluid, material);
- setBlockName(Variables.MODID + ".moltenMetal");
- setQuantaPerBlock(5);
- setRenderPass(1);
- setLightLevel(15f);
- }
-
- /**
- * @param side
- * @param meta
- * @return
- */
- @Override
- public IIcon getIcon(int side, int meta)
- {
- return side == 0 || side == 1 ? stillIcon : flowingIcon;
- }
-
- /**
- * @param register
- */
- @Override
- @SideOnly (Side.CLIENT)
- public void registerBlockIcons(IIconRegister register)
- {
- stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill");
- flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow");
- }
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @return
- */
- @Override
- public boolean canDisplace(IBlockAccess world, int x, int y, int z)
- {
- if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
- return super.canDisplace(world, x, y, z);
- }
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @return
- */
- @Override
- public boolean displaceIfPossible(World world, int x, int y, int z)
- {
- if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
- return super.displaceIfPossible(world, x, y, z);
- }
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @return
- */
- @Override
- protected boolean canFlowInto(IBlockAccess world, int x, int y, int z)
- {
- if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true;
- Block block = world.getBlock(x, y, z);
- if (block == this) return false;
- if (displacements.containsKey(block)) return displacements.get(block);
- Material material = block.getMaterial();
- if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) return false;
- int density = getDensity(world, x, y, z);
- if (density == Integer.MAX_VALUE) return true;
- if (this.density > density) return true;
- else return false;
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @return
- */
- @Override
- @SideOnly (Side.CLIENT)
- public int colorMultiplier(IBlockAccess world, int i, int j, int k)
- {
- try{
- return color(world, i, j, k, false, null);
- }
- catch(IOException e){
- e.printStackTrace();
- }
- return 0;
- }
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @param rand
- */
- @Override
- public void updateTick(World world, int x, int y, int z, Random rand)
- {
- int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
- int expQuanta = -101;
- // check adjacent block levels if non-source
- if (quantaRemaining < quantaPerBlock){
- int y2 = y - densityDir;
- if (world.getBlock(x, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x - 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x + 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z - 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z + 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) expQuanta = quantaPerBlock - 1;
- else{
- int maxQuanta = -100;
- if (JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta);
- if (JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta);
- if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta);
- if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta);
- expQuanta = maxQuanta - 1;
- }
- // decay calculation
- if (expQuanta != quantaRemaining){
- quantaRemaining = expQuanta;
- if (expQuanta <= 0) world.setBlock(x, y, z, Blocks.air);
- else{
- world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
- world.scheduleBlockUpdate(x, y, z, this, tickRate);
- world.notifyBlocksOfNeighborChange(x, y, z, this);
- }
- }
- }
- // This is a "source" block, set meta to zero, and send a server only
- // update
- else if (quantaRemaining >= quantaPerBlock) world.setBlockMetadataWithNotify(x, y, z, 0, 2);
- String originData = JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId));
- // Flow vertically if possible
- if (canDisplace(world, x, y + densityDir, z)){
- JewelrycraftMod.saveData.setString(stringFromLocation(x, y + densityDir, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)));
- flowIntoBlock(world, x, y + densityDir, z, 1, originData);
- return;
- }
- // Flow outward if possible
- int flowMeta = quantaPerBlock - quantaRemaining + 1;
- if (flowMeta >= quantaPerBlock) return;
- if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)){
- if (world.getBlock(x, y - densityDir, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y - densityDir, z, world.provider.dimensionId)))) flowMeta = 1;
- boolean flowTo[] = getOptimalFlowDirections(world, x, y, z);
- if (flowTo[0]){
- if (JewelrycraftMod.saveData.getTag(stringFromLocation(x - 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x - 1, y, z).isAir(world, x - 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x - 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)));
- flowIntoBlock(world, x - 1, y, z, flowMeta, originData);
- }
- if (flowTo[1]){
- if (JewelrycraftMod.saveData.getTag(stringFromLocation(x + 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x + 1, y, z).isAir(world, x + 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x + 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)));
- flowIntoBlock(world, x + 1, y, z, flowMeta, originData);
- }
- if (flowTo[2]){
- if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z - 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z - 1).isAir(world, x, y, z - 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z - 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)));
- flowIntoBlock(world, x, y, z - 1, flowMeta, originData);
- }
- if (flowTo[3]){
- if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z + 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z + 1).isAir(world, x, y, z + 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z + 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)));
- flowIntoBlock(world, x, y, z + 1, flowMeta, originData);
- }
- }
- }
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @param meta
- * @param originData
- */
- public void flowIntoBlock(World world, int x, int y, int z, int meta, String originData)
- {
- if (meta < 0 || world.isRemote) return;
- if (displaceIfPossible(world, x, y, z)){
- world.setBlock(x, y, z, this, meta, 3);
- JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z, world.provider.dimensionId), originData);
- String[] data = originData.split(":");
- try{
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1])));
- }
- catch(Exception e){
- System.out.println("The liquids file is either corrupt, missing or the metal for the liquid simply doesn't exist!");
- }
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param forcecolor
- * @param itemC
- * @return
- * @throws IOException
- */
- @SideOnly (Side.CLIENT)
- public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException
- {
- String ingotData = JewelrycraftMod.clientData.getString(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k) + " " + Minecraft.getMinecraft().theWorld.provider.dimensionId);
- if (ingotData == ""){
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestLiquidData(Minecraft.getMinecraft().theWorld.provider.dimensionId, i, j, k));
- return 0xFFFFFF;
- }else{
- String[] splitData = ingotData.split(":");
- if (splitData.length == 2){
- int color;
- try{
- Integer.parseInt(splitData[0]);
- Integer.parseInt(splitData[1]);
- return JewelrycraftUtil.getColor(new ItemStack(Item.getItemById(Integer.parseInt(splitData[0])), 1, Integer.parseInt(splitData[1])));
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- }
- return 16777215;
- }
-
- /**
- * @param x
- * @param y
- * @param z
- * @param dimID
- * @return
- */
- public static String stringFromLocation(int x, int y, int z, int dimID)
- {
- return x + " " + y + " " + z + " " + dimID;
- }
+public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityProvider {
+ @SideOnly(Side.CLIENT)
+ protected IIcon stillIcon;
+ @SideOnly(Side.CLIENT)
+ protected IIcon flowingIcon;
+
+ public BlockMoltenMetal(Fluid fluid, Material material) {
+ super(fluid, material);
+ setBlockName(Variables.MODID + ".moltenMetal");
+ setQuantaPerBlock(5);
+ setRenderPass(1);
+ setLightLevel(15f);
+ }
+
+ @Override
+ public IIcon getIcon(int side, int meta) {
+ return side == 0 || side == 1 ? stillIcon : flowingIcon;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister register) {
+ stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill");
+ flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow");
+ }
+
+ @Override
+ public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
+ return super.canDisplace(world, x, y, z);
+ }
+
+ @Override
+ public boolean displaceIfPossible(World world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
+ return super.displaceIfPossible(world, x, y, z);
+ }
+
+ @Override
+ protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true;
+ Block block = world.getBlock(x, y, z);
+ if (block == this) return false;
+ if (displacements.containsKey(block)) return displacements.get(block);
+ Material material = block.getMaterial();
+ if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) return false;
+ int density = getDensity(world, x, y, z);
+ if (density == Integer.MAX_VALUE) return true;
+ if (this.density > density) return true;
+ else return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int colorMultiplier(IBlockAccess world, int i, int j, int k) {
+ try {
+ return color(world, i, j, k, false, null);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
+
+ @Override
+ public void updateTick(World world, int x, int y, int z, Random rand) {
+ if (getTileEntity(world, x, y, z) == null || (getTileEntity(world, x, y, z).getMetal() == null)) world.setBlockToAir(x, y, z);
+ else {
+ int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
+ int expQuanta = -101;
+ // check adjacent block levels if non-source
+ if (quantaRemaining < quantaPerBlock) {
+ int y2 = y - densityDir;
+ if ((world.getBlock(x, y2, z) == this && getTileEntity(world, x, y2, z) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z, x, y, z)) || (world.getBlock(x - 1, y2, z) == this && getTileEntity(world, x - 1, y2, z) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x - 1, y2, z, x, y, z)) || (world.getBlock(x + 1, y2, z) == this && getTileEntity(world, x + 1, y2, z) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x + 1, y2, z, x, y, z)) || (world.getBlock(x, y2, z - 1) == this && getTileEntity(world, x, y2, z - 1) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z - 1, x, y, z)) || (world.getBlock(x, y2, z + 1) == this && getTileEntity(world, x, y2, z + 1) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z + 1, x, y, z))) expQuanta = quantaPerBlock - 1;
+ else {
+ int maxQuanta = -100;
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x - 1, y, z) != null && areMetalsEqual(world, x, y, z, x - 1, y, z)) maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x + 1, y, z) != null && areMetalsEqual(world, x, y, z, x + 1, y, z)) maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y, z - 1) != null && areMetalsEqual(world, x, y, z, x, y, z - 1)) maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y, z + 1) != null && areMetalsEqual(world, x, y, z, x, y, z + 1)) maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta);
+ expQuanta = maxQuanta - 1;
+ }
+ // decay calculation
+ if (expQuanta != quantaRemaining) {
+ quantaRemaining = expQuanta;
+ if (expQuanta <= 0) world.setBlock(x, y, z, Blocks.air);
+ else {
+ world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
+ world.scheduleBlockUpdate(x, y, z, this, tickRate);
+ world.notifyBlocksOfNeighborChange(x, y, z, this);
+ }
+ }
+ }
+ // This is a "source" block, set meta to zero, and send a server only update
+ else if (quantaRemaining >= quantaPerBlock) world.setBlockMetadataWithNotify(x, y, z, 0, 2);
+ // Flow vertically if possible
+ if (canDisplace(world, x, y + densityDir, z)) {
+ if (getTileEntity(world, x, y + densityDir, z) != null && getTileEntity(world, x, y, z) != null) this.getTileEntity(world, x, y + densityDir, z).setMetal(getTileEntity(world, x, y, z).getMetal());
+ flowIntoBlock(world, x, y + densityDir, z, 1, getTileEntity(world, x, y, z).getMetal());
+ return;
+ }
+ // Flow outward if possible
+ int flowMeta = quantaPerBlock - quantaRemaining + 1;
+ if (flowMeta >= quantaPerBlock) return;
+ if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)) {
+ if (world.getBlock(x, y - densityDir, z) == this && getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y - densityDir, z) != null && areMetalsEqual(world, x, y, z, x, y - densityDir, z)) flowMeta = 1;
+ boolean flowTo[] = getOptimalFlowDirections(world, x, y, z);
+ if (flowTo[0]) flowIntoBlock(world, x - 1, y, z, flowMeta, getTileEntity(world, x, y, z).getMetal());
+ if (flowTo[1]) flowIntoBlock(world, x + 1, y, z, flowMeta, getTileEntity(world, x, y, z).getMetal());
+ if (flowTo[2]) flowIntoBlock(world, x, y, z - 1, flowMeta, getTileEntity(world, x, y, z).getMetal());
+ if (flowTo[3]) flowIntoBlock(world, x, y, z + 1, flowMeta, getTileEntity(world, x, y, z).getMetal());
+ }
+ }
+ }
+
+ public void flowIntoBlock(World world, int x, int y, int z, int meta, ItemStack metal) {
+ if (meta < 0 || world.isRemote) return;
+ if (displaceIfPossible(world, x, y, z)) {
+ world.setBlock(x, y, z, this, meta, 3);
+ if (getTileEntity(world, x, y, z) != null) getTileEntity(world, x, y, z).setMetal(metal);
+ }
+ }
+
+ public static TileEntityMoltenMetal getTileEntity(World world, int x, int y, int z) {
+ TileEntity moltenLiquid = world.getTileEntity(x, y, z);
+ if (moltenLiquid != null && moltenLiquid instanceof TileEntityMoltenMetal) return (TileEntityMoltenMetal) moltenLiquid;
+ return null;
+ }
+
+ public static boolean areMetalsEqual(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
+ return ItemStack.areItemStacksEqual(getTileEntity(world, x1, y1, z1).getMetal(), getTileEntity(world, x2, y2, z2).getMetal());
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException {
+ TileEntity te = world.getTileEntity(i, j, k);
+ if (te instanceof TileEntityMoltenMetal && ((TileEntityMoltenMetal) te).getMetal() != null) return JewelrycraftUtil.getColor(((TileEntityMoltenMetal) te).getMetal().copy());
+ return 16777215;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int value) {
+ return new TileEntityMoltenMetal();
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java
index 1e68e34..cd24deb 100644
--- a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java
+++ b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java
@@ -1,7 +1,15 @@
package darkknight.jewelrycraft.block;
import java.util.Random;
-
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.item.ItemMoltenMetalBucket;
+import darkknight.jewelrycraft.tileentity.TileEntityMolder;
+import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal;
+import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -13,246 +21,196 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.item.ItemMoltenMetalBucket;
-import darkknight.jewelrycraft.network.PacketSendLiquidData;
-import darkknight.jewelrycraft.tileentity.TileEntityMolder;
-import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.Variables;
-public class BlockSmelter extends BlockContainer
-{
- Random rand = new Random();
-
- public BlockSmelter()
- {
- super(Material.rock);
- }
-
- @Override
- public TileEntity createNewTileEntity(World world, int var2)
- {
- return new TileEntitySmelter();
- }
-
- @Override
- public boolean renderAsNormalBlock()
- {
- return false;
- }
-
- /**
- * Spawns an item in the world at the specified location
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @param stack
- */
- public void dropItem(World world, double x, double y, double z, ItemStack stack)
- {
- EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack);
- entityitem.motionX = 0;
- entityitem.motionZ = 0;
- entityitem.motionY = 0.11000000298023224D;
- entityitem.delayBeforeCanPickup = 0;
- world.spawnEntityInWorld(entityitem);
- }
-
- @Override
- public void breakBlock(World world, int i, int j, int k, Block par5, int par6)
- {
- TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k);
- if (te != null){
- if (te.hasMetal) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy());
- if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0){
- ItemStack metal = te.moltenMetal;
- ItemStack item = te.moltenMetal;
- if (Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) metal.setItemDamage(15 - metal.getItemDamage());
- JewelryNBT.addMetal(item, metal);
- JewelrycraftMod.saveData.setString(i + " " + j + " " + k + " " + world.provider.dimensionId, Item.getIdFromItem(metal.getItem()) + ":" + metal.getItemDamage());
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, i, j, k, Item.getIdFromItem(metal.getItem()), metal.getItemDamage()));
- world.setBlock(i, j, k, BlockList.moltenMetal, 0, 3);
- int quant = (int)(te.quantity * 10);
- if (quant == 1) world.setBlockMetadataWithNotify(i, j, k, 4, 3);
- if (quant == 2) world.setBlockMetadataWithNotify(i, j, k, 4, 3);
- if (quant == 3) world.setBlockMetadataWithNotify(i, j, k, 3, 3);
- if (quant == 4) world.setBlockMetadataWithNotify(i, j, k, 3, 3);
- if (quant == 5) world.setBlockMetadataWithNotify(i, j, k, 2, 3);
- if (quant == 6) world.setBlockMetadataWithNotify(i, j, k, 2, 3);
- if (quant == 7) world.setBlockMetadataWithNotify(i, j, k, 1, 3);
- if (quant == 8) world.setBlockMetadataWithNotify(i, j, k, 1, 3);
- if (quant == 9) world.setBlockMetadataWithNotify(i, j, k, 0, 3);
- }
- world.removeTileEntity(i, j, k);
- }
- super.breakBlock(world, i, j, k, par5, par6);
- }
-
- @Override
- public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
- {
- TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k);
- ItemStack item = entityPlayer.inventory.getCurrentItem();
- if (te != null && te.hasMoltenMetal && te.quantity >= .9f && !te.pouring && item != null && item.getItem() == Items.bucket){
- te.quantity = 0f;
- te.hasMoltenMetal = false;
- ItemStack metalBucket = new ItemStack(ItemList.bucket, 1);
- ItemStack ingot = te.moltenMetal.copy();
- if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage());
- JewelryNBT.addMetal(metalBucket, ingot);
- --item.stackSize;
- entityPlayer.inventory.addItemStackToInventory(metalBucket);
- te.isDirty = true;
- return true;
- }
- if (te != null && !world.isRemote){
- if (te.hasMetal && entityPlayer.isSneaking()){
- dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy());
- te.hasMetal = false;
- te.melting = -1;
- te.isDirty = true;
- }
- if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)){
- int index = -1;
- for(int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++)
- if (entityPlayer.getUniqueID().toString().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a;
- if(entityPlayer.capabilities.isCreativeMode) index = 1;
- boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0 || JewelryNBT.ingot(item) != null);
- boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false;
- isOre = JewelrycraftUtil.isOre(item);
- if (te.metal != null && te.metal.getItem() != null) {
- if(JewelryNBT.ingot(item) == null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage();
- else itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage() && JewelryNBT.ingot(item).getItem().equals(JewelryNBT.ingot(te.metal).getItem()) && JewelryNBT.ingot(item).getItemDamage() == JewelryNBT.ingot(te.metal).getItemDamage();
- }
- if (te.moltenMetal != null && te.moltenMetal.getItem() != null){
- if(JewelryNBT.ingot(item) == null) itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage();
- else itemCoincidesWithMoltenMetal = JewelryNBT.ingot(item).getItem().equals(te.moltenMetal.getItem()) && JewelryNBT.ingot(item).getItemDamage() == te.moltenMetal.getItemDamage();
- if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item).getItemDamage();
- }
- overflow = isOre ? te.metal.stackSize * 0.2f + te.quantity < 0.8f : te.metal.stackSize*0.1f + te.quantity < 0.9f;
- boolean isValid = te.hasMoltenMetal ? isOre ? oreCoincidesWithMetal : itemCoincidesWithMoltenMetal : true;
- if (te.quantity < 0.9f && !te.pouring && canPlace && isValid){
- boolean check = isOre ? oreCoincidesWithMetal && te.quantity < 0.8f : itemCoincidesWithMoltenMetal;
- boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal;
- if (!te.hasMetal && !te.hasMoltenMetal || !te.hasMetal && te.hasMoltenMetal && check){
- entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.nowsmeltingingot", item.getDisplayName())));
- te.metal = item.copy();
- // if (Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) te.metal.setItemDamage(15 - te.metal.getItemDamage());
- te.metal.stackSize = 1;
- te.hasMetal = true;
- te.melting = ConfigHandler.INGOT_MELTING_TIME;
- if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
- te.isDirty = true;
- }else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow){
- entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")")));
- te.metal.stackSize++;
- te.hasMetal = true;
- te.melting += ConfigHandler.INGOT_MELTING_TIME;
- if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
- te.isDirty = true;
- }
- te.isDirty = true;
- }else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.contentdoesnotmatch")));
- else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().toLowerCase().contains("ingot") && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.itemrenamedtoingot")));
- else if (item != null && te.quantity >= .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.full")));
- else entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.cannotsmelt")));
- }else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal){
- te.hasMoltenMetal = true;
- ItemStack ingot = JewelryNBT.ingot(item);
- if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage());
- te.moltenMetal = ingot;
- te.quantity = .9f;
- te.isDirty = true;
- if (!entityPlayer.capabilities.isCreativeMode){
- --item.stackSize;
- dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket));
- }
- }
- else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.hasmolteningot", te.moltenMetal.getDisplayName().replace(" Ingot",""))));
- world.setTileEntity(i, j, k, te);
- }
- return true;
- }
-
- @Override
- public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player)
- {
- TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k);
- TileEntityMolder me = null;
- if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k - 1);
- else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i + 1, j, k);
- else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k + 1);
- else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i - 1, j, k);
- if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase){
- te.pouring = true;
- te.isDirty = true;
- }else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)"));
- else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing")));
- else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold")));
- else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal")));
- else if (me.hasJewelBase && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.modlerhasitem")));
- else player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.empty")));
- }
-
- /**
- * Determines if a molder is placed in front of this
- *
- * @param world
- * @param i
- * @param j
- * @param k
- * @return true if a molder is attached, false otherwise
- */
- public boolean isConnectedToMolder(World world, int i, int j, int k)
- {
- int blockMeta = world.getBlockMetadata(i, j, k);
- if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) return true;
- else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) return true;
- else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) return true;
- else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) return true;
- return false;
- }
-
- @Override
- public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack)
- {
- int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
- world.setBlockMetadataWithNotify(i, j, k, rotation, 2);
- }
+public class BlockSmelter extends BlockContainer {
+ Random rand = new Random();
+
+ public BlockSmelter() {
+ super(Material.rock);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new TileEntitySmelter();
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ public void dropItem(World world, double x, double y, double z, ItemStack stack) {
+ EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack);
+ entityitem.motionX = 0;
+ entityitem.motionZ = 0;
+ entityitem.motionY = 0.11000000298023224D;
+ entityitem.delayBeforeCanPickup = 0;
+ world.spawnEntityInWorld(entityitem);
+ }
+
+ @Override
+ public void breakBlock(World world, int i, int j, int k, Block block, int meta) {
+ TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k);
+ if (te != null) {
+ if (te.hasMetal) dropItem(world, i, j, k, te.metal.copy());
+ if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0) {
+ int quant = (int) (te.quantity * 10);
+ ItemStack metalBucket = new ItemStack(ItemList.bucket);
+ JewelryNBT.addMetal(metalBucket, te.moltenMetal.copy());
+ if (quant == 9){
+ dropItem(world, i, j, k, new ItemStack(Blocks.cobblestone, 6));
+ dropItem(world, i, j, k, new ItemStack(Items.lava_bucket));
+ dropItem(world, i, j, k, metalBucket);
+ }
+ }
+ world.removeTileEntity(i, j, k);
+ }
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
+ TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k);
+ ItemStack item = entityPlayer.inventory.getCurrentItem();
+ if (te != null && te.hasMoltenMetal && te.quantity >= .9f && !te.pouring && item != null && item.getItem() == Items.bucket) {
+ te.quantity = 0f;
+ te.hasMoltenMetal = false;
+ ItemStack metalBucket = new ItemStack(ItemList.bucket, 1);
+ ItemStack ingot = te.moltenMetal.copy();
+ JewelryNBT.addMetal(metalBucket, ingot);
+ --item.stackSize;
+ entityPlayer.inventory.addItemStackToInventory(metalBucket);
+ te.isDirty = true;
+ return true;
+ }
+ if (te != null && !world.isRemote) {
+ if (te.hasMetal && entityPlayer.isSneaking()) {
+ dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy());
+ te.hasMetal = false;
+ te.melting = -1;
+ te.isDirty = true;
+ }
+ if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)) {
+ int index = -1;
+ for (int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++)
+ if (entityPlayer.getUniqueID().toString().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a;
+ if (entityPlayer.capabilities.isCreativeMode) index = 1;
+ boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0 || JewelryNBT.ingot(item) != null);
+ boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false;
+ isOre = JewelrycraftUtil.isOre(item);
+ if (te.metal != null && te.metal.getItem() != null) {
+ if (JewelryNBT.ingot(item) == null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage();
+ else itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage() && JewelryNBT.ingot(item).getItem().equals(JewelryNBT.ingot(te.metal).getItem()) && JewelryNBT.ingot(item).getItemDamage() == JewelryNBT.ingot(te.metal).getItemDamage();
+ }
+ if (te.moltenMetal != null && te.moltenMetal.getItem() != null) {
+ if (JewelryNBT.ingot(item) == null) itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage();
+ else itemCoincidesWithMoltenMetal = JewelryNBT.ingot(item).getItem().equals(te.moltenMetal.getItem()) && JewelryNBT.ingot(item).getItemDamage() == te.moltenMetal.getItemDamage();
+ if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item).getItemDamage();
+ }
+ overflow = isOre ? te.metal.stackSize * 0.2f + te.quantity < 0.8f : te.metal.stackSize * 0.1f + te.quantity < 0.9f;
+ boolean isValid = te.hasMoltenMetal ? isOre ? oreCoincidesWithMetal : itemCoincidesWithMoltenMetal : true;
+ if (te.quantity < 0.9f && !te.pouring && canPlace && isValid) {
+ boolean check = isOre ? oreCoincidesWithMetal && te.quantity < 0.8f : itemCoincidesWithMoltenMetal;
+ boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal;
+ if (!te.hasMetal && !te.hasMoltenMetal || !te.hasMetal && te.hasMoltenMetal && check) {
+ entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.nowsmeltingingot", item.getDisplayName())));
+ te.metal = item.copy();
+ te.metal.stackSize = 1;
+ te.hasMetal = true;
+ te.melting = ConfigHandler.INGOT_MELTING_TIME;
+ if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
+ te.isDirty = true;
+ }
+ else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow) {
+ entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")")));
+ te.metal.stackSize++;
+ te.hasMetal = true;
+ te.melting += ConfigHandler.INGOT_MELTING_TIME;
+ if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
+ te.isDirty = true;
+ }
+ te.isDirty = true;
+ }
+ else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.contentdoesnotmatch")));
+ else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().toLowerCase().contains("ingot") && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.itemrenamedtoingot")));
+ else if (item != null && te.quantity >= .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.full")));
+ else entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.cannotsmelt")));
+ }
+ else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal) {
+ te.hasMoltenMetal = true;
+ ItemStack ingot = JewelryNBT.ingot(item);
+ te.moltenMetal = ingot;
+ te.quantity = .9f;
+ te.isDirty = true;
+ if (!entityPlayer.capabilities.isCreativeMode) {
+ --item.stackSize;
+ dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket));
+ }
+ }
+ else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.hasmolteningot", te.moltenMetal.getDisplayName().replace(" Ingot", ""))));
+ world.setTileEntity(i, j, k, te);
+ }
+ return true;
+ }
+
+ @Override
+ public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) {
+ TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k);
+ TileEntityMolder me = null;
+ if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i, j, k - 1);
+ else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i + 1, j, k);
+ else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i, j, k + 1);
+ else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i - 1, j, k);
+ if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase) {
+ te.pouring = true;
+ te.isDirty = true;
+ }
+ else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)"));
+ else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing")));
+ else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold")));
+ else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal")));
+ else if (me.hasJewelBase && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.modlerhasitem")));
+ else player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.empty")));
+ }
+
+ public boolean isConnectedToMolder(World world, int i, int j, int k) {
+ int blockMeta = world.getBlockMetadata(i, j, k);
+ if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) return true;
+ else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) return true;
+ else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) return true;
+ else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) return true;
+ return false;
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) {
+ int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ world.setBlockMetadataWithNotify(i, j, k, rotation, 2);
+ }
+
+ @Override
+ public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ return false;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public int getRenderType() {
+ return -1;
+ }
- @Override
- public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
- {
- return false;
- }
-
- @Override
- public boolean isOpaqueCube()
- {
- return false;
- }
-
- @Override
- public int getRenderType()
- {
- return -1;
- }
-
- @Override
- public void registerBlockIcons(IIconRegister icon)
- {
- blockIcon = icon.registerIcon(Variables.MODID + ":smelter");
- }
+ @Override
+ public void registerBlockIcons(IIconRegister icon) {
+ blockIcon = icon.registerIcon(Variables.MODID + ":smelter");
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java
index 0fc2f37..3582c5a 100644
--- a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java
+++ b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java
@@ -1,147 +1,147 @@
-/**
- *
- */
-package darkknight.jewelrycraft.block.render;
-
-import java.util.Random;
-import net.minecraft.block.Block;
-import net.minecraft.client.renderer.RenderBlocks;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.util.IIcon;
-import net.minecraft.world.IBlockAccess;
-import org.lwjgl.opengl.GL11;
-import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.block.BlockCrystal;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.proxy.ClientProxy.BlockRenderIDs;
-import darkknight.jewelrycraft.tileentity.TileEntityCrystal;
-
-/**
- * @author Sorin
- */
-@SideOnly (Side.CLIENT)
-public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler
-{
- @Override
- public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
- {
- Tessellator tessellator = Tessellator.instance;
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- tessellator.startDrawingQuads();
- if (metadata < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[metadata], 100);
- GL11.glTranslatef(-0.5f, 0f, -0.5f);
- this.renderWorldBlock(null, 0, 0, 0, block, modelID, renderer);
- tessellator.draw();
- GL11.glTranslatef(0.5f, 0f, 0.5f);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
-
- @Override
- public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
- {
- int crystals = 5;
- Random rnd = new Random();
- Tessellator tessellator = Tessellator.instance;
- IIcon icon = ((BlockCrystal)block).getIcon(0, 0);
- double umin = icon.getMinU();
- double vmin = icon.getMinV();
- double umax = icon.getMaxU();
- double vmax = icon.getMaxV();
- tessellator.addTranslation(x, y, z);
- if (world != null && world.getTileEntity(x, y, z) != null && ConfigHandler.CRYSTAL_GLOW) tessellator.setBrightness(((TileEntityCrystal)world.getTileEntity(x, y, z)).shine);
- else tessellator.setBrightness(230);
- // 37435, 76464
- if (world != null) rnd.setSeed(2 * x * 3 * y * z * 5);
- else rnd.setSeed(76464);
- if (world != null && world.getBlockMetadata(x, y, z) < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[world.getBlockMetadata(x, y, z)], 100);
- crystal(tessellator, umin, vmin, umax, vmax, 0.8D, 0.2D, 0D, 0D, 0D, 0.0D, 0.0D);
- for(int i = 0; i < crystals; i++){
- double rotation = Math.PI * 2.0f / (float)crystals * (float)i;
- double xp1 = Math.sin(rotation) * 0.2f;
- double zp1 = Math.cos(rotation) * 0.2f;
- double height = 0.2f + rnd.nextFloat();
- double topHeight = 0.1f + rnd.nextFloat() / 2f;
- crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, -xp1, 0D, zp1, xp1, zp1);
- }
- if (world != null){
- crystals = 4;
- for(int i = 0; i < crystals; i++){
- double rotation = Math.PI * 2.0f / (float)crystals * (float)i;
- double xp1 = Math.sin(rotation) * 0.2f;
- double zp1 = Math.cos(rotation) * 0.2f;
- double height = 0.2f + rnd.nextFloat();
- double topHeight = 0.1f + rnd.nextFloat() / 2f;
- float xOff = (rnd.nextFloat() * 1.5f - 0.5f) * 0.2f;
- float zOff = (rnd.nextFloat() * 1.5f - 0.5f) * 0.2f;
- crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, xOff, 0D, zOff, xp1, zp1);
- }
- }
- tessellator.addTranslation(-x, -y, -z);
- return true;
- }
-
- private void crystal(Tessellator tessellator, double umin, double vmin, double umax, double vmax, double height, double topHeight, double posX, double posY, double posZ, double rotX, double rotZ)
- {
- // Negative X
- tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin);
- // Positive X
- tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin);
- // Negative Z
- tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin);
- // Positive Z
- tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin);
- // Top -X
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin);
- // Top +X
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin);
- // Top +Z
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin);
- // Top -Z
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin);
- // Bottom
- tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmax);
- tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin);
- }
-
- @Override
- public boolean shouldRender3DInInventory(int modelId)
- {
- return true;
- }
-
- @Override
- public int getRenderId()
- {
- return BlockRenderIDs.CRYSTAL.id();
- }
-}
+/**
+ *
+ */
+package darkknight.jewelrycraft.block.render;
+
+import java.util.Random;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.block.BlockCrystal;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.proxy.ClientProxy.BlockRenderIDs;
+import darkknight.jewelrycraft.tileentity.TileEntityCrystal;
+
+/**
+ * @author Sorin
+ */
+@SideOnly (Side.CLIENT)
+public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler
+{
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
+ {
+ Tessellator tessellator = Tessellator.instance;
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ tessellator.startDrawingQuads();
+ if (metadata < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[metadata], 100);
+ GL11.glTranslatef(-0.5f, 0f, -0.5f);
+ this.renderWorldBlock(null, 0, 0, 0, block, modelID, renderer);
+ tessellator.draw();
+ GL11.glTranslatef(0.5f, 0f, 0.5f);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
+ {
+ int crystals = 5;
+ Random rnd = new Random();
+ Tessellator tessellator = Tessellator.instance;
+ IIcon icon = ((BlockCrystal)block).getIcon(0, 0);
+ double umin = icon.getMinU();
+ double vmin = icon.getMinV();
+ double umax = icon.getMaxU();
+ double vmax = icon.getMaxV();
+ tessellator.addTranslation(x, y, z);
+ if (world != null && world.getTileEntity(x, y, z) != null && ConfigHandler.CRYSTAL_GLOW) tessellator.setBrightness(((TileEntityCrystal)world.getTileEntity(x, y, z)).shine);
+ else tessellator.setBrightness(230);
+ // 37435, 76464
+ if (world != null) rnd.setSeed(2 * x * 3 * y * z * 5);
+ else rnd.setSeed(76464);
+ if (world != null && world.getBlockMetadata(x, y, z) < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[world.getBlockMetadata(x, y, z)], 100);
+ crystal(tessellator, umin, vmin, umax, vmax, 0.8D, 0.2D, 0D, 0D, 0D, 0.0D, 0.0D);
+ for(int i = 0; i < crystals; i++){
+ double rotation = Math.PI * 2.0f / (float)crystals * (float)i;
+ double xp1 = Math.sin(rotation) * (rnd.nextFloat()/2f);
+ double zp1 = Math.cos(rotation) * (rnd.nextFloat()/2f);
+ double height = 0.2f + rnd.nextFloat();
+ double topHeight = 0.1f + rnd.nextFloat() / 2f;
+ crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, -xp1, 0D, zp1, xp1, zp1);
+ }
+ if (world != null){
+ crystals = 4;
+ for(int i = 0; i < crystals; i++){
+ double rotation = Math.PI * 2.0f / (float)crystals * (float)i;
+ double xp1 = Math.sin(rotation) * (rnd.nextFloat()/2f);
+ double zp1 = Math.cos(rotation) * (rnd.nextFloat()/2f);
+ double height = 0.2f + rnd.nextFloat();
+ double topHeight = 0.1f + rnd.nextFloat() / 2f;
+ float xOff = (rnd.nextFloat() * 1.5f - 0.5f) * (rnd.nextFloat()/2f);
+ float zOff = (rnd.nextFloat() * 1.5f - 0.5f) * (rnd.nextFloat()/2f);
+ crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, xOff, 0D, zOff, xp1, zp1);
+ }
+ }
+ tessellator.addTranslation(-x, -y, -z);
+ return true;
+ }
+
+ private void crystal(Tessellator tessellator, double umin, double vmin, double umax, double vmax, double height, double topHeight, double posX, double posY, double posZ, double rotX, double rotZ)
+ {
+ // Negative X
+ tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin);
+ // Positive X
+ tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin);
+ // Negative Z
+ tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin);
+ // Positive Z
+ tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin);
+ // Top -X
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin);
+ // Top +X
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin);
+ // Top +Z
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin);
+ // Top -Z
+ tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin);
+ // Bottom
+ tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmax);
+ tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin);
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory(int modelId)
+ {
+ return true;
+ }
+
+ @Override
+ public int getRenderId()
+ {
+ return BlockRenderIDs.CRYSTAL.id();
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/client/Page.java b/src/main/java/darkknight/jewelrycraft/client/Page.java
index d117fb7..d1ca8fd 100644
--- a/src/main/java/darkknight/jewelrycraft/client/Page.java
+++ b/src/main/java/darkknight/jewelrycraft/client/Page.java
@@ -1,198 +1,166 @@
-package darkknight.jewelrycraft.client;
-
-import java.util.ArrayList;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL12;
-import darkknight.jewelrycraft.client.gui.GuiGuide;
-import darkknight.jewelrycraft.util.Variables;
-
-public class Page
-{
- static ResourceLocation pageFlipped = new ResourceLocation(Variables.MODID, "textures/gui/guidePageFlip.png");
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param isSmall
- * @param text
- * @param mouseX
- * @param mouseY
- * @param items
- */
- public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, String text, int mouseX, int mouseY, boolean rotate, ItemStack ... items)
- {
- y += 5;
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items[0].getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items[0].getDisplayName()) / 2) - 10, y - 2, 0);
- GL11.glColor4f(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pageFlipped);
- ArrayList<String> name = new ArrayList<String>();
- if (isSmall){
- gui.drawTexturedModalRect(x, y + 10, 145, 54, 111, 46);
- gui.renderItem(items[0], x + 89, y + 22 + 10, 30f, rotate, 0, 0, 0);
- for(int i = 1; i <= 4; i++)
- if (items.length > i && items[i] != null){
- int posX = x + 8 + (i - 1) % 2 * 22;
- int posY = y + 26 + (i - 1) / 2 * 22;
- gui.renderItem(items[i], posX, posY, 30f, rotate, 0, 0, 0);
- name.add(items[i].getDisplayName());
- if (mouseX >= posX - 8 && mouseX <= posX + 8 && mouseY >= posY - 16 && mouseY <= posY) gui.drawHoverString(name, posX - 20, posY - 14);
- name.removeAll(name);
- GL11.glDisable(GL11.GL_LIGHTING);
- }
- drawText(gui, text, x, y + 25);
- }else{
- gui.drawTexturedModalRect(x, y + 12, 145, 0, 111, 54);
- gui.renderItem(items[0], x + 91, y + 28 + 10, 30f, rotate, 0, 0, 0);
- for(int i = 1; i <= 9; i++)
- if (items.length > i && items[i] != null){
- int posX = x + 8 + (i - 1) % 3 * 19;
- int posY = y + 22 + (i - 1) / 3 * 17;
- gui.renderItem(items[i], posX, posY, 30f, rotate, 0, 0, 0);
- name.add(items[i].getDisplayName());
- if (mouseX >= posX - 8 && mouseX <= posX + 8 && mouseY >= posY - 10 && mouseY <= posY) gui.drawHoverString(name, posX - 20, posY - 12);
- name.removeAll(name);
- GL11.glDisable(GL11.GL_LIGHTING);
- }
- drawText(gui, text, x, y + 32);
- GL11.glColor4f(1, 1, 1, 1);
- }
- GL11.glDisable(GL11.GL_BLEND);
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param text
- * @param mouseX
- * @param mouseY
- * @param items
- */
- public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, String text, int mouseX, int mouseY, boolean rotate, ItemStack ... items)
- {
- ArrayList<String> name = new ArrayList<String>();
- gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items[1].getDisplayName(), x + 30 - items[0].getDisplayName().length() / 2, y + 2, 0);
- GL11.glColor4f(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pageFlipped);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 52);
- gui.renderItem(items[0], x + 13, y + 20 + 10, 35f, rotate, 0, 0, 0);
- name.add(items[0].getDisplayName());
- if (mouseX >= x && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 20 + 16) gui.drawHoverString(name, x, y + 20);
- name.removeAll(name);
- GL11.glDisable(GL11.GL_LIGHTING);
- gui.renderItem(items[1], x + 77, y + 28 + 10, 35f, rotate, 0, 0, 0);
- drawText(gui, text, x, y + 30);
- GL11.glColor4f(1, 1, 1, 1);
- GL11.glDisable(GL11.GL_BLEND);
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param item
- * @param text
- * @param size
- */
- public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, boolean rotate)
- {
- y += 5;
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + (int)size/5, 0);
- GL11.glColor4f(1, 1, 1, 1);
- gui.renderItem(item, x + 13, y + 18, size, rotate, 0, 0, 0);
- drawText(gui, text, x - 2, y - (int)(250 / size));
- GL11.glDisable(GL11.GL_BLEND);
- }
-
- public static void addSlotItem(GuiGuide gui, int x, int y, int mouseX, int mouseY, ItemStack item, float xRot, float yRot, float zRot)
- {
- ArrayList<String> name = new ArrayList<String>();
- GL11.glColor4f(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pageFlipped);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- gui.drawTexturedModalRect(x + 9, y + 19, 148, 153, 12, 12);
- if(item.getItem() != null){
- name.add(item.getDisplayName());
- if (mouseX >= x + 10 && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 30) gui.drawHoverString(name, x, y + 10);
- name.removeAll(name);
- }
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glColor4f(1, 1, 1, 1);
- if(item.getItem() != null) gui.renderItem(item, x + 15, y + 25, 40f, false, xRot, yRot, zRot);
- GL11.glDisable(GL11.GL_BLEND);
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param item
- * @param text
- * @param size
- * @param txtX
- * @param txtY
- * @param showName
- * @param imgX
- * @param imgY
- */
- public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY, boolean rotate)
- {
- y += 5;
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glEnable(GL12.GL_RESCALE_NORMAL);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- if (showName) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName().substring(0, item.getDisplayName().length() > 23?23:item.getDisplayName().length()), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + 2, 0);
- GL11.glColor4f(1, 1, 1, 1);
- gui.renderItem(item, x + 13 + imgX, y + 18 + imgY, size, rotate, 0, 0, 0);
- drawText(gui, text, x + txtX, y + txtY);
- GL11.glDisable(GL11.GL_BLEND);
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param text
- */
- public static void addTextPage(GuiGuide gui, int x, int y, String text)
- {
- y -= 25;
- drawText(gui, text, x, y);
- GL11.glColor4f(1, 1, 1, 1);
- }
-
- /**
- * @param gui
- * @param text
- * @param x
- * @param y
- */
- public static void drawText(GuiGuide gui, String text, int x, int y)
- {
- String[] s = text.split(" ");
- String displayText = "";
- ArrayList<String> textLines = new ArrayList<String>();
- for(String element: s)
- if ((displayText + element + " ").length() <= 24) displayText += element + " ";
- else{
- textLines.add(displayText.trim());
- displayText = element + " ";
- }
- textLines.add(displayText.trim());
- for(int i = 0; i < textLines.size(); i++)
- gui.getFont().drawString(textLines.get(i), x, y + 30 + i * 12, 0);
- }
-}
+package darkknight.jewelrycraft.client;
+
+import java.util.ArrayList;
+
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import darkknight.jewelrycraft.client.gui.GuiGuide;
+import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+
+public class Page
+{
+ static ResourceLocation pageFlipped = new ResourceLocation(Variables.MODID, "textures/gui/guidePageFlip.png");
+
+ public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, String text, int mouseX, int mouseY, boolean rotate, ItemStack ... items)
+ {
+ y += 5;
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items[0].getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items[0].getDisplayName()) / 2) - 10, y - 2, 0);
+ GL11.glColor4f(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pageFlipped);
+ ArrayList<String> name = new ArrayList<String>();
+ if (isSmall){
+ gui.drawTexturedModalRect(x, y + 10, 145, 54, 111, 46);
+ gui.renderItem(items[0], x + 89, y + 22 + 10, 30f, rotate, 0, 0, 0);
+ for(int i = 1; i <= 4; i++)
+ if (items.length > i && items[i] != null){
+ int posX = x + 8 + (i - 1) % 2 * 22;
+ int posY = y + 26 + (i - 1) / 2 * 22;
+ gui.renderItem(items[i], posX, posY, 30f, rotate, 0, 0, 0);
+ name.add(items[i].getDisplayName());
+ if (mouseX >= posX - 8 && mouseX <= posX + 8 && mouseY >= posY - 16 && mouseY <= posY) gui.drawHoverString(name, posX - 20, posY - 14);
+ name.removeAll(name);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ }
+ drawText(gui, text, x, y + 25);
+ }else{
+ gui.drawTexturedModalRect(x, y + 12, 145, 0, 111, 54);
+ gui.renderItem(items[0], x + 91, y + 28 + 10, 30f, rotate, 0, 0, 0);
+ for(int i = 1; i <= 9; i++)
+ if (items.length > i && items[i] != null){
+ int posX = x + 8 + (i - 1) % 3 * 19;
+ int posY = y + 22 + (i - 1) / 3 * 17;
+ gui.renderItem(items[i], posX, posY, 30f, rotate, 0, 0, 0);
+ name.add(items[i].getDisplayName());
+ if (mouseX >= posX - 8 && mouseX <= posX + 8 && mouseY >= posY - 10 && mouseY <= posY) gui.drawHoverString(name, posX - 20, posY - 12);
+ name.removeAll(name);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ }
+ drawText(gui, text, x, y + 32);
+ GL11.glColor4f(1, 1, 1, 1);
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+ public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, String text, int mouseX, int mouseY, boolean rotate, ItemStack ... items)
+ {
+ ArrayList<String> name = new ArrayList<String>();
+ gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items[1].getDisplayName(), x + 30 - items[0].getDisplayName().length() / 2, y + 2, 0);
+ GL11.glColor4f(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pageFlipped);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 52);
+ gui.renderItem(items[0], x + 13, y + 20 + 10, 35f, rotate, 0, 0, 0);
+ name.add(items[0].getDisplayName());
+ if (mouseX >= x && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 20 + 16) gui.drawHoverString(name, x, y + 20);
+ name.removeAll(name);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ gui.renderItem(items[1], x + 77, y + 28 + 10, 35f, rotate, 0, 0, 0);
+ drawText(gui, text, x, y + 30);
+ GL11.glColor4f(1, 1, 1, 1);
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+ public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, boolean rotate)
+ {
+ y += 5;
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + (int)size/5, 0);
+ GL11.glColor4f(1, 1, 1, 1);
+ gui.renderItem(item, x + 13, y + 18, size, rotate, 0, 0, 0);
+ drawText(gui, text, x - 2, y - (int)(250 / size));
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+ public static void addSlotItem(GuiGuide gui, int x, int y, int mouseX, int mouseY, ItemStack item, float xRot, float yRot, float zRot)
+ {
+ ArrayList<String> name = new ArrayList<String>();
+ GL11.glColor4f(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pageFlipped);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ gui.drawTexturedModalRect(x + 9, y + 19, 148, 153, 12, 12);
+ if(item.getItem() != null){
+ name.add(item.getDisplayName());
+ if (mouseX >= x + 10 && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 30) gui.drawHoverString(name, x, y + 10);
+ name.removeAll(name);
+ }
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glColor4f(1, 1, 1, 1);
+ if(item.getItem() != null) gui.renderItem(item, x + 15, y + 25, 40f, false, xRot, yRot, zRot);
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+ public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY, boolean rotate)
+ {
+ y += 5;
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ if (showName) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName().substring(0, item.getDisplayName().length() > 23?23:item.getDisplayName().length()), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + 2, 0);
+ GL11.glColor4f(1, 1, 1, 1);
+ gui.renderItem(item, x + 13 + imgX, y + 18 + imgY, size, rotate, 0, 0, 0);
+ drawText(gui, text, x + txtX, y + txtY);
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+ public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, int txtX, int txtY, String title, int imgX, int imgY, boolean rotate)
+ {
+ y += 5;
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + title.substring(0, item.getDisplayName().length() > 23?23:title.length()), x + Math.abs(70 - gui.getFont().getStringWidth(title) / 2) - 10, y + 2, 0);
+ GL11.glColor4f(1, 1, 1, 1);
+ gui.renderItem(item, x + 13 + imgX, y + 18 + imgY, size, rotate, 0, 0, 0);
+ drawText(gui, text, x + txtX, y + txtY);
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+ public static void addTextPage(GuiGuide gui, int x, int y, String text)
+ {
+ y -= 25;
+ drawText(gui, text, x, y);
+ GL11.glColor4f(1, 1, 1, 1);
+ }
+
+ public static void drawText(GuiGuide gui, String text, int x, int y)
+ {
+ String[] s = text.split(" ");
+ String displayText = "";
+ float scale = 0.75F;
+ ArrayList<String> textLines = new ArrayList<String>();
+ for(String element: s)
+ if ((displayText + element + " ").length() <= 31) displayText += element + " ";
+ else{
+ textLines.add(displayText.trim());
+ displayText = element + " ";
+ }
+ textLines.add(displayText.trim());
+ for(int i = 0; i < textLines.size(); i++)
+ {
+ GL11.glPushMatrix();
+ GL11.glScalef(scale, scale, 0f);
+ gui.getFont().drawString(textLines.get(i), (int)(x/scale), (int)((y + 32 + i * 9)/scale), 0);
+ GL11.glPopMatrix();
+ }
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/client/TabCurses.java b/src/main/java/darkknight/jewelrycraft/client/TabCurses.java
index e9878b0..d5e8fdd 100644
--- a/src/main/java/darkknight/jewelrycraft/client/TabCurses.java
+++ b/src/main/java/darkknight/jewelrycraft/client/TabCurses.java
@@ -10,7 +10,7 @@ public class TabCurses extends AbstractTab
{
public TabCurses()
{
- super(0, 0, 0, new ItemStack(Items.ender_eye));
+ super(0, 0, 0, new ItemStack(ItemList.testItem, 1, 4));
}
@Override
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java
index 59f5e91..752a2a7 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java
@@ -1,26 +1,36 @@
package darkknight.jewelrycraft.client.gui;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.Container;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.world.World;
+import java.util.List;
+import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.client.TabCurses;
import darkknight.jewelrycraft.client.TabRegistry;
import darkknight.jewelrycraft.events.KeyBindings;
+import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
+import darkknight.jewelrycraft.network.PacketSendServerPlayerInfo;
+import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo;
import darkknight.jewelrycraft.util.PlayerUtils;
import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.inventory.Container;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+import scala.swing.event.Key;
public class GuiCurseInfo extends GuiContainer {
World world;
EntityPlayer player;
ResourceLocation texture;
+ int page = 0, maxPages = 1;
+ String selectedCurse = "";
public GuiCurseInfo(Container container, World world, EntityPlayer player, ResourceLocation texture) {
super(container);
@@ -33,35 +43,6 @@ public class GuiCurseInfo extends GuiContainer {
public void drawScreen(int x, int y, float size) {
super.drawScreen(x, y, size);
- // this.drawGradientRect(0, 0, this.width, this.height, -1072689136,
- // -804253680);
- // int ind = 0;
- // if (player != null){
- // NBTTagCompound playerInfo =
- // PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- // if (!playerInfo.hasNoTags()){
- // for(Curse curse: Curse.getCurseList())
- // if (playerInfo.getInteger(curse.getName()) > 0){
- // int halfDescrSize =
- // fontRendererObj.getStringWidth(curse.getDescription()) / 2;
- // mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
- // this.drawRect(0, 12 + ind * 34, this.width, 10 + (ind + 1) * 34,
- // 0xff000000);
- // mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID,
- // "textures/gui/" + curse.getTexturePack() + ".png"));
- // int tag = curse.getTextureID();
- // GL11.glColor3f(1F, 1F, 1F);
- // drawTexturedModalRect(this.width/2 - halfDescrSize - 35, 12 + ind *
- // 34, tag % 8 * 32, tag / 8 * 32, 32, 32);
- // this.drawString(fontRendererObj,
- // curse.getName().substring(curse.getName().indexOf(':') + 1),
- // this.width/2 - halfDescrSize, 20 + ind * 34, 0xffff00);
- // this.drawCenteredString(fontRendererObj, curse.getDescription(),
- // this.width/2, 30 + ind * 34, 0xffffff);
- // ind++;
- // }
- // }
- // }
}
@Override
@@ -69,21 +50,50 @@ public class GuiCurseInfo extends GuiContainer {
GL11.glColor3f(1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
- int ind = 0;
- int size = 32;
if (player != null) {
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (!playerInfo.hasNoTags()) {
- for (Curse curse : Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) {
+ if (!player.capabilities.isCreativeMode) maxPages = playerInfo.getInteger("activeCurses") / 5 - (playerInfo.getInteger("activeCurses") % 5 == 0 ? 1 : 0);
+ else maxPages = Curse.getCurseList().size() / 5 - (Curse.getCurseList().size() % 5 == 0 ? 1 : 0);
+ if (!player.capabilities.isCreativeMode) survivalCurses(playerInfo);
+ else creativeCurses(playerInfo);
+ if (playerInfo.hasKey("cursePoints")) this.drawString(fontRendererObj, "Curse points: " + playerInfo.getInteger("cursePoints") + " | Active curses: " + playerInfo.getInteger("activeCurses"), guiLeft, guiTop - 10, 0xffffff);
+ }
+ this.drawString(fontRendererObj, page + "/" + maxPages, guiLeft + 90, guiTop + 153, 0xffffff);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
+ drawTexturedModalRect(guiLeft + 5, guiTop + ySize - 14, 0, ySize, 13, 11);
+ drawTexturedModalRect(guiLeft + xSize - 38, guiTop + ySize - 14, 13, ySize, 13, 11);
+ }
+
+ private void survivalCurses(NBTTagCompound playerInfo) {
+ int size = 32;
+ int ind = 0;
+ if (!playerInfo.hasNoTags()) {
+ for (Curse curse : Curse.getCurseList()) {
+ if (playerInfo.getInteger(curse.getName()) > 0) {
+ if (ind >= page * 5 && ind < (page + 1) * 5) {
+ if (ind == page * 5 && selectedCurse == "") selectedCurse = curse.getName();
mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
- drawTexturedModalRect(guiLeft + 43, guiTop + 5 + (size - 8) * ind, 0, 32, 112, 22);
+ drawTexturedModalRect(guiLeft + 43, guiTop + 8 + (size - 8) * (ind - page * 5), 0, 32, 112, 22);
+ if (selectedCurse == curse.getName()) {
+ GL11.glPushMatrix();
+ GL11.glScalef(1.2f, 1.5f, 0f);
+ drawTexturedModalRect((int) (guiLeft / (1.2)) + 126, (int) (guiTop / (1.5)) + 7 + (size - 16) * (ind - page * 5), 48, 16, 32, 16);
+ drawTexturedModalRect((int) (guiLeft / (1.2)) + 5, (int) (guiTop / (1.5)) + 7 + (size - 16) * (ind - page * 5), 80, 16, 32, 16);
+ GL11.glPopMatrix();
+ GL11.glPushMatrix();
+ List descr = fontRendererObj.listFormattedStringToWidth(curse.getDescription(), 238);
+ GL11.glScalef(0.75F, 0.75F, 0F);
+ for (int i = 0; i < descr.size(); i++)
+ this.drawString(fontRendererObj, descr.get(i).toString(), (int) (guiLeft / 0.75F) + 12, (int) (guiTop / 0.75F) + 184 + i * 12 - (descr.size() > 1 ? 6 : 0), 0xffffff);
+ GL11.glPopMatrix();
+ }
if (playerInfo.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(guiLeft + 134, guiTop + 8 + (size - 8) * ind, 3 * 16, 0, 16, 16);
+ drawTexturedModalRect(guiLeft + 134, guiTop + 11 + (size - 8) * (ind - page * 5), 3 * 16, 0, 16, 16);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@@ -94,28 +104,72 @@ public class GuiCurseInfo extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glScalef(0.5f, 0.5f, 0.0f);
- drawTexturedModalRect(guiLeft*2 + 100, guiTop*2 + 16 + ind * 48, tag % 8 * 32, tag / 8 * 32, 32, 32);
+ drawTexturedModalRect(guiLeft * 2 + 100, guiTop * 2 + 22 + (ind - page * 5) * 48, tag % 8 * 32, tag / 8 * 32, 32, 32);
GL11.glPopMatrix();
- this.drawString(fontRendererObj, curse.getDisplayName(), guiLeft + 70, guiTop + 12 + ind * (size - 8), 0xffffff);
- // this.drawCenteredString(fontRendererObj,
- // curse.getDescription(), this.width/2, 30 + ind * 34,
- // 0xffffff);
- ind++;
+ this.drawString(fontRendererObj, curse.getDisplayName(), guiLeft + 70, guiTop + 15 + (ind - page * 5) * (size - 8), 0xffffff);
}
+ ind++;
+ }
}
}
}
+ private void creativeCurses(NBTTagCompound playerInfo) {
+ int size = 32;
+ int ind = 0;
+ for (Curse curse : Curse.getCurseList()) {
+ if (ind >= page * 5 && ind < (page + 1) * 5) {
+ if (ind == page * 5 && selectedCurse == "") selectedCurse = curse.getName();
+ if (playerInfo.getInteger(curse.getName()) <= 0) {
+ 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);
+ }
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
+ drawTexturedModalRect(guiLeft + 43, guiTop + 8 + (size - 8) * (ind - page * 5), 0, 32, 112, 22);
+ if (selectedCurse == curse.getName()) {
+ GL11.glPushMatrix();
+ GL11.glScalef(1.2f, 1.5f, 0f);
+ drawTexturedModalRect((int) (guiLeft / (1.2)) + 126, (int) (guiTop / (1.5)) + 7 + (size - 16) * (ind - page * 5), 48, 16, 32, 16);
+ drawTexturedModalRect((int) (guiLeft / (1.2)) + 5, (int) (guiTop / (1.5)) + 7 + (size - 16) * (ind - page * 5), 80, 16, 32, 16);
+ GL11.glPopMatrix();
+ GL11.glPushMatrix();
+ List descr = fontRendererObj.listFormattedStringToWidth(curse.getDescription(), 238);
+ GL11.glScalef(0.75F, 0.75F, 0F);
+ for (int i = 0; i < descr.size(); i++)
+ this.drawString(fontRendererObj, descr.get(i).toString(), (int) (guiLeft / 0.75F) + 12, (int) (guiTop / 0.75F) + 184 + i * 12 - (descr.size() > 1 ? 6 : 0), 0xffffff);
+ GL11.glPopMatrix();
+ }
+ int halfDescrSize = fontRendererObj.getStringWidth(curse.getDescription()) / 2;
+ mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png"));
+ int tag = curse.getTextureID();
+ GL11.glPushMatrix();
+ if (playerInfo.getInteger(curse.getName()) <= 0) GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
+ else GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glScalef(0.5f, 0.5f, 0.0f);
+ drawTexturedModalRect(guiLeft * 2 + 100, guiTop * 2 + 22 + (ind - page * 5) * 48, tag % 8 * 32, tag / 8 * 32, 32, 32);
+ GL11.glPopMatrix();
+ this.drawString(fontRendererObj, curse.getDisplayName(), guiLeft + 70, guiTop + 15 + (ind - page * 5) * (size - 8), playerInfo.getInteger(curse.getName()) > 0 ? 0xffffffff : 0xaaffffff);
+ if (playerInfo.getInteger(curse.getName()) <= 0) {
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+ }
+ }
+ ind++;
+ }
+ }
+
@Override
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
}
-
- @Override
- protected void keyTyped(char charecter, int key)
- {
- super.keyTyped(charecter, key);
- if (key == KeyBindings.curses.getKeyCode()) mc.thePlayer.closeScreen();
- }
+
+ @Override
+ protected void keyTyped(char charecter, int key) {
+ super.keyTyped(charecter, key);
+ if (key == KeyBindings.curses.getKeyCode()) mc.thePlayer.closeScreen();
+ }
@Override
public void initGui() {
@@ -129,5 +183,41 @@ public class GuiCurseInfo extends GuiContainer {
protected void mouseClicked(int x, int y, int id) {
super.mouseClicked(x, y, id);
+ int ind = 0;
+ int size = 32;
+ if (player != null) {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ for (Curse curse : Curse.getCurseList()) {
+ if (player.capabilities.isCreativeMode) {
+ if (x > (guiLeft + 43) && y > (guiTop + 8 + (size - 8) * (ind - page * 5)) && x < (guiLeft + 43 + 112) && y < (guiTop + 40 + (size - 8) * (ind - page * 5)) && ind >= page * 5 && ind < (page + 1) * 5) {
+ if (player.capabilities.isCreativeMode && isCtrlKeyDown() && playerInfo.getInteger(curse.getName()) > 0) {
+ playerInfo.setInteger(curse.getName(), 0);
+ playerInfo.setInteger("activeCurses", playerInfo.getInteger("activeCurses") - 1);
+ Curse.availableCurses.add(curse);
+ JewelrycraftMod.netWrapper.sendToServer(new PacketSendServerPlayerInfo("remove", curse.getName(), playerInfo));
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ } else if (player.capabilities.isCreativeMode && isCtrlKeyDown() && playerInfo.getInteger(curse.getName()) <= 0) {
+ playerInfo.setInteger(curse.getName(), 1);
+ playerInfo.setInteger("activeCurses", playerInfo.getInteger("activeCurses") + 1);
+ Curse.availableCurses.remove(curse);
+ JewelrycraftMod.netWrapper.sendToServer(new PacketSendServerPlayerInfo("add", curse.getName(), playerInfo));
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ } else selectedCurse = curse.getName();
+ }
+ ind++;
+ } else if (playerInfo.getInteger(curse.getName()) > 0) {
+ if (x > (guiLeft + 43) && y > (guiTop + 8 + (size - 8) * (ind - page * 5)) && x < (guiLeft + 43 + 112) && y < (guiTop + 40 + (size - 8) * (ind - page * 5)) && ind >= page * 5 && ind < (page + 1) * 5) selectedCurse = curse.getName();
+ ind++;
+ }
+ }
+ }
+ if (page > 0 && x > guiLeft + 5 && x < guiLeft + 18 && y > guiTop + ySize - 14 && y < guiTop + ySize - 3) {
+ page--;
+ selectedCurse = "";
+ }
+ if (page < maxPages && x > guiLeft + xSize - 38 && x < guiLeft + xSize - 25 && y > guiTop + ySize - 14 && y < guiTop + ySize - 3) {
+ page++;
+ selectedCurse = "";
+ }
}
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiGuide.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiGuide.java
index 1ff2ef3..b3caaf2 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiGuide.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiGuide.java
@@ -1,239 +1,187 @@
-package darkknight.jewelrycraft.client.gui;
-
-import java.util.ArrayList;
-import java.util.List;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockAir;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.client.renderer.entity.RenderManager;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.inventory.Container;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.world.World;
-import org.lwjgl.opengl.GL11;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.block.BlockShadowEye;
-
-public class GuiGuide extends GuiContainer
-{
- public int page, rot, del;
- public boolean prevHover, nextHover;
- World world;
- private final GuiTab[] tabs;
- private GuiTab activeTab;
- ResourceLocation pageTexture, flippedPageTexture;
-
- /**
- * @param container
- * @param world
- * @param pageTex
- * @param flipPageTex
- */
- public GuiGuide(Container container, World world, ResourceLocation pageTex, ResourceLocation flipPageTex)
- {
- super(container);
- page = 1;
- rot = 0;
- del = 0;
- this.world = world;
- tabs = new GuiTab[]{new GuiTabIntroduction(0), new GuiTabBlocks(1), new GuiTabItems(2), new GuiTabGemsAndIngots(3), new GuiTabOresToIngots(4), new GuiTabModifiers(5), new GuiTabRitual(6)};
- activeTab = tabs[0];
- pageTexture = pageTex;
- flippedPageTexture = flipPageTex;
- this.xSize = 240;
- }
-
- /**
- * @param f
- * @param i
- * @param j
- */
- @Override
- protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
- {
- nextHover = false;
- prevHover = false;
- if (del == 0) rot++;
- del++;
- if (del >= 2) del = 0;
- Minecraft.getMinecraft().getTextureManager().bindTexture(pageTexture);
- drawTexturedModalRect(guiLeft + 147 / 2 + 20, guiTop - 10, 0, 0, 145, 180);
- Minecraft.getMinecraft().getTextureManager().bindTexture(flippedPageTexture);
- drawTexturedModalRect(guiLeft - 147 / 2 + 21, guiTop - 10, 0, 0, 145, 180);
- for(GuiRectangle tab: tabs){
- int srcX = 24;
- int sizeX = 19;
- if (tab == activeTab){
- srcX += 38;
- sizeX += 3;
- }else if (tab.inRect(this, i, j)) srcX += 19;
- tab.draw(this, srcX, 180, sizeX, 18);
- }
- if (i >= guiLeft + 195 + 20 && i <= guiLeft + 195 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14 && page + 2 <= activeTab.getMaxPages()){
- drawTexturedModalRect(guiLeft + 195 + 20, guiTop + 127 + 20, 0, 180, 11, 14);
- nextHover = true;
- }
- if (i >= guiLeft + 20 - 61 && i <= guiLeft - 61 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14 && page - 2 > 0){
- drawTexturedModalRect(guiLeft - 61 + 20, guiTop + 127 + 20, 11, 180, 11, 14);
- prevHover = true;
- }
- activeTab.drawBackground(this, i, j, page);
- activeTab.drawBackground(this, i, j, page + 1);
- ArrayList<String> text = new ArrayList<String>();
- text.add(Integer.toString(page));
- drawHoveringText(text, guiLeft - 10 + 20 - text.get(0).length(), guiTop + 150 + 25, fontRendererObj);
- text.remove(Integer.toString(page));
- text.add(Integer.toString(page + 1));
- drawHoveringText(text, guiLeft - 10 + 20 + 147 - text.get(0).length(), guiTop + 150 + 25, fontRendererObj);
- for(int tab = 0; tab < tabs.length; tab++)
- renderItem(tabs[tab].getIcon(), guiLeft - 52, guiTop + 26 + tab * 19, activeTab.getIcon());
- }
-
- /**
- * @param x
- * @param y
- */
- @Override
- protected void drawGuiContainerForegroundLayer(int x, int y)
- {
- activeTab.drawForeground(this, x, y, page);
- activeTab.drawForeground(this, x, y, page + 1);
- for(GuiTab tab: tabs)
- tab.drawString(this, x, y, tab.getName());
- }
-
- /**
- * @param x
- * @param y
- * @param button
- */
- @Override
- protected void mouseClicked(int x, int y, int button)
- {
- if (nextHover && page + 2 <= activeTab.getMaxPages()) page += 2;
- else if (prevHover && page > 1) page -= 2;
- activeTab.mouseClick(this, x, y, button);
- for(GuiTab tab: tabs)
- if (activeTab != tab) if (tab.inRect(this, x, y)){
- activeTab = tab;
- page = 1;
- break;
- }
- }
-
- /**
- * @param item
- * @param x
- * @param y
- * @param activeIcon
- */
- public void renderItem(ItemStack item, float x, float y, ItemStack activeIcon)
- {
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item);
- entityitem.hoverStart = 0.0F;
- if (item.isItemEqual(new ItemStack(BlockList.smelter))){
- y -= 3;
- x += 1;
- }
- GL11.glTranslatef(x, y, 100);
- float scale = 30F;
- GL11.glScalef(-scale, scale, scale);
- if (activeIcon != null && item.isItemEqual(activeIcon)) GL11.glRotatef(rot, 0, 1, 0);
- if (item.isItemEqual(new ItemStack(BlockList.smelter))){
- GL11.glScalef(1.5F, 1.5F, 1.5F);
- GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
- }else if (item.isItemEqual(new ItemStack(BlockList.handPedestal))){
- GL11.glScalef(1.2F, 1.2F, 1.2F);
- GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
- GL11.glTranslatef(0F, 0.05F, 0F);
- }else if (item.isItemEqual(new ItemStack(BlockList.shadowOre))){
- GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
- GL11.glTranslatef(0F, 0.13F, 0F);
- }else GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
- if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.enableStandardItemLighting();
- if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- else{
- GL11.glRotatef(180F, 0F, 1F, 0F);
- RenderManager.instance.options.fancyGraphics = true;
- RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderManager.instance.options.fancyGraphics = false;
- }
- if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.disableStandardItemLighting();
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
-
- /**
- * @param item
- * @param x
- * @param y
- * @param scale
- */
- public void renderItem(ItemStack item, float x, float y, float scale, boolean rotate, float xRot, float yRot, float zRot)
- {
- GL11.glPushMatrix();
- EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item);
- entityitem.hoverStart = 0.0F;
- GL11.glTranslatef(x, y, 100);
- GL11.glScalef(-scale, scale, scale);
- GL11.glRotatef(160.0F, 1.0F, 0.0F, 0.0F);
- if (rotate) GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F);
- else{
- GL11.glRotatef(xRot, 1, 0, 0);
- GL11.glRotatef(yRot, 0, 1, 0);
- GL11.glRotatef(zRot, 0, 0, 1);
- if (xRot >= 90F || zRot >= 90F) GL11.glTranslatef(0F, -0.2F, 0F);
- if (Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockShadowEye) GL11.glTranslatef(0F, 0F, 0.025F);
- }
- if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.enableStandardItemLighting();
- if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- else{
- RenderManager.instance.options.fancyGraphics = true;
- RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderManager.instance.options.fancyGraphics = false;
- }
- if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.disableStandardItemLighting();
- GL11.glPopMatrix();
- }
-
- /**
- * @return
- */
- public int getLeft()
- {
- return guiLeft;
- }
-
- /**
- * @return
- */
- public int getTop()
- {
- return guiTop;
- }
-
- /**
- * @return
- */
- public FontRenderer getFont()
- {
- return fontRendererObj;
- }
-
- /**
- * @param lst
- * @param x
- * @param y
- */
- @SuppressWarnings ("rawtypes")
- public void drawHoverString(List lst, int x, int y)
- {
- drawHoveringText(lst, x, y, fontRendererObj);
- }
+package darkknight.jewelrycraft.client.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockAir;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.inventory.Container;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.block.BlockShadowEye;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+
+public class GuiGuide extends GuiContainer {
+ public int page, rot, del;
+ public boolean prevHover, nextHover;
+ World world;
+ private final GuiTab[] tabs = new GuiTab[] { new GuiTabIntroduction(0), new GuiTabBlocks(1), new GuiTabItems(2), new GuiTabGemsAndIngots(3), new GuiTabCurses(4), new GuiTabModifiers(5), new GuiTabRitual(6) };
+ private GuiTab activeTab;
+ ResourceLocation pageTexture, flippedPageTexture;
+
+ public GuiGuide(Container container, World world, ResourceLocation pageTex, ResourceLocation flipPageTex) {
+ super(container);
+ page = JewelrycraftMod.prevPage;
+ rot = 0;
+ del = 0;
+ this.world = world;
+ activeTab = JewelrycraftMod.prevActive;
+ pageTexture = pageTex;
+ flippedPageTexture = flipPageTex;
+ this.xSize = 240;
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
+ nextHover = false;
+ prevHover = false;
+ if (del == 0) rot++;
+ del++;
+ if (del >= 2) del = 0;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pageTexture);
+ drawTexturedModalRect(guiLeft + 147 / 2 + 20, guiTop - 10, 0, 0, 145, 179);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(flippedPageTexture);
+ drawTexturedModalRect(guiLeft - 147 / 2 + 21, guiTop - 10, 0, 0, 145, 179);
+ for (GuiRectangle tab : tabs) {
+ int srcX = 24;
+ int sizeX = 19;
+ if (tab == activeTab) {
+ srcX += 38;
+ sizeX += 3;
+ }
+ else if (tab.inRect(this, i, j)) srcX += 19;
+ tab.draw(this, srcX, 180, sizeX, 18);
+ }
+ if (i >= guiLeft + 195 + 20 && i <= guiLeft + 195 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14 && page + 2 <= activeTab.getMaxPages()) {
+ drawTexturedModalRect(guiLeft + 195 + 20, guiTop + 127 + 20, 0, 180, 11, 14);
+ nextHover = true;
+ }
+ if (i >= guiLeft + 20 - 61 && i <= guiLeft - 61 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14 && page - 2 > 0) {
+ drawTexturedModalRect(guiLeft - 61 + 20, guiTop + 127 + 20, 11, 180, 11, 14);
+ prevHover = true;
+ }
+ activeTab.drawBackground(this, i, j, page);
+ activeTab.drawBackground(this, i, j, page + 1);
+ ArrayList<String> text = new ArrayList<String>();
+ text.add(Integer.toString(page));
+ drawHoveringText(text, guiLeft - 10 + 20 - text.get(0).length(), guiTop + 150 + 25, fontRendererObj);
+ text.remove(Integer.toString(page));
+ text.add(Integer.toString(page + 1));
+ drawHoveringText(text, guiLeft - 10 + 20 + 147 - text.get(0).length(), guiTop + 150 + 25, fontRendererObj);
+ for (int tab = 0; tab < tabs.length; tab++)
+ renderItem(tabs[tab].getIcon(), guiLeft - 52, guiTop + 26 + tab * 19, activeTab.getIcon());
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int x, int y) {
+ activeTab.drawForeground(this, x, y, page);
+ activeTab.drawForeground(this, x, y, page + 1);
+ for (GuiTab tab : tabs)
+ tab.drawString(this, x, y, tab.getName());
+ }
+
+ @Override
+ protected void mouseClicked(int x, int y, int button) {
+ if (nextHover && page + 2 <= activeTab.getMaxPages()) {
+ page += 2;
+ JewelrycraftMod.prevPage = page;
+ }
+ else if (prevHover && page > 1) {
+ page -= 2;
+ JewelrycraftMod.prevPage = page;
+ }
+ activeTab.mouseClick(this, x, y, button);
+ for (GuiTab tab : tabs)
+ if (activeTab != tab) if (tab.inRect(this, x, y)) {
+ activeTab = tab;
+ JewelrycraftMod.prevActive = tab;
+ page = 1;
+ JewelrycraftMod.prevPage = page;
+ break;
+ }
+ }
+
+ public void renderItem(ItemStack item, float x, float y, ItemStack activeIcon) {
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item);
+ entityitem.hoverStart = 0.0F;
+ if (item.isItemEqual(new ItemStack(BlockList.smelter))) {
+ y -= 3;
+ x += 1;
+ }
+ GL11.glTranslatef(x, y, 100);
+ float scale = 30F;
+ GL11.glScalef(-scale, scale, scale);
+ if (activeIcon != null && item.isItemEqual(activeIcon)) GL11.glRotatef(rot, 0, 1, 0);
+ if (item.isItemEqual(new ItemStack(BlockList.smelter))) GL11.glScalef(1.5F, 1.5F, 1.5F);
+ else if (item.isItemEqual(new ItemStack(BlockList.handPedestal))) {
+ GL11.glScalef(1.2F, 1.2F, 1.2F);
+ GL11.glTranslatef(0F, -0.05F, 0F);
+ }
+ GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
+ if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.enableStandardItemLighting();
+ if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ else {
+ GL11.glRotatef(180F, 0F, 1F, 0F);
+ RenderManager.instance.options.fancyGraphics = true;
+ RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderManager.instance.options.fancyGraphics = false;
+ }
+ if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.disableStandardItemLighting();
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+
+ public void renderItem(ItemStack item, float x, float y, float scale, boolean rotate, float xRot, float yRot, float zRot) {
+ GL11.glPushMatrix();
+ EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item);
+ entityitem.hoverStart = 0.0F;
+ GL11.glTranslatef(x, y, 100);
+ GL11.glScalef(-scale, scale, scale);
+ GL11.glRotatef(160.0F, 1.0F, 0.0F, 0.0F);
+ if (rotate) GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F);
+ else {
+ GL11.glRotatef(xRot, 1, 0, 0);
+ GL11.glRotatef(yRot, 0, 1, 0);
+ GL11.glRotatef(zRot, 0, 0, 1);
+ if (xRot >= 90F || zRot >= 90F) GL11.glTranslatef(0F, -0.2F, 0F);
+ if (Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockShadowEye) GL11.glTranslatef(0F, 0F, 0.025F);
+ }
+ if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.enableStandardItemLighting();
+ if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ else {
+ RenderManager.instance.options.fancyGraphics = true;
+ RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderManager.instance.options.fancyGraphics = false;
+ }
+ if (!(Block.getBlockFromItem(entityitem.getEntityItem().getItem()) instanceof BlockAir)) RenderHelper.disableStandardItemLighting();
+ GL11.glPopMatrix();
+ }
+
+ public int getLeft() {
+ return guiLeft;
+ }
+
+ public int getTop() {
+ return guiTop;
+ }
+
+ public FontRenderer getFont() {
+ return fontRendererObj;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void drawHoverString(List lst, int x, int y) {
+ drawHoveringText(lst, x, y, fontRendererObj);
+ }
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabBlocks.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabBlocks.java
index 2712821..d3f92e3 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabBlocks.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabBlocks.java
@@ -52,99 +52,71 @@ public class GuiTabBlocks extends GuiTab
{
case 1:
text = "This ore is extremely rare and can be found only between Y-level 5 and 8. It can only be mined using a diamond pickaxe.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.shadowOre), text, 90f, true);
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.shadowOre), text, 180f, 0, -18, true, 42, 100, true);
break;
case 2:
- text = "The Shadow Block is crafted using 9 shadow ingots. Magicians believed it held the ability to merge with the shadows. It becomes more transparent as it";
+ text = "Magicians believed this block held the ability to merge with the shadows. It becomes more transparent as it gets darker. If a comparator is attached to it, the output strength will be equal to the value of darkness it is in.";
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.shadowBlock), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot), new ItemStack(ItemList.shadowIngot));
break;
case 3:
- text = "gets darker. If a comparator is attached to it, the output strength will be equal to the value of darkness it is in.";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
+ text = "The smelter is one of the first blocks needed to get started with Jewelrycraft. Requiring just some cobble and a couple buckets. It is required in order to melt ingots or even ores which can be made into rings, necklaces, bracelets or earrings. To use the block all you need to do";
+ Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.smelter), new ItemStack(Blocks.cobblestone), new ItemStack(Items.bucket), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), null, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Items.lava_bucket), new ItemStack(Blocks.cobblestone));
break;
case 4:
- text = "The smelter is one of the first blocks needed to get started with Jewelrycraft. Requiring just some cobble and a couple buckets. It is required in order to";
- Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.smelter), new ItemStack(Blocks.cobblestone), new ItemStack(Items.bucket), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), null, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Items.lava_bucket), new ItemStack(Blocks.cobblestone));
+ text = "is right click on it with any ore or ingot. It can melt multimple ingots/ores at a time. Crouch (default: Shift) + Right Click will remove all items added. If right clicked when done smelting, it will say what the block contains.";
+ Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
case 5:
- text = "melt ingots or even ores which can be made into rings, necklaces, bracelets or earrings. To use the block all you need to do is right click on it with any ore or ingot. It can melt multimple ingots/ores at a time. Crouch (default: Shift) + Right Click will remove all items";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
+ text = "The molder is a key piece in creating jewellery. You need to pour the molten metal out of the smelter somewhere. That somewhere is the molder. But before pouring the molten metal in it, you must first add a mold. You can do that by simply right clicking the block with the mold of your";
+ Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.molder), new ItemStack(Blocks.cobblestone), null, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone));
break;
case 6:
- text = "added. If right clicked when done smelting, it will say what the block contains.";
+ text = "choice. If you want to get the mold out, simply crouch and Right Click it with an empty hand. Once you have a mold inside, left click on the smelter and wait for the metal to cool down. When it's done, left click on the molder to get the jewellery. Be aware that this block must be placed directly in front of the smelter, otherwise it won't work!";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
case 7:
- text = "The molder is a key piece in creating jewellery. You need to pour the molten metal out of the smelter somewhere. That somewhere is the";
- Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.molder), new ItemStack(Blocks.cobblestone), null, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone));
- break;
- case 8:
- text = "molder. But before pouring the molten metal in it, you must first add a mold. You can do that by simply right clicking the block with the mold of your choice. If you want to get the mold out, simply crouch and Right Click it with an empty hand. Once you";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 9:
- text = "have a mold inside, left click on the smelter and wait for the metal to cool down. When it's done, left click on the molder to get the jewellery. Be aware that this block must be placed directly in front of the smelter, otherwise it won't work!";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 10:
- text = "This table allows you to add a gem to a piece of jewellery. Right click the block while holding a jewellery to add it in. Then do the same with a gem (you";
+ text = "This table allows you to add a gem to a piece of jewellery. Right click the block while holding a jewellery to add it in. Then do the same with a gem (you can find a list with all possible gems in this guide). Crouch + Right Click to retreive placed items. Left Click the block to see the";
if (del == 0) values++;
del++;
if (del >= 300) del = 0;
if (values >= 4) values = 0;
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.jewelCraftingTable), new ItemStack(Blocks.planks, 1, values), new ItemStack(Blocks.planks, 1, values), new ItemStack(Blocks.planks, 1, values), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone), new ItemStack(Blocks.stone), null, new ItemStack(Blocks.stone));
break;
- case 11:
- text = "can find a list with all possible gems in this guide). Crouch + Right Click to retreive placed items. Left Click the block to see the progress the crafting has made. Once the crafting is done, Left Click the block to get the item. You are able to recraft a";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 12:
- text = "jewellery by readding the modified version to this block and adding a different gem to it. Once the crafting is done, the current gem will be replaced by the new one. There is also a 50% chance that you will get back the old gem.";
+ case 8:
+ text = "progress the crafting has made. Once the crafting is done, Left Click the block to get the item. You are able to recraft a jewellery by readding the modified version to this block and adding a different gem to it. Once the crafting is done, the current gem will be replaced by the new one. There is also a 50% chance that you will get back the old gem.";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
- case 13:
- text = "The Storage Displayer, as the name suggests, can store a large amount (Up to: " + Integer.MAX_VALUE + ") of a single item/block placed in it. It will";
+ case 9:
+ text = "The Storage Displayer, as the name suggests, can store a large amount (Up to: " + Integer.MAX_VALUE + ") of a single item/block placed in it. It will display all possible infromation about the object in it, such as the name, durability, enchantments etc. To store something in it";
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.displayer), null, new ItemStack(Items.iron_ingot), null, new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Blocks.emerald_block), new ItemStack(Blocks.emerald_block), new ItemStack(Blocks.emerald_block));
break;
- case 14:
- text = "display all possible infromation about the object in it, such as the name, durability, enchantments etc. To store something in it simply right click with that object on it and the whole amount of items or blocks you are holding will be immediately stored inside.";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 15:
- text = "If a displayer already contains an item and you have that in your inventory, you can simply hold right click on it with an empty hand to add all of your items of that type from your inventory. To retrieve a single item just left click the block. If you wish to";
+ case 10:
+ text = "simply right click with that object on it and the whole amount of items or blocks you are holding will be immediately stored inside. If a displayer already contains an item and you have that in your inventory, you can simply hold right click on it with an empty hand to add all of your items of that type from your inventory. To retrieve a single item just left click the block. If you wish to get a whole stack, Crouch + Left Click on it. In creative mode you can simply hold Right";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
- case 16:
- text = "get a whole stack, Crouch + Left Click on it. In creative mode you can simply hold Right Click on a displayer containing an object and it will add 64 of it with every right click, without it being in your inventory.";
+ case 11:
+ text = "Click on a displayer containing an object and it will add 64 of it with every right click, without it being in your inventory.";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
- case 17:
- text = "This mysterious shaped block is used in the ritual. The acient ones claimed it had the power to travel through worlds. They would use these to offer";
+ case 12:
+ text = "This mysterious shaped block is used in the ritual. The acient ones claimed it had the power to travel through worlds. They would use these to offer sacrifices to 'The Dark One' in exchange for unimaginable powers.";
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.handPedestal), new ItemStack(Blocks.cobblestone_wall), new ItemStack(Blocks.cobblestone_wall), new ItemStack(Blocks.cobblestone_wall), null, new ItemStack(Blocks.stonebrick), null, new ItemStack(Blocks.stone_slab, 1, 5), new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stone_slab, 1, 5));
break;
- case 18:
- text = "sacrifices to 'The Dark One' in exchange for unimaginable powers.";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 19:
- text = "The Cursed Eye is an ancient artifact also known as 'The Dark One's Eye'. It is part of the sacrifice ritual the ancient ones talk about. Be careful";
+ case 13:
+ text = "The Cursed Eye is an ancient artifact also known as 'The Dark One's Eye'. It is part of the sacrifice ritual the ancient ones talk about. Be careful though, for He sees everything. To see how to create the ritual look in the Ritual tab. One you created the ritual, simply place a";
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(BlockList.shadowEye), new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stained_hardened_clay, 1, 15), new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stained_hardened_clay, 1, 15), new ItemStack(Items.ender_eye), new ItemStack(Blocks.stained_hardened_clay, 1, 15), new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stained_hardened_clay, 1, 15), new ItemStack(Blocks.stonebrick));
break;
- case 20:
- text = "though, for He sees everything. To see how to create the ritual look in the Ritual tab. One you created the ritual, simple place a piece of jewelery in the middle pedestal and your modifiers of choice in the other ones (you don't need to put an item in every single pedestal). After";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 21:
- text = "you do that simply right click the eye to activate the ritual. Be careful not to leave the premise or you'll die! When the ritual is done, Shift+Right Click on the central hand pedestal to retrieve your newly modified item!";
+ case 14:
+ text = "piece of jewelery in the middle pedestal and your modifiers of choice in the other ones (you don't need to put an item in every single pedestal). After you do that simply right click the eye to activate the ritual. Be careful not to leave the premise or you'll die! When the ritual is done, Shift+Right Click on the central hand pedestal to retrieve your newly modified item!";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
- case 22:
+ case 15:
if (del == 0) values++;
del++;
- if (del >= 300) del = 0;
+ if (del >= 50) del = 0;
if (values >= 15) values = 0;
text = "Crystals don't do much as of yet. They spawn naturally in caves and come in all 16 colors.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.crystal, 1, values), text, 40f, true);
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.crystal, 1, values), text, 180f, 0, -18, true, 48, 120, true);
break;
default:
;
@@ -157,7 +129,7 @@ public class GuiTabBlocks extends GuiTab
@Override
public int getMaxPages()
{
- return 22;
+ return 16;
}
/**
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabCurses.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabCurses.java
new file mode 100644
index 0000000..0bbf258
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabCurses.java
@@ -0,0 +1,89 @@
+package darkknight.jewelrycraft.client.gui;
+
+import java.awt.Desktop;
+import java.net.URL;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.client.Page;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
+
+public class GuiTabCurses extends GuiTab
+{
+ public GuiTabCurses(int id) {
+ super(id);
+ }
+
+ public String getName() {
+ return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.curses");
+ }
+
+ @Override
+ public ItemStack getIcon() {
+ return new ItemStack(ItemList.testItem);
+ }
+
+ @Override
+ public void drawBackground(GuiGuide gui, int x, int y, int page) {
+ String text = "";
+ int xPos = page % 2 == 0 ? 107 : -35;
+ switch (page) {
+ case 1:
+ text = "You are poisoned for as long as this curse is active.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 0), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 2:
+ text = "Whenever you attack an entity you are set on fire.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 1), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 3:
+ text = "You can no longer throw any item. I mean, you might need them later, right?";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 2), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 4:
+ text = "You are blinded. Literally. I mean, what did you expect?";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 3), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 5:
+ text = "There is a random chance that when you attack a passive mob you will lose a full heart, but gain a black heart.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 4), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 6:
+ text = "Whatever you touch turns into gold. Believe me, this is no good to you, you can't even harvest this gold.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 5), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 7:
+ text = "Entities have a higher chance of dropping more items and hearts when killed.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 6), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 8:
+ text = "There is a random chance that you'll steal 1 heart from an entity that is collided with you. If you are low on health, you will heal. If you are fully healed, an extra heart will be added to you. You can steal up to 2 hearts per entity (3 if you complete the challenge). When you steal a heart, that entity will have their max health reduced by 1.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 7), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 9:
+ text = "When you attack an entity and are low on health, there is a 50% chance that you'll heal half a heart. Also you will catch on fire if you're exposed to sun.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 8), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ case 10:
+ text = "Any mob you kill or block you destroy(eg. Diamond Ore, Redstone Ore, stuff that drops items not the block itself) drops double the amount of items it normally would.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.testItem, 1, 9), text, 40f, 0, 0, Curse.getCurseList().get(page-1).getDisplayName(), 45, 10, false);
+ break;
+ default:;
+ }
+ }
+
+ @Override
+ public int getMaxPages() {
+ return 10;
+ }
+
+ @Override
+ public void drawForeground(GuiGuide gui, int x, int y, int page) {}
+}
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabGemsAndIngots.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabGemsAndIngots.java
index 33d94f2..a124703 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabGemsAndIngots.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabGemsAndIngots.java
@@ -1,92 +1,96 @@
-package darkknight.jewelrycraft.client.gui;
-
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.StatCollector;
-import org.lwjgl.opengl.GL11;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.Variables;
-
-public class GuiTabGemsAndIngots extends GuiTab
-{
-
- /**
- * @param id
- */
- public GuiTabGemsAndIngots(int id)
- {
- super(id);
- }
-
- public String getName()
- {
- return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.misc");
- }
-
- /**
- * @return
- */
- @Override
- public ItemStack getIcon()
- {
- return new ItemStack(Items.emerald);
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param page
- */
- @Override
- public void drawBackground(GuiGuide gui, int x, int y, int page)
- {
- int xPos = page % 2 == 0 ? 107 : -35;
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- for(int i = (page - 1) * 9; i < page * 9; i++)
- if (i < JewelrycraftUtil.gem.size()){
- gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Gems", gui.getLeft() + xPos + 40, gui.getTop(), 0);
- gui.renderItem(JewelrycraftUtil.gem.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16 * (i - 9 * (page - 1)), 30f, true, 0, 0, 0);
- gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.gem.get(i).getDisplayName()), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0);
- GL11.glDisable(GL11.GL_LIGHTING);
- }
- page -= JewelrycraftUtil.gem.size() / 9 + 1;
- for(int i = (page - 1) * 9; i < page * 9; i++)
- if (i < JewelrycraftUtil.metal.size() && page > 0){
- gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Ingots", gui.getLeft() + xPos + 40, gui.getTop(), 0);
- gui.renderItem(JewelrycraftUtil.metal.get(i).copy(), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16 * (i - 9 * (page - 1)), 30f, true, 0, 0, 0);
- gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.metal.get(i).copy().getDisplayName()), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0);
- GL11.glDisable(GL11.GL_LIGHTING);
- }
- page -= JewelrycraftUtil.metal.size() / 9 + 1;
- for(int i = (page - 1) * 9; i < page * 9; i++)
- if (i < JewelrycraftUtil.ores.size() && page > 0){
- gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Ores", gui.getLeft() + xPos + 40, gui.getTop(), 0);
- gui.renderItem(JewelrycraftUtil.ores.get(i).copy(), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16 * (i - 9 * (page - 1)), 30f, true, 0, 0, 0);
- gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.ores.get(i).copy().getDisplayName()), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0);
- GL11.glDisable(GL11.GL_LIGHTING);
- }
- GL11.glDisable(GL11.GL_BLEND);
- }
-
- /**
- * @return
- */
- @Override
- public int getMaxPages()
- {
- return JewelrycraftUtil.gem.size() / 9 + JewelrycraftUtil.metal.size() / 9 + JewelrycraftUtil.ores.size() / 9 + 4;
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param page
- */
- @Override
- public void drawForeground(GuiGuide gui, int x, int y, int page)
- {}
-}
+package darkknight.jewelrycraft.client.gui;
+
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
+
+public class GuiTabGemsAndIngots extends GuiTab
+{
+
+ /**
+ * @param id
+ */
+ public GuiTabGemsAndIngots(int id)
+ {
+ super(id);
+ }
+
+ public String getName()
+ {
+ return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.misc");
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public ItemStack getIcon()
+ {
+ return new ItemStack(Items.emerald);
+ }
+
+ /**
+ * @param gui
+ * @param x
+ * @param y
+ * @param page
+ */
+ @Override
+ public void drawBackground(GuiGuide gui, int x, int y, int page)
+ {
+ int xPos = page % 2 == 0 ? 107 : -35;
+ float scale = 0.75F;
+ for(int i = (page - 1) * 12; i < page * 12; i++)
+ if (i < JewelrycraftUtil.gem.size()){
+ GL11.glPushMatrix();
+ if(i==(page - 1) * 12) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Gems", gui.getLeft() + xPos + 40, gui.getTop(), 0);
+ GL11.glScalef(scale, scale, 0f);
+ gui.getFont().drawString(String.format("%-1.26s", JewelrycraftUtil.gem.get(i).getDisplayName()), (int)((gui.getLeft() + xPos + 12)/scale), (int)((gui.getTop() + 12 + 12 * (i - 12 * (page - 1)))/scale), 0);
+ GL11.glPopMatrix();
+ gui.renderItem(JewelrycraftUtil.gem.get(i), gui.getLeft() + xPos + 5, gui.getTop() + 18 + 12 * (i - 12 * (page - 1)), 24f, true, 0, 0, 0);
+ }
+ page -= JewelrycraftUtil.gem.size() / 13 + 1;
+ for(int i = (page - 1) * 12; i < page * 12; i++)
+ if (i < JewelrycraftUtil.metal.size() && page > 0){
+ GL11.glPushMatrix();
+ if(i==(page - 1) * 12) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Ingots", gui.getLeft() + xPos + 40, gui.getTop(), 0);
+ GL11.glScalef(scale, scale, 0f);
+ gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.metal.get(i).copy().getDisplayName()), (int)((gui.getLeft() + xPos + 12)/scale), (int)((gui.getTop() + 12 + 12 * (i - 12 * (page - 1)))/scale), 0);
+ GL11.glPopMatrix();
+ gui.renderItem(JewelrycraftUtil.metal.get(i), gui.getLeft() + xPos + 5, gui.getTop() + 18 + 12 * (i - 12 * (page - 1)), 24f, true, 0, 0, 0);
+ }
+ page -= JewelrycraftUtil.metal.size() / 13 + 1;
+ for(int i = (page - 1) * 12; i < page * 12; i++)
+ if (i < JewelrycraftUtil.ores.size() && page > 0){
+ GL11.glPushMatrix();
+ if(i==(page - 1) * 12) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Ores", gui.getLeft() + xPos + 40, gui.getTop(), 0);
+ GL11.glScalef(scale, scale, 0f);
+ gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.ores.get(i).copy().getDisplayName()), (int)((gui.getLeft() + xPos + 12)/scale), (int)((gui.getTop() + 12 + 12 * (i - 12 * (page - 1)))/scale), 0);
+ GL11.glPopMatrix();
+ gui.renderItem(JewelrycraftUtil.ores.get(i), gui.getLeft() + xPos + 5, gui.getTop() + 18 + 12 * (i - 12 * (page - 1)), 24f, true, 0, 0, 0);
+ }
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public int getMaxPages()
+ {
+ return (JewelrycraftUtil.gem.size() / 13) + (JewelrycraftUtil.metal.size() / 13) + (JewelrycraftUtil.ores.size() / 13) + 3;
+ }
+
+ /**
+ * @param gui
+ * @param x
+ * @param y
+ * @param page
+ */
+ @Override
+ public void drawForeground(GuiGuide gui, int x, int y, int page)
+ {}
+}
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabIntroduction.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabIntroduction.java
index 25acf21..158a1f5 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabIntroduction.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabIntroduction.java
@@ -1,59 +1,55 @@
-package darkknight.jewelrycraft.client.gui;
-
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.StatCollector;
-import darkknight.jewelrycraft.client.Page;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.util.Variables;
-
-public class GuiTabIntroduction extends GuiTab
-{
- public GuiTabIntroduction(int id)
- {
- super(id);
- }
-
- @Override
- public ItemStack getIcon()
- {
- return new ItemStack(ItemList.ring);
- }
-
- public String getName()
- {
- return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction");
- }
-
- @Override
- public void drawBackground(GuiGuide gui, int x, int y, int page)
- {
- String text = "";
- int xPos = page % 2 == 0 ? 107 : -35;
- switch(page)
- {
- case 1:
- text = StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction."+page);
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 2:
- text = StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction."+page);
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 3:
- text = StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction."+page);
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- }
- }
-
- @Override
- public int getMaxPages()
- {
- return 4;
- }
-
- @Override
- public void drawForeground(GuiGuide gui, int x, int y, int page)
- {}
-}
+package darkknight.jewelrycraft.client.gui;
+
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import darkknight.jewelrycraft.client.Page;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.util.Variables;
+
+public class GuiTabIntroduction extends GuiTab
+{
+ public GuiTabIntroduction(int id)
+ {
+ super(id);
+ }
+
+ @Override
+ public ItemStack getIcon()
+ {
+ return new ItemStack(ItemList.ring);
+ }
+
+ public String getName()
+ {
+ return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction");
+ }
+
+ @Override
+ public void drawBackground(GuiGuide gui, int x, int y, int page)
+ {
+ String text = "";
+ int xPos = page % 2 == 0 ? 107 : -35;
+ switch(page)
+ {
+ case 1:
+ text = StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction."+page);
+ Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
+ break;
+ case 2:
+ text = StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.introduction."+page);
+ Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
+ break;
+ }
+ }
+
+ @Override
+ public int getMaxPages()
+ {
+ return 2;
+ }
+
+ @Override
+ public void drawForeground(GuiGuide gui, int x, int y, int page)
+ {}
+}
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabItems.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabItems.java
index de77a73..e6883f9 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabItems.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabItems.java
@@ -57,11 +57,11 @@ public class GuiTabItems extends GuiTab
Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, x, y, true, new ItemStack(BlockList.shadowOre), new ItemStack(ItemList.shadowIngot));
break;
case 2:
- text = "These gloves give you the chance to steal the trades those pesky Testificates have to offer. To use these simply open their gui at least once, then Crouch and";
+ text = "These gloves give you the chance to steal the trades those pesky Testificates have to offer. To use these simply open their gui at least once, then Crouch and right click on the them to hopefully steal the trades. If you traded with him before, then you have a chance of getting the traded";
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, x, y, true, new ItemStack(ItemList.thiefGloves), new ItemStack(ItemList.shadowIngot), null, new ItemStack(ItemList.shadowIngot), new ItemStack(Blocks.wool, 1, 15), new ItemStack(ItemList.shadowIngot), new ItemStack(Blocks.wool, 1, 15), new ItemStack(Blocks.wool, 1, 15), new ItemStack(ItemList.shadowIngot), new ItemStack(Blocks.wool, 1, 15));
break;
case 3:
- text = "right click on the them to hopefully steal the trades. If you traded with him before, then you have a chance of getting the traded emeralds back as well. This has a maximum of 10 uses before it breaks.";
+ text = "emeralds back as well. This has a maximum of 10 uses before it breaks.";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
case 4:
@@ -97,33 +97,37 @@ public class GuiTabItems extends GuiTab
del++;
if (del >= 300) del = 0;
if (values > 4) values = 0;
- text = "It's this exact guide. I don't even know why you're reading this. I added this recipe in case you lose the original. Even if this is more helpful than NEI, I do suggest";
+ text = "It's this exact guide. I don't even know why you're reading this. I added this recipe in case you lose the original. Even if this is more helpful than NEI, I do suggest installing it so you can see all the recipes. Since you are reading this, how about making a youtube video spotlighting this mod. I'd really";
Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, x, y, true, new ItemStack(ItemList.guide), new ItemStack(ItemList.molds, 1, values), new ItemStack(Items.book));
break;
case 11:
String link = "HERE";
- if (x >= gui.getLeft() && x <= gui.getLeft() + 30 && y >= gui.getTop() + 104 && y <= gui.getTop() + 124) link = EnumChatFormatting.DARK_BLUE + "HERE" + EnumChatFormatting.BLACK;
- text = "installing it so you can see all the recipes. Since you are reading this, how about making a youtube video spotlighting this mod. I'd really appreciate it. After that you can share it in the main thread " + link + ".";
+ if (x >= gui.getLeft() - 7 && x <= gui.getLeft() + 10 && y >= gui.getTop() + 20 && y <= gui.getTop() + 34) link = EnumChatFormatting.DARK_BLUE + "HERE" + EnumChatFormatting.BLACK;
+ text = "appreciate it. After that you can share it in the main thread " + link + ".";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
case 12:
ItemStack item = new ItemStack(ItemList.bucket);
if (del == 0) values++;
del++;
- if (del >= 300) del = 0;
+ if (del >= 50) del = 0;
if (values > JewelrycraftUtil.metal.size() - 1) values = 0;
JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy());
text = "These buckets contain molten metal. To obtain one simply Right Click a full Smelter to get a bucket. You can pour the metal, other than that it has no use. You can place the molten metal back in a Smelter by Right Clicking one with it.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, item, text, 40f, 0, 0, true, 45, 10, true);
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, item, text, 40f, 0, 0, true, 45, 10, false);
break;
case 13:
- text = "This item is a creative only item! Right click it while in creative mode to open a GUI. Place a piece of jewelery inside the slot, select what you want to add, then click on 'Add Items'. If you selected Modifiers, you can select multiple";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.jewelryModifier), text, 40f, 0, 0, true, 45, 10, true);
+ text = "This item is a creative only item! Right click it while in creative mode to open a GUI. Place a piece of jewelery inside the slot, select what you want to add, then click on 'Add Items'. If you selected Modifiers, you can select multiple items at once. The 'Item' button is to add an Item to a Golden Object, which can not be obtained normally. This tool can be really useful, especially for those";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.jewelryModifier), text, 40f, 0, 0, true, 45, 10, false);
break;
case 14:
- text = "items at once. The 'Item' button is to add an Item to a Golden Object, which can not be obtained normally. This tool can be really useful, especially for those who want to test the mod and can't wait for the normal processes to finish (Smelter, Jewelers Table, Ritual).";
+ text = "who want to test the mod and can't wait for the normal processes to finish (Smelter, Jewelers Table, Ritual).";
Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
break;
+ case 15:
+ text = "This item is a creative only item! If you right click in the air while holding this item you'll increment the number of the structure to spawn. Crouch and right click to go backwards. To spawn a structure simply right click on a block with this.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, new ItemStack(ItemList.structureGen), text, 40f, 0, 0, true, 45, 10, false);
+ break;
default:
;
}
@@ -147,8 +151,8 @@ public class GuiTabItems extends GuiTab
@Override
public void mouseClick(GuiGuide gui, int x, int y, int button)
{
- if (gui.page == 13 && x >= gui.getLeft() && x <= gui.getLeft() + 30 && y >= gui.getTop() + 104 && y <= gui.getTop() + 124) try{
- Desktop.getDesktop().browse(new URL("http://www.minecraftforum.net/forums/topics/2414865").toURI());
+ if (gui.page == 11 && x >= gui.getLeft() - 7 && x <= gui.getLeft() + 10 && y >= gui.getTop() + 20 && y <= gui.getTop() + 34) try{
+ Desktop.getDesktop().browse(new URL("http://minecraft.curseforge.com/mc-mods/229927-jewelrycraft-2").toURI());
}
catch(Exception e){}
}
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabModifiers.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabModifiers.java
index 1f92967..dd8573f 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabModifiers.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiTabModifiers.java
@@ -1,94 +1,90 @@
-package darkknight.jewelrycraft.client.gui;
-
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.StatCollector;
-import darkknight.jewelrycraft.client.Page;
-import darkknight.jewelrycraft.util.Variables;
-
-public class GuiTabModifiers extends GuiTab
-{
- int maxPages;
- public GuiTabModifiers(int id)
- {
- super(id);
- }
-
- public String getName()
- {
- return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.modifiers");
- }
-
- /**
- * @return
- */
- @Override
- public ItemStack getIcon()
- {
- return new ItemStack(Items.blaze_powder);
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param page
- */
- @Override
- public void drawBackground(GuiGuide gui, int x, int y, int page)
- {
- String text = "";
- int xPos = page % 2 == 0 ? 107 : -35;
- switch(page)
- {
- case 1:
- text = "Although you can add anything as a modifier, only some objects have an effect. In this tab you can find all modifiers that have a use and what they do, in the form of a story/riddle/poem. However, different jewellery have different effects for the same modifier.";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- case 2:
- text = "The ancient ones talked about a rising fire in your heart. Fret do not, for flames do not burn, but water might sting a turn. Watch your step, do not be cocky, for its protection is a bit sloppy.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.blaze_powder), text, 40f, true);
- break;
- case 3:
- text = "Light and swift as a feather can be good all together. Enemies miss and get confused, this power can be abused. Against an arrow you can't compare, so move around, don't just stare. Fire is your enemy and weakness is the penalty.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.feather), text, 40f, true);
- break;
- case 4:
- text = "Endermen may tolerate you, end portals are near too, you may find ore that is true. But be careful, for the power may make you dizzy, blind you if you're a sissy, worsen your vision if you're unaware and shift positions everywhere.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.ender_eye), text, 40f, true);
- break;
- case 5:
- text = "Through the power of a pearl arrows don't know where to go. In confusion they can explode, making you a helpless toad. But if an enemy hits, they get damaged like a blitz. You may be weaker, water is bad, but you get saved if health is weak like a lilly pad.";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.ender_pearl), text, 40f, true);
- break;
- case 6:
- text = "Toughest stone made on Earth, falling damage is absurd. Deal more damage, more protection, anvils and arrows need inspection. But after long and hard abuse, the stone is starting to get loose. You are weak and heavy, sink like a ship, arrows need only one";
- Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Blocks.obsidian), text, 40f, true);
- break;
- case 7:
- text = "hit, deal less damage overall, don't abuse its power now.";
- Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
- break;
- }
- }
-
- /**
- * @return
- */
- @Override
- public int getMaxPages()
- {
- return 7;
- }
-
- /**
- * @param gui
- * @param x
- * @param y
- * @param page
- */
- @Override
- public void drawForeground(GuiGuide gui, int x, int y, int page)
- {}
-}
+package darkknight.jewelrycraft.client.gui;
+
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import darkknight.jewelrycraft.client.Page;
+import darkknight.jewelrycraft.util.Variables;
+
+public class GuiTabModifiers extends GuiTab
+{
+ int maxPages;
+ public GuiTabModifiers(int id)
+ {
+ super(id);
+ }
+
+ public String getName()
+ {
+ return StatCollector.translateToLocal("guide." + Variables.MODID + ".tab.modifiers");
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public ItemStack getIcon()
+ {
+ return new ItemStack(Items.blaze_powder);
+ }
+
+ /**
+ * @param gui
+ * @param x
+ * @param y
+ * @param page
+ */
+ @Override
+ public void drawBackground(GuiGuide gui, int x, int y, int page)
+ {
+ String text = "";
+ int xPos = page % 2 == 0 ? 107 : -35;
+ switch(page)
+ {
+ case 1:
+ text = "Although you can add anything as a modifier, only some objects have an effect. In this tab you can find all modifiers that have a use and what they do, in the form of a story/riddle/poem. However, different jewellery have different effects for the same modifier.";
+ Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text);
+ break;
+ case 2:
+ text = "The ancient ones talked about a rising fire in your heart. Fret do not, for flames do not burn, but water might sting a turn. Watch your step, do not be cocky, for its protection is a bit sloppy.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.blaze_powder), text, 40f, true);
+ break;
+ case 3:
+ text = "Light and swift as a feather can be good all together. Enemies miss and get confused, this power can be abused. Against an arrow you can't compare, so move around, don't just stare. Fire is your enemy and weakness is the penalty.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.feather), text, 40f, true);
+ break;
+ case 4:
+ text = "Endermen may tolerate you, end portals are near too, you may find ore that is true. But be careful, for the power may make you dizzy, blind you if you're a sissy, worsen your vision if you're unaware and shift positions everywhere.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.ender_eye), text, 40f, true);
+ break;
+ case 5:
+ text = "Through the power of a pearl arrows don't know where to go. In confusion they can explode, making you a helpless toad. But if an enemy hits, they get damaged like a blitz. You may be weaker, water is bad, but you get saved if health is weak like a lilly pad.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Items.ender_pearl), text, 40f, true);
+ break;
+ case 6:
+ text = "Toughest stone made on Earth, falling damage is absurd. Deal more damage, more protection, anvils and arrows need inspection. But after long and hard abuse, the stone is starting to get loose. You are weak and heavy, sink like a ship, arrows need only one hit, deal less damage overall, don't abuse its power now.";
+ Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 10, new ItemStack(Blocks.obsidian), text, 40f, true);
+ break;
+ }
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public int getMaxPages()
+ {
+ return 6;
+ }
+
+ /**
+ * @param gui
+ * @param x
+ * @param y
+ * @param page
+ */
+ @Override
+ public void drawForeground(GuiGuide gui, int x, int y, int page)
+ {}
+}
diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java
index 8252f1a..6324a86 100644
--- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java
@@ -32,6 +32,7 @@ public class ConfigHandler
public static int FURNACE_MAX_INGOT_STACK;
public static boolean CRYSTAL_GLOW;
+ public static boolean CRYSTAL_PARTICLES;
public static boolean HEARTS_DESPAWN;
public static boolean JEWELRY_INFO;
@@ -50,11 +51,7 @@ public class ConfigHandler
public static boolean ENABLE_WORLD_GEN = true;
public static boolean ORE_GEN = true;
public static boolean CRYSTAL_GEN = true;
- public static boolean STRUCTURE_1_GEN = true;
- public static boolean STRUCTURE_2_GEN = true;
- public static boolean STRUCTURE_3_GEN = true;
- public static boolean STRUCTURE_4_GEN = true;
- public static boolean STRUCTURE_5_GEN = true;
+ public static boolean STRUCTURES[] = {true, true, true, true, true, true};
public void loadConfig(FMLPreInitializationEvent event)
{
@@ -85,17 +82,15 @@ public class ConfigHandler
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)");
+ CRYSTAL_PARTICLES = config.getBoolean("Crystal Particles", categories[2], true, "If false, then crystal will no longer spawn particles");
HEARTS_DESPAWN = config.getBoolean("Hearts Despawn", categories[2], true, "If false, then Hearts and Half-hearts will no longer despawn");
JEWELRY_INFO = config.getBoolean("Jewelry Info", categories[2], true, "If false, then extra info won't be show when hovering over a jewelery.");
ENABLE_WORLD_GEN = config.getBoolean("World Generation", categories[3], true, "If false, nothing will generate (this includes ore)");
ORE_GEN = config.getBoolean("Ore Generation", categories[3], true, "If false, ores won't generate");
CRYSTAL_GEN = config.getBoolean("Crystal Generation", categories[3], true, "If false, crystals won't generate");
- STRUCTURE_1_GEN = config.getBoolean("Structure 1 Generation", categories[3], true, "If false, structure no.1 won't generate");
- STRUCTURE_2_GEN = config.getBoolean("Structure 2 Generation", categories[3], true, "If false, structure no.2 won't generate");
- STRUCTURE_3_GEN = config.getBoolean("Structure 3 Generation", categories[3], true, "If false, structure no.3 won't generate");
- STRUCTURE_4_GEN = config.getBoolean("Structure 4 Generation", categories[3], true, "If false, structure no.4 won't generate");
- STRUCTURE_5_GEN = config.getBoolean("Structure 5 Generation", categories[3], true, "If false, structure no.5 won't generate");
+ for(int i = 0; i < STRUCTURES.length; i++)
+ STRUCTURES[i] = config.getBoolean("Structure "+(i+1)+" Generation", categories[3], true, "If false, structure no."+(i+1)+" won't generate");
// 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.");
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseDeathsTouch.java b/src/main/java/darkknight/jewelrycraft/curses/CurseDeathsTouch.java
new file mode 100644
index 0000000..3a4d984
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseDeathsTouch.java
@@ -0,0 +1,49 @@
+package darkknight.jewelrycraft.curses;
+
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.entities.EntityHalfHeart;
+import darkknight.jewelrycraft.entities.EntityHeart;
+import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
+import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.SharedMonsterAttributes;
+import net.minecraft.entity.monster.EntityMob;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+
+public class CurseDeathsTouch extends Curse
+{
+ public CurseDeathsTouch(String name, int txtID, String pack)
+ {
+ super(name, txtID, pack);
+ }
+
+ @Override
+ public boolean attackedByPlayerActionCancelable(LivingAttackEvent event, World world, EntityPlayer player, Entity target)
+ {
+ if (!world.isRemote) target.attackEntityFrom(DamageSource.wither, event.ammount);
+ return true;
+ }
+
+ public String getDescription()
+ {
+ return StatCollector.translateToLocal("curse." + Variables.MODID + ".deathsTouch.description");
+ }
+
+ @Override
+ public String getDisplayName()
+ {
+ return StatCollector.translateToLocal("curse." + Variables.MODID + ".deathsTouch");
+ }
+
+}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
index 138f322..f56c66d 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
@@ -11,10 +11,13 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderPlayerEvent;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.damage.DamageSourceList;
@@ -22,6 +25,8 @@ import darkknight.jewelrycraft.entities.EntityHalfHeart;
import darkknight.jewelrycraft.entities.EntityHeart;
import darkknight.jewelrycraft.entities.renders.RenderHelper;
import darkknight.jewelrycraft.item.render.MaskRender;
+import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
+import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.util.PlayerUtils;
import darkknight.jewelrycraft.util.Variables;
@@ -34,7 +39,7 @@ public class CurseInfamy extends Curse
}
@Override
- public void attackedByPlayerAction(World world, EntityPlayer player, Entity target)
+ public void attackedByPlayerAction(LivingAttackEvent event, World world, EntityPlayer player, Entity target)
{
if (rand.nextInt(5) == 0 && !world.isRemote && !(target instanceof EntityMob) && target instanceof EntityLiving && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && target.canAttackWithItem()){
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
@@ -44,6 +49,8 @@ public class CurseInfamy extends Curse
player.setHealth(player.getHealth() - 1.0F);
}
JewelrycraftUtil.addCursePoints(player, 10);
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java
index a812b24..6c682a2 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java
@@ -1,42 +1,42 @@
-package darkknight.jewelrycraft.curses;
-
-import cpw.mods.fml.common.event.FMLPreInitializationEvent;
-import darkknight.jewelrycraft.api.Curse;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.util.Variables;
-
-public class CurseList
-{
- public static Curse rotten;
- public static Curse flaming;
- public static Curse blind;
- public static Curse greed;
- public static Curse infamy;
- public static Curse midasTouch;
- public static Curse rabbitsPaw;
- public static Curse pentagram;
- public static Curse vampireHunger;
- public static Curse humbleBundle;
- public static Curse deathsTouch;
- public static Curse antichrist;
- public static Curse moneyEqualsPower;
-
- public static void preInit(FMLPreInitializationEvent e)
- {
- if (ConfigHandler.CURSES_ENABLED){
- rotten = new CurseRottenHeart(Variables.MODNAME + ":" + "Rotten Heart", 0, Variables.MODID + "_curses_0");
- flaming = new CurseFlamingSoul(Variables.MODNAME + ":" + "Flaming Soul", 1, Variables.MODID + "_curses_0");
- greed = new CurseGreed(Variables.MODNAME + ":" + "Greed", 2, Variables.MODID + "_curses_0");
- blind = new CurseBlind(Variables.MODNAME + ":" + "Blind", 3, Variables.MODID + "_curses_0");
- infamy = new CurseInfamy(Variables.MODNAME + ":" + "Infamy", 4, Variables.MODID + "_curses_0");
- midasTouch = new CurseMidasTouch(Variables.MODNAME + ":" + "Midas Touch", 5, Variables.MODID + "_curses_0");
- rabbitsPaw = new CurseRabbitsPaw(Variables.MODNAME + ":" + "Rabbit's Paw", 6, Variables.MODID + "_curses_0");
- pentagram = new CursePentagram(Variables.MODNAME + ":" + "Pentagram", 7, Variables.MODID + "_curses_0");
- vampireHunger = new CurseVampireHunger(Variables.MODNAME + ":" + "Vampire Hunger", 8, Variables.MODID + "_curses_0");
- humbleBundle = new CurseHumbleBundle(Variables.MODNAME + ":" + "Humble Bundle", 9, Variables.MODID + "_curses_0");
- }
- // deathsTouch = new CurseMidasTouch(Variables.MODNAME + ":" + "Deaths Touch", 10, Variables.MODID + "_curses_0");
- // antichrist = new CurseMidasTouch(Variables.MODNAME + ":" + "Antichrist", 11, Variables.MODID + "_curses_0");
- // moneyEqualsPower = new CurseMidasTouch(Variables.MODNAME + ":" + "Money Equals Power", 12, Variables.MODID + "_curses_0");
- }
-}
+package darkknight.jewelrycraft.curses;
+
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.Variables;
+
+public class CurseList
+{
+ public static Curse rotten;
+ public static Curse flaming;
+ public static Curse blind;
+ public static Curse greed;
+ public static Curse infamy;
+ public static Curse midasTouch;
+ public static Curse rabbitsPaw;
+ public static Curse pentagram;
+ public static Curse vampireHunger;
+ public static Curse humbleBundle;
+ public static Curse deathsTouch;
+ public static Curse antichrist;
+ public static Curse moneyEqualsPower;
+
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ if (ConfigHandler.CURSES_ENABLED){
+ rotten = new CurseRottenHeart(Variables.MODNAME + ":" + "Rotten Heart", 0, Variables.MODID + "_curses_0");
+ flaming = new CurseFlamingSoul(Variables.MODNAME + ":" + "Flaming Soul", 1, Variables.MODID + "_curses_0");
+ greed = new CurseGreed(Variables.MODNAME + ":" + "Greed", 2, Variables.MODID + "_curses_0");
+ blind = new CurseBlind(Variables.MODNAME + ":" + "Blind", 3, Variables.MODID + "_curses_0");
+ infamy = new CurseInfamy(Variables.MODNAME + ":" + "Infamy", 4, Variables.MODID + "_curses_0");
+ midasTouch = new CurseMidasTouch(Variables.MODNAME + ":" + "Midas Touch", 5, Variables.MODID + "_curses_0");
+ rabbitsPaw = new CurseRabbitsPaw(Variables.MODNAME + ":" + "Rabbit's Paw", 6, Variables.MODID + "_curses_0");
+ pentagram = new CursePentagram(Variables.MODNAME + ":" + "Pentagram", 7, Variables.MODID + "_curses_0");
+ vampireHunger = new CurseVampireHunger(Variables.MODNAME + ":" + "Vampire Hunger", 8, Variables.MODID + "_curses_0");
+ humbleBundle = new CurseHumbleBundle(Variables.MODNAME + ":" + "Humble Bundle", 9, Variables.MODID + "_curses_0");
+ deathsTouch = new CurseDeathsTouch(Variables.MODNAME + ":" + "Deaths Touch", 10, Variables.MODID + "_curses_0");
+ // antichrist = new CurseMidasTouch(Variables.MODNAME + ":" + "Antichrist", 11, Variables.MODID + "_curses_0");
+ // moneyEqualsPower = new CurseMidasTouch(Variables.MODNAME + ":" + "Money Equals Power", 12, Variables.MODID + "_curses_0");
+ }
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java
index 8133b75..0ce2810 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java
@@ -23,6 +23,7 @@ import net.minecraft.item.ItemSword;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.config.ConfigHandler;
@@ -41,7 +42,7 @@ public class CurseMidasTouch extends Curse
}
@Override
- public void attackedByPlayerAction(World world, EntityPlayer player, Entity target)
+ public void attackedByPlayerAction(LivingAttackEvent event, World world, EntityPlayer player, Entity target)
{
if (!world.isRemote && target instanceof EntityLivingBase && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && player.inventory.getCurrentItem() == null){
world.setBlock(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), BlockList.midasTouchBlock, 0, 2);
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java b/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java
index 730542a..56a1b11 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java
@@ -1,5 +1,15 @@
package darkknight.jewelrycraft.curses;
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.achievements.AchievementsList;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
@@ -7,26 +17,18 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.DamageSource;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
-import org.lwjgl.opengl.GL11;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.api.Curse;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.damage.DamageSourceList;
-import darkknight.jewelrycraft.util.Variables;
-
public class CursePentagram extends Curse {
- float rot = 0F;
+ float rot = 0F;
public CursePentagram(String name, int txtID, String pack) {
super(name, txtID, pack);
@@ -34,22 +36,32 @@ public class CursePentagram extends Curse {
@Override
public void action(World world, EntityPlayer player) {
+ super.action(world, player);
if (!world.isRemote) {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
for (Object entity : world.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(player.boundingBox.minX - 0.5F, player.boundingBox.minY, player.boundingBox.minZ - 0.5F, player.boundingBox.maxX + 0.5F, player.boundingBox.maxY, player.boundingBox.maxZ + 0.5F))) {
- if (entity instanceof EntityLivingBase && rand.nextInt(40) == 0) {
- ((EntityLivingBase) entity).getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(((EntityLivingBase) entity).getMaxHealth() - 2f);//attackEntityFrom(DamageSourceList.shadows, 2f);
- if (player.shouldHeal()) player.heal(2F);
- else player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f);
+ if (entity instanceof EntityLivingBase) {
+ NBTTagCompound target = ((EntityLivingBase) entity).getEntityData();
+ if (target.getInteger("stolenHealth") < (JewelrycraftUtil.AchievemtUnlocked(player, AchievementsList.pentagram) ? 3 : 2) && rand.nextInt(40) == 0) {
+ ((EntityLivingBase) entity).getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(((EntityLivingBase) entity).getMaxHealth() - 2f);
+ target.setInteger("stolenHealth", target.hasKey("stolenHealth") ? target.getInteger("stolenHealth") + 1 : 1);
+ playerInfo.setInteger("heartsStolen", playerInfo.hasKey("heartsStolen") ? playerInfo.getInteger("heartsStolen") + 1 : 1);
+ if (player.shouldHeal()) player.heal(2F);
+ else player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f);
+ }
+ }
+ }
+ if (!playerInfo.getBoolean(AchievementsList.pentagram.statId)) {
+ if (ticksActive > 24000 && playerInfo.getInteger("heartsStolen") <= 0) player.addStat(AchievementsList.pentagram, 1);
+ else {
+ player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + StatCollector.translateToLocal("challenge.failed") + " " + EnumChatFormatting.GOLD + StatCollector.translateToLocal(AchievementsList.pentagram.statId)));
+ playerInfo.setBoolean(AchievementsList.pentagram.statId, true);
}
}
}
}
@Override
- public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) {
- }
-
- @Override
public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) {
ResourceLocation PENTAGRAM_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/" + getTexturePack() + ".png");
GL11.glPushMatrix();
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java b/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java
index c486e5d..3d6a2da 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java
@@ -5,6 +5,7 @@ package darkknight.jewelrycraft.curses;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import darkknight.jewelrycraft.api.Curse;
@@ -24,7 +25,13 @@ public class CurseVampireHunger extends Curse
public void attackedByPlayerAction(World world, EntityPlayer player, Entity target)
{
- if(player.shouldHeal() && rand.nextInt(5) == 0) player.heal(1F);
+ if(player.shouldHeal() && rand.nextBoolean()) player.heal(1F);
+ }
+
+ public void action(World world, EntityPlayer player)
+ {
+ if(!player.capabilities.isCreativeMode && world.isDaytime() && !world.isRaining() && world.canBlockSeeTheSky(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY + 1F), MathHelper.floor_double(player.posZ)))
+ player.setFire(8);
}
public String getDescription()
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
index 17db979..4e0a14b 100644
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
@@ -18,65 +18,52 @@ import darkknight.jewelrycraft.util.JewelryNBT;
import darkknight.jewelrycraft.util.PlayerUtils;
import darkknight.jewelrycraft.util.Variables;
-public class EffectBlazePowder extends ModifierEffects
-{
- public EffectBlazePowder()
- {
- super(new ItemStack(Items.blaze_powder));
- }
-
- @Override
- public void action(ItemStack item, EntityPlayer player, Item jewelry)
- {
- if (jewelry instanceof ItemNecklace){
- // Positive for necklace
- if (player.isBurning() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) player.extinguish();
- // Negative for necklace
- if (player.isInWater()) player.attackEntityFrom(DamageSource.drown, 1f + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F);
- }
- // Negative for bracelet
- if (jewelry instanceof ItemBracelet && player.isInWater()){
- double slowAmount = 0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D;
- player.motionX *= slowAmount;
- player.motionY *= slowAmount;
- player.motionZ *= slowAmount;
- player.motionY -= (0.02D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.005D);
- if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D;
- }
- // Negative for earrings
- if (jewelry instanceof ItemEarrings){
- if (player.getAir() >= 300) player.setAir(player.getAir() / 2);
- else player.setAir(player.getAir() - JewelryNBT.numberOfModifiers(item));
- }
- }
-
- @Override
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
- {
- // Balanced for ring
- if (jewelry instanceof ItemRing && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) target.setFire(2);
- return false;
- }
-
- @Override
- public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
- {
- return false;
- }
-
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
- {}
-
- public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
- {
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (jewelry instanceof ItemEarrings && rand.nextInt(4) == 0) if (source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire){
- // Positive for earrings
- int stackSize = JewelryNBT.modifierSize(item, modifier);
- player.heal(stackSize*0.05F - (JewelryNBT.numberOfModifiers(item) - 1)*0.01F);
- playerInfo.setBoolean("negateDamage", true);
- }
- // Positive for bracelet
- if (jewelry instanceof ItemBracelet) if (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava && player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY - 0.7, player.boundingBox.maxZ), Material.lava) && !player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY + 0.9, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY, player.boundingBox.maxZ), Material.lava)) playerInfo.setBoolean("negateDamage", true);
- }
+public class EffectBlazePowder extends ModifierEffects {
+ public EffectBlazePowder() {
+ super(new ItemStack(Items.blaze_powder));
+ }
+
+ @Override
+ public void action(ItemStack item, EntityPlayer player, Item jewelry) {
+ if (jewelry instanceof ItemNecklace) {
+ // Positive for necklace
+ if (player.isBurning() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) player.extinguish();
+ // Negative for necklace
+ if (player.isInWater()) player.attackEntityFrom(DamageSource.drown, 1f + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F);
+ }
+ // Negative for bracelet
+ if (jewelry instanceof ItemBracelet && player.isInWater()) {
+ double slowAmount = 0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D;
+ player.motionX *= slowAmount;
+ player.motionY *= slowAmount;
+ player.motionZ *= slowAmount;
+ player.motionY -= (0.02D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.005D);
+ if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D;
+ }
+ // Negative for earrings
+ if (jewelry instanceof ItemEarrings) {
+ if (player.getAir() >= 300) player.setAir(player.getAir() / 2);
+ else player.setAir(player.getAir() - JewelryNBT.numberOfModifiers(item));
+ }
+ }
+
+ @Override
+ public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) {
+ // Balanced for ring
+ if (jewelry instanceof ItemRing && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) target.setFire(2);
+ return false;
+ }
+
+ public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (jewelry instanceof ItemEarrings && rand.nextInt(4) == 0 && source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire) {
+ // Positive for earrings
+ int stackSize = JewelryNBT.modifierSize(item, modifier);
+ player.heal(stackSize * 0.05F - (JewelryNBT.numberOfModifiers(item) - 1) * 0.01F);
+ return true;
+ }
+ // Positive for bracelet
+ if (jewelry instanceof ItemBracelet) if (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava && player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY - 0.7, player.boundingBox.maxZ), Material.lava) && !player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY + 0.9, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY, player.boundingBox.maxZ), Material.lava)) return true;
+ return false;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
index d0a48d5..8efebcd 100644
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
@@ -61,35 +61,37 @@ public class EffectFeather extends ModifierEffects
}
@Override
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
+ public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
{
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
NBTTagCompound enemyData = target.getEntityData();
- if (jewelry instanceof ItemRing){
+ if (jewelry instanceof ItemRing && !player.worldObj.isRemote){
if (enemyData.getInteger("reAttacked") == 0){
// Negative ring
enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1);
- target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount / (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
+ target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount / (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.3F));
// Positive ring
if (rand.nextInt(2) == 0 && target instanceof EntityLivingBase) ((EntityLivingBase)target).addPotionEffect(new PotionEffect(PotionList.stun.id, (51 - JewelryNBT.numberOfModifiers(item))*2, 0, false));
- playerInfo.setBoolean("weakDamage", true);
+ return true;
}
- if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0);
+ else enemyData.setInteger("reAttacked", 0);
}
+ return false;
}
@Override
- public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
+ public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
{
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
// Positive necklace
if (jewelry instanceof ItemNecklace && rand.nextInt(3 + JewelryNBT.numberOfModifiers(item)) == 0 && source != DamageSourceList.weak && source != DamageSource.inFire && source != DamageSource.onFire && source != DamageSource.lava){
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY + StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.feather")));
- playerInfo.setBoolean("negateDamage", true);
+ return true;
}
// Negative necklace
if (jewelry instanceof ItemNecklace && (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava) && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (3F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
// Negative earrings
- if (jewelry instanceof ItemEarrings && source.damageType.equals("arrow") && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
+ if (jewelry instanceof ItemEarrings && source.damageType.equals("arrow")) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
+ return false;
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
index cf409b2..0a7f268 100644
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
@@ -53,22 +53,23 @@ public class EffectObsidian extends ModifierEffects
}
@Override
- public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
+ public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
{
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
if (jewelry instanceof ItemEarrings && (source == DamageSource.anvil || source.damageType.equals("arrow"))){
if (playerInfo.hasKey("protected")) playerInfo.setInteger("protected", playerInfo.getInteger("protected") + 1);
else playerInfo.setInteger("protected", 1);
// Positive && Negative earrings
- if (playerInfo.getInteger("protected") < 200) playerInfo.setBoolean("negateDamage", true);
+ if (playerInfo.getInteger("protected") < 2000) return true;
else player.attackEntityFrom(DamageSourceList.weak, player.getHealth() * 3F);
}
if (jewelry instanceof ItemBracelet && source == DamageSource.fall){
if (playerInfo.hasKey("falls")) playerInfo.setInteger("falls", playerInfo.getInteger("falls") + 1);
else playerInfo.setInteger("falls", 1);
// Positive bracelet
- if (playerInfo.getInteger("falls") < 300) playerInfo.setBoolean("negateDamage", true);
+ if (playerInfo.getInteger("falls") < 3000) return true;
}
+ return false;
}
public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry)
@@ -79,21 +80,22 @@ public class EffectObsidian extends ModifierEffects
playerInfo.setInteger("protected", 0);
}
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
+ public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
{
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
NBTTagCompound enemyData = target.getEntityData();
// Positive ring
- if (jewelry instanceof ItemRing && playerInfo.getInteger("strikes") < 200 && !player.worldObj.isRemote){
+ if (jewelry instanceof ItemRing && playerInfo.getInteger("strikes") < 2000 && !player.worldObj.isRemote){
if (enemyData.getInteger("reAttacked") == 0){
if (playerInfo.hasKey("strikes")) playerInfo.setInteger("strikes", playerInfo.getInteger("strikes") + 1);
else playerInfo.setInteger("strikes", 1);
// Negative ring
enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1);
- target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 2F);
- playerInfo.setBoolean("weakDamage", true);
+ target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 1.5F);
+ return true;
}
if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0);
}
+ return false;
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java b/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java
index 793fcd5..7f547bb 100644
--- a/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java
+++ b/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java
@@ -10,6 +10,9 @@ import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -73,8 +76,8 @@ public class EntityHeart extends EntityLiving {
} else if (getType().equals("White") && playerInfo.getFloat("WhiteHeart") > 0.1F) {
playerInfo.setFloat(getType() + "Heart", 0F);
player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f);
+ player.setHealth(player.getHealth() + 2f);
JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
-// player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + playerInfo.getFloat("WhiteHeart"));
this.setDead();
} else if (!getType().equals("Red")) {
if(playerInfo.hasKey(getType() + "Heart")) playerInfo.setFloat(getType() + "Heart", playerInfo.getFloat(getType() + "Heart") + getQuantity());
@@ -85,6 +88,13 @@ public class EntityHeart extends EntityLiving {
}
}
}
+
+ public void onDeath(DamageSource source)
+ {
+ super.onDeath(source);
+ if(source.getEntity() != null && source.getEntity() instanceof EntityPlayer)
+ ((EntityPlayer)source.getEntity()).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".heartKilled."+this.getType())));
+ }
@SideOnly(Side.CLIENT)
public boolean canRenderOnFire() {
diff --git a/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java b/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java
index c11f2ee..38e60a5 100644
--- a/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java
@@ -9,6 +9,11 @@ package darkknight.jewelrycraft.events;
import java.util.HashMap;
import java.util.Map;
+import cpw.mods.fml.common.eventhandler.Event.Result;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import darkknight.jewelrycraft.block.BlockMoltenMetal;
+import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal;
+import darkknight.jewelrycraft.util.JewelryNBT;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@@ -16,26 +21,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;
-import cpw.mods.fml.common.eventhandler.Event.Result;
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.block.BlockMoltenMetal;
-import darkknight.jewelrycraft.util.JewelryNBT;
public class BucketHandler
{
public static BucketHandler INSTANCE = new BucketHandler();
public Map<Block, Item> buckets = new HashMap<Block, Item>();
- /**
- *
- */
private BucketHandler()
{}
- /**
- * @param event
- */
@SubscribeEvent
public void onBucketFill(FillBucketEvent event)
{
@@ -45,33 +39,14 @@ public class BucketHandler
event.setResult(Result.ALLOW);
}
- /**
- * @param world
- * @param pos
- * @return
- */
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
Item bucket = buckets.get(block);
if (bucket != null && world.getBlock(pos.blockX, pos.blockY, pos.blockZ) != Blocks.air && world.getBlock(pos.blockX, pos.blockY, pos.blockZ) instanceof BlockMoltenMetal){
- world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
ItemStack item = new ItemStack(bucket);
- String ingotData = JewelrycraftMod.saveData.getString(pos.blockX + " " + pos.blockY + " " + pos.blockZ + " " + world.provider.dimensionId);
- if (ingotData != null && ingotData != ""){
- String[] splitData = ingotData.split(":");
- if (splitData.length == 2){
- int itemID, itemDamage;
- try{
- itemID = Integer.parseInt(splitData[0]);
- itemDamage = Integer.parseInt(splitData[1]);
- JewelryNBT.addMetal(item, new ItemStack(Item.getItemById(itemID), 1, itemDamage));
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- }
+ if(BlockMoltenMetal.getTileEntity(world, pos.blockX, pos.blockY, pos.blockZ) != null) JewelryNBT.addMetal(item, BlockMoltenMetal.getTileEntity(world, pos.blockX, pos.blockY, pos.blockZ).getMetal());
+ world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
return item;
}else return null;
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
index ce2bb25..edf22bf 100644
--- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
@@ -1,28 +1,41 @@
package darkknight.jewelrycraft.events;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
-
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.api.IJewelryItem;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.damage.DamageSourceList;
+import darkknight.jewelrycraft.entities.EntityHalfHeart;
+import darkknight.jewelrycraft.entities.EntityHeart;
+import darkknight.jewelrycraft.item.ItemBaseJewelry;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.network.PacketRequestPlayerInfo;
+import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
+import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo;
+import darkknight.jewelrycraft.potions.PotionBase;
+import darkknight.jewelrycraft.potions.PotionList;
+import darkknight.jewelrycraft.random.WeightedRandomCurse;
+import darkknight.jewelrycraft.util.BlockUtils;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
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;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.util.WeightedRandom;
@@ -34,45 +47,14 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
-import net.minecraftforge.event.world.WorldEvent;
-import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.api.Curse;
-import darkknight.jewelrycraft.api.IJewelryItem;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.damage.DamageSourceList;
-import darkknight.jewelrycraft.entities.EntityHalfHeart;
-import darkknight.jewelrycraft.entities.EntityHeart;
-import darkknight.jewelrycraft.item.ItemBaseJewelry;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.network.PacketClearColorCache;
-import darkknight.jewelrycraft.network.PacketRequestPlayerInfo;
-import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
-import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo;
-import darkknight.jewelrycraft.potions.PotionList;
-import darkknight.jewelrycraft.random.WeightedRandomCurse;
-import darkknight.jewelrycraft.util.BlockUtils;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.PlayerUtils;
-import darkknight.jewelrycraft.util.Variables;
-/**
- * Code taken from OpenBlocks
- */
public class EntityEventHandler {
- int updateTime = 0, totalUnavailableCurses = 0;
- boolean addedCurses = false;
- Random rand = new Random();
+ 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) {
@@ -93,7 +75,8 @@ public class EntityEventHandler {
Curse.availableCurses.remove(curse);
persistTag.setInteger(curse.getName(), 0);
totalUnavailableCurses++;
- } else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse);
+ }
+ else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse);
persistTag.setBoolean("sendInfo", true);
}
}
@@ -105,22 +88,8 @@ public class EntityEventHandler {
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);
+ for (PotionBase potion : PotionBase.getPotionList())
+ if(entityLiving.isPotionActive(potion)) potion.action(entityLiving);
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
@@ -142,13 +111,16 @@ public class EntityEventHandler {
}
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);
+ int maxCurses = playerInfo.getInteger("cursePoints") / 1750 + 1;
+ if (points > 0 && playerInfo.getInteger("activeCurses") < maxCurses) while (playerInfo.getInteger("activeCurses") < maxCurses && Curse.availableCurses.size() > 0 && playerInfo.getInteger("activeCurses") < Curse.getCurseList().size()) {
+ addCurse(player, playerInfo);
+ System.out.println("Curse added");
+ }
if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")) {
playerInfo.setInteger("curseTime", 23000);
playerInfo.setBoolean("reselectCurses", false);
}
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP) player);
if (addedCurses) {
JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("curse." + Variables.MODID + ".activated")));
@@ -176,9 +148,6 @@ public class EntityEventHandler {
}
}
- /**
- * @param event
- */
@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event) {
EntityLivingBase entity = event.entityLiving;
@@ -191,63 +160,20 @@ public class EntityEventHandler {
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 ItemBaseJewelry) {
+ ((ItemBaseJewelry) item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount);
+ if (((ItemBaseJewelry) item.getItem()).onPlayerAttackedCacellable(item, player, event.source, event.ammount)) event.setCanceled(true);
+ }
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 && !player.capabilities.isCreativeMode && (float) player.hurtResistantTime <= (float) player.maxHurtResistantTime / 2.0F && !event.source.isUnblockable()) {
- if (playerInfo.getFloat("WhiteHeart") > 0) {
- playerInfo.setFloat("WhiteHeart", 0f);
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
- }
- 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.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
- 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, 2f * event.ammount);
- }
- }
- float damage = playerInfo.getFloat("BlackHeart") - event.ammount;
- if (damage >= 0) playerInfo.setFloat("BlackHeart", damage);
- else playerInfo.setFloat("BlackHeart", 0f);
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
- 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);
- }
}
+ removeHearts(event, player, playerInfo);
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP) player);
}
if (event.source.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
@@ -256,29 +182,67 @@ public class EntityEventHandler {
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 ItemBaseJewelry) {
+ ((ItemBaseJewelry) item.getItem()).onEntityAttacked(item, player, entity, event.ammount);
+ if (((ItemBaseJewelry) item.getItem()).onEntityAttackedCacellable(item, player, entity, event.ammount)) event.setCanceled(true);
+ }
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);
- if(entity instanceof EntityHeart && entity.getAge() < 50) event.setCanceled(true);
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) {
+ curse.attackedByPlayerAction(event, entity.worldObj, player, entity);
+ if (curse.attackedByPlayerActionCancelable(event, player.worldObj, player, entity)) event.setCanceled(true);
+ }
+ if (entity instanceof EntityHeart && entity.getAge() < 30) event.setCanceled(true);
+ if (event.source.getEntity() instanceof EntityPlayerMP) {
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP) player);
+ }
+ }
+ }
+
+ public void removeHearts(LivingAttackEvent event, EntityPlayer player, NBTTagCompound playerInfo) {
+ if (!player.worldObj.isRemote && !player.capabilities.isCreativeMode && (float) player.hurtResistantTime <= (float) player.maxHurtResistantTime / 2.0F) {
+ if (playerInfo.getFloat("WhiteHeart") > 0) {
+ playerInfo.setFloat("WhiteHeart", 0f);
+ }
+ if (playerInfo.getFloat("BlueHeart") > 0) {
+ float damage = playerInfo.getFloat("BlueHeart") - event.ammount;
+ if (damage >= 0) playerInfo.setFloat("BlueHeart", damage);
+ else playerInfo.setFloat("BlueHeart", 0f);
+ 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(3.0D, 0.0D, 3.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, 0.5f * event.ammount);
+ }
+ }
+ float damage = playerInfo.getFloat("BlackHeart") - event.ammount;
+ if (damage >= 0) playerInfo.setFloat("BlackHeart", damage);
+ else playerInfo.setFloat("BlackHeart", 0f);
+ 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);
+ }
}
}
- /**
- * @param event
- */
@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.Clone event) {
EntityPlayer player = event.entityPlayer;
@@ -286,8 +250,9 @@ public class EntityEventHandler {
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);
+ int maxCurses = playerInfo.getInteger("cursePoints") / 1750 + 1;
+ if (points > 0 && playerInfo.getInteger("activeCurses") < maxCurses) while (playerInfo.getInteger("activeCurses") < maxCurses && Curse.availableCurses.size() > 0 && playerInfo.getInteger("activeCurses") < Curse.getCurseList().size())
+ addCurse(player, playerInfo);
if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")) {
playerInfo.setInteger("curseTime", 23000);
playerInfo.setBoolean("reselectCurses", false);
@@ -307,11 +272,7 @@ public class EntityEventHandler {
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) {
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP) player);
if (addedCurses) {
JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
addedCurses = false;
@@ -319,20 +280,16 @@ public class EntityEventHandler {
}
}
- /**
- * @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) {
+ public void addCurse(EntityPlayer player, NBTTagCompound playerInfo) {
+ if (ConfigHandler.CURSES_ENABLED && Curse.availableCurses.size() > 0) {
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;
-// JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ if (playerInfo.getInteger("activeCurses") == 0) playerInfo.setInteger("activeCurses", 1);
+ else playerInfo.setInteger("activeCurses", playerInfo.getInteger("activeCurses") + 1);
JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP) player);
}
}
@@ -340,28 +297,24 @@ public class EntityEventHandler {
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()) {
+ if (event.player != null && 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);
+ if (entityitem != null) {
+ entityitem.motionX = 0;
+ entityitem.motionZ = 0;
+ entityitem.motionY = 0.11000000298023224D;
+ event.player.worldObj.spawnEntityInWorld(entityitem);
+ MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText("<" + event.player.getDisplayName() + "> I shouldn't drop this. I might need it later."));
+ 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;
@@ -376,7 +329,8 @@ public class EntityEventHandler {
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 {
+ }
+ 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)];
@@ -400,11 +354,14 @@ public class EntityEventHandler {
playerInfo.setFloat("BlackHeart", 0f);
playerInfo.setFloat("WhiteHeart", 0f);
if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")) {
+ playerInfo.setInteger("activeCurses", 0);
if (ConfigHandler.CURSES_ENABLED) for (Curse l : Curse.getCurseList()) {
if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) == 1) {
playerInfo.setInteger(l.getName(), 0);
+ l.setTicksActive(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);
+ }
+ 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());
}
@@ -423,64 +380,15 @@ public class EntityEventHandler {
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) {
- }
+ public void fogColors(EntityViewRenderEvent.FogColors event) {}
- /**
- * @param event
- */
@SubscribeEvent
@SideOnly(Side.CLIENT)
- public void fogDensity(EntityViewRenderEvent.FogDensity event) {
- }
+ public void fogDensity(EntityViewRenderEvent.FogDensity event) {}
- /**
- * @param event
- */
@SubscribeEvent
@SideOnly(Side.CLIENT)
- public void renderFog(EntityViewRenderEvent.RenderFogEvent event) {
- }
+ public void renderFog(EntityViewRenderEvent.RenderFogEvent event) {}
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
index c86597e..ca475d5 100644
--- a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
@@ -37,18 +37,18 @@ public class ScreenHandler extends Gui {
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);
+ drawTexturedModalRect(resolution.getScaledWidth() / 2 + 90 + 35 * count, resolution.getScaledHeight() - 40, 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() - 36, 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);
+ drawTexturedModalRect(resolution.getScaledWidth() / 2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35 * count, resolution.getScaledHeight() - 40, 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() - 36, 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);
+ 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() - 40, 2 * size, 1 * size, size, size);
GL11.glPopMatrix();
}
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
index f5dafb8..a67a274 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
@@ -111,7 +111,7 @@ public abstract class ItemBaseJewelry extends Item
public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount)
{
for(ModifierEffects mod: ModifierEffects.getEffects())
- return JewelryNBT.doesModifierExist(item, mod.getModifier()) ? mod.onPlayerAttackedCacellable(item, player, source, this, amount) : false;
+ if(JewelryNBT.doesModifierExist(item, mod.getModifier())) return mod.onPlayerAttackedCacellable(item, player, source, this, amount);
return false;
}
@@ -124,7 +124,7 @@ public abstract class ItemBaseJewelry extends Item
public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount)
{
for(ModifierEffects mod: ModifierEffects.getEffects())
- return JewelryNBT.doesModifierExist(item, mod.getModifier()) ? mod.onEntityAttackedCacellable(item, player, target, this, amount) : false;
+ if(JewelryNBT.doesModifierExist(item, mod.getModifier())) return mod.onEntityAttackedCacellable(item, player, target, this, amount);
return false;
}
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java b/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java
index 9c2f627..ce42093 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java
@@ -1,28 +1,30 @@
-package darkknight.jewelrycraft.item;
-
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.potion.Potion;
-import net.minecraft.potion.PotionEffect;
-import net.minecraft.util.DamageSource;
-import net.minecraft.world.World;
-import net.minecraftforge.event.entity.player.PlayerEvent.Clone;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.api.IJewelryItem;
-
-public class ItemGuide extends Item
-{
- public ItemGuide()
- {
- super();
- }
-
- @Override
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
- {
- if (world.isRemote) player.openGui(JewelrycraftMod.instance, 1, player.worldObj, 0, 0, 0);
- return stack;
- }
+package darkknight.jewelrycraft.item;
+
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.DamageSource;
+import net.minecraft.world.World;
+import net.minecraftforge.event.entity.player.PlayerEvent.Clone;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.achievements.AchievementsList;
+import darkknight.jewelrycraft.api.IJewelryItem;
+
+public class ItemGuide extends Item
+{
+ public ItemGuide()
+ {
+ super();
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
+ {
+ if (world.isRemote) player.openGui(JewelrycraftMod.instance, 1, player.worldObj, 0, 0, 0);
+ player.addStat(AchievementsList.openGuide, 1);
+ return stack;
+ }
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemJewelryModifier.java b/src/main/java/darkknight/jewelrycraft/item/ItemJewelryModifier.java
index 0ffed2c..c8fbb9d 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemJewelryModifier.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemJewelryModifier.java
@@ -1,23 +1,31 @@
-package darkknight.jewelrycraft.item;
-
-import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-import darkknight.jewelrycraft.JewelrycraftMod;
-
-public class ItemJewelryModifier extends Item
-{
- public ItemJewelryModifier()
- {
- super();
- }
-
- @Override
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
- {
- if (!world.isRemote && player.capabilities.isCreativeMode) player.openGui(JewelrycraftMod.instance, 3, world, 0, 0, 0);
- return stack;
- }
+package darkknight.jewelrycraft.item;
+
+import java.util.List;
+
+import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+import darkknight.jewelrycraft.JewelrycraftMod;
+
+public class ItemJewelryModifier extends Item
+{
+ public ItemJewelryModifier()
+ {
+ super();
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
+ {
+ if (!world.isRemote && player.capabilities.isCreativeMode) player.openGui(JewelrycraftMod.instance, 3, world, 0, 0, 0);
+ return stack;
+ }
+
+ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
+ {
+ list.add(EnumChatFormatting.GRAY + "Creative Only");
+ }
} \ 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 49c6679..0105d4a 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemList.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemList.java
@@ -1,12 +1,12 @@
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;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
public class ItemList
{
@@ -25,6 +25,7 @@ public class ItemList
public static Item goldObj;
public static Item structureGen;
public static Item spawnEgg;
+ public static Item testItem;
private static boolean isInitialized = false;
/**
@@ -47,6 +48,7 @@ public class ItemList
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");
+ testItem = new ItemTest().setUnlocalizedName(Variables.MODID + ".test");
GameRegistry.registerItem(thiefGloves, "thiefGloves");
GameRegistry.registerItem(shadowIngot, "shadowIngot");
@@ -63,6 +65,7 @@ public class ItemList
GameRegistry.registerItem(goldObj, "goldObject");
GameRegistry.registerItem(structureGen, "structureGen");
GameRegistry.registerItem(spawnEgg, "spawnEgg");
+ GameRegistry.registerItem(testItem, "testItem");
OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot));
}
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java b/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java
index d376648..869af26 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java
@@ -1,52 +1,37 @@
package darkknight.jewelrycraft.item;
import java.io.IOException;
-
+import cpw.mods.fml.common.eventhandler.Event;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.FillBucketEvent;
-import cpw.mods.fml.common.eventhandler.Event;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.network.PacketRequestLiquidData;
-import darkknight.jewelrycraft.network.PacketSendLiquidData;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.Variables;
public class ItemMoltenMetalBucket extends Item {
- public IIcon liquid;
+ public IIcon liquid;
- /**
- *
- */
public ItemMoltenMetalBucket() {
maxStackSize = 1;
}
- /**
- * Called whenever this item is equipped and the right mouse button is
- * pressed. Args: itemStack, world, entityPlayer
- *
- * @param stack
- * @param par2World
- * @param par3EntityPlayer
- * @return
- */
@Override
public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) {
boolean flag = BlockList.moltenMetal == Blocks.air;
@@ -75,11 +60,11 @@ public class ItemMoltenMetalBucket extends Item {
} else {
if (BlockList.moltenMetal == Blocks.air) return new ItemStack(Items.bucket);
if (movingobjectposition.sideHit == 0) --j;
- if (movingobjectposition.sideHit == 1) ++j;
- if (movingobjectposition.sideHit == 2) --k;
- if (movingobjectposition.sideHit == 3) ++k;
- if (movingobjectposition.sideHit == 4) --i;
- if (movingobjectposition.sideHit == 5) ++i;
+ else if (movingobjectposition.sideHit == 1) ++j;
+ else if (movingobjectposition.sideHit == 2) --k;
+ else if (movingobjectposition.sideHit == 3) ++k;
+ else if (movingobjectposition.sideHit == 4) --i;
+ else if (movingobjectposition.sideHit == 5) ++i;
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) return stack;
if (tryPlaceContainedLiquid(par2World, i, j, k, stack) && !par3EntityPlayer.capabilities.isCreativeMode) return new ItemStack(Items.bucket);
}
@@ -88,12 +73,6 @@ public class ItemMoltenMetalBucket extends Item {
}
}
- /**
- * @param p_150910_1_
- * @param p_150910_2_
- * @param p_150910_3_
- * @return
- */
private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) {
if (p_150910_2_.capabilities.isCreativeMode) return p_150910_1_;
else if (--p_150910_1_.stackSize <= 0) return new ItemStack(p_150910_3_);
@@ -103,18 +82,7 @@ public class ItemMoltenMetalBucket extends Item {
}
}
- /**
- * Attempts to place the liquid contained inside the bucket.
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @param stack
- * @return
- * @throws IOException
- */
- public boolean tryPlaceContainedLiquid(World world, int x, int y, int z, ItemStack stack) {
+ public static boolean tryPlaceContainedLiquid(World world, int x, int y, int z, ItemStack stack) {
if (BlockList.moltenMetal == Blocks.air) return false;
else {
Material material = world.getBlock(x, y, z).getMaterial();
@@ -122,30 +90,20 @@ public class ItemMoltenMetalBucket extends Item {
if (!world.isAirBlock(x, y, z) && !flag) return false;
else if (stack != null && JewelryNBT.ingot(stack) != null) {
if (!world.isRemote && flag && !material.isLiquid()) world.func_147480_a(x, y, z, true);
- if (world.isRemote) {
- JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage());
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage()));
- }
world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3);
+ TileEntity moltenLiquid = world.getTileEntity(x, y, z);
+ if(moltenLiquid instanceof TileEntityMoltenMetal) ((TileEntityMoltenMetal) moltenLiquid).setMetal(JewelryNBT.ingot(stack));
return true;
} else return false;
}
}
- /**
- * @param iconRegister
- */
@Override
public void registerIcons(IIconRegister iconRegister) {
itemIcon = iconRegister.registerIcon("bucket_empty");
liquid = iconRegister.registerIcon(Variables.MODID + ":bucketOverlay");
}
- /**
- * @param stack
- * @param pass
- * @return
- */
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass) {
@@ -153,19 +111,11 @@ public class ItemMoltenMetalBucket extends Item {
return 16777215;
}
- /**
- * @return
- */
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
- /**
- * @param stack
- * @param pass
- * @return
- */
@Override
public IIcon getIcon(ItemStack stack, int pass) {
if (pass == 0) return itemIcon;
@@ -173,27 +123,18 @@ public class ItemMoltenMetalBucket extends Item {
return itemIcon;
}
- /**
- * @param ingot
- * @return
- */
public ItemStack getModifiedItemStack(ItemStack ingot) {
ItemStack itemstack = new ItemStack(this);
JewelryNBT.addMetal(itemstack, ingot);
return itemstack;
}
- /**
- * @param stack
- * @return
- */
@Override
public String getItemStackDisplayName(ItemStack stack) {
try {
if (JewelryNBT.ingot(stack) != null) {
ItemStack ingot = JewelryNBT.ingot(stack);
if (ingot != null) {
- if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage());
return StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name").trim() + " " + ingot.getDisplayName().replace("Ingot", " ").trim();
} else return StatCollector.translateToLocal("bucket.unknown");
}
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java b/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java
index 25f5f4d..33ffd3d 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java
@@ -4,8 +4,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.JewelryNBT;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
public class ItemStructureGen extends Item
{
@@ -19,7 +28,7 @@ public class ItemStructureGen extends Item
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
- if (!world.isRemote){
+ if (!world.isRemote && player.capabilities.isCreativeMode){
if (!player.isSneaking()){
if (no < JewelrycraftUtil.structures.size() - 1) no++;
else no = 0;
@@ -36,7 +45,12 @@ public class ItemStructureGen extends Item
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par1, float par2, float par3, float par4)
{
- JewelrycraftUtil.structures.get(no).generate(world, itemRand, x, y + 1, z);
+ if(player.capabilities.isCreativeMode) JewelrycraftUtil.structures.get(no).generate(world, world.getBiomeGenForCoords(x, z), itemRand, x, y + 1, z);
return true;
}
+
+ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
+ {
+ list.add(EnumChatFormatting.GRAY + "Creative Only");
+ }
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemTest.java b/src/main/java/darkknight/jewelrycraft/item/ItemTest.java
new file mode 100644
index 0000000..e7dbb33
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemTest.java
@@ -0,0 +1,54 @@
+package darkknight.jewelrycraft.item;
+
+import java.util.List;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemFood;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.Variables;
+
+public class ItemTest extends Item
+{
+ @SideOnly (Side.CLIENT)
+ private IIcon[] icons;
+
+ public ItemTest()
+ {
+ super();
+ setHasSubtypes(true);
+ }
+
+ @Override
+ @SideOnly (Side.CLIENT)
+ public IIcon getIconFromDamage(int damage)
+ {
+ int j = MathHelper.clamp_int(damage, 0, Curse.getCurseList().size() - 1);
+ return icons[j];
+ }
+
+ public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List)
+ {
+ for(int j = 0; j < Curse.getCurseList().size(); ++j)
+ par3List.add(new ItemStack(par1, 1, j));
+ }
+
+ public void registerIcons(IIconRegister par1IconRegister)
+ {
+ icons = new IIcon[Curse.getCurseList().size()];
+ for(int i = 0; i < Curse.getCurseList().size(); ++i)
+ icons[i] = par1IconRegister.registerIcon(Variables.MODID + ":" + "testItem_" + i);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketClearColorCache.java b/src/main/java/darkknight/jewelrycraft/network/PacketClearColorCache.java
deleted file mode 100644
index 4d8351c..0000000
--- a/src/main/java/darkknight/jewelrycraft/network/PacketClearColorCache.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package darkknight.jewelrycraft.network;
-
-import io.netty.buffer.ByteBuf;
-import net.minecraft.nbt.NBTTagCompound;
-import cpw.mods.fml.common.network.simpleimpl.IMessage;
-import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
-import cpw.mods.fml.common.network.simpleimpl.MessageContext;
-import darkknight.jewelrycraft.JewelrycraftMod;
-
-public class PacketClearColorCache implements IMessage, IMessageHandler<PacketClearColorCache, IMessage>
-{
-
- /**
- *
- */
- public PacketClearColorCache()
- {}
-
- /**
- * @param message
- * @param ctx
- * @return
- */
- @Override
- public IMessage onMessage(PacketClearColorCache message, MessageContext ctx)
- {
- JewelrycraftMod.clientData = new NBTTagCompound();
- return null;
- }
-
- /**
- * @param buf
- */
- @Override
- public void fromBytes(ByteBuf buf)
- {}
-
- /**
- * @param buf
- */
- @Override
- public void toBytes(ByteBuf buf)
- {}
-}
diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketHandler.java b/src/main/java/darkknight/jewelrycraft/network/PacketHandler.java
index 0ec7db4..db24ead 100644
--- a/src/main/java/darkknight/jewelrycraft/network/PacketHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/network/PacketHandler.java
@@ -1,24 +1,22 @@
-package darkknight.jewelrycraft.network;
-
-import cpw.mods.fml.common.event.FMLPreInitializationEvent;
-import cpw.mods.fml.common.network.NetworkRegistry;
-import cpw.mods.fml.relauncher.Side;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.util.Variables;
-
-public class PacketHandler
-{
-
- public static void preInit(FMLPreInitializationEvent e)
- {
- JewelrycraftMod.netWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Variables.MODID);
- JewelrycraftMod.netWrapper.registerMessage(PacketRequestLiquidData.class, PacketRequestLiquidData.class, 0, Side.SERVER);
- JewelrycraftMod.netWrapper.registerMessage(PacketSendLiquidData.class, PacketSendLiquidData.class, 1, Side.CLIENT);
- JewelrycraftMod.netWrapper.registerMessage(PacketClearColorCache.class, PacketClearColorCache.class, 2, Side.CLIENT);
- JewelrycraftMod.netWrapper.registerMessage(PacketKeyPressEvent.class, PacketKeyPressEvent.class, 3, Side.SERVER);
- JewelrycraftMod.netWrapper.registerMessage(PacketRequestPlayerInfo.class, PacketRequestPlayerInfo.class, 4, Side.SERVER);
- JewelrycraftMod.netWrapper.registerMessage(PacketSendClientPlayerInfo.class, PacketSendClientPlayerInfo.class, 5, Side.CLIENT);
- JewelrycraftMod.netWrapper.registerMessage(PacketSendServerPlayersInfo.class, PacketSendServerPlayersInfo.class, 6, Side.CLIENT);
- JewelrycraftMod.netWrapper.registerMessage(PacketRequestSetSlot.class, PacketRequestSetSlot.class, 7, Side.SERVER);
- }
-}
+package darkknight.jewelrycraft.network;
+
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.relauncher.Side;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.util.Variables;
+
+public class PacketHandler
+{
+
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ JewelrycraftMod.netWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Variables.MODID);
+ JewelrycraftMod.netWrapper.registerMessage(PacketKeyPressEvent.class, PacketKeyPressEvent.class, 3, Side.SERVER);
+ JewelrycraftMod.netWrapper.registerMessage(PacketRequestPlayerInfo.class, PacketRequestPlayerInfo.class, 4, Side.SERVER);
+ JewelrycraftMod.netWrapper.registerMessage(PacketSendClientPlayerInfo.class, PacketSendClientPlayerInfo.class, 5, Side.CLIENT);
+ JewelrycraftMod.netWrapper.registerMessage(PacketSendServerPlayersInfo.class, PacketSendServerPlayersInfo.class, 6, Side.CLIENT);
+ JewelrycraftMod.netWrapper.registerMessage(PacketRequestSetSlot.class, PacketRequestSetSlot.class, 7, Side.SERVER);
+ JewelrycraftMod.netWrapper.registerMessage(PacketSendServerPlayerInfo.class, PacketSendServerPlayerInfo.class, 8, Side.SERVER);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java b/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java
deleted file mode 100644
index 52440e2..0000000
--- a/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package darkknight.jewelrycraft.network;
-
-import io.netty.buffer.ByteBuf;
-import cpw.mods.fml.common.network.simpleimpl.IMessage;
-import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
-import cpw.mods.fml.common.network.simpleimpl.MessageContext;
-import darkknight.jewelrycraft.JewelrycraftMod;
-
-public class PacketRequestLiquidData implements IMessage, IMessageHandler<PacketRequestLiquidData, IMessage>
-{
- int dimID, x, y, z;
-
- /**
- *
- */
- public PacketRequestLiquidData()
- {}
-
- /**
- * @param dimID
- * @param x
- * @param y
- * @param z
- */
- public PacketRequestLiquidData(int dimID, int x, int y, int z)
- {
- this.dimID = dimID;
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /**
- * @param message
- * @param ctx
- * @return
- */
- @Override
- public IMessage onMessage(PacketRequestLiquidData message, MessageContext ctx)
- {
- String data = JewelrycraftMod.saveData.getString(message.x + " " + message.y + " " + message.z + " " + message.dimID);
- String[] splitData = data.split(":");
- IMessage replyPacket = null;
- if (splitData.length == 2){
- int itemID, itemDamage;
- try{
- itemID = Integer.parseInt(splitData[0]);
- itemDamage = Integer.parseInt(splitData[1]);
- replyPacket = new PacketSendLiquidData(message, itemID, itemDamage);
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- return replyPacket;
- }
-
- /**
- * @param buf
- */
- @Override
- public void fromBytes(ByteBuf buf)
- {
- dimID = buf.readInt();
- x = buf.readInt();
- y = buf.readInt();
- z = buf.readInt();
- }
-
- /**
- * @param buf
- */
- @Override
- public void toBytes(ByteBuf buf)
- {
- buf.writeInt(dimID);
- buf.writeInt(x);
- buf.writeInt(y);
- buf.writeInt(z);
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketSendClientPlayerInfo.java b/src/main/java/darkknight/jewelrycraft/network/PacketSendClientPlayerInfo.java
index 05567a0..5c391cd 100644
--- a/src/main/java/darkknight/jewelrycraft/network/PacketSendClientPlayerInfo.java
+++ b/src/main/java/darkknight/jewelrycraft/network/PacketSendClientPlayerInfo.java
@@ -1,58 +1,58 @@
-package darkknight.jewelrycraft.network;
-
-import io.netty.buffer.ByteBuf;
-import net.minecraft.nbt.NBTTagCompound;
-import cpw.mods.fml.common.network.ByteBufUtils;
-import cpw.mods.fml.common.network.simpleimpl.IMessage;
-import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
-import cpw.mods.fml.common.network.simpleimpl.MessageContext;
-import darkknight.jewelrycraft.events.ScreenHandler;
-
-public class PacketSendClientPlayerInfo implements IMessage, IMessageHandler<PacketSendClientPlayerInfo, IMessage>
-{
- public NBTTagCompound tagCompound;
-
- /**
- * @param tagCompound
- */
- public PacketSendClientPlayerInfo(NBTTagCompound tagCompound)
- {
- this.tagCompound = tagCompound;
- }
-
- /**
- *
- */
- public PacketSendClientPlayerInfo()
- {}
-
- /**
- * @param message
- * @param ctx
- * @return
- */
- @Override
- public IMessage onMessage(PacketSendClientPlayerInfo message, MessageContext ctx)
- {
- ScreenHandler.tagCache = message.tagCompound;
- return null;
- }
-
- /**
- * @param buf
- */
- @Override
- public void fromBytes(ByteBuf buf)
- {
- tagCompound = ByteBufUtils.readTag(buf);
- }
-
- /**
- * @param buf
- */
- @Override
- public void toBytes(ByteBuf buf)
- {
- ByteBufUtils.writeTag(buf, tagCompound);
- }
-}
+package darkknight.jewelrycraft.network;
+
+import io.netty.buffer.ByteBuf;
+import net.minecraft.nbt.NBTTagCompound;
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import darkknight.jewelrycraft.events.ScreenHandler;
+
+public class PacketSendClientPlayerInfo implements IMessage, IMessageHandler<PacketSendClientPlayerInfo, IMessage>
+{
+ public NBTTagCompound tagCompound;
+
+ /**
+ * @param tagCompound
+ */
+ public PacketSendClientPlayerInfo(NBTTagCompound tagCompound)
+ {
+ this.tagCompound = tagCompound;
+ }
+
+ /**
+ *
+ */
+ public PacketSendClientPlayerInfo()
+ {}
+
+ /**
+ * @param message
+ * @param ctx
+ * @return
+ */
+ @Override
+ public IMessage onMessage(PacketSendClientPlayerInfo message, MessageContext ctx)
+ {
+ ScreenHandler.tagCache = message.tagCompound;
+ return null;
+ }
+
+ /**
+ * @param buf
+ */
+ @Override
+ public void fromBytes(ByteBuf buf)
+ {
+ tagCompound = ByteBufUtils.readTag(buf);
+ }
+
+ /**
+ * @param buf
+ */
+ @Override
+ public void toBytes(ByteBuf buf)
+ {
+ ByteBufUtils.writeTag(buf, tagCompound);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java b/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java
deleted file mode 100644
index dcb265b..0000000
--- a/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package darkknight.jewelrycraft.network;
-
-import io.netty.buffer.ByteBuf;
-import net.minecraft.client.Minecraft;
-import cpw.mods.fml.common.network.simpleimpl.IMessage;
-import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
-import cpw.mods.fml.common.network.simpleimpl.MessageContext;
-import darkknight.jewelrycraft.JewelrycraftMod;
-
-public class PacketSendLiquidData implements IMessage, IMessageHandler<PacketSendLiquidData, IMessage>
-{
- int dimID, x, y, z, itemID, itemMeta;
-
- /**
- *
- */
- public PacketSendLiquidData()
- {}
-
- /**
- * @param packet
- * @param itemID
- * @param itemMeta
- * @param color
- */
- public PacketSendLiquidData(PacketRequestLiquidData packet, int itemID, int itemMeta)
- {
- dimID = packet.dimID;
- x = packet.x;
- y = packet.y;
- z = packet.z;
- this.itemID = itemID;
- this.itemMeta = itemMeta;
- }
-
- /**
- * @param dimID
- * @param x
- * @param y
- * @param z
- * @param itemID
- * @param itemMeta
- * @param color
- */
- public PacketSendLiquidData(int dimID, int x, int y, int z, int itemID, int itemMeta)
- {
- this.dimID = dimID;
- this.x = x;
- this.y = y;
- this.z = z;
- this.itemID = itemID;
- this.itemMeta = itemMeta;
- }
-
- /**
- * @param buf
- */
- @Override
- public void fromBytes(ByteBuf buf)
- {
- dimID = buf.readInt();
- x = buf.readInt();
- y = buf.readInt();
- z = buf.readInt();
- itemID = buf.readInt();
- itemMeta = buf.readInt();
- }
-
- /**
- * @param buf
- */
- @Override
- public void toBytes(ByteBuf buf)
- {
- buf.writeInt(dimID);
- buf.writeInt(x);
- buf.writeInt(y);
- buf.writeInt(z);
- buf.writeInt(itemID);
- buf.writeInt(itemMeta);
- }
-
- /**
- * @param message
- * @param ctx
- * @return
- */
- @Override
- public IMessage onMessage(PacketSendLiquidData message, MessageContext ctx)
- {
- JewelrycraftMod.clientData.setString(message.x + " " + message.y + " " + message.z + " " + message.dimID, message.itemID + ":" + message.itemMeta);
- Minecraft.getMinecraft().theWorld.getBlock(message.x, message.y, message.z);
- Minecraft.getMinecraft().theWorld.markBlockForUpdate(message.x, message.y, message.z);
- return null;
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java b/src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java
new file mode 100644
index 0000000..afefb65
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java
@@ -0,0 +1,71 @@
+package darkknight.jewelrycraft.network;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class PacketSendServerPlayerInfo implements IMessage, IMessageHandler<PacketSendServerPlayerInfo, IMessage>
+{
+ public NBTTagCompound tagCompound;
+ public String curse, action;
+
+ /**
+ * @param tagCompound
+ */
+ public PacketSendServerPlayerInfo(String action, String curse, NBTTagCompound tagCompound)
+ {
+ this.tagCompound = tagCompound;
+ this.curse = curse;
+ this.action = action;
+ }
+
+ /**
+ *
+ */
+ public PacketSendServerPlayerInfo()
+ {}
+
+ /**
+ * @param message
+ * @param ctx
+ * @return
+ */
+ @Override
+ public IMessage onMessage(PacketSendServerPlayerInfo message, MessageContext ctx)
+ {
+ EntityPlayerMP serverPlayer = ctx.getServerHandler().playerEntity;
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(serverPlayer, Variables.MODID);
+ playerInfo.setInteger(message.curse, message.action.equals("remove") ? 0 : 1);
+ playerInfo.setInteger("activeCurses", message.tagCompound.getInteger("activeCurses"));
+ System.out.println(message.action + " " + message.curse + " " + message.tagCompound.getInteger(curse) + " " + message.tagCompound.getInteger("activeCurses"));
+ return null;
+ }
+
+ /**
+ * @param buf
+ */
+ @Override
+ public void fromBytes(ByteBuf buf)
+ {
+ tagCompound = ByteBufUtils.readTag(buf);
+ curse = ByteBufUtils.readUTF8String(buf);
+ action = ByteBufUtils.readUTF8String(buf);
+ }
+
+ /**
+ * @param buf
+ */
+ @Override
+ public void toBytes(ByteBuf buf)
+ {
+ ByteBufUtils.writeTag(buf, tagCompound);
+ ByteBufUtils.writeUTF8String(buf, curse);
+ ByteBufUtils.writeUTF8String(buf, action);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/potions/PotionBase.java b/src/main/java/darkknight/jewelrycraft/potions/PotionBase.java
new file mode 100644
index 0000000..3160e91
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/potions/PotionBase.java
@@ -0,0 +1,20 @@
+package darkknight.jewelrycraft.potions;
+
+import java.util.ArrayList;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.potion.Potion;
+
+public class PotionBase extends Potion {
+ private static ArrayList<PotionBase> potions = new ArrayList<PotionBase>();
+
+ public PotionBase(int id, boolean isBad, int color) {
+ super(id, isBad, color);
+ potions.add(this);
+ }
+
+ public static ArrayList<PotionBase> getPotionList() {
+ return potions;
+ }
+
+ public void action(EntityLivingBase entity) {}
+}
diff --git a/src/main/java/darkknight/jewelrycraft/potions/PotionStun.java b/src/main/java/darkknight/jewelrycraft/potions/PotionStun.java
index f01a467..0e8ad7f 100644
--- a/src/main/java/darkknight/jewelrycraft/potions/PotionStun.java
+++ b/src/main/java/darkknight/jewelrycraft/potions/PotionStun.java
@@ -1,26 +1,38 @@
-/**
- *
- */
-package darkknight.jewelrycraft.potions;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.util.Variables;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.potion.Potion;
-import net.minecraft.potion.PotionEffect;
-
-/**
- * @author Sorin
- */
-public class PotionStun extends Potion
-{
- protected PotionStun(int id, boolean isBad, int color)
- {
- super(id, isBad, color);
- this.setPotionName(Variables.MODID + ".potion.stun");
- }
-
- @SideOnly(Side.CLIENT)
- public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc) { }
-}
+/**
+ *
+ */
+package darkknight.jewelrycraft.potions;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+
+/**
+ * @author Sorin
+ */
+public class PotionStun extends PotionBase {
+ protected PotionStun(int id, boolean isBad, int color) {
+ super(id, isBad, color);
+ this.setPotionName(Variables.MODID + ".potion.stun");
+ }
+
+ public void action(EntityLivingBase entity) {
+ entity.motionX *= 0D;
+ entity.motionZ *= 0D;
+ entity.motionY *= 0D;
+ entity.isSwingInProgress = false;
+ entity.moveForward = 0F;
+ entity.moveStrafing = 0F;
+ entity.setAIMoveSpeed(0F);
+ entity.limbSwing = 0F;
+ entity.limbSwingAmount = 0F;
+ entity.swingProgressInt = 0;
+ entity.rotationPitch = entity.prevRotationPitch;
+ entity.rotationYaw = entity.prevRotationYaw;
+ entity.worldObj.spawnParticle("spell", entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ, 0.0D, 0.3D, 0.0D);
+ if (entity.getActivePotionEffect(PotionList.stun).getDuration() == 0) entity.removePotionEffect(PotionList.stun.id);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java
index dbb68be..0923817 100644
--- a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java
+++ b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java
@@ -1,11 +1,12 @@
package darkknight.jewelrycraft.proxy;
-import java.util.logging.Level;
-
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
+
+import org.apache.logging.log4j.Level;
+
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
diff --git a/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java
index b22ec6e..0239da3 100644
--- a/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java
+++ b/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java
@@ -1,53 +1,53 @@
-package darkknight.jewelrycraft.recipes;
-
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.oredict.ShapedOreRecipe;
-import cpw.mods.fml.common.event.FMLPreInitializationEvent;
-import cpw.mods.fml.common.registry.GameRegistry;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.item.ItemList;
-
-public class CraftingRecipes
-{
- private static boolean isInitialized = false;
-
- /**
- * @param e
- */
- public static void preInit(FMLPreInitializationEvent e)
- {
- if (!isInitialized){
- // Items
- GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Blocks.wool, 1, 15));
- GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 0), "xx", 'x', Items.clay_ball);
- GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 1), " x ", "x x", " x ", 'x', Items.clay_ball);
- GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 2), "x x", "x x", " x ", 'x', Items.clay_ball);
- GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 3), "xxx", "x x", "xxx", 'x', Items.clay_ball);
- GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 4), "x x", 'x', Items.clay_ball);
- GameRegistry.addRecipe(new ItemStack(BlockList.handPedestal, 1, 4), "bbb", " x ", "yxy", 'x', Blocks.stonebrick, 'y', new ItemStack(Blocks.stone_slab, 1, 5), 'b', Blocks.cobblestone_wall);
- GameRegistry.addRecipe(new ItemStack(BlockList.shadowEye, 1, 4), "bcb", "cec", "bcb", 'b', Blocks.stonebrick, 'c', new ItemStack(Blocks.stained_hardened_clay, 1, 15), 'e', Items.ender_eye);
- GameRegistry.addShapelessRecipe(new ItemStack(ItemList.shadowIngot, 9), new Object[]{new ItemStack(BlockList.shadowBlock)});
- GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 0)});
- GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 1)});
- GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 2)});
- GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 3)});
- GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 4)});
- // Blocks
- GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Blocks.cobblestone));
- GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Blocks.cobblestone, 'y', Items.bucket, 'z', Items.lava_bucket));
- GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Blocks.planks, 'y', Blocks.stone));
- GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.displayer, 2), " x ", "xxx", "yyy", 'x', Items.iron_ingot, 'y', Blocks.emerald_block));
- GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.shadowBlock, 1), "xxx", "xxx", "xxx", 'x', ItemList.shadowIngot));
- // Smelting
- GameRegistry.addSmelting(BlockList.shadowOre, new ItemStack(ItemList.shadowIngot), 1.5f);
- GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 0), new ItemStack(ItemList.molds, 1, 0), 0.2F);
- GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 1), new ItemStack(ItemList.molds, 1, 1), 0.2F);
- GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 2), new ItemStack(ItemList.molds, 1, 2), 0.2F);
- GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 3), new ItemStack(ItemList.molds, 1, 3), 0.2F);
- GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 4), new ItemStack(ItemList.molds, 1, 4), 0.2F);
- isInitialized = true;
- }
- }
-}
+package darkknight.jewelrycraft.recipes;
+
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.GameRegistry;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.item.ItemList;
+
+public class CraftingRecipes
+{
+ private static boolean isInitialized = false;
+
+ /**
+ * @param e
+ */
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ if (!isInitialized){
+ // Items
+ GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Blocks.wool, 1, 15));
+ GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 0), "xx", 'x', Items.clay_ball);
+ GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 1), " x ", "x x", " x ", 'x', Items.clay_ball);
+ GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 2), "x x", "x x", " x ", 'x', Items.clay_ball);
+ GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 3), "xxx", "x x", "xxx", 'x', Items.clay_ball);
+ GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 4), "x x", 'x', Items.clay_ball);
+ GameRegistry.addRecipe(new ItemStack(BlockList.handPedestal), "bbb", " x ", "yxy", 'x', Blocks.stonebrick, 'y', new ItemStack(Blocks.stone_slab, 1, 5), 'b', Blocks.cobblestone_wall);
+ GameRegistry.addRecipe(new ItemStack(BlockList.shadowEye), "bcb", "cec", "bcb", 'b', Blocks.stonebrick, 'c', new ItemStack(Blocks.stained_hardened_clay, 1, 15), 'e', Items.ender_eye);
+ GameRegistry.addShapelessRecipe(new ItemStack(ItemList.shadowIngot, 9), new Object[]{new ItemStack(BlockList.shadowBlock)});
+ GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 0)});
+ GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 1)});
+ GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 2)});
+ GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 3)});
+ GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 4)});
+ // Blocks
+ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Blocks.cobblestone));
+ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Blocks.cobblestone, 'y', Items.bucket, 'z', Items.lava_bucket));
+ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Blocks.planks, 'y', Blocks.stone));
+ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.displayer, 2), " x ", "xxx", "yyy", 'x', Items.iron_ingot, 'y', Blocks.emerald_block));
+ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.shadowBlock, 1), "xxx", "xxx", "xxx", 'x', ItemList.shadowIngot));
+ // Smelting
+ GameRegistry.addSmelting(BlockList.shadowOre, new ItemStack(ItemList.shadowIngot), 1.5f);
+ GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 0), new ItemStack(ItemList.molds, 1, 0), 0.2F);
+ GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 1), new ItemStack(ItemList.molds, 1, 1), 0.2F);
+ GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 2), new ItemStack(ItemList.molds, 1, 2), 0.2F);
+ GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 3), new ItemStack(ItemList.molds, 1, 3), 0.2F);
+ GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 4), new ItemStack(ItemList.molds, 1, 4), 0.2F);
+ isInitialized = true;
+ }
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java b/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java
index c2808f9..21158f1 100644
--- a/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java
+++ b/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java
@@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
+
+import org.apache.logging.log4j.Level;
+
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@@ -46,7 +48,7 @@ public class ThirdPartyManager implements IGuiHandler{
try {
thirdPartyMods.add(entry.getValue().newInstance());
} catch(Exception e) {
- JewelrycraftMod.logger.log(Level.SEVERE, "Failed to instantiate third party handler!");
+ JewelrycraftMod.logger.log(Level.ERROR, "Failed to instantiate third party handler!");
e.printStackTrace();
}
}
@@ -70,7 +72,7 @@ public class ThirdPartyManager implements IGuiHandler{
try {
thirdParty.preInit();
} catch(Throwable e) {
- JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PreInit phase!");
+ JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PreInit phase!");
e.printStackTrace();
}
}
@@ -81,7 +83,7 @@ public class ThirdPartyManager implements IGuiHandler{
try {
thirdParty.init();
} catch(Throwable e) {
- JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the Init phase!");
+ JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the Init phase!");
e.printStackTrace();
}
}
@@ -92,7 +94,7 @@ public class ThirdPartyManager implements IGuiHandler{
try {
thirdParty.postInit();
} catch(Throwable e) {
- JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PostInit phase!");
+ JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PostInit phase!");
e.printStackTrace();
}
}
@@ -103,7 +105,7 @@ public class ThirdPartyManager implements IGuiHandler{
try {
thirdParty.clientSide();
} catch(Throwable e) {
- JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side!");
+ JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side!");
e.printStackTrace();
}
}
@@ -114,7 +116,7 @@ public class ThirdPartyManager implements IGuiHandler{
try {
thirdParty.clientInit();
} catch(Throwable e) {
- JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side on the init!");
+ JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side on the init!");
e.printStackTrace();
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java
index 7eac88f..9cb60e4 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java
@@ -1,42 +1,45 @@
-/**
- *
- */
-package darkknight.jewelrycraft.tileentity;
-
-import darkknight.jewelrycraft.config.ConfigHandler;
-import net.minecraft.tileentity.TileEntity;
-
-/**
- * @author Sorin
- */
-public class TileEntityCrystal extends TileEntity
-{
- public int shine = 120;
- boolean descent = false;
- int timer = 0;
-
- @Override
- public void updateEntity()
- {
- if (ConfigHandler.CRYSTAL_GLOW){
- timer++;
- if (timer > 20){
- if (shine < 230 && !descent){
- shine += 2;
- if (shine >= 230) descent = true;
- }else if (shine > 100 && descent){
- shine -= 2;
- if (shine <= 100) descent = false;
- }
- this.worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
- timer = 0;
- }
- }
- }
-
- public boolean canUpdate()
- {
- return ConfigHandler.CRYSTAL_GLOW;
- }
-
-}
+/**
+ *
+ */
+package darkknight.jewelrycraft.tileentity;
+
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * @author Sorin
+ */
+public class TileEntityCrystal extends TileEntity
+{
+ public int shine = 120;
+ boolean descent = false;
+ int timer = 0;
+
+ @Override
+ public void updateEntity()
+ {
+ if (ConfigHandler.CRYSTAL_GLOW){
+ timer++;
+ if (timer > 20){
+ if (shine < 230 && !descent){
+ shine += 2;
+ if (shine >= 230) descent = true;
+ }else if (shine > 100 && descent){
+ shine -= 2;
+ if (shine <= 100) descent = false;
+ }
+ this.worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
+ timer = 0;
+ }
+ }
+ if(ConfigHandler.CRYSTAL_PARTICLES)
+ worldObj.spawnParticle("instantSpell", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), 0.0D, -1.0D, 0.0D);
+ }
+
+ public boolean canUpdate()
+ {
+ return ConfigHandler.CRYSTAL_GLOW || ConfigHandler.CRYSTAL_PARTICLES;
+ }
+
+}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java
index ee48d08..e4a8602 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java
@@ -1,182 +1,168 @@
-package darkknight.jewelrycraft.tileentity;
-
-import net.minecraft.item.ItemBlock;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.NetworkManager;
-import net.minecraft.network.Packet;
-import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
-import net.minecraft.tileentity.TileEntity;
-
-/**
- * @author Paul Fulham (pau101)
- */
-public class TileEntityHandPedestal extends TileEntity
-{
- protected boolean isDirty;
- protected ItemStack heldItemStack;
- /**
- * When the hand is open the grip is 0 and is 20 when closed.
- */
- private float grip;
- private float prevGrip;
- private float gripMax;
- private float gripScale;
- private boolean isHandOpen;
-
- /**
- *
- */
- public TileEntityHandPedestal()
- {
- isDirty = false;
- heldItemStack = null;
- grip = 0;
- gripMax = 20;
- gripScale = 1;
- isHandOpen = true;
- }
-
- /**
- * @param tagCompound
- */
- @Override
- public void writeToNBT(NBTTagCompound tagCompound)
- {
- super.writeToNBT(tagCompound);
- if (heldItemStack != null){
- NBTTagCompound objectCompound = new NBTTagCompound();
- heldItemStack.writeToNBT(objectCompound);
- tagCompound.setTag("object", objectCompound);
- }
- tagCompound.setBoolean("isHandOpen", isHandOpen);
- }
-
- /**
- * @param tagCompound
- */
- @Override
- public void readFromNBT(NBTTagCompound tagCompound)
- {
- super.readFromNBT(tagCompound);
- if (tagCompound.hasKey("object", 10)) setHeldItemStack(ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("object")));
- else removeHeldItemStack();
- isHandOpen = tagCompound.getBoolean("isHandOpen");
- }
-
- /**
- *
- */
- @Override
- public void updateEntity()
- {
- super.updateEntity();
- updateGrip();
- if (isDirty){
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- isDirty = false;
- }
- }
-
- /**
- *
- */
- private void updateGrip()
- {
- prevGrip = grip;
- if (grip > 0 && isHandOpen) grip -= 1 / gripScale;
- else if (grip < gripMax && !isHandOpen) grip += 1 / gripScale;
- }
-
- /**
- * @return
- */
- @Override
- public Packet getDescriptionPacket()
- {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- writeToNBT(nbttagcompound);
- return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound);
- }
-
- /**
- * @param networkManager
- * @param packet
- */
- @Override
- public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet)
- {
- readFromNBT(packet.func_148857_g());
- worldObj.func_147479_m(xCoord, yCoord, zCoord);
- }
-
- /**
- *
- */
- @Override
- public void markDirty()
- {
- super.markDirty();
- isDirty = true;
- }
-
- /**
- * @return
- */
- public ItemStack getHeldItemStack()
- {
- return heldItemStack;
- }
-
- /**
- * @param heldItemStack
- */
- public void setHeldItemStack(ItemStack heldItemStack)
- {
- heldItemStack.stackSize = 1;
- this.heldItemStack = heldItemStack;
- if (heldItemStack.getItem() instanceof ItemBlock) gripScale = 0.5f;
- else gripScale = 1;
- }
-
- /**
- *
- */
- public void removeHeldItemStack()
- {
- heldItemStack = null;
- }
-
- /**
- *
- */
- public void openHand()
- {
- isHandOpen = true;
- }
-
- /**
- *
- */
- public void closeHand()
- {
- isHandOpen = false;
- }
-
- /**
- * @param t
- * @return
- */
- public float getGrip(float t)
- {
- return (prevGrip * (1 - t) + grip * t) / gripMax;
- }
-
- /**
- * @return
- */
- public float getGripScale()
- {
- return gripScale;
- }
+package darkknight.jewelrycraft.tileentity;
+
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * @author Paul Fulham (pau101)
+ */
+public class TileEntityHandPedestal extends TileEntity {
+ protected boolean isDirty;
+ protected ItemStack heldItemStack;
+ /**
+ * When the hand is open the grip is 0 and is 20 when closed.
+ */
+ private float grip;
+ private float prevGrip;
+ private float gripMax;
+ private float gripScale;
+ private boolean isHandOpen;
+
+ /**
+ *
+ */
+ public TileEntityHandPedestal() {
+ isDirty = false;
+ heldItemStack = null;
+ grip = 0;
+ gripMax = 20;
+ gripScale = 1;
+ isHandOpen = true;
+ }
+
+ /**
+ * @param tagCompound
+ */
+ @Override
+ public void writeToNBT(NBTTagCompound tagCompound) {
+ super.writeToNBT(tagCompound);
+ if (heldItemStack != null) {
+ NBTTagCompound objectCompound = new NBTTagCompound();
+ heldItemStack.writeToNBT(objectCompound);
+ tagCompound.setTag("object", objectCompound);
+ }
+ tagCompound.setBoolean("isHandOpen", isHandOpen);
+ }
+
+ /**
+ * @param tagCompound
+ */
+ @Override
+ public void readFromNBT(NBTTagCompound tagCompound) {
+ super.readFromNBT(tagCompound);
+ if (tagCompound.hasKey("object", 10)) setHeldItemStack(ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("object")));
+ else removeHeldItemStack();
+ isHandOpen = tagCompound.getBoolean("isHandOpen");
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void updateEntity() {
+ super.updateEntity();
+ updateGrip();
+ if (isDirty) {
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ isDirty = false;
+ }
+ }
+
+ /**
+ *
+ */
+ private void updateGrip() {
+ prevGrip = grip;
+ if (grip > 0 && isHandOpen) grip -= 1 / gripScale;
+ else if (grip < gripMax && !isHandOpen) grip += 1 / gripScale;
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeToNBT(nbttagcompound);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound);
+ }
+
+ /**
+ * @param networkManager
+ * @param packet
+ */
+ @Override
+ public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) {
+ readFromNBT(packet.func_148857_g());
+ worldObj.func_147479_m(xCoord, yCoord, zCoord);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void markDirty() {
+ super.markDirty();
+ isDirty = true;
+ }
+
+ /**
+ * @return
+ */
+ public ItemStack getHeldItemStack() {
+ return heldItemStack;
+ }
+
+ /**
+ * @param heldItemStack
+ */
+ public void setHeldItemStack(ItemStack heldItemStack) {
+ if (heldItemStack != null && heldItemStack.getItem() != null) {
+ heldItemStack.stackSize = 1;
+ this.heldItemStack = heldItemStack;
+ if (heldItemStack.getItem() instanceof ItemBlock) gripScale = 0.5f;
+ else gripScale = 1;
+ }
+ }
+
+ /**
+ *
+ */
+ public void removeHeldItemStack() {
+ heldItemStack = null;
+ }
+
+ /**
+ *
+ */
+ public void openHand() {
+ isHandOpen = true;
+ }
+
+ /**
+ *
+ */
+ public void closeHand() {
+ isHandOpen = false;
+ }
+
+ /**
+ * @param t
+ * @return
+ */
+ public float getGrip(float t) {
+ return (prevGrip * (1 - t) + grip * t) / gripMax;
+ }
+
+ /**
+ * @return
+ */
+ public float getGripScale() {
+ return gripScale;
+ }
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
index cb216a0..4ecaf7d 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
@@ -1,154 +1,224 @@
-package darkknight.jewelrycraft.tileentity;
-
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.NetworkManager;
-import net.minecraft.network.Packet;
-import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
-import net.minecraft.tileentity.TileEntity;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-
-public class TileEntityJewelrsCraftingTable extends TileEntity
-{
- public boolean hasJewelry, hasEndItem, isDirty, hasGem, crafting;
- public ItemStack jewelry, endItem, gem;
- public int carving, effect;
- public float angle;
-
- /**
- *
- */
- public TileEntityJewelrsCraftingTable()
- {
- jewelry = new ItemStack(Item.getItemById(0), 0, 0);
- endItem = new ItemStack(Item.getItemById(0), 0, 0);
- gem = new ItemStack(Item.getItemById(0), 0, 0);
- hasJewelry = false;
- hasEndItem = false;
- hasGem = false;
- crafting = false;
- carving = 0;
- effect = 0;
- angle = 0;
- isDirty = false;
- }
-
- /**
- * @param nbt
- */
- @Override
- public void writeToNBT(NBTTagCompound nbt)
- {
- super.writeToNBT(nbt);
- nbt.setBoolean("hasJewelry", hasJewelry);
- nbt.setBoolean("hasEndItem", hasEndItem);
- nbt.setBoolean("hasJewel", hasGem);
- nbt.setBoolean("crafting", crafting);
- nbt.setInteger("timer", carving);
- nbt.setInteger("effect", effect);
- nbt.setFloat("angle", angle);
- NBTTagCompound tag1 = new NBTTagCompound();
- NBTTagCompound tag2 = new NBTTagCompound();
- NBTTagCompound tag3 = new NBTTagCompound();
- jewelry.writeToNBT(tag1);
- nbt.setTag("jewelry", tag1);
- endItem.writeToNBT(tag2);
- nbt.setTag("endItem", tag2);
- gem.writeToNBT(tag3);
- nbt.setTag("jewel", tag3);
- }
-
- /**
- * @param nbt
- */
- @Override
- public void readFromNBT(NBTTagCompound nbt)
- {
- super.readFromNBT(nbt);
- hasJewelry = nbt.getBoolean("hasJewelry");
- hasEndItem = nbt.getBoolean("hasEndItem");
- hasGem = nbt.getBoolean("hasJewel");
- crafting = nbt.getBoolean("crafting");
- carving = nbt.getInteger("timer");
- effect = nbt.getInteger("effect");
- angle = nbt.getFloat("angle");
- jewelry = new ItemStack(Item.getItemById(0), 0, 0);
- jewelry.readFromNBT(nbt.getCompoundTag("jewelry"));
- endItem = new ItemStack(Item.getItemById(0), 0, 0);
- endItem.readFromNBT(nbt.getCompoundTag("endItem"));
- gem = new ItemStack(Item.getItemById(0), 0, 0);
- gem.readFromNBT(nbt.getCompoundTag("jewel"));
- }
-
- /**
- *
- */
- @Override
- public void updateEntity()
- {
- super.updateEntity();
- if (isDirty){
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- isDirty = false;
- }
- if (angle < 360F) angle += 3F;
- else angle = 0F;
- if (hasJewelry && hasGem && !hasEndItem && crafting){
- if (carving > 0) carving--;
- if (crafting) for(int l = 0; l < ConfigHandler.GEM_PLACEMENT_TIME / (carving + 2); ++l){
- if (worldObj.rand.nextInt(10) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F);
- if (getBlockMetadata() == 0) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D);
- if (getBlockMetadata() == 1) worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D);
- if (getBlockMetadata() == 2) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D);
- if (getBlockMetadata() == 3) worldObj.spawnParticle("instantSpell", xCoord + 0.2F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D);
- }
- if (carving == 0){
- hasEndItem = true;
- endItem = jewelry.copy();
- if (hasGem && gem != new ItemStack(Item.getItemById(0), 0, 0)) if (!JewelryNBT.hasTag(jewelry, "gem")){
- JewelryNBT.addGem(endItem, gem);
- hasGem = false;
- gem = new ItemStack(Item.getItemById(0), 0, 0);
- }else{
- ItemStack aux = JewelryNBT.gem(jewelry);
- JewelryNBT.addGem(endItem, gem);
- if (JewelrycraftUtil.rand.nextBoolean()) gem = aux.copy();
- else{
- hasGem = false;
- gem = new ItemStack(Item.getItemById(0), 0, 0);
- }
- }
- hasJewelry = false;
- jewelry = new ItemStack(Item.getItemById(0), 0, 0);
- carving = -1;
- crafting = false;
- isDirty = true;
- }
- }
- }
-
- /**
- * @return
- */
- @Override
- public Packet getDescriptionPacket()
- {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- writeToNBT(nbttagcompound);
- return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
- }
-
- /**
- * @param net
- * @param packet
- */
- @Override
- public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
- {
- readFromNBT(packet.func_148857_g());
- worldObj.func_147479_m(xCoord, yCoord, zCoord);
- }
-}
+package darkknight.jewelrycraft.tileentity;
+
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+
+public class TileEntityJewelrsCraftingTable extends TileEntity
+{
+ public boolean hasJewelry, hasEndItem, isDirty, hasGem, crafting;
+ public ItemStack jewelry, endItem, gem;
+ public int carving, effect;
+ public float angle;
+
+ /**
+ *
+ */
+ public TileEntityJewelrsCraftingTable()
+ {
+ jewelry = new ItemStack(Item.getItemById(0), 0, 0);
+ endItem = new ItemStack(Item.getItemById(0), 0, 0);
+ gem = new ItemStack(Item.getItemById(0), 0, 0);
+ hasJewelry = false;
+ hasEndItem = false;
+ hasGem = false;
+ crafting = false;
+ carving = 0;
+ effect = 0;
+ angle = 0;
+ isDirty = false;
+ }
+
+ /**
+ * @param nbt
+ */
+ @Override
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ super.writeToNBT(nbt);
+ nbt.setBoolean("hasJewelry", hasJewelry);
+ nbt.setBoolean("hasEndItem", hasEndItem);
+ nbt.setBoolean("hasJewel", hasGem);
+ nbt.setBoolean("crafting", crafting);
+ nbt.setInteger("timer", carving);
+ nbt.setInteger("effect", effect);
+ nbt.setFloat("angle", angle);
+ NBTTagCompound tag1 = new NBTTagCompound();
+ NBTTagCompound tag2 = new NBTTagCompound();
+ NBTTagCompound tag3 = new NBTTagCompound();
+ jewelry.writeToNBT(tag1);
+ nbt.setTag("jewelry", tag1);
+ endItem.writeToNBT(tag2);
+ nbt.setTag("endItem", tag2);
+ gem.writeToNBT(tag3);
+ nbt.setTag("jewel", tag3);
+ }
+
+ /**
+ * @param nbt
+ */
+ @Override
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ super.readFromNBT(nbt);
+ hasJewelry = nbt.getBoolean("hasJewelry");
+ hasEndItem = nbt.getBoolean("hasEndItem");
+ hasGem = nbt.getBoolean("hasJewel");
+ crafting = nbt.getBoolean("crafting");
+ carving = nbt.getInteger("timer");
+ effect = nbt.getInteger("effect");
+ angle = nbt.getFloat("angle");
+ jewelry = new ItemStack(Item.getItemById(0), 0, 0);
+ jewelry.readFromNBT(nbt.getCompoundTag("jewelry"));
+ endItem = new ItemStack(Item.getItemById(0), 0, 0);
+ endItem.readFromNBT(nbt.getCompoundTag("endItem"));
+ gem = new ItemStack(Item.getItemById(0), 0, 0);
+ gem.readFromNBT(nbt.getCompoundTag("jewel"));
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if (isDirty){
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ isDirty = false;
+ }
+ if (angle < 360F) angle += 3F;
+ else angle = 0F;
+ if (hasJewelry && hasGem && !hasEndItem && crafting){
+ if (carving > 0) carving--;
+ if (crafting) for(int l = 0; l < ConfigHandler.GEM_PLACEMENT_TIME / (carving + 2); ++l){
+ if (worldObj.rand.nextInt(10) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F);
+ if (getBlockMetadata() == 0) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D);
+ if (getBlockMetadata() == 1) worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D);
+ if (getBlockMetadata() == 2) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D);
+ if (getBlockMetadata() == 3) worldObj.spawnParticle("instantSpell", xCoord + 0.2F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D);
+ }
+ if (carving == 0){
+ hasEndItem = true;
+ endItem = jewelry.copy();
+ if (hasGem && gem != new ItemStack(Item.getItemById(0), 0, 0)) if (!JewelryNBT.hasTag(jewelry, "gem")){
+ JewelryNBT.addGem(endItem, gem);
+ hasGem = false;
+ gem = new ItemStack(Item.getItemById(0), 0, 0);
+ }else{
+ ItemStack aux = JewelryNBT.gem(jewelry);
+ JewelryNBT.addGem(endItem, gem);
+ if (JewelrycraftUtil.rand.nextBoolean()) gem = aux.copy();
+ else{
+ hasGem = false;
+ gem = new ItemStack(Item.getItemById(0), 0, 0);
+ }
+ }
+ hasJewelry = false;
+ jewelry = new ItemStack(Item.getItemById(0), 0, 0);
+ carving = -1;
+ crafting = false;
+ isDirty = true;
+ }
+ }
+ }
+
+ public void setGemItemStack(ItemStack itemStack)
+ {
+ if (itemStack != null && itemStack.getItem() != null) {
+ this.gem = itemStack.copy();
+ this.gem.stackSize = 1;
+ this.hasGem = true;
+ this.isDirty = true;
+ }
+ }
+
+ public void setJewelryItemStack(ItemStack itemStack)
+ {
+ if (itemStack != null && itemStack.getItem() != null) {
+ this.jewelry = itemStack.copy();
+ this.jewelry.stackSize = 1;
+ this.hasJewelry = true;
+ this.isDirty = true;
+ }
+ }
+
+ public void setCrafting()
+ {
+ carving = ConfigHandler.GEM_PLACEMENT_TIME;
+ angle = 0;
+ crafting = true;
+ isDirty = true;
+ }
+
+ public void removeGem()
+ {
+ dropItem(worldObj, xCoord, yCoord, zCoord, gem.copy());
+ gem = new ItemStack(Item.getItemById(0), 0, 0);
+ hasGem = false;
+ carving = -1;
+ crafting = false;
+ angle = 0F;
+ isDirty = true;
+ }
+
+ public void removeJewelry()
+ {
+ dropItem(worldObj, xCoord, yCoord, zCoord, jewelry.copy());
+ jewelry = new ItemStack(Item.getItemById(0), 0, 0);
+ hasJewelry = false;
+ carving = -1;
+ crafting = false;
+ angle = 0F;
+ isDirty = true;
+ }
+
+ public void removeResult()
+ {
+ dropItem(worldObj, xCoord, yCoord, zCoord, endItem.copy());
+ endItem = new ItemStack(Item.getItemById(0), 0, 0);
+ hasEndItem = false;
+ isDirty = true;
+ }
+
+ public void dropItem(World world, double x, double y, double z, ItemStack stack)
+ {
+ EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack);
+ entityitem.motionX = 0;
+ entityitem.motionZ = 0;
+ entityitem.motionY = 0.21000000298023224D;
+ world.spawnEntityInWorld(entityitem);
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public Packet getDescriptionPacket()
+ {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeToNBT(nbttagcompound);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
+ }
+
+ /**
+ * @param net
+ * @param packet
+ */
+ @Override
+ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
+ {
+ readFromNBT(packet.func_148857_g());
+ worldObj.func_147479_m(xCoord, yCoord, zCoord);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java
new file mode 100644
index 0000000..5da722a
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package darkknight.jewelrycraft.tileentity;
+
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * @author Sorin
+ */
+public class TileEntityMoltenMetal extends TileEntity {
+ private ItemStack metal;
+
+ public TileEntityMoltenMetal() {
+ metal = null;
+ }
+
+ public boolean canUpdate() {
+ return false;
+ }
+
+ public void setMetal(ItemStack metal) {
+ if(metal != null) this.metal = metal.copy();
+ else this.metal = null;
+ }
+
+ public ItemStack getMetal() {
+ return metal;
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ if (metal != null) {
+ NBTTagCompound tag = new NBTTagCompound();
+ metal.writeToNBT(tag);
+ nbt.setTag("metal", tag);
+ }
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ if (nbt.hasKey("metal")) setMetal(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("metal")));
+ else metal = null;
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeToNBT(nbttagcompound);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
+ readFromNBT(packet.func_148857_g());
+ worldObj.func_147479_m(xCoord, yCoord, zCoord);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
index cac74e2..c5e77e6 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
@@ -30,7 +30,7 @@ import darkknight.jewelrycraft.util.Variables;
public class TileEntityShadowEye extends TileEntity
{
- public int opening, timer, t = 20;
+ public int opening, timer, t = 20, soundTimer;
public boolean active, shouldAddData;
public ArrayList<ItemStack> pedestalItems = new ArrayList<ItemStack>();
ResourceLocation particleTexture = new ResourceLocation(Variables.MODID, "textures/particle/shadows.png");
@@ -107,6 +107,7 @@ public class TileEntityShadowEye extends TileEntity
if (opening < 4){
opening++;
timer = 20;
+ soundTimer = 0;
}
if (canStartRitual && opening == 4) timer = ConfigHandler.RITUAL_TIME;
else if (!canStartRitual){
@@ -124,6 +125,9 @@ public class TileEntityShadowEye extends TileEntity
int i = Minecraft.getMinecraft().gameSettings.particleSetting;
for(int l = 0; l <= 100 - i*45; l++)
worldObj.spawnParticle("depthsuspend", xCoord + 6.5F - worldObj.rand.nextInt(12) - worldObj.rand.nextFloat(), yCoord - 2F + worldObj.rand.nextInt(9) - worldObj.rand.nextFloat(), zCoord + 6.5F - worldObj.rand.nextInt(12) - worldObj.rand.nextFloat(), 0, 0, 0);
+ if(soundTimer == 0) worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "jewelrycraft2:Ritual", 1.0F, 1.0F, false);
+ if(soundTimer < 20*14) soundTimer++;
+ else soundTimer = 0;
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
index 745eb51..cb3da14 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
@@ -1,190 +1,189 @@
-package darkknight.jewelrycraft.tileentity;
-
-import java.util.Random;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.NetworkManager;
-import net.minecraft.network.Packet;
-import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
-import net.minecraft.tileentity.TileEntity;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-
-public class TileEntitySmelter extends TileEntity
-{
- public int melting, flow, n = 0, p = 0;
- public boolean hasMetal, hasMoltenMetal, isDirty, pouring;
- public ItemStack metal, moltenMetal;
- public float quantity, pouredQuantity = 0.1f;
-
- /**
- *
- */
- public TileEntitySmelter()
- {
- melting = 0;
- pouring = false;
- flow = 0;
- quantity = 0f;
- hasMetal = false;
- hasMoltenMetal = false;
- metal = new ItemStack(Item.getItemById(0), 0, 0);
- moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
- isDirty = false;
- }
-
- /**
- * @param nbt
- */
- @Override
- public void writeToNBT(NBTTagCompound nbt)
- {
- super.writeToNBT(nbt);
- nbt.setInteger("melting", melting);
- nbt.setFloat("quantity", quantity);
- nbt.setBoolean("hasMetal", hasMetal);
- nbt.setBoolean("hasMoltenMetal", hasMoltenMetal);
- nbt.setBoolean("pouring", pouring);
- NBTTagCompound tag = new NBTTagCompound();
- NBTTagCompound tag1 = new NBTTagCompound();
- metal.writeToNBT(tag);
- nbt.setTag("metal", tag);
- moltenMetal.writeToNBT(tag1);
- nbt.setTag("moltenMetal", tag1);
- }
-
- /**
- * @param nbt
- */
- @Override
- public void readFromNBT(NBTTagCompound nbt)
- {
- super.readFromNBT(nbt);
- melting = nbt.getInteger("melting");
- quantity = nbt.getFloat("quantity");
- hasMetal = nbt.getBoolean("hasMetal");
- hasMoltenMetal = nbt.getBoolean("hasMoltenMetal");
- pouring = nbt.getBoolean("pouring");
- metal = new ItemStack(Item.getItemById(0), 0, 0);
- metal.readFromNBT(nbt.getCompoundTag("metal"));
- moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
- moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal"));
- }
-
- /**
- *
- */
- @Override
- public void updateEntity()
- {
- super.updateEntity();
- Random rand = new Random();
- if (isDirty){
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- isDirty = false;
- }
- if (p > 0) --p;
- else p = 5;
- if (n == 0 && p == 0){
- flow += 16;
- if (flow >= 16 * 20) n = 1;
- }
- if (n == 1 && p == 0){
- flow -= 16;
- if (flow <= 0) n = 0;
- }
- if (hasMetal) for(int l = 0; l < 2; ++l)
- worldObj.spawnParticle("flame", xCoord + rand.nextFloat(), (double)yCoord + 0.3F, zCoord + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
- if (rand.nextInt(65) == 0){
- double d5 = xCoord + rand.nextFloat();
- double d7 = yCoord;
- double d6 = zCoord + rand.nextFloat();
- worldObj.playSound(d5, d7, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
- }
- if (hasMetal && !hasMoltenMetal){
- boolean isOre = JewelrycraftUtil.isOre(metal);
- if (melting > 0) melting--;
- if (melting == 0){
- hasMetal = false;
- if (!isOre){
- if(JewelryNBT.ingot(metal) == null) moltenMetal = metal;
- else moltenMetal = JewelryNBT.ingot(metal);
- }
- else{
- moltenMetal = JewelrycraftUtil.getIngotFromOre(metal);
- moltenMetal.stackSize *= 2;
- }
- hasMoltenMetal = true;
- if (!isOre) quantity = 0.1f * metal.stackSize;
- else quantity = 0.2f * metal.stackSize;
- metal = new ItemStack(Item.getItemById(0), 0, 0);
- melting = -1;
- isDirty = true;
- }
- }else if (hasMoltenMetal){
- boolean isOre = JewelrycraftUtil.isOre(metal);
- if (melting > 0) melting--;
- if (melting == 0){
- hasMetal = false;
- if (!isOre) moltenMetal.stackSize += metal.stackSize;
- else moltenMetal.stackSize += metal.stackSize * 2;
- if (!isOre) quantity += 0.1f * metal.stackSize;
- else quantity += 0.2f * metal.stackSize;
- metal = new ItemStack(Item.getItemById(0), 0, 0);
- melting = -1;
- isDirty = true;
- }
- }
- TileEntityMolder me = null;
- if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0 && worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) != null && worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
- else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 && worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) != null && worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
- else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 2 && worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) != null && worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
- else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 3 && worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) != null && worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
- if (pouring && pouredQuantity > 0f){
- quantity -= 0.01f;
- pouredQuantity -= 0.01f;
- me.quantity += 0.01f;
- if (!me.hasMoltenMetal){
- me.moltenMetal = moltenMetal;
- me.hasMoltenMetal = true;
- }
- if (pouredQuantity <= 0f){
- pouring = false;
- pouredQuantity = 0.1f;
- me.cooling = ConfigHandler.INGOT_COOLING_TIME;
- }
- if (quantity <= 0f){
- quantity = 0f;
- hasMoltenMetal = false;
- moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
- // pouring = false;
- me.cooling = ConfigHandler.INGOT_COOLING_TIME;
- }
- me.isDirty = true;
- }
- }
-
- /**
- * @return
- */
- @Override
- public Packet getDescriptionPacket()
- {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- writeToNBT(nbttagcompound);
- return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
- }
-
- /**
- * @param net
- * @param packet
- */
- @Override
- public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
- {
- readFromNBT(packet.func_148857_g());
- worldObj.func_147479_m(xCoord, yCoord, zCoord);
- }
-}
+package darkknight.jewelrycraft.tileentity;
+
+import java.util.Random;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+
+public class TileEntitySmelter extends TileEntity
+{
+ public int melting, flow, n = 0, p = 0;
+ public boolean hasMetal, hasMoltenMetal, isDirty, pouring;
+ public ItemStack metal, moltenMetal;
+ public float quantity, pouredQuantity = 0.1f;
+
+ /**
+ *
+ */
+ public TileEntitySmelter()
+ {
+ melting = 0;
+ pouring = false;
+ flow = 0;
+ quantity = 0f;
+ hasMetal = false;
+ hasMoltenMetal = false;
+ metal = new ItemStack(Item.getItemById(0), 0, 0);
+ moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
+ isDirty = false;
+ }
+
+ /**
+ * @param nbt
+ */
+ @Override
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ super.writeToNBT(nbt);
+ nbt.setInteger("melting", melting);
+ nbt.setFloat("quantity", quantity);
+ nbt.setBoolean("hasMetal", hasMetal);
+ nbt.setBoolean("hasMoltenMetal", hasMoltenMetal);
+ nbt.setBoolean("pouring", pouring);
+ NBTTagCompound tag = new NBTTagCompound();
+ NBTTagCompound tag1 = new NBTTagCompound();
+ metal.writeToNBT(tag);
+ nbt.setTag("metal", tag);
+ moltenMetal.writeToNBT(tag1);
+ nbt.setTag("moltenMetal", tag1);
+ }
+
+ /**
+ * @param nbt
+ */
+ @Override
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ super.readFromNBT(nbt);
+ melting = nbt.getInteger("melting");
+ quantity = nbt.getFloat("quantity");
+ hasMetal = nbt.getBoolean("hasMetal");
+ hasMoltenMetal = nbt.getBoolean("hasMoltenMetal");
+ pouring = nbt.getBoolean("pouring");
+ metal = new ItemStack(Item.getItemById(0), 0, 0);
+ metal.readFromNBT(nbt.getCompoundTag("metal"));
+ moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
+ moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal"));
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ Random rand = new Random();
+ if (isDirty){
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ isDirty = false;
+ }
+ if (p > 0) --p;
+ else p = 5;
+ if (n == 0 && p == 0){
+ flow += 16;
+ if (flow >= 16 * 20) n = 1;
+ }
+ if (n == 1 && p == 0){
+ flow -= 16;
+ if (flow <= 0) n = 0;
+ }
+ if (hasMetal) for(int l = 0; l < 2; ++l)
+ worldObj.spawnParticle("flame", xCoord + rand.nextFloat(), (double)yCoord + 0.3F, zCoord + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
+ if (rand.nextInt(65) == 0){
+ double d5 = xCoord + rand.nextFloat();
+ double d7 = yCoord;
+ double d6 = zCoord + rand.nextFloat();
+ worldObj.playSound(d5, d7, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
+ }
+ if (hasMetal && !hasMoltenMetal){
+ boolean isOre = JewelrycraftUtil.isOre(metal);
+ if (melting > 0) melting--;
+ if (melting == 0){
+ hasMetal = false;
+ if (!isOre){
+ if(JewelryNBT.ingot(metal) == null) moltenMetal = metal;
+ else moltenMetal = JewelryNBT.ingot(metal);
+ }
+ else{
+ moltenMetal = JewelrycraftUtil.getIngotFromOre(metal);
+ moltenMetal.stackSize *= 2;
+ }
+ hasMoltenMetal = true;
+ if (!isOre) quantity = 0.1f * metal.stackSize;
+ else quantity = 0.2f * metal.stackSize;
+ metal = new ItemStack(Item.getItemById(0), 0, 0);
+ melting = -1;
+ isDirty = true;
+ }
+ }else if (hasMoltenMetal){
+ boolean isOre = JewelrycraftUtil.isOre(metal);
+ if (melting > 0) melting--;
+ if (melting == 0){
+ hasMetal = false;
+ if (!isOre) moltenMetal.stackSize += metal.stackSize;
+ else moltenMetal.stackSize += metal.stackSize * 2;
+ if (!isOre) quantity += 0.1f * metal.stackSize;
+ else quantity += 0.2f * metal.stackSize;
+ metal = new ItemStack(Item.getItemById(0), 0, 0);
+ melting = -1;
+ isDirty = true;
+ }
+ }
+ TileEntityMolder me = null;
+ if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0 && worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) != null && worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
+ else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 && worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) != null && worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
+ else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 2 && worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) != null && worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
+ else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 3 && worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) != null && worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
+ if (pouring && pouredQuantity > 0f){
+ quantity -= 0.01f;
+ pouredQuantity -= 0.01f;
+ me.quantity += 0.01f;
+ if (!me.hasMoltenMetal){
+ me.moltenMetal = moltenMetal;
+ me.hasMoltenMetal = true;
+ }
+ if (pouredQuantity <= 0f){
+ pouring = false;
+ pouredQuantity = 0.1f;
+ me.cooling = ConfigHandler.INGOT_COOLING_TIME;
+ }
+ if (quantity <= 0f){
+ quantity = 0f;
+ hasMoltenMetal = false;
+ moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
+ me.cooling = ConfigHandler.INGOT_COOLING_TIME;
+ }
+ me.isDirty = true;
+ }
+ }
+
+ /**
+ * @return
+ */
+ @Override
+ public Packet getDescriptionPacket()
+ {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeToNBT(nbttagcompound);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
+ }
+
+ /**
+ * @param net
+ * @param packet
+ */
+ @Override
+ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
+ {
+ readFromNBT(packet.func_148857_g());
+ worldObj.func_147479_m(xCoord, yCoord, zCoord);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java
index 750c7cb..f36fa84 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java
@@ -1,264 +1,264 @@
-package darkknight.jewelrycraft.tileentity.renders;
-
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.List;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.OpenGlHelper;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.entity.RenderManager;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Items;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
-import darkknight.jewelrycraft.model.ModelDisplayer;
-import darkknight.jewelrycraft.tileentity.TileEntityDisplayer;
-import darkknight.jewelrycraft.util.Variables;
-
-public class TileEntityDisplayerRender extends TileEntitySpecialRenderer
-{
- ModelDisplayer displayer = new ModelDisplayer();
- String texture = "textures/tileentities/Displayer.png";
- HashMap<EnumChatFormatting, Integer> colors = new HashMap<EnumChatFormatting, Integer>(){
- {
- put(EnumChatFormatting.AQUA, 5636095);
- put(EnumChatFormatting.BLACK, 0);
- put(EnumChatFormatting.BLUE, 5592575);
- put(EnumChatFormatting.DARK_AQUA, 43690);
- put(EnumChatFormatting.DARK_BLUE, 170);
- put(EnumChatFormatting.DARK_GRAY, 5592405);
- put(EnumChatFormatting.DARK_GREEN, 43520);
- put(EnumChatFormatting.DARK_PURPLE, 11141290);
- put(EnumChatFormatting.DARK_RED, 11141120);
- put(EnumChatFormatting.GOLD, 16755200);
- put(EnumChatFormatting.GRAY, 11184810);
- put(EnumChatFormatting.GREEN, 5635925);
- put(EnumChatFormatting.LIGHT_PURPLE, 16733695);
- put(EnumChatFormatting.RED, 16733525);
- put(EnumChatFormatting.WHITE, 16777215);
- put(EnumChatFormatting.YELLOW, 16777045);
- }
- };
-
- /**
- * @param te
- * @param x
- * @param y
- * @param z
- * @param scale
- */
- @Override
- public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
- {
- GL11.glPushMatrix();
- GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
- TileEntityDisplayer disp = (TileEntityDisplayer)te;
- ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
- Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
- GL11.glPushMatrix();
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- displayer.render((Entity)null, disp.ringTranslation1, disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, 0.0625F);
- try{
- int block = disp.getBlockMetadata();
- if (disp != null && disp.hasObject && disp.object != null && disp.object.getItem() != null && disp.object != new ItemStack(Item.getItemById(0), 0, 0)){
- int ind = -3;
- GL11.glPushMatrix();
- EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, disp.object);
- entityitem.hoverStart = 0.0F;
- disp.object.stackSize = 1;
- GL11.glRotatef(180F, 1F, 0F, 0F);
- GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1 / 5, 0F);
- GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F);
- GL11.glColor4f(1F, 1F, 1F, 1F);
- if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- else{
- GL11.glRotatef(180F, 0F, 1F, 0F);
- RenderManager.instance.options.fancyGraphics = true;
- int i = 15728880;
- int j = i % 65536;
- int k = i / 65536;
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
- RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderManager.instance.options.fancyGraphics = false;
- }
- EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 5D);
- GL11.glPopMatrix();
- GL11.glPushMatrix();
- if (player != null) renderLabel(disp.object.getDisplayName(), 0F, -0.171F * ind, 0F, block, disp, colors.get(disp.object.getRarity().rarityColor));
- GL11.glPopMatrix();
- ind++;
- if (player != null && disp.quantity > 1){
- GL11.glPushMatrix();
- renderLabel("x" + Integer.toString(disp.quantity), 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB());
- GL11.glPopMatrix();
- ind++;
- }
- if (disp.object.getItem() != Items.map && player != null && disp.object.getTooltip(player, true) != null){
- List tooltips = disp.object.getTooltip(player, true);
- if (disp.infoIndex + 5 > tooltips.size()) disp.infoIndex = 1;
- if (tooltips.size() < 5) for(int i = 1; i < tooltips.size(); i++){
- String tooltip = tooltips.get(i).toString();
- RenderManager.instance.getFontRenderer();
- if (tooltip != ""){
- GL11.glPushMatrix();
- renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB());
- GL11.glPopMatrix();
- ind++;
- }
- }
- else for(int i = disp.infoIndex; i < disp.infoIndex + 5; i++){
- String tooltip = tooltips.get(i).toString();
- RenderManager.instance.getFontRenderer();
- if (tooltip != ""){
- GL11.glPushMatrix();
- renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB());
- GL11.glPopMatrix();
- ind++;
- }
- }
- }
- }
- }
- catch(Exception e){}
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- }
-
- /**
- * @param par2Str
- * @param x
- * @param y
- * @param z
- * @param metadata
- * @param te
- * @param color
- */
- protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te, int color)
- {
- FontRenderer fontrenderer = RenderManager.instance.getFontRenderer();
- float var14 = 0.01266667F * 1.5F;
- float var17 = 0.015F;
- GL11.glRotatef(180F, 0F, 0F, 1F);
- if (metadata == 0) GL11.glRotatef(0F, 0F, 1F, 0F);
- else if (metadata == 1) GL11.glRotatef(270F, 0F, 1F, 0F);
- else if (metadata == 2) GL11.glRotatef(180F, 0F, 1F, 0F);
- else if (metadata == 3) GL11.glRotatef(90F, 0F, 1F, 0F);
- GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F);
- GL11.glScalef(-0.015F, -var14, 0.015F);
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- Tessellator tessellator = Tessellator.instance;
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- int j = fontrenderer.getStringWidth(par2Str) / 2;
- tessellator.startDrawingQuads();
- tessellator.setColorRGBA_F(0.0F, 0.2F, 0.2F, 0.9F);
- tessellator.addVertex(-33.333 - 0, 0D, 0.1D);
- tessellator.addVertex(-33.333 - 0, 9D, 0.1D);
- tessellator.addVertex(33.333 + 0, 9D, 0.1D);
- tessellator.addVertex(33.333 + 0, 0D, 0.1D);
- tessellator.draw();
- if (fontrenderer.getStringWidth(par2Str) / 2 > 20) var17 = 0.9F / fontrenderer.getStringWidth(par2Str);
- else var17 = var14;
- int red = color >> 16 & 0xFF;
- int green = color >> 8 & 0xFF;
- int blue = color & 0xFF;
- GL11.glTranslatef((float)x + 1f, (float)y + 1f, (float)z);
- GL11.glPushMatrix();
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- GL11.glScalef(var17 * 70F, 1F, 0F);
- int i = 15728880;
- int t = i % 65536;
- int k = i / 65536;
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, t / 1.0F, k / 1.0F);
- fontrenderer.drawString(par2Str.replaceFirst("§0", "§r").replaceFirst("§1", "§r").replaceFirst("§2", "§r").replaceFirst("§3", "§r").replaceFirst("§4", "§r").replaceFirst("§5", "§r").replaceFirst("§6", "§r").replaceFirst("§7", "§r").replaceFirst("§8", "§r").replaceFirst("§9", "§r").replaceFirst("§a", "§r").replaceFirst("§b", "§r").replaceFirst("§c", "§r").replaceFirst("§d", "§r").replaceFirst("§e", "§r").replaceFirst("§f", "§r"), -j, 0, 65536 * (red > 170 ? red - 170 : 0) + 256 * (green > 170 ? green - 170 : 0) + (blue > 170 ? blue - 170 : 0));
- GL11.glPopMatrix();
- GL11.glTranslatef((float)x - 1f, (float)y - 1f, (float)z - 1F);
- GL11.glScalef(var17 * 70F, 1F, 0F);
- fontrenderer.drawString(par2Str, -j, 0, color);
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
-
- /**
- * @param str
- * @param color
- */
- public void replaceEnumEnchValues(String str, int color)
- {
- if (str.contains("§0")){
- color = Color.BLACK.getRGB();
- str.replace("§0", "");
- }
- if (str.contains("§1")){
- color = 85;
- str.replace("§1", "");
- }
- if (str.contains("§2")){
- color = 17920;
- str.replace("§2", "");
- }
- if (str.contains("§3")){
- color = 1336183;
- str.replace("§3", "");
- }
- if (str.contains("§4")){
- color = 4587520;
- str.replace("§4", "");
- }
- if (str.contains("§5")){
- color = 5701759;
- str.replace("§5", "");
- }
- if (str.contains("§6")){
- color = 16762880;
- str.replace("§6", "");
- }
- if (str.contains("§7")){
- color = Color.GRAY.getRGB();
- str.replace("§7", "");
- }
- if (str.contains("§8")){
- color = Color.DARK_GRAY.getRGB();
- str.replace("§8", "");
- }
- if (str.contains("§9")){
- color = Color.BLUE.getRGB();
- str.replace("§9", "");
- }
- if (str.contains("§a")){
- color = Color.GREEN.getRGB();
- str.replace("§a", "");
- }
- if (str.contains("§b")){
- color = Color.CYAN.getRGB();
- str.replace("§b", "");
- }
- if (str.contains("§c")){
- color = Color.RED.getRGB();
- str.replace("§c", "");
- }
- if (str.contains("§d")){
- color = 11665663;
- str.replace("§d", "");
- }
- if (str.contains("§e")){
- color = Color.YELLOW.getRGB();
- str.replace("§e", "");
- }
- if (str.contains("§f")){
- color = Color.WHITE.getRGB();
- str.replace("§f", "");
- }
- }
+package darkknight.jewelrycraft.tileentity.renders;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.List;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.model.ModelDisplayer;
+import darkknight.jewelrycraft.tileentity.TileEntityDisplayer;
+import darkknight.jewelrycraft.util.Variables;
+
+public class TileEntityDisplayerRender extends TileEntitySpecialRenderer
+{
+ ModelDisplayer displayer = new ModelDisplayer();
+ String texture = "textures/tileentities/Displayer.png";
+ HashMap<EnumChatFormatting, Integer> colors = new HashMap<EnumChatFormatting, Integer>(){
+ {
+ put(EnumChatFormatting.AQUA, 5636095);
+ put(EnumChatFormatting.BLACK, 0);
+ put(EnumChatFormatting.BLUE, 5592575);
+ put(EnumChatFormatting.DARK_AQUA, 43690);
+ put(EnumChatFormatting.DARK_BLUE, 170);
+ put(EnumChatFormatting.DARK_GRAY, 5592405);
+ put(EnumChatFormatting.DARK_GREEN, 43520);
+ put(EnumChatFormatting.DARK_PURPLE, 11141290);
+ put(EnumChatFormatting.DARK_RED, 11141120);
+ put(EnumChatFormatting.GOLD, 16755200);
+ put(EnumChatFormatting.GRAY, 11184810);
+ put(EnumChatFormatting.GREEN, 5635925);
+ put(EnumChatFormatting.LIGHT_PURPLE, 16733695);
+ put(EnumChatFormatting.RED, 16733525);
+ put(EnumChatFormatting.WHITE, 16777215);
+ put(EnumChatFormatting.YELLOW, 16777045);
+ }
+ };
+
+ /**
+ * @param te
+ * @param x
+ * @param y
+ * @param z
+ * @param scale
+ */
+ @Override
+ public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ TileEntityDisplayer disp = (TileEntityDisplayer)te;
+ ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
+ Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
+ GL11.glPushMatrix();
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ displayer.render((Entity)null, disp.ringTranslation1, disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, 0.0625F);
+ try{
+ int block = disp.getBlockMetadata();
+ if (disp != null && disp.hasObject && disp.object != null && disp.object.getItem() != null && disp.object != new ItemStack(Item.getItemById(0), 0, 0)){
+ int ind = -3;
+ GL11.glPushMatrix();
+ EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, disp.object);
+ entityitem.hoverStart = 0.0F;
+ disp.object.stackSize = 1;
+ GL11.glRotatef(180F, 1F, 0F, 0F);
+ GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1 / 5, 0F);
+ GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F);
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ else{
+ GL11.glRotatef(180F, 0F, 1F, 0F);
+ RenderManager.instance.options.fancyGraphics = true;
+ int i = 15728880;
+ int j = i % 65536;
+ int k = i / 65536;
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
+ RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderManager.instance.options.fancyGraphics = false;
+ }
+ EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 5D);
+ GL11.glPopMatrix();
+ GL11.glPushMatrix();
+ if (player != null) renderLabel(disp.object.getDisplayName(), 0F, -0.171F * ind, 0F, block, disp, colors.get(disp.object.getRarity().rarityColor));
+ GL11.glPopMatrix();
+ ind++;
+ if (player != null && disp.quantity > 1){
+ GL11.glPushMatrix();
+ renderLabel("x" + Integer.toString(disp.quantity), 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB());
+ GL11.glPopMatrix();
+ ind++;
+ }
+ if (disp.object.getItem() != Items.map && player != null && disp.object.getTooltip(player, true) != null){
+ List tooltips = disp.object.getTooltip(player, true);
+ if (disp.infoIndex + 5 > tooltips.size()) disp.infoIndex = 1;
+ if (tooltips.size() < 5) for(int i = 1; i < tooltips.size(); i++){
+ String tooltip = tooltips.get(i).toString();
+ RenderManager.instance.getFontRenderer();
+ if (tooltip != ""){
+ GL11.glPushMatrix();
+ renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB());
+ GL11.glPopMatrix();
+ ind++;
+ }
+ }
+ else for(int i = disp.infoIndex; i < disp.infoIndex + 5; i++){
+ String tooltip = tooltips.get(i).toString();
+ RenderManager.instance.getFontRenderer();
+ if (tooltip != ""){
+ GL11.glPushMatrix();
+ renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB());
+ GL11.glPopMatrix();
+ ind++;
+ }
+ }
+ }
+ }
+ }
+ catch(Exception e){}
+ GL11.glPopMatrix();
+ GL11.glPopMatrix();
+ }
+
+ /**
+ * @param par2Str
+ * @param x
+ * @param y
+ * @param z
+ * @param metadata
+ * @param te
+ * @param color
+ */
+ protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te, int color)
+ {
+ FontRenderer fontrenderer = RenderManager.instance.getFontRenderer();
+ float var14 = 0.01266667F * 1.5F;
+ float var17 = 0.015F;
+ GL11.glRotatef(180F, 0F, 0F, 1F);
+ if (metadata == 0) GL11.glRotatef(0F, 0F, 1F, 0F);
+ else if (metadata == 1) GL11.glRotatef(270F, 0F, 1F, 0F);
+ else if (metadata == 2) GL11.glRotatef(180F, 0F, 1F, 0F);
+ else if (metadata == 3) GL11.glRotatef(90F, 0F, 1F, 0F);
+ GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F);
+ GL11.glScalef(-0.015F, -var14, 0.015F);
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ Tessellator tessellator = Tessellator.instance;
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ int j = fontrenderer.getStringWidth(par2Str) / 2;
+ tessellator.startDrawingQuads();
+ tessellator.setColorRGBA_F(0.0F, 0.2F, 0.2F, 0.9F);
+ tessellator.addVertex(-33.333 - 0, 0D, 0.1D);
+ tessellator.addVertex(-33.333 - 0, 9D, 0.1D);
+ tessellator.addVertex(33.333 + 0, 9D, 0.1D);
+ tessellator.addVertex(33.333 + 0, 0D, 0.1D);
+ tessellator.draw();
+ if (fontrenderer.getStringWidth(par2Str) / 2 > 20) var17 = 0.9F / fontrenderer.getStringWidth(par2Str);
+ else var17 = var14;
+ int red = color >> 16 & 0xFF;
+ int green = color >> 8 & 0xFF;
+ int blue = color & 0xFF;
+ GL11.glTranslatef((float)x + 1f, (float)y + 1f, (float)z);
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ GL11.glScalef(var17 * 70F, 1F, 0F);
+ int i = 15728880;
+ int t = i % 65536;
+ int k = i / 65536;
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, t / 1.0F, k / 1.0F);
+ fontrenderer.drawString(par2Str.replaceFirst("§0", "§r").replaceFirst("§1", "§r").replaceFirst("§2", "§r").replaceFirst("§3", "§r").replaceFirst("§4", "§r").replaceFirst("§5", "§r").replaceFirst("§6", "§r").replaceFirst("§7", "§r").replaceFirst("§8", "§r").replaceFirst("§9", "§r").replaceFirst("§a", "§r").replaceFirst("§b", "§r").replaceFirst("§c", "§r").replaceFirst("§d", "§r").replaceFirst("§e", "§r").replaceFirst("§f", "§r"), -j, 0, 1973790);
+ GL11.glPopMatrix();
+ GL11.glTranslatef((float)x - 1f, (float)y - 1f, (float)z - 1F);
+ GL11.glScalef(var17 * 70F, 1F, 0F);
+ fontrenderer.drawString(par2Str, -j, 0, color);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+
+ /**
+ * @param str
+ * @param color
+ */
+ public void replaceEnumEnchValues(String str, int color)
+ {
+ if (str.contains("§0")){
+ color = Color.BLACK.getRGB();
+ str.replace("§0", "");
+ }
+ if (str.contains("§1")){
+ color = 85;
+ str.replace("§1", "");
+ }
+ if (str.contains("§2")){
+ color = 17920;
+ str.replace("§2", "");
+ }
+ if (str.contains("§3")){
+ color = 1336183;
+ str.replace("§3", "");
+ }
+ if (str.contains("§4")){
+ color = 4587520;
+ str.replace("§4", "");
+ }
+ if (str.contains("§5")){
+ color = 5701759;
+ str.replace("§5", "");
+ }
+ if (str.contains("§6")){
+ color = 16762880;
+ str.replace("§6", "");
+ }
+ if (str.contains("§7")){
+ color = Color.GRAY.getRGB();
+ str.replace("§7", "");
+ }
+ if (str.contains("§8")){
+ color = Color.DARK_GRAY.getRGB();
+ str.replace("§8", "");
+ }
+ if (str.contains("§9")){
+ color = Color.BLUE.getRGB();
+ str.replace("§9", "");
+ }
+ if (str.contains("§a")){
+ color = Color.GREEN.getRGB();
+ str.replace("§a", "");
+ }
+ if (str.contains("§b")){
+ color = Color.CYAN.getRGB();
+ str.replace("§b", "");
+ }
+ if (str.contains("§c")){
+ color = Color.RED.getRGB();
+ str.replace("§c", "");
+ }
+ if (str.contains("§d")){
+ color = 11665663;
+ str.replace("§d", "");
+ }
+ if (str.contains("§e")){
+ color = Color.YELLOW.getRGB();
+ str.replace("§e", "");
+ }
+ if (str.contains("§f")){
+ color = Color.WHITE.getRGB();
+ str.replace("§f", "");
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java
index 62e3945..6067e2a 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java
@@ -1,139 +1,138 @@
-package darkknight.jewelrycraft.tileentity.renders;
-
-import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.OpenGlHelper;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.entity.RenderItem;
-import net.minecraft.client.renderer.entity.RenderManager;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.world.World;
-import org.lwjgl.opengl.GL11;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.model.ModelMolder;
-import darkknight.jewelrycraft.tileentity.TileEntityMolder;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.Variables;
-
-public class TileEntityMolderRender extends TileEntitySpecialRenderer
-{
- ModelMolder modelMolder = new ModelMolder();
-
- /**
- * @param te
- * @param x
- * @param y
- * @param z
- * @param scale
- */
- @Override
- public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
- {
- GL11.glPushMatrix();
- GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
- TileEntityMolder me = (TileEntityMolder)te;
- String texture = "textures/tileentities/Molder.png";
- ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
- Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
- GL11.glPushMatrix();
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- try{
- int block = me.getBlockMetadata();
- if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
- else if (block == 2){
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
- }else if (block == 3){
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
- }
- }
- catch(Exception e){}
- modelMolder.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
- boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics;
- if (me != null){
- if (me.hasMold){
- GL11.glPushMatrix();
- EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.mold);
- entityitem.getEntityItem().stackSize = 1;
- entityitem.hoverStart = 0.0F;
- GL11.glTranslatef(0F, 1.43F, -0.28F);
- GL11.glScalef(1.25F, 1.0F, 1.25F);
- GL11.glRotatef(90F, 1F, 0F, 0f);
- Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
- if (entityitem != null){
- RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.03D, 0.0F, 0.0F);
- }
- Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics;
- GL11.glPopMatrix();
- }
- if (me.hasJewelBase && me.jewelBase != null && me.jewelBase.getItem() != Item.getItemFromBlock(Blocks.air) && me.jewelBase.getIconIndex() != null && me.jewelBase.getIconIndex().getIconName() != ""){
- GL11.glPushMatrix();
- EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.jewelBase);
- entityitem.getEntityItem().stackSize = 1;
- entityitem.hoverStart = 0.0F;
- GL11.glTranslatef(0F, 1.4F, -0.28F);
- GL11.glScalef(1.25F, 1.0F, 1.25F);
- GL11.glRotatef(90F, 1F, 0F, 0f);
- Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
- if (entityitem != null) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.01D, 0.0F, 0.0F);
- Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics;
- GL11.glColor4f(1, 1F, 1F, 1.0F);
- GL11.glPopMatrix();
- }
- if (me.hasMoltenMetal && me.moltenMetal != null && me.moltenMetal != new ItemStack(Item.getItemById(0), 0, 0)){
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- if (JewelrycraftMod.fancyRender){
- GL11.glEnable(GL11.GL_BLEND);
- OpenGlHelper.glBlendFunc(1, 1, 0, 0);
- }
- ItemStack metal = new ItemStack(ItemList.metal);
- ItemStack ingot = me.moltenMetal.copy();
- if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage());
- JewelryNBT.addMetal(metal, ingot);
- EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal);
- moltenMetal.getEntityItem().stackSize = 1;
- moltenMetal.hoverStart = 0.0F;
- GL11.glTranslatef(-0F, 1.4f - 0.005f * me.quantity, -0.29F);
- GL11.glScalef(1.2F, 1.0F, 1.4F);
- GL11.glRotatef(90F, 1F, 0F, 0f);
- RenderItem.renderInFrame = true;
- RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderItem.renderInFrame = false;
- if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
- }
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param block
- */
- public void adjustLightFixture(World world, int i, int j, int k, Block block)
- {
- Tessellator tess = Tessellator.instance;
- float brightness = block.getLightOpacity(world, i, j, k);
- int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
- int modulousModifier = skyLight % 65536;
- int divModifier = skyLight / 65536;
- tess.setColorOpaque_F(brightness, brightness, brightness);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier);
- }
-}
+package darkknight.jewelrycraft.tileentity.renders;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.model.ModelMolder;
+import darkknight.jewelrycraft.tileentity.TileEntityMolder;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.Variables;
+
+public class TileEntityMolderRender extends TileEntitySpecialRenderer
+{
+ ModelMolder modelMolder = new ModelMolder();
+
+ /**
+ * @param te
+ * @param x
+ * @param y
+ * @param z
+ * @param scale
+ */
+ @Override
+ public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ TileEntityMolder me = (TileEntityMolder)te;
+ String texture = "textures/tileentities/Molder.png";
+ ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
+ Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
+ GL11.glPushMatrix();
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ try{
+ int block = me.getBlockMetadata();
+ if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
+ else if (block == 2){
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
+ }else if (block == 3){
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
+ }
+ }
+ catch(Exception e){}
+ modelMolder.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
+ boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics;
+ if (me != null){
+ if (me.hasMold){
+ GL11.glPushMatrix();
+ EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.mold);
+ entityitem.getEntityItem().stackSize = 1;
+ entityitem.hoverStart = 0.0F;
+ GL11.glTranslatef(0F, 1.43F, -0.28F);
+ GL11.glScalef(1.25F, 1.0F, 1.25F);
+ GL11.glRotatef(90F, 1F, 0F, 0f);
+ Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
+ if (entityitem != null){
+ RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.03D, 0.0F, 0.0F);
+ }
+ Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics;
+ GL11.glPopMatrix();
+ }
+ if (me.hasJewelBase && me.jewelBase != null && me.jewelBase.getItem() != Item.getItemFromBlock(Blocks.air) && me.jewelBase.getIconIndex() != null && me.jewelBase.getIconIndex().getIconName() != ""){
+ GL11.glPushMatrix();
+ EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.jewelBase);
+ entityitem.getEntityItem().stackSize = 1;
+ entityitem.hoverStart = 0.0F;
+ GL11.glTranslatef(0F, 1.4F, -0.28F);
+ GL11.glScalef(1.25F, 1.0F, 1.25F);
+ GL11.glRotatef(90F, 1F, 0F, 0f);
+ Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
+ if (entityitem != null) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.01D, 0.0F, 0.0F);
+ Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics;
+ GL11.glColor4f(1, 1F, 1F, 1.0F);
+ GL11.glPopMatrix();
+ }
+ if (me.hasMoltenMetal && me.moltenMetal != null && me.moltenMetal != new ItemStack(Item.getItemById(0), 0, 0)){
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ if (JewelrycraftMod.fancyRender){
+ GL11.glEnable(GL11.GL_BLEND);
+ OpenGlHelper.glBlendFunc(1, 1, 0, 0);
+ }
+ ItemStack metal = new ItemStack(ItemList.metal);
+ ItemStack ingot = me.moltenMetal.copy();
+ JewelryNBT.addMetal(metal, ingot);
+ EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal);
+ moltenMetal.getEntityItem().stackSize = 1;
+ moltenMetal.hoverStart = 0.0F;
+ GL11.glTranslatef(-0F, 1.4f - 0.005f * me.quantity, -0.29F);
+ GL11.glScalef(1.2F, 1.0F, 1.4F);
+ GL11.glRotatef(90F, 1F, 0F, 0f);
+ RenderItem.renderInFrame = true;
+ RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderItem.renderInFrame = false;
+ if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+ }
+ GL11.glPopMatrix();
+ GL11.glPopMatrix();
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param block
+ */
+ public void adjustLightFixture(World world, int i, int j, int k, Block block)
+ {
+ Tessellator tess = Tessellator.instance;
+ float brightness = block.getLightOpacity(world, i, j, k);
+ int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
+ int modulousModifier = skyLight % 65536;
+ int divModifier = skyLight / 65536;
+ tess.setColorOpaque_F(brightness, brightness, brightness);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java
index 2892ead..3db99c8 100644
--- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java
+++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java
@@ -1,126 +1,125 @@
-package darkknight.jewelrycraft.tileentity.renders;
-
-import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.OpenGlHelper;
-import net.minecraft.client.renderer.entity.RenderItem;
-import net.minecraft.client.renderer.entity.RenderManager;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.model.ModelSmelter;
-import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.Variables;
-
-public class TileEntitySmelterRender extends TileEntitySpecialRenderer
-{
- ModelSmelter modelSmelter = new ModelSmelter();
- public static final float p = 1 / 16, p3 = 3 * p, p13 = 13 * p, p15 = 15 * p;
-
- /**
- * @param te
- * @param x
- * @param y
- * @param z
- * @param scale
- */
- @Override
- public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
- {
- GL11.glPushMatrix();
- GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
- String texture = "textures/tileentities/Smelter.png";
- ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
- Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
- TileEntitySmelter st = (TileEntitySmelter)te;
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- try{
- int block = te.getBlockMetadata();
- if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
- else if (block == 2){
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
- }else if (block == 3){
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
- }
- }
- catch(Exception e){}
- boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics;
- modelSmelter.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
- if (scale != 0){
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- if (JewelrycraftMod.fancyRender){
- GL11.glEnable(GL11.GL_BLEND);
- OpenGlHelper.glBlendFunc(1, 1, 0, 0);
- }
- EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, new ItemStack(Blocks.lava, 1, 1));
- entityitem.hoverStart = 0.0F;
- GL11.glTranslatef(-0F, 1.25F, -0.345F);
- GL11.glScalef(1.2F, 1.0F, 1.7F);
- GL11.glRotatef(90F, 1F, 0F, 0f);
- RenderItem.renderInFrame = true;
- int i = 15728880;
- int j = i % 65536;
- int k = i / 65536;
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
- RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderItem.renderInFrame = false;
- if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
- if (st != null){
- if (st.hasMetal && st.metal != null && st.metal.getItem() != null){
- GL11.glPushMatrix();
- EntityItem metal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, st.metal);
- metal.getEntityItem().stackSize = 1;
- metal.hoverStart = 0.0F;
- GL11.glRotatef(-50F, 1F, 0F, 0F);
- GL11.glRotatef(-50F, 0F, 0F, 1F);
- GL11.glRotatef(180F, 1F, 0F, 0F);
- GL11.glScalef(0.5F, 0.5F, 0.5F);
- GL11.glTranslatef(-0.9F, -0.9F, -1.6F);
- Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
- RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics;
- GL11.glPopMatrix();
- }
- if (st.hasMoltenMetal && st.moltenMetal != null && st.moltenMetal.getItem() != null){
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- if (JewelrycraftMod.fancyRender){
- GL11.glEnable(GL11.GL_BLEND);
- OpenGlHelper.glBlendFunc(1, 1, 0, 0);
- }
- ItemStack metal = new ItemStack(ItemList.metal);
- ItemStack ingot = st.moltenMetal.copy();
- if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage());
- JewelryNBT.addMetal(metal, ingot);
- EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal);
- moltenMetal.getEntityItem().stackSize = 1;
- moltenMetal.hoverStart = 0.0F;
- GL11.glTranslatef(-0F, 1.00f - .4F * st.quantity, -0.14F);
- GL11.glScalef(0.71F, 1F, 0.84F);
- GL11.glRotatef(90F, 1F, 0F, 0f);
- RenderItem.renderInFrame = true;
- RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
- RenderItem.renderInFrame = false;
- if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
- }
- GL11.glPopMatrix();
- }
-}
+package darkknight.jewelrycraft.tileentity.renders;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.model.ModelSmelter;
+import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.Variables;
+
+public class TileEntitySmelterRender extends TileEntitySpecialRenderer
+{
+ ModelSmelter modelSmelter = new ModelSmelter();
+ public static final float p = 1 / 16, p3 = 3 * p, p13 = 13 * p, p15 = 15 * p;
+
+ /**
+ * @param te
+ * @param x
+ * @param y
+ * @param z
+ * @param scale
+ */
+ @Override
+ public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ String texture = "textures/tileentities/Smelter.png";
+ ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
+ Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
+ TileEntitySmelter st = (TileEntitySmelter)te;
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ try{
+ int block = te.getBlockMetadata();
+ if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
+ else if (block == 2){
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
+ }else if (block == 3){
+ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
+ }
+ }
+ catch(Exception e){}
+ boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics;
+ modelSmelter.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
+ if (scale != 0){
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ if (JewelrycraftMod.fancyRender){
+ GL11.glEnable(GL11.GL_BLEND);
+ OpenGlHelper.glBlendFunc(1, 1, 0, 0);
+ }
+ EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, new ItemStack(Blocks.lava, 1, 1));
+ entityitem.hoverStart = 0.0F;
+ GL11.glTranslatef(-0F, 1.25F, -0.345F);
+ GL11.glScalef(1.2F, 1.0F, 1.7F);
+ GL11.glRotatef(90F, 1F, 0F, 0f);
+ RenderItem.renderInFrame = true;
+ int i = 15728880;
+ int j = i % 65536;
+ int k = i / 65536;
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
+ RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderItem.renderInFrame = false;
+ if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+ if (st != null){
+ if (st.hasMetal && st.metal != null && st.metal.getItem() != null){
+ GL11.glPushMatrix();
+ EntityItem metal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, st.metal);
+ metal.getEntityItem().stackSize = 1;
+ metal.hoverStart = 0.0F;
+ GL11.glRotatef(-50F, 1F, 0F, 0F);
+ GL11.glRotatef(-50F, 0F, 0F, 1F);
+ GL11.glRotatef(180F, 1F, 0F, 0F);
+ GL11.glScalef(0.5F, 0.5F, 0.5F);
+ GL11.glTranslatef(-0.9F, -0.9F, -1.6F);
+ Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
+ RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics;
+ GL11.glPopMatrix();
+ }
+ if (st.hasMoltenMetal && st.moltenMetal != null && st.moltenMetal.getItem() != null){
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ if (JewelrycraftMod.fancyRender){
+ GL11.glEnable(GL11.GL_BLEND);
+ OpenGlHelper.glBlendFunc(1, 1, 0, 0);
+ }
+ ItemStack metal = new ItemStack(ItemList.metal);
+ ItemStack ingot = st.moltenMetal.copy();
+ JewelryNBT.addMetal(metal, ingot);
+ EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal);
+ moltenMetal.getEntityItem().stackSize = 1;
+ moltenMetal.hoverStart = 0.0F;
+ GL11.glTranslatef(-0F, 1.00f - .4F * st.quantity, -0.14F);
+ GL11.glScalef(0.71F, 1F, 0.84F);
+ GL11.glRotatef(90F, 1F, 0F, 0f);
+ RenderItem.renderInFrame = true;
+ RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderItem.renderInFrame = false;
+ if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+ }
+ GL11.glPopMatrix();
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index bee2c95..cb3b622 100644
--- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -12,52 +12,52 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
-
import javax.imageio.ImageIO;
-
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.registry.GameData;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.random.WeightedRandomCurse;
+import darkknight.jewelrycraft.worldGen.Generation;
+import darkknight.jewelrycraft.worldGen.WorldGenStructure;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.stats.Achievement;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.oredict.OreDictionary;
-import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.registry.GameData;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.api.Curse;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.item.ItemBaseJewelry;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.random.WeightedRandomCurse;
-import darkknight.jewelrycraft.worldGen.Generation;
public class JewelrycraftUtil {
- public static ArrayList<ItemStack> objects = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> gem = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> ores = new ArrayList<ItemStack>();
- public static HashMap<ItemStack, ItemStack> oreToIngot = new HashMap<ItemStack, ItemStack>();
- public static HashMap<ItemStack, Integer> colors = new HashMap<ItemStack, Integer>();
- public static ArrayList<String> jamcraftPlayers = new ArrayList<String>();
- private static ArrayList<ItemStack> items = new ArrayList<ItemStack>();
- public static ArrayList<WorldGenerator> structures = new ArrayList<WorldGenerator>();
- public static Random rand = new Random();
- public static EnumCreatureAttribute HEART;
+ public static ArrayList<ItemStack> objects = new ArrayList<ItemStack>();
+ public static ArrayList<ItemStack> gem = new ArrayList<ItemStack>();
+ public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>();
+ public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>();
+ public static ArrayList<ItemStack> ores = new ArrayList<ItemStack>();
+ public static HashMap<ItemStack, ItemStack> oreToIngot = new HashMap<ItemStack, ItemStack>();
+ public static HashMap<ItemStack, Integer> colors = new HashMap<ItemStack, Integer>();
+ public static ArrayList<String> jamcraftPlayers = new ArrayList<String>();
+ private static ArrayList<ItemStack> items = new ArrayList<ItemStack>();
+ public static ArrayList<WorldGenStructure> structures = new ArrayList<WorldGenStructure>();
+ public static Random rand = new Random();
+ public static EnumCreatureAttribute HEART;
/**
* Adds gems and jewelry to their appropriate list
@@ -83,10 +83,12 @@ public class JewelrycraftUtil {
try {
if (item != null && (Item) item != null && ((Item) item).getHasSubtypes() && FMLCommonHandler.instance().getSide() == Side.CLIENT) {
((Item) item).getSubItems((Item) item, null, items);
- } else objects.add(new ItemStack((Item) item));
+ }
+ else objects.add(new ItemStack((Item) item));
if (!items.isEmpty()) objects.addAll(items);
items.removeAll(items);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
JewelrycraftMod.logger.info("Error, tried to add subtypes of item " + ((Item) item).getUnlocalizedName() + "\nItem is not added in the list.");
}
}
@@ -94,9 +96,10 @@ public class JewelrycraftUtil {
try {
for (Field f : Generation.class.getDeclaredFields()) {
Object obj = f.get(null);
- if (obj instanceof WorldGenerator) structures.add((WorldGenerator) obj);
+ if (obj instanceof WorldGenStructure) structures.add((WorldGenStructure) obj);
}
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@@ -108,14 +111,16 @@ public class JewelrycraftUtil {
try {
if (item != null && (Item) item != null && ((Item) item).getHasSubtypes() && FMLCommonHandler.instance().getSide() == Side.CLIENT) {
((Item) item).getSubItems((Item) item, null, items);
- } else {
+ }
+ else {
ItemStack it = new ItemStack((Item) item);
colors.put(it, color(it, 0));
}
if (!items.isEmpty()) for (ItemStack it : items)
colors.put(it, color(it, 0));
items.removeAll(items);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
JewelrycraftMod.logger.info("Error, tried to add subtypes of item " + ((Item) item).getUnlocalizedName() + "\nItem is not added in the list.");
}
}
@@ -123,9 +128,9 @@ public class JewelrycraftUtil {
@SideOnly(Side.CLIENT)
public static int getColor(ItemStack item) {
+ if (Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.carpet)) item.setItemDamage(15 - item.getItemDamage());
for (ItemStack stack : colors.keySet())
- if (item.getItem().equals(stack.getItem()) && item.getItemDamage() == stack.getItemDamage())
- return colors.get(stack);
+ if (item != null && item.getItem() != null && stack.getItem() != null && item.getItem().equals(stack.getItem()) && item.getItemDamage() == stack.getItemDamage()) return colors.get(stack);
return 0xFFFFFF;
}
@@ -136,8 +141,9 @@ public class JewelrycraftUtil {
BufferedImage icon;
if (stack != null && Item.getIdFromItem(stack.getItem()) > 0 && stack.getIconIndex() != null && stack.getItem().getColorFromItemStack(stack, pass) == 16777215) {
try {
- ingot = getLocation(stack, stack, false);
- } catch (Exception e) {
+ ingot = getLocation(stack);
+ }
+ catch (Exception e) {
ingot = new ResourceLocation("textures/items/apple.png");
}
icon = ImageIO.read(rm.getResource(ingot).getInputStream());
@@ -156,24 +162,24 @@ public class JewelrycraftUtil {
if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2);
}
return getMostCommonColour(m);
- } else return stack.getItem().getColorFromItemStack(stack, pass);
+ }
+ else return stack.getItem().getColorFromItemStack(stack, pass);
+ }
+
+ public static ResourceLocation getLocation(ItemStack item) {
+ String domain = "";
+ String texture;
+ IIcon itemIcon = item.getItem().getIcon(item, 0);
+ String iconName = itemIcon.getIconName();
+ if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim();
+ else domain = "minecraft";
+ texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png";
+ ResourceLocation textureLocation = null;
+ TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
+ if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture);
+ else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture);
+ return textureLocation;
}
-
- public static ResourceLocation getLocation(ItemStack item, ItemStack stack, boolean changeMeta)
- {
- String domain = "";
- String texture;
- IIcon itemIcon = item.getItem().getIcon(item, 0);
- String iconName = itemIcon.getIconName();
- if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim();
- else domain = "minecraft";
- texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png";
- ResourceLocation textureLocation = null;
- TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
- if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture);
- else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture);
- return textureLocation;
- }
@SideOnly(Side.CLIENT)
public static int getMostCommonColour(Map map) {
@@ -209,10 +215,8 @@ public class JewelrycraftUtil {
/**
* Adds curse points to a player
*
- * @param player
- * the player to add the points to
- * @param points
- * amount of curse points
+ * @param player the player to add the points to
+ * @param points amount of curse points
*/
public static void addCursePoints(EntityPlayer player, int points) {
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
@@ -251,8 +255,7 @@ public class JewelrycraftUtil {
/**
* Adds a random amount of modifiers to a list
*
- * @param randValue
- * maximum number of modifiers
+ * @param randValue maximum number of modifiers
* @return a list containing the random modifiers
*/
public static ArrayList<ItemStack> addRandomModifiers(int randValue) {
@@ -293,8 +296,7 @@ public class JewelrycraftUtil {
/**
* Checks to see if the specified item is a gem
*
- * @param item
- * ItemStack containing the item
+ * @param item ItemStack containing the item
* @return is the item a gem
*/
public static boolean isGem(ItemStack item) {
@@ -309,8 +311,7 @@ public class JewelrycraftUtil {
/**
* Checks to see if the specified item is a metal
*
- * @param item
- * ItemStack containing the item
+ * @param item ItemStack containing the item
* @return is the item a metal
*/
public static boolean isMetal(ItemStack item) {
@@ -325,8 +326,7 @@ public class JewelrycraftUtil {
/**
* Checks to see if the specified item is a piece of jewelry
*
- * @param item
- * ItemStack containing the item
+ * @param item ItemStack containing the item
* @return is the item a piece of jewelry
*/
public static boolean isJewelry(ItemStack item) {
@@ -341,8 +341,7 @@ public class JewelrycraftUtil {
/**
* Checks to see if the specified item is an ore
*
- * @param item
- * ItemStack containing the item
+ * @param item ItemStack containing the item
* @return is the item an ore
*/
public static boolean isOre(ItemStack item) {
@@ -357,8 +356,7 @@ public class JewelrycraftUtil {
/**
* Gets the ingot from the ore
*
- * @param ore
- * the ore
+ * @param ore the ore
* @return the ingot
*/
public static ItemStack getIngotFromOre(ItemStack ore) {
@@ -366,4 +364,15 @@ public class JewelrycraftUtil {
if (ores.getItem().equals(ore.getItem()) && ores.getItemDamage() == ore.getItemDamage()) return oreToIngot.get(ores);
return null;
}
+
+ /**
+ * This determines whether the player unlocked an achievement or not.
+ *
+ * @param player The player to unlock the achievement
+ * @param achievement The achievement to be unlocked
+ * @return True or False depending if the player did unlock the achievement or not
+ */
+ public static boolean AchievemtUnlocked(EntityPlayer player, Achievement achievement) {
+ return ((EntityPlayerMP) player).func_147099_x().hasAchievementUnlocked(achievement);
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/util/Variables.java b/src/main/java/darkknight/jewelrycraft/util/Variables.java
index f30d968..bab281d 100644
--- a/src/main/java/darkknight/jewelrycraft/util/Variables.java
+++ b/src/main/java/darkknight/jewelrycraft/util/Variables.java
@@ -6,14 +6,14 @@ public class Variables
{
public static final String MODID = "jewelrycraft2";
public static final String MODNAME = "Jewelrycraft 2";
- public static final String VERSION = "1.0.12.3";
+ public static final String VERSION = "1.0.12.4";
public static final String PACKET_CHANNEL = "jewelrycraft2";
public static final String CONFIG_GUI = "darkknight.jewelrycraft.config.ConfigGuiFactory";
public static final String CLIENT_PROXY = "darkknight.jewelrycraft.proxy.ClientProxy";
public static final String SERVER_PROXY = "darkknight.jewelrycraft.proxy.CommonProxy";
- public static final int MAX_CURSES = 10;
+ public static final int MAX_CURSES = 1000;
public static final ResourceLocation PEDESTAL_TEXTURE = new ResourceLocation(Variables.MODID, "textures/tileentities/BricksPedestal.png");
public static final ResourceLocation SHADOW_HAND_TEXTURE = new ResourceLocation(Variables.MODID, "textures/tileentities/ShadowHand.png");
public static final ResourceLocation VILLAGER_TEXTURE = new ResourceLocation(Variables.MODID, "textures/entities/jeweler.png");
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
index 3a81cfb..a6c49e8 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
@@ -1,28 +1,24 @@
package darkknight.jewelrycraft.worldGen;
import java.util.Random;
-
+import cpw.mods.fml.common.IWorldGenerator;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
-import cpw.mods.fml.common.IWorldGenerator;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.config.ConfigHandler;
+import net.minecraftforge.event.terraingen.ChunkProviderEvent;
public class Generation implements IWorldGenerator {
- public static WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1();
- public static WorldGenStructure2 STRUCTURE_2 = new WorldGenStructure2();
- public static WorldGenStructure3 STRUCTURE_3 = new WorldGenStructure3();
- public static WorldGenStructure4 STRUCTURE_4 = new WorldGenStructure4();
- public static WorldGenStructure5 STRUCTURE_5 = new WorldGenStructure5();
+ public static WorldGenStructure STRUCTURE_1 = new WorldGenStructure1();
+ public static WorldGenStructure STRUCTURE_2 = new WorldGenStructure2();
+ public static WorldGenStructure STRUCTURE_3 = new WorldGenStructure3();
+ public static WorldGenStructure STRUCTURE_4 = new WorldGenStructure4();
+ public static WorldGenStructure STRUCTURE_5 = new WorldGenStructure5();
+ public static WorldGenStructure STRUCTURE_6 = new WorldGenStructure6();
- // public static WorldGenerator STRUCTURE_6 = new WorldGenStructure6();
- // public static WorldGenerator STRUCTURE_7 = new WorldGenStructure7();
- // public static WorldGenerator STRUCTURE_8 = new WorldGenStructure8();
- // public static WorldGenerator STRUCTURE_9 = new WorldGenStructure9();
- // public static WorldGenerator STRUCTURE_10 = new WorldGenStructure10();
- // public static WorldGenerator STRUCTURE_11 = new WorldGenStructure11();
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch (world.provider.dimensionId) {
@@ -38,23 +34,22 @@ public class Generation implements IWorldGenerator {
}
}
- private void generateEnd(World world, Random random, int i, int j) {
- }
+ private void generateEnd(World world, Random random, int i, int j) {}
private void generateSurface(World world, Random random, int i, int j) {
if (ConfigHandler.ENABLE_WORLD_GEN) {
- if(ConfigHandler.ORE_GEN) generateShadowOre(world, random, i, j);
- if(ConfigHandler.CRYSTAL_GEN) generateCrystals(world, random, i, j);
- if(ConfigHandler.STRUCTURE_1_GEN) generateStructure1(world, random, i, j);
- if(ConfigHandler.STRUCTURE_2_GEN) generateStructure2(world, random, i, j);
- if(ConfigHandler.STRUCTURE_3_GEN) generateStructure3(world, random, i, j);
- if(ConfigHandler.STRUCTURE_4_GEN) generateStructure4(world, random, i, j);
- if(ConfigHandler.STRUCTURE_5_GEN) generateStructure5(world, random, i, j);
+ if (ConfigHandler.ORE_GEN) generateShadowOre(world, random, i, j);
+ if (ConfigHandler.CRYSTAL_GEN) generateCrystals(world, random, i, j);
+ if (ConfigHandler.STRUCTURES[0]) generateStructureOverground(STRUCTURE_1, world, random, i, j, 1, false, true);
+ if (ConfigHandler.STRUCTURES[1]) generateStructureUnderground(STRUCTURE_2, world, random, i, j, 3, false, true);
+ if (ConfigHandler.STRUCTURES[2]) generateStructureUnderground(STRUCTURE_3, world, random, i, j, 3, false, true);
+ if (ConfigHandler.STRUCTURES[3]) generateStructureOverground(STRUCTURE_4, world, random, i, j, 5, false, true);
+ if (ConfigHandler.STRUCTURES[4]) generateStructureUnderground(STRUCTURE_5, world, random, i, j, 3, false, true);
+ if (ConfigHandler.STRUCTURES[5]) generateStructureOverground(STRUCTURE_6, world, random, i, j, 3, false, true);
}
}
- private void generateNether(World world, Random random, int i, int j) {
- }
+ private void generateNether(World world, Random random, int i, int j) {}
private void generateShadowOre(World world, Random random, int i, int j) {
for (int k = 0; k < 1; k++) {
@@ -81,51 +76,47 @@ public class Generation implements IWorldGenerator {
}
}
- private void generateStructure1(World world, Random random, int i, int j) {
- BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
- int x = i + random.nextInt(16);
- int y = random.nextInt(100);
- int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_1.generate(world, biomeBase, random, x, y, z);
- }
-
- private void generateStructure2(World world, Random random, int i, int j) {
+ private void generateStructureUnderground(WorldGenStructure structure, World world, Random random, int i, int j, int maxAttempts, boolean noOfAttempts, boolean chanceOfSpawning) {
BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
- if (random.nextInt(3) == 0) {
- int x = i + random.nextInt(16);
- int y = random.nextInt(100);
- int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_2.generate(world, biomeBase, random, x, y, z);
+ if (noOfAttempts) {
+ for (int k = 0; k < maxAttempts; k++) {
+ int x = i + random.nextInt(16);
+ int y = random.nextInt(64);
+ int z = j + random.nextInt(16);
+ if (world.getBlock(x, y, z) == Blocks.stone) structure.generate(world, biomeBase, random, x, y, z);
+ }
}
- }
-
- private void generateStructure3(World world, Random random, int i, int j) {
- BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
- if (random.nextInt(3) == 0) {
- int x = i + random.nextInt(16);
- int y = random.nextInt(100);
- int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_3.generate(world, biomeBase, random, x, y, z);
+ else if (chanceOfSpawning) {
+ if (random.nextInt(maxAttempts) == 0) {
+ int x = i + random.nextInt(16);
+ int y = random.nextInt(64);
+ int z = j + random.nextInt(16);
+ if (world.getBlock(x, y, z) == Blocks.stone) structure.generate(world, biomeBase, random, x, y, z);
+ }
}
}
- private void generateStructure4(World world, Random random, int i, int j) {
+ private void generateStructureOverground(WorldGenStructure structure, World world, Random random, int i, int j, int maxAttempts, boolean noOfAttempts, boolean chanceOfSpawning) {
BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
- if (random.nextInt(5) == 0) {
- int x = i + random.nextInt(16);
- int y = random.nextInt(100);
- int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_4.generate(world, biomeBase, random, x, y, z);
+ if (noOfAttempts) {
+ for (int k = 0; k < maxAttempts; k++) {
+ int x = i + random.nextInt(16);
+ int y = (world.getChunkHeightMapMinimum(i, j) > 0 ? world.getChunkHeightMapMinimum(i, j): world.getChunkFromChunkCoords(i, j).heightMapMinimum - 16) + random.nextInt(4);
+ int z = j + random.nextInt(16);
+ if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) structure.generate(world, biomeBase, random, x, y, z);
+ }
}
- }
-
- private void generateStructure5(World world, Random random, int i, int j) {
- BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
- if (random.nextInt(3) == 0) {
- int x = i + random.nextInt(16);
- int y = random.nextInt(100);
- int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_5.generate(world, biomeBase, random, x, y, z);
+ else if (chanceOfSpawning) {
+ if (random.nextInt(maxAttempts) == 0) {
+ int x = i + random.nextInt(16);
+ int y = (world.getChunkHeightMapMinimum(i, j) > 0 ? world.getChunkHeightMapMinimum(i, j): world.getChunkFromChunkCoords(i, j).heightMapMinimum - 16) + random.nextInt(4);
+ int z = j + random.nextInt(16);
+ if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone
+ || world.getBlock(x, y - 1, z) == Blocks.sand
+ || world.getBlock(x, y - 1, z) == Blocks.grass)){ structure.generate(world, biomeBase, random, x, y, z);
+ System.out.println(x + " " + z);
+ }
+ }
}
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java
new file mode 100644
index 0000000..c2c4046
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package darkknight.jewelrycraft.worldGen;
+
+import java.util.Random;
+import net.minecraft.world.World;
+import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraft.world.gen.feature.WorldGenerator;
+
+/**
+ * @author Sorin
+ */
+public class WorldGenStructure extends WorldGenerator
+{
+ public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean generate(World world, Random rand, int x, int y, int z) {
+ return false;
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java
index 5d9118f..c982e00 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java
@@ -20,7 +20,7 @@ import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal;
/**
* @author Sorin
*/
-public class WorldGenStructure1 extends WorldGenerator
+public class WorldGenStructure1 extends WorldGenStructure
{
public static final WeightedRandomItem[] items = new WeightedRandomItem[]{new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 10), new WeightedRandomItem(new ItemStack(Items.golden_apple), 8), new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1), new WeightedRandomItem(new ItemStack(ItemList.guide), 20), new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 25), new WeightedRandomItem(new ItemStack(BlockList.shadowEye), 2), new WeightedRandomItem(new ItemStack(Items.nether_star), 1), new WeightedRandomItem(new ItemStack(BlockList.shadowBlock), 2), new WeightedRandomItem(new ItemStack(BlockList.crystal), 16, 20)};
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java
deleted file mode 100644
index b838368..0000000
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package darkknight.jewelrycraft.worldGen;
-
-import java.util.Random;
-import net.minecraft.init.Blocks;
-import net.minecraft.tileentity.TileEntityMobSpawner;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
-
-/**
- * @author Sorin
- */
-public class WorldGenStructure10 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java
deleted file mode 100644
index cfe84fb..0000000
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package darkknight.jewelrycraft.worldGen;
-
-import java.util.Random;
-import net.minecraft.init.Blocks;
-import net.minecraft.tileentity.TileEntityMobSpawner;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
-
-/**
- * @author Sorin
- */
-public class WorldGenStructure11 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java
index fbed30c..c58c0b8 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java
@@ -1,26 +1,21 @@
package darkknight.jewelrycraft.worldGen;
-import java.io.IOException;
import java.util.Random;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.block.BlockMoltenMetal;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.item.ItemMoltenMetalBucket;
-import darkknight.jewelrycraft.network.PacketSendLiquidData;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
/**
* @author Sorin
*/
-public class WorldGenStructure2 extends WorldGenerator {
+public class WorldGenStructure2 extends WorldGenStructure {
public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) {
Block block = Blocks.stonebrick;
Block stair = Blocks.stone_brick_stairs;
@@ -47,9 +42,8 @@ public class WorldGenStructure2 extends WorldGenerator {
JewelryNBT.addMetal(stack, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size())));
if (stack != null && JewelryNBT.ingot(stack) != null) {
if (!world.isRemote) world.func_147480_a(x, y, z, true);
- JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage());
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage()));
world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3);
+ if(BlockMoltenMetal.getTileEntity(world, x, y, z) != null) BlockMoltenMetal.getTileEntity(world, x, y, z).setMetal(JewelryNBT.ingot(stack));
}
return true;
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java
index 7234aa9..1f6f15c 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java
@@ -15,7 +15,7 @@ import net.minecraftforge.common.DungeonHooks;
/**
* @author Sorin
*/
-public class WorldGenStructure3 extends WorldGenerator
+public class WorldGenStructure3 extends WorldGenStructure
{
public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
{
@@ -49,7 +49,7 @@ public class WorldGenStructure3 extends WorldGenerator
if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) slabMeta = 1;
for(int i = -1; i <= 1; i++)
for(int k = -1; k <= 1; k++)
- world.setBlock(x + i, y + 2, z + k, slab, slabMeta, 1);
+ world.setBlock(x + i, y + 2, z + k, slab, slabMeta, 2);
world.setBlock(x, y, z, Blocks.mob_spawner);
world.setBlock(x, y + 1, z, Blocks.mob_spawner);
for(int l = 0; l < 2; l++){
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java
index 4171438..6af8dc2 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java
@@ -14,7 +14,7 @@ import darkknight.jewelrycraft.block.BlockList;
/**
* @author Sorin
*/
-public class WorldGenStructure4 extends WorldGenerator
+public class WorldGenStructure4 extends WorldGenStructure
{
public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
{
@@ -34,7 +34,7 @@ public class WorldGenStructure4 extends WorldGenerator
world.setBlock(x + i, y + j, z + k, Blocks.air);
for(int i = -1; i <= 1; i++)
for(int k = -1; k <= 1; k++)
- world.setBlock(x + i, y, z + k, Blocks.stone_slab, slabMeta, 1);
+ world.setBlock(x + i, y, z + k, Blocks.stone_slab, slabMeta, 2);
world.setBlock(x, y, z, block, metadata, 2);
world.setBlock(x, y, z - 1, stair, 3, 1);
world.setBlock(x, y, z + 1, stair, 2, 1);
@@ -49,7 +49,7 @@ public class WorldGenStructure4 extends WorldGenerator
if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) slabMeta = 1;
for(int i = -1; i <= 1; i++)
for(int k = -1; k <= 1; k++)
- if (i == 0 || k == 0) world.setBlock(x + i, y + 2, z + k, Blocks.stone_slab, slabMeta, 1);
+ if (i == 0 || k == 0) world.setBlock(x + i, y + 2, z + k, Blocks.stone_slab, slabMeta, 2);
world.setBlock(x, y + 2, z, block, metadata, 2);
world.setBlock(x, y + 3, z, BlockList.crystal);
return true;
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java
index 77ce6c1..7ede3ef 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java
@@ -3,34 +3,22 @@
*/
package darkknight.jewelrycraft.worldGen;
-import java.io.IOException;
import java.util.Random;
-
-import cpw.mods.fml.relauncher.Side;
-import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.block.BlockMoltenMetal;
import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.item.ItemMoltenMetalBucket;
-import darkknight.jewelrycraft.network.PacketRequestLiquidData;
-import darkknight.jewelrycraft.network.PacketSendLiquidData;
import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
/**
* @author Sorin
*/
-public class WorldGenStructure5 extends WorldGenerator {
+public class WorldGenStructure5 extends WorldGenStructure {
public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) {
Block slab = Blocks.stone_slab;
Block stair = Blocks.stone_brick_stairs;
@@ -51,13 +39,13 @@ public class WorldGenStructure5 extends WorldGenerator {
world.setBlock(x + i, y, z + k, Blocks.air);
for (int i = -2; i <= 2; i++)
for (int k = -3; k <= -1; k++)
- world.setBlock(x + i, y, z + k, block, metadata, 1);
+ world.setBlock(x + i, y, z + k, block, metadata, 2);
for (int i = 1; i <= 2; i++)
for (int k = -3; k <= -1; k++)
- world.setBlock(x + i, y + 1, z + k, block, metadata, 1);
+ world.setBlock(x + i, y + 1, z + k, block, metadata, 2);
for (int i = -5; i <= -3; i++)
for (int k = -3; k <= 2; k++)
- world.setBlock(x + i, y - 1, z + k, block, metadata, 1);
+ world.setBlock(x + i, y - 1, z + k, block, metadata, 2);
for (int i = -5; i <= -3; i++)
for (int k = -3; k <= 2; k++)
if ((i != -4 || k <= -3 || k >= 2) && !(i == -3 && k == -2)) world.setBlock(x + i, y, z + k, slab, slabMeta, 2);
@@ -72,17 +60,16 @@ public class WorldGenStructure5 extends WorldGenerator {
world.setBlock(x + 1, y + 2, z - 3, slab, slabMeta, 2);
world.setBlock(x + 1, y + 2, z - 1, slab, slabMeta, 2);
for (int k = -3; k <= -1; k++)
- world.setBlock(x + 2, y + 2, z + k, block, metadata, 1);
+ world.setBlock(x + 2, y + 2, z + k, block, metadata, 2);
if (rand.nextInt(5) == 0) {
ItemStack stack = new ItemStack(ItemList.bucket);
JewelryNBT.addMetal(stack, new ItemStack(Items.gold_ingot));
if (stack != null && JewelryNBT.ingot(stack) != null) {
if (!world.isRemote) world.func_147480_a(x, y, z, true);
- JewelrycraftMod.saveData.setString((x + 1) + " " + (y + 2) + " " + (z - 2) + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage());
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x + 1, y + 2, z - 2, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage()));
world.setBlock(x + 1, y + 2, z - 2, BlockList.moltenMetal, 0, 3);
+ if(BlockMoltenMetal.getTileEntity(world, x + 1, y + 2, z - 2) != null) BlockMoltenMetal.getTileEntity(world, x + 1, y + 2, z - 2).setMetal(JewelryNBT.ingot(stack));
}
- } else if (rand.nextBoolean()) world.setBlock(x + 1, y + 2, z - 2, Blocks.lava, 0, 3);
+ }
else world.setBlock(x + 1, y + 2, z - 2, Blocks.water, 0, 3);
return true;
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java
index 1755396..9df172d 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java
@@ -4,26 +4,91 @@
package darkknight.jewelrycraft.worldGen;
import java.util.Random;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.random.WeightedRandomItem;
+import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal;
+import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockSkull;
import net.minecraft.init.Blocks;
-import net.minecraft.tileentity.TileEntityMobSpawner;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntitySkull;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
/**
* @author Sorin
*/
-public class WorldGenStructure6 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- return true;
- }
+public class WorldGenStructure6 extends WorldGenStructure {
+ public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) {
+ int randBlock, randBlockMeta;
+ Block block;
+ for (int i = -2; i <= 1; i++)
+ for (int j = -1; j <= 1; j++)
+ for (int k = -2; k <= 1; k++)
+ world.setBlock(x + i, y + j, z + k, Blocks.air);
+ for (int i = -2; i <= 1; i++)
+ for (int k = -2; k <= 1; k++) {
+ randBlock = rand.nextInt(4);
+ switch (randBlock) {
+ case 0:
+ block = Blocks.cobblestone;
+ randBlockMeta = 0;
+ break;
+ case 1:
+ block = Blocks.stonebrick;
+ randBlockMeta = 2;
+ break;
+ case 2:
+ block = Blocks.stonebrick;
+ randBlockMeta = 0;
+ break;
+ default:
+ block = Blocks.cobblestone;
+ randBlockMeta = 0;
+ break;
+ }
+ world.setBlock(x + i, y - 1, z + k, block, randBlockMeta, 2);
+ }
+ int crystalCol = rand.nextInt(15);
+ world.setBlock(x - 2, y, z - 2, BlockList.crystal, 0, 2);
+ world.setBlock(x - 2, y, z + 1, BlockList.crystal, 1 + crystalCol, 2);
+ world.setBlock(x + 1, y, z - 2, BlockList.crystal, 1 + crystalCol, 2);
+ world.setBlock(x + 1, y, z + 1, BlockList.crystal, 0, 2);
+ world.setBlock(x - 1, y, z - 1, Blocks.skull, 1, 2);
+ TileEntity tileentity = world.getTileEntity(x - 1, y, z - 1);
+ if (tileentity != null && tileentity instanceof TileEntitySkull) {
+ ((TileEntitySkull) tileentity).func_152107_a(rand.nextInt(50) == 0 ? 1 : 0);
+ ((TileEntitySkull) tileentity).func_145903_a(MathHelper.floor_double((double) (rand.nextInt(361) * 16.0F / 360.0F) + 0.5D) & 15);
+ ((BlockSkull) Blocks.skull).func_149965_a(world, x - 1, y, z - 1, (TileEntitySkull) tileentity);
+ }
+ world.setBlock(x + 1, y, z - 1, BlockList.jewelCraftingTable, 3, 2);
+ TileEntity jewelersTable = world.getTileEntity(x + 1, y, z - 1);
+ Item[] jewelry = new Item[] { ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings };
+ if (jewelersTable != null && jewelersTable instanceof TileEntityJewelrsCraftingTable) {
+ if (rand.nextBoolean()) ((TileEntityJewelrsCraftingTable) jewelersTable).setGemItemStack(JewelrycraftUtil.gem.get(rand.nextInt(JewelrycraftUtil.gem.size())));
+ else if (rand.nextBoolean()) {
+ ItemStack result = new ItemStack(jewelry[rand.nextInt(4)], 1, 0);
+ if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(result, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size())));
+ ((TileEntityJewelrsCraftingTable) jewelersTable).setJewelryItemStack(result);
+ }
+ }
+ world.setBlock(x - 1, y, z + 1, BlockList.handPedestal, 0, 2);
+ TileEntity pedestal = world.getTileEntity(x - 1, y, z + 1);
+ if (pedestal != null && pedestal instanceof TileEntityHandPedestal) ((TileEntityHandPedestal) pedestal).setHeldItemStack(((WeightedRandomItem) WeightedRandom.getRandomItem(rand, WorldGenStructure1.items)).getItem(rand));
+ world.setBlock(x - 1, y + 1, z + 1, BlockList.shadowEye, 0, 2);
+ return true;
+ }
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
+ @Override
+ public boolean generate(World world, Random rand, int x, int y, int z) {
+ return generate(world, BiomeGenBase.plains, rand, x, y, z);
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java
deleted file mode 100644
index 964e8e6..0000000
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package darkknight.jewelrycraft.worldGen;
-
-import java.util.Random;
-import net.minecraft.init.Blocks;
-import net.minecraft.tileentity.TileEntityMobSpawner;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
-
-/**
- * @author Sorin
- */
-public class WorldGenStructure7 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java
deleted file mode 100644
index 868b623..0000000
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package darkknight.jewelrycraft.worldGen;
-
-import java.util.Random;
-import net.minecraft.init.Blocks;
-import net.minecraft.tileentity.TileEntityMobSpawner;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
-
-/**
- * @author Sorin
- */
-public class WorldGenStructure8 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java
deleted file mode 100644
index e349ac6..0000000
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package darkknight.jewelrycraft.worldGen;
-
-import java.util.Random;
-import net.minecraft.init.Blocks;
-import net.minecraft.tileentity.TileEntityMobSpawner;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.DungeonHooks;
-
-/**
- * @author Sorin
- */
-public class WorldGenStructure9 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
-}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
index dfcdaba..bc676b7 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
@@ -1,456 +1,446 @@
-package darkknight.jewelrycraft.worldGen.village;
-
-import java.util.List;
-import java.util.Random;
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntityChest;
-import net.minecraft.tileentity.TileEntityFurnace;
-import net.minecraft.util.StatCollector;
-import net.minecraft.world.World;
-import net.minecraft.world.gen.structure.StructureBoundingBox;
-import net.minecraft.world.gen.structure.StructureComponent;
-import net.minecraft.world.gen.structure.StructureVillagePieces;
-import net.minecraft.world.gen.structure.StructureVillagePieces.Start;
-import darkknight.jewelrycraft.block.BlockList;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.item.ItemList;
-import darkknight.jewelrycraft.item.ItemMolds;
-import darkknight.jewelrycraft.tileentity.TileEntityDisplayer;
-import darkknight.jewelrycraft.tileentity.TileEntityMolder;
-import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.Variables;
-
-public class ComponentJewelry extends StructureVillagePieces.House1
-{
- private int averageGroundLevel = -1;
-
- /**
- *
- */
- public ComponentJewelry()
- {}
-
- /**
- * @param par1ComponentVillageStartPiece
- * @param par2
- * @param par3Random
- * @param par4StructureBoundingBox
- * @param par5
- */
- public ComponentJewelry(Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5)
- {
- super();
- coordBaseMode = par5;
- boundingBox = par4StructureBoundingBox;
- }
-
- /**
- * @param villagePiece
- * @param pieces
- * @param random
- * @param p1
- * @param p2
- * @param p3
- * @param p4
- * @param p5
- * @return
- */
- @SuppressWarnings ("rawtypes")
- public static ComponentJewelry buildComponent(Start villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5)
- {
- StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 11, 5, 12, p4);
- return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentJewelry(villagePiece, p5, random, structureboundingbox, p4) : null;
- }
-
- /**
- * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at the end, it adds Fences...
- *
- * @param world
- * @param random
- * @param sbb
- * @return
- */
- @Override
- public boolean addComponentParts(World world, Random random, StructureBoundingBox sbb)
- {
- if (averageGroundLevel < 0){
- averageGroundLevel = getAverageGroundLevel(world, sbb);
- if (averageGroundLevel < 0) return true;
- boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 3, 0);
- }
- /**
- * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int placeBlockId, int replaceBlockId, boolean alwaysreplace)
- */
- fillWithBlocks(world, sbb, 0, 0, 6, 10, 5, 11, Block.getBlockById(0), Block.getBlockById(0), false);
- fillWithBlocks(world, sbb, 2, 0, 0, 8, 5, 5, Block.getBlockById(0), Block.getBlockById(0), false);
- // Pillars
- fillWithBlocks(world, sbb, 2, 0, 0, 2, 3, 0, Blocks.log, Blocks.log, false);
- fillWithBlocks(world, sbb, 2, 0, 3, 2, 3, 3, Blocks.log, Blocks.log, false);
- fillWithBlocks(world, sbb, 8, 0, 0, 8, 3, 0, Blocks.log, Blocks.log, false);
- fillWithBlocks(world, sbb, 8, 0, 3, 8, 3, 3, Blocks.log, Blocks.log, false);
- // Walls
- fillWithBlocks(world, sbb, 2, 0, 1, 2, 3, 2, Blocks.planks, Blocks.planks, false);
- fillWithBlocks(world, sbb, 2, 0, 4, 2, 3, 5, Blocks.planks, Blocks.planks, false);
- fillWithBlocks(world, sbb, 8, 0, 1, 8, 3, 2, Blocks.planks, Blocks.planks, false);
- fillWithBlocks(world, sbb, 8, 0, 4, 8, 3, 5, Blocks.planks, Blocks.planks, false);
- fillWithBlocks(world, sbb, 3, 0, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false);
- fillWithBlocks(world, sbb, 0, 0, 6, 10, 3, 6, Blocks.cobblestone, Blocks.cobblestone, false);
- fillWithBlocks(world, sbb, 0, 0, 11, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false);
- fillWithBlocks(world, sbb, 0, 0, 6, 0, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false);
- fillWithBlocks(world, sbb, 10, 0, 6, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false);
- // Roof
- for(int i = 3; i <= 7; i++)
- for(int j = 1; j <= 5; j++)
- placeBlockAtCurrentPosition(world, Blocks.wooden_slab, 2, i, 4, j, sbb);
- for(int i = 3; i <= 7; i++)
- for(int j = 6; j <= 6; j++)
- placeBlockAtCurrentPosition(world, Blocks.stone_slab, 0, i, 4, j, sbb);
- for(int i = 1; i <= 9; i++)
- for(int j = 7; j <= 10; j++)
- placeBlockAtCurrentPosition(world, Blocks.stone_slab, 3, i, 4, j, sbb);
- for(int i = 2; i <= 8; i++)
- placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, i, 4, 0, sbb);
- for(int i = 1; i <= 5; i++){
- placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 2, 4, i, sbb);
- placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 8, 4, i, sbb);
- }
- for(int i = 0; i <= 2; i++){
- placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 6, sbb);
- placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i + 8, 4, 6, sbb);
- }
- for(int i = 7; i <= 11; i++){
- placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 0, 4, i, sbb);
- placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 10, 4, i, sbb);
- }
- for(int i = 0; i <= 10; i++)
- placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 11, sbb);
- // Base
- for(int i = 2; i <= 8; i++)
- for(int j = 0; j <= 5; j++)
- placeBlockAtCurrentPosition(world, Blocks.planks, 1, i, 0, j, sbb);
- fillWithBlocks(world, sbb, 0, 0, 6, 10, 0, 11, Blocks.stonebrick, Blocks.stonebrick, false);
- for(int i = 6; i <= 10; i++)
- placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 5, 0, i, sbb);
- for(int i = 7; i <= 10; i++){
- placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 1, 0, i, sbb);
- placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 9, 0, i, sbb);
- }
- // Decorations
- placeDoorAtCurrentPosition(world, sbb, random, 6, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1));
- placeDoorAtCurrentPosition(world, sbb, random, 5, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1));
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 0, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 0, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 1, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 2, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 4, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 1, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 4, sbb);
- placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 5, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 3, 3, 3, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 7, 3, 3, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 5, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 7, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 10, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 8, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 9, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 8, sbb);
- placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 9, sbb);
- int bgCarpetColor = random.nextInt(16);
- for(int i = 4; i <= 7; i++)
- for(int j = 1; j <= 5; j++)
- placeBlockAtCurrentPosition(world, Blocks.carpet, bgCarpetColor, i, 1, j, sbb);
- generateChest(world, 3, 1, 1, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX);
- generateDisplayer(world, 3, 1, 2, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb);
- placeBlockAtCurrentPosition(world, BlockList.jewelCraftingTable, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, 3, 1, 3, sbb);
- generateDisplayer(world, 3, 1, 4, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb);
- generateChest(world, 3, 1, 5, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX);
- generateFurnace(world, 1, 1, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
- generateFurnace(world, 1, 2, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
- generateFurnace(world, 1, 3, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
- generateFurnace(world, 1, 1, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
- generateFurnace(world, 1, 2, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
- generateFurnace(world, 1, 3, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
- generateSmelter(world, 1, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean());
- generateSmelter(world, 1, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean());
- generateMolder(world, 2, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean());
- generateMolder(world, 2, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean());
- if (random.nextBoolean()) generateIngotChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- else generateOresChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- if (random.nextBoolean()) generateIngotChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- else generateOresChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- if (random.nextBoolean()) generateIngotChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- else generateOresChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- if (random.nextBoolean()) generateIngotChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- else generateOresChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
- for(int l = 0; l < 6; ++l)
- for(int i1 = 2; i1 < 9; ++i1){
- clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb);
- func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb);
- }
- for(int l = 6; l < 12; ++l)
- for(int i1 = 0; i1 < 11; ++i1){
- clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb);
- func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb);
- }
- spawnVillagers(world, sbb, 3, 1, 3, 1);
- return true;
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- * @param min
- * @param max
- */
- public void generateChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- int t = random.nextInt(max - min + 1) + min;
- placeBlockAtCurrentPosition(world, Blocks.chest, metadata, i, j, k, sbb);
- TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1);
- while (chest != null && t > 0 && JewelrycraftUtil.gem.size() > 0){
- ItemStack jewels = JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()));
- chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".jewelerchest"));
- if (jewels.getItem() == Items.nether_star && ConfigHandler.GENERATE_VILLAGE_NETHERSTAR) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels);
- else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels);
- t--;
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- * @param min
- * @param max
- * @param chestB
- * @param randomAmount
- */
- public void generateIngotChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- int t = random.nextInt(max - min + 1) + min;
- placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb);
- TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1);
- while (chest != null && t > 0 && JewelrycraftUtil.metal.size() > 0){
- chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".ingotchest"));
- int metalID = random.nextInt(JewelrycraftUtil.metal.size());
- ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy();
- metal.stackSize = 2 + random.nextInt(randomAmount);
- if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), metal);
- t--;
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- * @param min
- * @param max
- * @param chestB
- * @param randomAmount
- */
- public void generateOresChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- int t = random.nextInt(max - min + 1) + min;
- placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb);
- TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1);
- while (chest != null && t > 0 && JewelrycraftUtil.ores.size() > 0){
- chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".orechest"));
- int oreID = random.nextInt(JewelrycraftUtil.ores.size());
- ItemStack ores = JewelrycraftUtil.ores.get(oreID).copy();
- ores.stackSize = 2 + random.nextInt(randomAmount);
- if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), ores);
- t--;
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- */
- public void generateDisplayer(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- placeBlockAtCurrentPosition(world, BlockList.displayer, metadata, i, j, k, sbb);
- TileEntityDisplayer displayer = (TileEntityDisplayer)world.getTileEntity(i1, j1, k1);
- if (displayer != null){
- Item[] jewels = {ItemList.ring, ItemList.necklace};
- ItemStack jewel = new ItemStack(jewels[random.nextInt(jewels.length)]);
- if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(jewel, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())));
- if (JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(jewel, JewelrycraftUtil.addRandomModifiers(random.nextInt(4)));
- if (JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(jewel, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())));
- displayer.object = jewel;
- displayer.quantity = 1;
- displayer.hasObject = true;
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- * @param isEmpty
- */
- public void generateSmelter(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean isEmpty)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- placeBlockAtCurrentPosition(world, BlockList.smelter, metadata, i, j, k, sbb);
- TileEntitySmelter smelter = (TileEntitySmelter)world.getTileEntity(i1, j1, k1);
- if (smelter != null && !isEmpty && JewelrycraftUtil.metal.size() > 0){
- int metal = random.nextInt(JewelrycraftUtil.metal.size());
- smelter.moltenMetal = JewelrycraftUtil.metal.get(metal).copy();
- smelter.hasMoltenMetal = true;
- int quantity = random.nextInt(9);
- switch(quantity)
- {
- case 0:
- smelter.quantity = 0.1f;
- case 1:
- smelter.quantity = 0.2f;
- case 2:
- smelter.quantity = 0.3f;
- case 3:
- smelter.quantity = 0.4f;
- case 4:
- smelter.quantity = 0.5f;
- case 5:
- smelter.quantity = 0.6f;
- case 6:
- smelter.quantity = 0.7f;
- case 7:
- smelter.quantity = 0.8f;
- case 8:
- smelter.quantity = 0.9f;
- default:
- smelter.quantity = 0.1f;
- }
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- * @param hasMold
- * @param hasStuff
- */
- public void generateMolder(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean hasMold, boolean hasStuff)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- placeBlockAtCurrentPosition(world, BlockList.molder, metadata, i, j, k, sbb);
- TileEntityMolder molder = (TileEntityMolder)world.getTileEntity(i1, j1, k1);
- if (molder != null && !molder.hasMold) if (hasMold){
- int meta = random.nextInt(ItemMolds.moldsItemNames.length);
- molder.mold = new ItemStack(ItemList.molds, 1, meta);
- molder.hasMold = true;
- if (hasStuff && JewelrycraftUtil.metal.size() > 0){
- ItemStack ring = new ItemStack(ItemList.ring);
- JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
- ItemStack necklace = new ItemStack(ItemList.necklace);
- JewelryNBT.addMetal(necklace, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
- ItemStack bracelet = new ItemStack(ItemList.bracelet);
- JewelryNBT.addMetal(bracelet, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
- ItemStack earrings = new ItemStack(ItemList.earrings);
- JewelryNBT.addMetal(earrings, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
- if (meta == 0) molder.jewelBase = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
- else if (meta == 1) molder.jewelBase = ring;
- else if (meta == 2) molder.jewelBase = necklace;
- else if (meta == 3) molder.jewelBase = bracelet;
- else if (meta == 4) molder.jewelBase = earrings;
- molder.hasJewelBase = true;
- }
- }
- }
-
- /**
- * @param world
- * @param i
- * @param j
- * @param k
- * @param metadata
- * @param random
- * @param sbb
- * @param min
- * @param max
- * @param hasMetal
- */
- public void generateFurnace(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, boolean hasMetal)
- {
- int i1 = getXWithOffset(i, k);
- int j1 = getYWithOffset(j);
- int k1 = getZWithOffset(i, k);
- placeBlockAtCurrentPosition(world, Blocks.furnace, metadata, i, j, k, sbb);
- TileEntityFurnace furnace = (TileEntityFurnace)world.getTileEntity(i1, j1, k1);
- if (furnace != null){
- if (random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Items.coal, 1 + random.nextInt(16)));
- if (hasMetal && JewelrycraftUtil.metal.size() > 0){
- int metalID = random.nextInt(JewelrycraftUtil.metal.size());
- ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy();
- metal.stackSize = random.nextInt(max - min + 1) + min;
- furnace.setInventorySlotContents(2, metal);
- }
- }
- }
-
- /**
- * Returns the villager type to spawn in this component, based on the number of villagers already spawned.
- *
- * @param par1
- * @return
- */
- @Override
- protected int getVillagerType(int par1)
- {
- return 3000;
- }
+package darkknight.jewelrycraft.worldGen.village;
+
+import java.util.List;
+import java.util.Random;
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntityChest;
+import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraft.world.gen.structure.StructureBoundingBox;
+import net.minecraft.world.gen.structure.StructureComponent;
+import net.minecraft.world.gen.structure.StructureVillagePieces;
+import net.minecraft.world.gen.structure.StructureVillagePieces.Start;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.item.ItemMolds;
+import darkknight.jewelrycraft.tileentity.TileEntityDisplayer;
+import darkknight.jewelrycraft.tileentity.TileEntityMolder;
+import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.Variables;
+
+public class ComponentJewelry extends StructureVillagePieces.House1 {
+ private int averageGroundLevel = -1;
+
+ /**
+ *
+ */
+ public ComponentJewelry() {
+ }
+
+ /**
+ * @param par1ComponentVillageStartPiece
+ * @param par2
+ * @param par3Random
+ * @param par4StructureBoundingBox
+ * @param par5
+ */
+ public ComponentJewelry(Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) {
+ super();
+ coordBaseMode = par5;
+ boundingBox = par4StructureBoundingBox;
+ }
+
+ /**
+ * @param villagePiece
+ * @param pieces
+ * @param random
+ * @param p1
+ * @param p2
+ * @param p3
+ * @param p4
+ * @param p5
+ * @return
+ */
+ @SuppressWarnings("rawtypes")
+ public static ComponentJewelry buildComponent(Start villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) {
+ StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 11, 5, 12, p4);
+ return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentJewelry(villagePiece, p5, random, structureboundingbox, p4) : null;
+ }
+
+ /**
+ * second Part of Structure generating, this for example places Spiderwebs,
+ * Mob Spawners, it closes Mineshafts at the end, it adds Fences...
+ *
+ * @param world
+ * @param random
+ * @param sbb
+ * @return
+ */
+ @Override
+ public boolean addComponentParts(World world, Random random, StructureBoundingBox sbb) {
+ if (averageGroundLevel < 0) {
+ averageGroundLevel = getAverageGroundLevel(world, sbb);
+ if (averageGroundLevel < 0) return true;
+ boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 3, 0);
+ }
+ /**
+ * arguments: (World worldObj, StructureBoundingBox structBB, int minX,
+ * int minY, int minZ, int maxX, int maxY, int maxZ, int placeBlockId,
+ * int replaceBlockId, boolean alwaysreplace)
+ */
+ fillWithBlocks(world, sbb, 0, 0, 6, 10, 5, 11, Block.getBlockById(0), Block.getBlockById(0), false);
+ fillWithBlocks(world, sbb, 2, 0, 0, 8, 5, 5, Block.getBlockById(0), Block.getBlockById(0), false);
+ // Pillars
+ fillWithBlocks(world, sbb, 2, 0, 0, 2, 3, 0, Blocks.log, Blocks.log, false);
+ fillWithBlocks(world, sbb, 2, 0, 3, 2, 3, 3, Blocks.log, Blocks.log, false);
+ fillWithBlocks(world, sbb, 8, 0, 0, 8, 3, 0, Blocks.log, Blocks.log, false);
+ fillWithBlocks(world, sbb, 8, 0, 3, 8, 3, 3, Blocks.log, Blocks.log, false);
+ // Walls
+ fillWithBlocks(world, sbb, 2, 0, 1, 2, 3, 2, Blocks.planks, Blocks.planks, false);
+ fillWithBlocks(world, sbb, 2, 0, 4, 2, 3, 5, Blocks.planks, Blocks.planks, false);
+ fillWithBlocks(world, sbb, 8, 0, 1, 8, 3, 2, Blocks.planks, Blocks.planks, false);
+ fillWithBlocks(world, sbb, 8, 0, 4, 8, 3, 5, Blocks.planks, Blocks.planks, false);
+ fillWithBlocks(world, sbb, 3, 0, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false);
+ fillWithBlocks(world, sbb, 0, 0, 6, 10, 3, 6, Blocks.cobblestone, Blocks.cobblestone, false);
+ fillWithBlocks(world, sbb, 0, 0, 11, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false);
+ fillWithBlocks(world, sbb, 0, 0, 6, 0, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false);
+ fillWithBlocks(world, sbb, 10, 0, 6, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false);
+ // Roof
+ for (int i = 3; i <= 7; i++)
+ for (int j = 1; j <= 5; j++)
+ placeBlockAtCurrentPosition(world, Blocks.wooden_slab, 2, i, 4, j, sbb);
+ for (int i = 3; i <= 7; i++)
+ for (int j = 6; j <= 6; j++)
+ placeBlockAtCurrentPosition(world, Blocks.stone_slab, 0, i, 4, j, sbb);
+ for (int i = 1; i <= 9; i++)
+ for (int j = 7; j <= 10; j++)
+ placeBlockAtCurrentPosition(world, Blocks.stone_slab, 3, i, 4, j, sbb);
+ for (int i = 2; i <= 8; i++)
+ placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, i, 4, 0, sbb);
+ for (int i = 1; i <= 5; i++) {
+ placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 2, 4, i, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 8, 4, i, sbb);
+ }
+ for (int i = 0; i <= 2; i++) {
+ placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 6, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i + 8, 4, 6, sbb);
+ }
+ for (int i = 7; i <= 11; i++) {
+ placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 0, 4, i, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 10, 4, i, sbb);
+ }
+ for (int i = 0; i <= 10; i++)
+ placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 11, sbb);
+ // Base
+ for (int i = 2; i <= 8; i++)
+ for (int j = 0; j <= 5; j++)
+ placeBlockAtCurrentPosition(world, Blocks.planks, 1, i, 0, j, sbb);
+ fillWithBlocks(world, sbb, 0, 0, 6, 10, 0, 11, Blocks.stonebrick, Blocks.stonebrick, false);
+ for (int i = 6; i <= 10; i++)
+ placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 5, 0, i, sbb);
+ for (int i = 7; i <= 10; i++) {
+ placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 1, 0, i, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 9, 0, i, sbb);
+ }
+ // Decorations
+ placeDoorAtCurrentPosition(world, sbb, random, 6, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1));
+ placeDoorAtCurrentPosition(world, sbb, random, 5, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1));
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 0, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 0, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 1, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 2, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 4, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 1, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 4, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 5, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 3, 3, 3, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 7, 3, 3, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 5, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 7, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 10, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 8, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 9, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 8, sbb);
+ placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 9, sbb);
+ int bgCarpetColor = random.nextInt(16);
+ for (int i = 4; i <= 7; i++)
+ for (int j = 1; j <= 5; j++)
+ placeBlockAtCurrentPosition(world, Blocks.carpet, bgCarpetColor, i, 1, j, sbb);
+ generateChest(world, 3, 1, 1, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX);
+ generateDisplayer(world, 3, 1, 2, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb);
+ placeBlockAtCurrentPosition(world, BlockList.jewelCraftingTable, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, 3, 1, 3, sbb);
+ generateDisplayer(world, 3, 1, 4, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb);
+ generateChest(world, 3, 1, 5, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX);
+ generateFurnace(world, 1, 1, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
+ generateFurnace(world, 1, 2, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
+ generateFurnace(world, 1, 3, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
+ generateFurnace(world, 1, 1, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
+ generateFurnace(world, 1, 2, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
+ generateFurnace(world, 1, 3, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS);
+ generateSmelter(world, 1, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean());
+ generateSmelter(world, 1, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean());
+ generateMolder(world, 2, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean());
+ generateMolder(world, 2, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean());
+ if (random.nextBoolean()) generateIngotChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ else generateOresChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ if (random.nextBoolean()) generateIngotChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ else generateOresChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ if (random.nextBoolean()) generateIngotChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ else generateOresChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ if (random.nextBoolean()) generateIngotChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ else generateOresChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK);
+ for (int l = 0; l < 6; ++l)
+ for (int i1 = 2; i1 < 9; ++i1) {
+ clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb);
+ func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb);
+ }
+ for (int l = 6; l < 12; ++l)
+ for (int i1 = 0; i1 < 11; ++i1) {
+ clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb);
+ func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb);
+ }
+ spawnVillagers(world, sbb, 3, 1, 3, 1);
+ return true;
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ * @param min
+ * @param max
+ */
+ public void generateChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ if (max >= min) {
+ int t = random.nextInt(max - min + 1) + min;
+ placeBlockAtCurrentPosition(world, Blocks.chest, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntityChest chest = (TileEntityChest) world.getTileEntity(i1, j1, k1);
+ while (chest != null && t > 0 && JewelrycraftUtil.gem.size() > 0) {
+ ItemStack jewels = JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()));
+ chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".jewelerchest"));
+ if (jewels.getItem() == Items.nether_star && ConfigHandler.GENERATE_VILLAGE_NETHERSTAR) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels);
+ else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels);
+ t--;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ * @param min
+ * @param max
+ * @param chestB
+ * @param randomAmount
+ */
+ public void generateIngotChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ if (max >= min) {
+ int t = random.nextInt(max - min + 1) + min;
+ placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntityChest chest = (TileEntityChest) world.getTileEntity(i1, j1, k1);
+ while (chest != null && t > 0 && JewelrycraftUtil.metal.size() > 0) {
+ chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".ingotchest"));
+ int metalID = random.nextInt(JewelrycraftUtil.metal.size());
+ ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy();
+ metal.stackSize = 2 + random.nextInt(randomAmount);
+ if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), metal);
+ t--;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ * @param min
+ * @param max
+ * @param chestB
+ * @param randomAmount
+ */
+ public void generateOresChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ if (max >= min) {
+ int t = random.nextInt(max - min + 1) + min;
+ placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntityChest chest = (TileEntityChest) world.getTileEntity(i1, j1, k1);
+ while (chest != null && t > 0 && JewelrycraftUtil.ores.size() > 0) {
+ chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".orechest"));
+ int oreID = random.nextInt(JewelrycraftUtil.ores.size());
+ ItemStack ores = JewelrycraftUtil.ores.get(oreID).copy();
+ ores.stackSize = 2 + random.nextInt(randomAmount);
+ if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), ores);
+ t--;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ */
+ public void generateDisplayer(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, BlockList.displayer, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntityDisplayer displayer = (TileEntityDisplayer) world.getTileEntity(i1, j1, k1);
+ if (displayer != null) {
+ Item[] jewels = { ItemList.ring, ItemList.necklace };
+ ItemStack jewel = new ItemStack(jewels[random.nextInt(jewels.length)]);
+ if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(jewel, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())));
+ if (JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(jewel, JewelrycraftUtil.addRandomModifiers(random.nextInt(4)));
+ if (JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(jewel, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())));
+ displayer.object = jewel;
+ displayer.quantity = 1;
+ displayer.hasObject = true;
+ }
+ }
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ * @param isEmpty
+ */
+ public void generateSmelter(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean isEmpty) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, BlockList.smelter, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntitySmelter smelter = (TileEntitySmelter) world.getTileEntity(i1, j1, k1);
+ if (smelter != null && !isEmpty && JewelrycraftUtil.metal.size() > 0) {
+ int metal = random.nextInt(JewelrycraftUtil.metal.size());
+ smelter.moltenMetal = JewelrycraftUtil.metal.get(metal).copy();
+ smelter.hasMoltenMetal = random.nextBoolean();
+ float quantity = random.nextFloat();
+ if (smelter.hasMoltenMetal) smelter.quantity = quantity < 0.9F ? 0.1F + Math.round(quantity * 10) / 10 : Math.round(quantity * 10) / 10;
+ }
+ }
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ * @param hasMold
+ * @param hasStuff
+ */
+ public void generateMolder(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean hasMold, boolean hasStuff) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, BlockList.molder, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntityMolder molder = (TileEntityMolder) world.getTileEntity(i1, j1, k1);
+ if (molder != null && !molder.hasMold) if (hasMold) {
+ int meta = random.nextInt(ItemMolds.moldsItemNames.length);
+ molder.mold = new ItemStack(ItemList.molds, 1, meta);
+ molder.hasMold = true;
+ if (hasStuff && JewelrycraftUtil.metal.size() > 0) {
+ ItemStack ring = new ItemStack(ItemList.ring);
+ JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
+ ItemStack necklace = new ItemStack(ItemList.necklace);
+ JewelryNBT.addMetal(necklace, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
+ ItemStack bracelet = new ItemStack(ItemList.bracelet);
+ JewelryNBT.addMetal(bracelet, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
+ ItemStack earrings = new ItemStack(ItemList.earrings);
+ JewelryNBT.addMetal(earrings, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy());
+ if (meta == 0) molder.jewelBase = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+ else if (meta == 1) molder.jewelBase = ring;
+ else if (meta == 2) molder.jewelBase = necklace;
+ else if (meta == 3) molder.jewelBase = bracelet;
+ else if (meta == 4) molder.jewelBase = earrings;
+ molder.hasJewelBase = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param world
+ * @param i
+ * @param j
+ * @param k
+ * @param metadata
+ * @param random
+ * @param sbb
+ * @param min
+ * @param max
+ * @param hasMetal
+ */
+ public void generateFurnace(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, boolean hasMetal) {
+ int i1 = getXWithOffset(i, k);
+ int j1 = getYWithOffset(j);
+ int k1 = getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, Blocks.furnace, metadata, i, j, k, sbb);
+ if (world.getTileEntity(i1, j1, k1) != null) {
+ TileEntityFurnace furnace = (TileEntityFurnace) world.getTileEntity(i1, j1, k1);
+ if (furnace != null) {
+ if (random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Items.coal, 1 + random.nextInt(16)));
+ if (hasMetal && JewelrycraftUtil.metal.size() > 0) {
+ int metalID = random.nextInt(JewelrycraftUtil.metal.size());
+ ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy();
+ metal.stackSize = random.nextInt(max - min + 1) + min;
+ furnace.setInventorySlotContents(2, metal);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the villager type to spawn in this component, based on the number
+ * of villagers already spawned.
+ *
+ * @param par1
+ * @return
+ */
+ @Override
+ protected int getVillagerType(int par1) {
+ return 3000;
+ }
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java
index a1b508b..3a31a8f 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java
@@ -87,7 +87,7 @@ public class JCTrades implements IVillageTradeHandler
result = JewelrycraftUtil.gem.get(end);
result.stackSize = 1 + random.nextInt(JewelrycraftUtil.gem.size() - end);
if (JewelrycraftUtil.gem.size() - 1 - end >= 1){
- int value = end;
+ int value = 1 + end;
if (value > 64) value = 64;
ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(value));
if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(value));
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java
index 95d20ee..5ef855e 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java
@@ -1,27 +1,27 @@
-/**
- *
- */
-package darkknight.jewelrycraft.worldGen.village;
-
-import java.io.IOException;
-import net.minecraft.world.gen.structure.MapGenStructureIO;
-import cpw.mods.fml.common.event.FMLPreInitializationEvent;
-import cpw.mods.fml.common.registry.VillagerRegistry;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.util.Variables;
-
-public class VillageHandler
-{
- public static void preInit(FMLPreInitializationEvent e) throws IOException
- {
- VillagerRegistry.instance().registerVillagerId(3000);
- VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades());
- VillagerRegistry.instance().registerVillageCreationHandler(new VillageJewelryHandler());
- try{
- MapGenStructureIO.func_143031_a(ComponentJewelry.class, Variables.MODID + ":Jewelry");
- }
- catch(Throwable e2){
- JewelrycraftMod.logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.7.10");
- }
- }
-}
+/**
+ *
+ */
+package darkknight.jewelrycraft.worldGen.village;
+
+import java.io.IOException;
+import net.minecraft.world.gen.structure.MapGenStructureIO;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.VillagerRegistry;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.util.Variables;
+
+public class VillageHandler
+{
+ public static void preInit(FMLPreInitializationEvent e) throws IOException
+ {
+ VillagerRegistry.instance().registerVillagerId(3000);
+ VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades());
+ VillagerRegistry.instance().registerVillageCreationHandler(new VillageJewelryHandler());
+ try{
+ MapGenStructureIO.func_143031_a(ComponentJewelry.class, Variables.MODID + ":Jewelry");
+ }
+ catch(Throwable e2){
+ JewelrycraftMod.logger.error("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.7.10");
+ }
+ }
+}