summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-05-31 01:44:17 +0100
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-05-31 01:44:17 +0100
commit40487f07fa5ef31fde99713c0b842d34a0ba3622 (patch)
tree2accdb69c2507acd794d5009d520b2255763751b /src/main/java/darkknight
parentc5dfb2ef7353f13d71d8d582aa6d240420ed9ce7 (diff)
- Fixed an issue with the Liquids tab
- Changed Entity registration so it only uses 'registerModEntity' to fix potential issues - Added crystal blocks - Changed Jewelry Tab to not override TiCon tabs (sorry TiCon, your system is good, but not for me) - The player renders in the Jewelry GUI (makes it easier for you to see how the jewelry render) - The Pentagram now has an actual effect - The Pentagram now renders beneath your feet when you look down and no longer does it in your inventory; it is also a lot smaller - Working on Structures - Created my own WeightedRandomItem (why isn't this in vanilla?) - Updated the curse API so now people can specify when a curse can be activated (I believe the world is all you need :p) - Some curses can no longer aquired in hardcore (such as Rotten Heart, Midas Touch etc) which would make it impossible to work with and require a total restart of the game (as the only way to get rid of them is by dying to replace them) Hooraaay for proper changelogs!
Diffstat (limited to 'src/main/java/darkknight')
-rw-r--r--src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java8
-rw-r--r--src/main/java/darkknight/jewelrycraft/api/Curse.java6
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java1
-rw-r--r--src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java2
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/AbstractTab.java26
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/TabRegistry.java22
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java4
-rw-r--r--src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseList.java29
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java43
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java7
-rw-r--r--src/main/java/darkknight/jewelrycraft/entities/EntityList.java10
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java73
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java11
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java13
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemList.java3
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java17
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java44
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/Generation.java39
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java67
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java61
29 files changed, 442 insertions, 129 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
index 7275cd0..65e5c24 100644
--- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
+++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
@@ -10,7 +10,10 @@ import java.io.IOException;
import java.util.logging.Logger;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.WeightedRandomChestContent;
+import net.minecraftforge.common.ChestGenHooks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -81,6 +84,11 @@ public class JewelrycraftMod
EventList.preInit(e);
PotionList.preInit(e);
ThirdPartyManager.instance().preInit();
+
+ ChestGenHooks.addItem("dungeonChest", new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 1));
+ ChestGenHooks.addItem("villageBlacksmith", new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 1));
+ ChestGenHooks.addItem("strongholdCorridor", new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 5));
+ for(int i = 0; i < 16; i++) ChestGenHooks.addItem("mineshaftCorridor", new WeightedRandomChestContent(new ItemStack(BlockList.crystal, 1, i), 1, 4, 15));
}
@EventHandler
diff --git a/src/main/java/darkknight/jewelrycraft/api/Curse.java b/src/main/java/darkknight/jewelrycraft/api/Curse.java
index 206a7ad..c030aad 100644
--- a/src/main/java/darkknight/jewelrycraft/api/Curse.java
+++ b/src/main/java/darkknight/jewelrycraft/api/Curse.java
@@ -3,6 +3,7 @@ package darkknight.jewelrycraft.api;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiIngame;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
@@ -134,6 +135,11 @@ public class Curse
return false;
}
+ public boolean canCurseBeActivated(World world)
+ {
+ return true;
+ }
+
/**
* @return
*/
diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java b/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java
index 975f89f..6963084 100644
--- a/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java
+++ b/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java
@@ -34,6 +34,7 @@ public class BlockCrystal extends Block implements ITileEntityProvider
{
super(Material.glass);
setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F);
+ setHarvestLevel("pickaxe", 0);
}
@Override
diff --git a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java
index 2a81007..0fc2f37 100644
--- a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java
+++ b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java
@@ -28,6 +28,7 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler
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);
@@ -36,6 +37,7 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler
tessellator.draw();
GL11.glTranslatef(0.5f, 0f, 0.5f);
GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
}
@Override
diff --git a/src/main/java/darkknight/jewelrycraft/client/AbstractTab.java b/src/main/java/darkknight/jewelrycraft/client/AbstractTab.java
index 6728181..5ff4d2f 100644
--- a/src/main/java/darkknight/jewelrycraft/client/AbstractTab.java
+++ b/src/main/java/darkknight/jewelrycraft/client/AbstractTab.java
@@ -9,6 +9,7 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.util.Variables;
/**
* @author TinkersCOnstruct
@@ -16,13 +17,13 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public abstract class AbstractTab extends GuiButton
{
- ResourceLocation texture = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
+ ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/gui/hearts.png");
ItemStack renderStack;
RenderItem itemRenderer = new RenderItem();
public AbstractTab(int id, int posX, int posY, ItemStack renderStack)
{
- super(id, posX, posY, 28, 32, "");
+ super(id, posX, posY, 18, 18, "");
this.renderStack = renderStack;
}
@@ -32,26 +33,24 @@ public abstract class AbstractTab extends GuiButton
if (this.visible)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
-
- int yTexPos = this.enabled ? 3 : 32;
- int ySize = this.enabled ? 25 : 32;
- int xOffset = this.id == 2 ? 0 : 1;
- int yPos = this.yPosition + (this.enabled ? 3 : 0);
+ int xOffset = this.enabled ? 0 : 8;
mc.renderEngine.bindTexture(this.texture);
- this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28, yTexPos, 28, ySize);
+ this.drawTexturedModalRect(this.xPosition, yPosition, 144 + xOffset, 32, 18, 18);
+ GL11.glPushMatrix();
RenderHelper.enableGUIStandardItemLighting();
this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
- this.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, renderStack, xPosition + 6, yPosition + 8);
- this.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, renderStack, xPosition + 6, yPosition + 8);
+ this.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, renderStack, xPosition + 1, yPosition + 1);
+ this.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, renderStack, xPosition + 1, yPosition + 1);
GL11.glDisable(GL11.GL_LIGHTING);
this.itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
RenderHelper.disableStandardItemLighting();
+ GL11.glPopMatrix();
}
}
@@ -59,12 +58,7 @@ public abstract class AbstractTab extends GuiButton
public boolean mousePressed (Minecraft mc, int mouseX, int mouseY)
{
boolean inWindow = this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
-
- if (inWindow)
- {
- this.onTabClicked();
- }
-
+ if (inWindow) this.onTabClicked();
return inWindow;
}
diff --git a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java
index a264412..6ba37ad 100644
--- a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java
+++ b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java
@@ -39,7 +39,16 @@ public class TabRegistry
int ySize = 166;
int guiLeft = (event.gui.width - xSize) / 2;
int guiTop = (event.gui.height - ySize) / 2;
- if (!mc.thePlayer.getActivePotionEffects().isEmpty()) guiLeft += 60;
+ if (!mc.thePlayer.getActivePotionEffects().isEmpty()) if (Loader.isModLoaded("NotEnoughItems")){
+ try{
+ // Check whether NEI is hidden and enabled
+ Class<?> c = Class.forName("codechicken.nei.NEIClientConfig");
+ Object hidden = c.getMethod("isHidden").invoke(null);
+ Object enabled = c.getMethod("isEnabled").invoke(null);
+ if (hidden != null && hidden instanceof Boolean && enabled != null && enabled instanceof Boolean) if ((Boolean)hidden || !((Boolean)enabled)) guiLeft += 60;
+ }
+ catch(Exception e){}
+ }else guiLeft += 60;
updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class);
addTabsToList(event.buttonList);
}
@@ -56,13 +65,13 @@ public class TabRegistry
public static void updateTabValues(int cornerX, int cornerY, Class<?> selectedButton)
{
- int count = 2 + (Loader.isModLoaded("TConstruct") ? 1 : 0);
+ int count = 1;
for(int i = 0; i < tabList.size(); i++){
AbstractTab t = tabList.get(i);
if (t.shouldAddToList()){
t.id = count;
- t.xPosition = cornerX + (count - 2) * 28;
- t.yPosition = cornerY - 28;
+ t.xPosition = cornerX + 151 + (t.id==1?9:0);
+ t.yPosition = cornerY + 64;
t.enabled = !t.getClass().equals(selectedButton);
count++;
}
@@ -71,8 +80,7 @@ public class TabRegistry
public static void addTabsToList(List buttonList)
{
- for(AbstractTab tab: tabList){
- if (tab.shouldAddToList()) if (!(Loader.isModLoaded("TConstruct") && tab instanceof InventoryTabVanilla) || !tabList.get(1).enabled) buttonList.add(tab);
- }
+ for(AbstractTab tab: tabList)
+ if (tab.shouldAddToList() && tab.enabled) buttonList.add(tab);
}
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java
index 981fbfd..fc4f15b 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java
@@ -2,6 +2,7 @@ package darkknight.jewelrycraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import darkknight.jewelrycraft.client.TabJewelry;
@@ -36,6 +37,9 @@ public class GuiJewelry extends GuiContainer
GL11.glColor3f(1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
+ GL11.glPushMatrix();
+ GuiInventory.func_147046_a(guiLeft - 24, guiTop + 124, 60, (float)(guiLeft - 24) - mouseX, (float)(guiTop + 124 - 90) - mouseY, this.mc.thePlayer);
+ GL11.glPopMatrix();
}
/**
diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java
index c1e4612..108a1dc 100644
--- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java
@@ -11,7 +11,7 @@ public class ConfigHandler
{
public static Configuration config;
public static final ConfigHandler INSTANCE = new ConfigHandler();
- public static final String[] categories = {"Timers", "Village Generation", "Misc"};
+ public static final String[] categories = {"Timers", "Village Generation", "Misc", "Curses"};
public static int INGOT_COOLING_TIME;
public static int INGOT_MELTING_TIME;
@@ -32,6 +32,18 @@ public class ConfigHandler
public static int FURNACE_MIN_INGOT_STACK;
public static int FURNACE_MAX_INGOT_STACK;
+ public static boolean CURSES_ENABLED = true;
+ public static boolean CURSE_ROTTEN_HEART = true;
+ public static boolean CURSE_FLAMING_SOUL = true;
+ public static boolean CURSE_GREED = true;
+ public static boolean CURSE_BLIND = true;
+ public static boolean CURSE_INFAMY = true;
+ public static boolean CURSE_MIDAS_TOUCH = true;
+ public static boolean CURSE_RABBIT_PAW = true;
+ public static boolean CURSE_PENTAGRAM = true;
+ public static boolean CURSE_VAMPIRE_HUNGER = true;
+ public static boolean CURSE_HUMBLE_BUNDLE = true;
+
public void loadConfig(FMLPreInitializationEvent event)
{
config = new Configuration(event.getSuggestedConfigurationFile(),true);
@@ -49,7 +61,6 @@ public class ConfigHandler
GENERATE_VILLAGE_NETHERSTAR = config.getBoolean("Netherstar Generation", categories[1], false, "If set to true Nether Stars will be able to generate in Jewelers chests.");
CAN_FURNACE_GENERATE_INGOTS = config.getBoolean("Furnace Ingots Generation", categories[1], true, "If set to true jewelers will generate ingots in furnaces.");
- CRYSTAL_GLOW = config.getBoolean("Crystal Glow", categories[2], false, "If true, then crystal will slowly glow (can cause lag)");
MAX_VILLAGE_JEWELERS = config.getInt("Maximum Jewelers", categories[1], 1, 0, Integer.MAX_VALUE, "Sets how many jewelers can be in a village.");
JEWELER_WEIGHT = config.getInt("Jewelers Weight", categories[1], 30, 0, Integer.MAX_VALUE, "Chance of getting a jeweler in a village. The higher the value, the higher the chance.");
@@ -60,6 +71,20 @@ public class ConfigHandler
GEM_CHEST_MAX = config.getInt("Jewelers Chest Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler.");
FURNACE_MIN_INGOT_STACK = config.getInt("Ingot Furnace Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum number of ingots that can generate in a furnace.");
FURNACE_MAX_INGOT_STACK = config.getInt("Ingot Furnace Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum number of ingots that can generate in a furnace.");
+
+ CRYSTAL_GLOW = config.getBoolean("Crystal Glow", categories[2], false, "If true, then crystal will slowly glow (can cause lag)");
+
+// CURSES_ENABLED = config.getBoolean("Curses", categories[3], true, "If set to false curses will be deactivated.");
+// CURSE_ROTTEN_HEART = config.getBoolean("Rotten Heart", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_FLAMING_SOUL = config.getBoolean("Flaming Soul", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_GREED = config.getBoolean("Greed", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_BLIND = config.getBoolean("Blind", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_INFAMY = config.getBoolean("Infamy", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_MIDAS_TOUCH = config.getBoolean("Midas Touch", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_RABBIT_PAW = config.getBoolean("Rabbit's Paw", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_PENTAGRAM = config.getBoolean("Pentagram", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_VAMPIRE_HUNGER = config.getBoolean("Vampire Hunger", categories[3], true, "If set to false this curse will be deactivated.");
+// CURSE_HUMBLE_BUNDLE = config.getBoolean("Humble Bundle", categories[3], true, "If set to false this curse will be deactivated.");
if (config.hasChanged()) config.save();
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java b/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java
index e751822..8716ba9 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java
@@ -1,6 +1,7 @@
package darkknight.jewelrycraft.curses;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
@@ -25,4 +26,10 @@ public class CurseBlind extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".blind.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_BLIND;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java b/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java
index d1c6515..ed7cd2d 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java
@@ -1,6 +1,7 @@
package darkknight.jewelrycraft.curses;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -23,4 +24,10 @@ public class CurseFlamingSoul extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".flamingsoul.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_FLAMING_SOUL;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java b/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java
index de555b9..be5dd83 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java
@@ -1,6 +1,7 @@
package darkknight.jewelrycraft.curses;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
@@ -30,4 +31,10 @@ public class CurseGreed extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".greed.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_GREED;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java b/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java
index 8ad6b12..c65d9b7 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java
@@ -14,6 +14,7 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
/**
@@ -57,4 +58,10 @@ public class CurseHumbleBundle extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".humblebundle.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_HUMBLE_BUNDLE;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
index 82f3b97..90d01ac 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
@@ -15,6 +15,7 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderPlayerEvent;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.damage.DamageSourceList;
import darkknight.jewelrycraft.entities.EntityHalfHeart;
import darkknight.jewelrycraft.entities.EntityHeart;
@@ -69,4 +70,10 @@ public class CurseInfamy extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".infamy.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_INFAMY;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java
index cc8cbc6..a812b24 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java
@@ -2,6 +2,7 @@ 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
@@ -22,18 +23,20 @@ public class CurseList
public static void preInit(FMLPreInitializationEvent e)
{
- 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");
+ 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");
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java
index 3ce54cf..688acb6 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.util.StatCollector;
import net.minecraft.world.World;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.entities.EntityHalfHeart;
import darkknight.jewelrycraft.entities.EntityHeart;
import darkknight.jewelrycraft.item.ItemList;
@@ -94,4 +95,10 @@ public class CurseMidasTouch extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".midastouch.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_MIDAS_TOUCH;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java b/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java
index a794a75..c6057d0 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java
@@ -4,19 +4,23 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.DamageSource;
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.common.FMLCommonHandler;
-import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.event.FMLInterModComms;
-import cpw.mods.fml.common.registry.GameRegistry;
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
@@ -31,9 +35,18 @@ public class CursePentagram extends Curse
@Override
public void action(World world, EntityPlayer player)
{
-// FMLInterModComms.sendMessage(modId, key, value);
-// GameRegistry.findItem("Botania", "flower");
-// FMLInterModComms.fetchRuntimeMessages(forMod)
+ // FMLInterModComms.sendMessage(modId, key, value);
+ // GameRegistry.findItem("Botania", "flower");
+ // FMLInterModComms.fetchRuntimeMessages(forMod)
+ if (!world.isRemote){
+ 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).attackEntityFrom(DamageSourceList.shadows, 2f);
+ if (player.shouldHeal()) player.heal(2F);
+ else player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f);
+ }
+ }
+ }
}
@Override
@@ -42,8 +55,12 @@ public class CursePentagram extends Curse
@Override
public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event)
+ {}
+
+ @SideOnly (Side.CLIENT)
+ public void playerHandRender(EntityPlayer player, RenderHandEvent event)
{
- ResourceLocation PENTAGRAM_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/" + CurseList.pentagram.getTexturePack() + ".png");
+ ResourceLocation PENTAGRAM_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/" + getTexturePack() + ".png");
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_SRC_COLOR);
@@ -51,9 +68,9 @@ public class CursePentagram extends Curse
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
texturemanager.bindTexture(PENTAGRAM_TEXTURE);
GL11.glRotatef(rot, 0F, 1F, 0F);
- GL11.glScalef(0.1F, 0.1F, 0.1F);
- GL11.glTranslatef(-16F, 15F, -16F);
+ GL11.glTranslatef(-0.8F, (player.isSneaking() ? 0.1625F : 0F) + -1.6F, -0.8F);
GL11.glRotatef(90F, 1F, 0F, 0F);
+ GL11.glScalef(0.05F, 0.05F, 0.05F);
rot += 3F;
if (rot > 360F) rot = 0F;
float f = 0.00390625F;
@@ -78,4 +95,10 @@ public class CursePentagram extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".pentagram.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_PENTAGRAM;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java b/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java
index f853217..1c26558 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java
@@ -5,6 +5,7 @@ package darkknight.jewelrycraft.curses;
import java.util.ArrayList;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.entities.EntityHalfHeart;
import darkknight.jewelrycraft.entities.EntityHeart;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
@@ -63,4 +64,10 @@ public class CurseRabbitsPaw extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".rabbitspaw.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_RABBIT_PAW;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java b/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java
index 471d0e5..afc05b0 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java
@@ -1,6 +1,7 @@
package darkknight.jewelrycraft.curses;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
@@ -25,4 +26,10 @@ public class CurseRottenHeart extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".rottenheart.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_ROTTEN_HEART;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java b/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java
index 8c72e8e..3c63641 100644
--- a/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java
+++ b/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java
@@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
/**
@@ -30,4 +31,10 @@ public class CurseVampireHunger extends Curse
{
return StatCollector.translateToLocal("curse." + Variables.MODID + ".vampirehunger.description");
}
+
+ @Override
+ public boolean canCurseBeActivated(World world)
+ {
+ return ConfigHandler.CURSE_VAMPIRE_HUNGER;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java
index e8198aa..c17c553 100644
--- a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java
+++ b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java
@@ -10,15 +10,13 @@ public class EntityList
{
public static void preInit(FMLPreInitializationEvent e)
{
- createEntity(EntityHeart.class, Variables.MODID + ".Heart", 0xFF0000, 0xFF0000, false);
- createEntity(EntityHalfHeart.class, Variables.MODID + ".Half-Heart", 0x000000, 0xFF0000, false);
+ createEntity(EntityHeart.class, Variables.MODID + ".Heart");
+ createEntity(EntityHalfHeart.class, Variables.MODID + ".Half-Heart");
}
- public static void createEntity(Class<? extends Entity> entity, String entityName, int solidColor, int spotColor, boolean hasSpawnEgg)
+ public static void createEntity(Class<? extends Entity> entity, String entityName)
{
int randomID = EntityRegistry.findGlobalUniqueEntityId();
- if(hasSpawnEgg) EntityRegistry.registerGlobalEntityID(entity, entityName, randomID, solidColor, spotColor);
- else EntityRegistry.registerGlobalEntityID(entity, entityName, randomID);
- EntityRegistry.registerModEntity(entity, entityName, randomID, JewelrycraftMod.instance, 40, 3, true);
+ EntityRegistry.registerModEntity(entity, entityName, randomID, JewelrycraftMod.instance, 40, 3, false);
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
index a106e2a..7157759 100644
--- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
@@ -37,6 +37,7 @@ 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;
@@ -57,7 +58,7 @@ import darkknight.jewelrycraft.util.Variables;
*/
public class EntityEventHandler
{
- int updateTime = 0;
+ int updateTime = 0, totalUnavailableCurses = 0;
boolean addedCurses = false;
/**
@@ -80,8 +81,14 @@ public class EntityEventHandler
}
boolean render = persistTag.getBoolean("fancyRender");
JewelrycraftMod.fancyRender = render;
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(event.world) && !persistTag.hasKey(curse.getName())) persistTag.setInteger(curse.getName(), 0);
for(Curse curse: Curse.getCurseList())
- if (!persistTag.hasKey(curse.getName())) persistTag.setInteger(curse.getName(), 0);
+ if (!curse.canCurseBeActivated(event.world)){
+ Curse.availableCurses.remove(curse);
+ persistTag.setInteger(curse.getName(), 0);
+ totalUnavailableCurses++;
+ }else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse);
persistTag.setBoolean("sendInfo", true);
}
}
@@ -120,8 +127,8 @@ public class EntityEventHandler
NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
if (item != null){
- if(item.getItem() instanceof ItemBaseJewelry)((ItemBaseJewelry)item.getItem()).action(item, player);
- if(item.getItem() instanceof IJewelryItem)((IJewelryItem)item.getItem()).onWearAction(item, player);
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).action(item, player);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onWearAction(item, player);
}
}
if (!player.worldObj.isRemote){
@@ -149,8 +156,8 @@ public class EntityEventHandler
JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
updateTime = 200;
}
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.action(player.worldObj, player);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.action(player.worldObj, player);
}
}
}
@@ -161,8 +168,8 @@ public class EntityEventHandler
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)event.source.getEntity();
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.entityDropItems(player, event.entityLiving, event.drops);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDropItems(player, event.entityLiving, event.drops);
}
}
@@ -191,8 +198,8 @@ public class EntityEventHandler
break;
}
if (item != null){
- if(item.getItem() instanceof ItemBaseJewelry)((ItemBaseJewelry)item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount);
- if(item.getItem() instanceof IJewelryItem)((IJewelryItem)item.getItem()).onPlayerAttackedAction(item, player, event.source, event.ammount);
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerAttackedAction(item, player, event.source, event.ammount);
}
}
if (player.getHealth() != player.prevHealth){
@@ -233,8 +240,8 @@ public class EntityEventHandler
}
}
}
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player);
}else if (event.source.getEntity() instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)event.source.getEntity();
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
@@ -252,12 +259,12 @@ public class EntityEventHandler
break;
}
if (item != null){
- if(item.getItem() instanceof ItemBaseJewelry)((ItemBaseJewelry)item.getItem()).onEntityAttacked(item, player, entity, event.ammount);
- if(item.getItem() instanceof IJewelryItem)((IJewelryItem)item.getItem()).onEntityAttackedByPlayer(item, player, entity, event.ammount);
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onEntityAttacked(item, player, entity, event.ammount);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onEntityAttackedByPlayer(item, player, entity, event.ammount);
}
}
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.attackedByPlayerAction(entity.worldObj, player, entity);
+ 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);
}
}
@@ -282,15 +289,15 @@ public class EntityEventHandler
playerInfo.setFloat("BlueHeart", 0f);
playerInfo.setFloat("BlackHeart", 0f);
playerInfo.setFloat("WhiteHeart", 0f);
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.respawnAction(player.worldObj, player);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.respawnAction(player.worldObj, player);
for(int i = 0; i < 18; i++)
if (playerInfo.hasKey("ext" + i)){
NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
if (item != null){
- if(item.getItem() instanceof ItemBaseJewelry)((ItemBaseJewelry)item.getItem()).onPlayerRespawn(item, event);
- if(item.getItem() instanceof IJewelryItem)((IJewelryItem)item.getItem()).onPlayerRespawnAction(item, event);
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerRespawn(item, event);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerRespawnAction(item, event);
}
}
}
@@ -299,7 +306,7 @@ public class EntityEventHandler
JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
if (addedCurses){
JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
-// player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0);
+ // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0);
addedCurses = false;
}
}
@@ -312,7 +319,7 @@ public class EntityEventHandler
*/
public void addCurse(EntityPlayer player, NBTTagCompound playerInfo, int curseNo)
{
- if (Curse.availableCurses.size() > 0 && curseNo > Curse.getCurseList().size() - Curse.availableCurses.size()){
+ if (ConfigHandler.CURSES_ENABLED && Curse.availableCurses.size() > 0 && curseNo > Curse.getCurseList().size() - Curse.availableCurses.size() - totalUnavailableCurses){
int no = JewelrycraftUtil.rand.nextInt(Curse.availableCurses.size());
Curse cur = Curse.availableCurses.get(no);
playerInfo.setInteger(cur.getName(), 1);
@@ -325,8 +332,8 @@ public class EntityEventHandler
public void itemToss(ItemTossEvent event)
{
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(event.player, Variables.MODID);
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0 && curse.itemToss()){
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(event.player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && curse.itemToss()){
EntityItem entityitem = new EntityItem(event.player.worldObj, event.player.posX + 0.5D, event.player.posY + 0.5D, event.player.posZ + 0.5D, event.entityItem.getEntityItem());
entityitem.motionX = 0;
entityitem.motionZ = 0;
@@ -377,8 +384,8 @@ public class EntityEventHandler
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)event.source.getEntity();
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.entityDeathAction(player.worldObj, event.entityLiving, player);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDeathAction(player.worldObj, event.entityLiving, player);
}
}
if (entity instanceof EntityPlayer){
@@ -388,23 +395,23 @@ public class EntityEventHandler
playerInfo.setFloat("BlackHeart", 0f);
playerInfo.setFloat("WhiteHeart", 0f);
if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")){
- for(Curse l: Curse.getCurseList()){
- if (playerInfo.getInteger(l.getName()) == 1){
+ if (ConfigHandler.CURSES_ENABLED) for(Curse l: Curse.getCurseList()){
+ if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) == 1){
playerInfo.setInteger(l.getName(), 0);
if (!Curse.availableCurses.contains(l)) Curse.availableCurses.add(l);
- }else if (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());
}
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0) curse.playerDeathAction(player.worldObj, player);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.playerDeathAction(player.worldObj, player);
for(int i = 0; i < 18; i++)
if (playerInfo.hasKey("ext" + i)){
NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
if (item != null){
- if(item.getItem() instanceof ItemBaseJewelry)((ItemBaseJewelry)item.getItem()).onPlayerDead(item, player, event.source);
- if(item.getItem() instanceof IJewelryItem)((IJewelryItem)item.getItem()).onPlayerDeadAction(item, player, event.source);
+ if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerDead(item, player, event.source);
+ if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerDeadAction(item, player, event.source);
}
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
index 4d07cda..9eb783f 100644
--- a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
@@ -17,6 +17,7 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.item.render.BraceletRender;
import darkknight.jewelrycraft.item.render.EarringsRender;
import darkknight.jewelrycraft.item.render.NecklaceRender;
@@ -50,8 +51,8 @@ public class PlayerRenderHandler
int ingot = -1;
EntityPlayer player = players.next();
NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName());
- for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event);
int no = 0;
ModelRenderer arm = rightArm;
if (player.inventory.getCurrentItem() != null && Block.getBlockFromItem(player.inventory.getCurrentItem().getItem()) instanceof BlockAir){
@@ -66,7 +67,7 @@ public class PlayerRenderHandler
colorBuffer.put(0.03f).put(0.03f).put(0.03f).put(1.0F);
colorBuffer.flip();
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, colorBuffer);
- //GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(var2, var2, var2, 1.0F));
+ // GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(var2, var2, var2, 1.0F));
}
for(int i = 0; i <= 9; i++)
if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
@@ -192,8 +193,8 @@ public class PlayerRenderHandler
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null){
NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName());
- for(Curse curse: Curse.getCurseList())
- if (curse != null && playerInfo != null && playerInfo.hasKey(curse.getName()) && playerInfo.getInteger(curse.getName()) > 0 && playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event);
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(player.worldObj) && curse != null && playerInfo != null && playerInfo.hasKey(curse.getName()) && playerInfo.getInteger(curse.getName()) > 0 && playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event);
}
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
index badbfa9..68aace4 100644
--- a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
@@ -12,6 +12,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import darkknight.jewelrycraft.api.Curse;
+import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
public class ScreenHandler extends Gui
@@ -36,15 +37,15 @@ public class ScreenHandler extends Gui
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
if (tagCache.hasKey("cursePoints") && tagCache.getInteger("cursePoints") > 0){
mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
- for(Curse curse: Curse.getCurseList()){
- if (tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()){
+ if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
drawTexturedModalRect(-16, -16 + (size - 6) * count, 0, 32, 144, 60);
count++;
}
}
count = 0;
- for(Curse curse: Curse.getCurseList())
- if (tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png"));
int tag = curse.getTextureID();
GL11.glPushMatrix();
@@ -57,8 +58,8 @@ public class ScreenHandler extends Gui
}
count = 0;
size = 16;
- for(Curse curse: Curse.getCurseList())
- if (tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
+ if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList())
+ if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
mc.fontRenderer.drawStringWithShadow(curse.getName().split(":")[1], 30, 11 + (size + 10) * count, 16777215);
if (tagCache.getInteger(curse.getName()) == 2){
mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemList.java b/src/main/java/darkknight/jewelrycraft/item/ItemList.java
index 0d8c61c..064ee58 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemList.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemList.java
@@ -23,6 +23,7 @@ public class ItemList
public static ItemMoltenMetalBucket bucket;
public static ItemMoltenMetal metal;
public static Item goldObj;
+ public static Item structureGen;
private static boolean isInitialized = false;
/**
@@ -43,6 +44,7 @@ public class ItemList
metal = (ItemMoltenMetal)new ItemMoltenMetal().setUnlocalizedName(Variables.MODID + ".bucket");
jewelryModifier = new ItemJewelryModifier().setUnlocalizedName(Variables.MODID + ".jewelryModifier").setTextureName(Variables.MODID + ":jewelryModifier").setCreativeTab(JewelrycraftMod.jewelrycraft);
goldObj = new ItemGoldObj().setUnlocalizedName(Variables.MODID + ".goldObject");
+ structureGen = new ItemStructureGen().setUnlocalizedName(Variables.MODID + ".structureGen").setTextureName(Variables.MODID + ":structureGen").setCreativeTab(JewelrycraftMod.jewelrycraft);
GameRegistry.registerItem(thiefGloves, "thiefGloves");
GameRegistry.registerItem(shadowIngot, "shadowIngot");
@@ -57,6 +59,7 @@ public class ItemList
GameRegistry.registerItem(metal, "moltenMetal");
GameRegistry.registerItem(jewelryModifier, "jewelryModifier");
GameRegistry.registerItem(goldObj, "goldObject");
+ GameRegistry.registerItem(structureGen, "structureGen");
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 4fe0bd2..c7d32b4 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java
@@ -216,11 +216,18 @@ public class ItemMoltenMetalBucket extends Item
@Override
public String getItemStackDisplayName(ItemStack stack)
{
- if (JewelryNBT.ingot(stack) != null){
- ItemStack ingot = JewelryNBT.ingot(stack);
- 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();
+ 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");
+ }
+ }
+ catch(Exception e){
+ System.out.println("Error: " + e);
}
- return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " Metal";
+ return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " " + StatCollector.translateToLocal("info.jewelrycraft2.metal");
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java b/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java
new file mode 100644
index 0000000..6b736d2
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java
@@ -0,0 +1,44 @@
+package darkknight.jewelrycraft.item;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.world.World;
+import net.minecraft.world.gen.feature.WorldGenerator;
+import darkknight.jewelrycraft.worldGen.WorldGenStructure1;
+
+public class ItemStructureGen extends Item
+{
+ int structure = 0;
+ WorldGenerator[] structures = new WorldGenerator[]{new WorldGenStructure1(), new WorldGenStructure1(), new WorldGenStructure1()};
+
+ public ItemStructureGen()
+ {
+ super();
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
+ {
+ if (!world.isRemote){
+ if (!player.isSneaking()){
+ if (structure < structures.length - 1) structure++;
+ else structure = 0;
+ }else
+ {
+ if (structure > 0) structure--;
+ else structure = structures.length - 1;
+ }
+ player.addChatMessage(new ChatComponentText("Structure no. " + structure));
+ }
+ return stack;
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par1, float par2, float par3, float par4)
+ {
+ structures[structure].generate(world, itemRand, x, y + 1, z);
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
index 5992273..d71b44c 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
@@ -9,15 +9,8 @@ import darkknight.jewelrycraft.block.BlockList;
public class Generation implements IWorldGenerator
{
+ WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1();
- /**
- * @param random
- * @param chunkX
- * @param chunkZ
- * @param world
- * @param chunkGenerator
- * @param chunkProvider
- */
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
@@ -35,21 +28,9 @@ public class Generation implements IWorldGenerator
}
}
- /**
- * @param world
- * @param random
- * @param i
- * @param j
- */
private void generateEnd(World world, Random random, int i, int j)
{}
- /**
- * @param world
- * @param random
- * @param i
- * @param j
- */
private void generateSurface(World world, Random random, int i, int j)
{
for(int k = 0; k < 1; k++){
@@ -60,14 +41,20 @@ public class Generation implements IWorldGenerator
int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2);
if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre);
}
+ for(int k = 0; k < 16; k++){
+ int x = i + random.nextInt(12);
+ int y = 5 + random.nextInt(64);
+ int z = j + random.nextInt(12);
+ for(int r = 0; r < 12; r++){
+ int randX = random.nextInt(4);
+ int randY = random.nextInt(2);
+ int randZ = random.nextInt(4);
+ if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air)
+ world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2);
+ }
+ }
}
- /**
- * @param world
- * @param random
- * @param i
- * @param j
- */
private void generateNether(World world, Random random, int i, int j)
{}
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java b/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java
new file mode 100644
index 0000000..0528b66
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java
@@ -0,0 +1,67 @@
+package darkknight.jewelrycraft.worldGen;
+
+import java.util.Random;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.WeightedRandom;
+
+public class WeightedRandomItem extends WeightedRandom.Item
+{
+ private final ItemStack item;
+ private int maxMeta, minMeta, minItem, maxItem;
+
+ public WeightedRandomItem(ItemStack item, int weight)
+ {
+ super(weight);
+ this.item = item;
+ this.minItem = 1;
+ this.maxItem = 1;
+ this.maxMeta = 0;
+ this.minMeta = 0;
+ }
+
+ public WeightedRandomItem(ItemStack item, int maxMetadata, int weight)
+ {
+ this(item, weight);
+ this.maxMeta = maxMetadata;
+ }
+
+ public WeightedRandomItem(ItemStack item, int weight, int minItem, int maxItem)
+ {
+ this(item, weight);
+ this.minItem = minItem;
+ this.maxItem = maxItem;
+ }
+
+ public WeightedRandomItem setMaxMetadata(int meta)
+ {
+ this.maxMeta = meta;
+ return this;
+ }
+
+ public WeightedRandomItem setMinMetadata(int meta)
+ {
+ this.minMeta = meta;
+ return this;
+ }
+
+ public WeightedRandomItem setMinItem(int min)
+ {
+ this.minItem = min;
+ return this;
+ }
+
+ public WeightedRandomItem setMaxItem(int max)
+ {
+ this.maxItem = max;
+ return this;
+ }
+
+ public ItemStack getItem(Random random)
+ {
+ ItemStack itemstack = this.item.copy();
+ if(maxMeta > 0) itemstack.setItemDamage(minMeta + random.nextInt(maxMeta - minMeta));
+ if(maxItem > 1) itemstack.stackSize = this.minItem + random.nextInt(this.maxItem - this.minItem + 1);
+ return itemstack;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java
new file mode 100644
index 0000000..2d11cb5
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package darkknight.jewelrycraft.worldGen;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.WeightedRandom;
+import net.minecraft.world.World;
+import net.minecraft.world.gen.feature.WorldGenerator;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+
+/**
+ * @author Sorin
+ */
+public class WorldGenStructure1 extends WorldGenerator
+{
+ public static final WeightedRandomItem[] items = new WeightedRandomItem[] {
+ new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 7),
+ new WeightedRandomItem(new ItemStack(Items.golden_apple), 5),
+ new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1),
+ new WeightedRandomItem(new ItemStack(ItemList.guide), 10),
+ new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 15),
+ 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, 10)
+ };
+
+ @Override
+ public boolean generate(World world, Random rand, int x, int y, int z)
+ {
+ for(int i = -2; i <= 2; i++)
+ for(int j = -1; j <= 4; j++)
+ for(int k = -2; k <= 2; k++)
+ world.setBlock(x + i, y + j, z + k, Blocks.air);
+
+ for(int i = -2; i <= 2; i++)
+ for(int k = -2; k <= 2; k++){
+ world.setBlock(x + i, y - 1, z + k, Blocks.stonebrick);
+ if (i % 2 == 0 && k % 2 == 0 && i != 0 && k != 0) world.setBlock(x + i, y, z + k, BlockList.crystal);
+ }
+ for(int i = -1; i <= 1; i++)
+ for(int k = -1; k <= 1; k++)
+ world.setBlock(x + i, y, z + k, Blocks.stone_slab, 5, 2);
+
+ world.setBlock(x, y, z, Blocks.stonebrick);
+ world.setBlock(x, y+1, z, BlockList.handPedestal, 6, 2);
+ TileEntityHandPedestal pedestal = (TileEntityHandPedestal)world.getTileEntity(x, y+1, z);
+ pedestal.setHeldItemStack(((WeightedRandomItem)WeightedRandom.getRandomItem(rand, items)).getItem(rand));
+
+ return true;
+ }
+}