summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/JewelrycraftMod.java3
-rw-r--r--src/main/java/darkknight/jewelrycraft/affixes/AffixMods.java64
-rw-r--r--src/main/java/darkknight/jewelrycraft/affixes/DamageAffix.java16
-rw-r--r--src/main/java/darkknight/jewelrycraft/affixes/HealthAffix.java29
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/api/IJewelryItem.java9
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/api/ModifierEffect.java26
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/client/gui/container/ContainerJewelryTab.java11
-rw-r--r--src/main/java/darkknight/jewelrycraft/effects/AffixMods.java13
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java4
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java4
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java10
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/effects/EffectFeather.java5
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java5
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java55
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java203
-rw-r--r--src/main/java/darkknight/jewelrycraft/random/WeightedRandomAffix.java18
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java9
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java95
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java71
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java257
-rwxr-xr-xsrc/main/resources/assets/jewelrycraft2/lang/en_US.lang14
21 files changed, 691 insertions, 230 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
index bd652fd..ef6e8a5 100755
--- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
+++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java
@@ -18,6 +18,7 @@ import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import darkknight.jewelrycraft.achievements.AchievementsList;
+import darkknight.jewelrycraft.affixes.AffixMods;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.commands.JewelrycraftCommands;
import darkknight.jewelrycraft.config.ConfigHandler;
@@ -107,6 +108,8 @@ public class JewelrycraftMod {
ThirdPartyManager.instance().preInit();
logger.log(Level.INFO, "Adding Dungeons loot");
ChestGeneration.preInit(e);
+ logger.log(Level.INFO, "Adding Jewlery Affixes");
+ AffixMods.initializeAffixes(e);
MinecraftForge.EVENT_BUS.register(this);
}
diff --git a/src/main/java/darkknight/jewelrycraft/affixes/AffixMods.java b/src/main/java/darkknight/jewelrycraft/affixes/AffixMods.java
new file mode 100644
index 0000000..d124251
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/affixes/AffixMods.java
@@ -0,0 +1,64 @@
+package darkknight.jewelrycraft.affixes;
+
+import java.util.*;
+
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import darkknight.jewelrycraft.api.ModifierEffect;
+import darkknight.jewelrycraft.random.WeightedRandomAffix;
+import net.minecraft.util.WeightedRandom;
+
+public class AffixMods {
+ private static Map<String, ModifierEffect> prefixes;
+ private static Map<String, ModifierEffect> suffixes;
+
+ private static List<WeightedRandomAffix> prefixGen;
+ private static List<WeightedRandomAffix> suffixGen;
+
+ public static void initializeAffixes(FMLPreInitializationEvent fpie) {
+ prefixes = new HashMap<String, ModifierEffect>();
+ suffixes = new HashMap<String, ModifierEffect>();
+
+ prefixGen = new LinkedList<WeightedRandomAffix>();
+ suffixGen = new LinkedList<WeightedRandomAffix>();
+
+ ModifierEffect health1 = new HealthAffix(1);
+ ModifierEffect health2 = new HealthAffix(2);
+ ModifierEffect health3 = new HealthAffix(3);
+
+ prefixes.put("health1", health1);
+ prefixes.put("health2", health2);
+ prefixes.put("health3", health3);
+
+ prefixGen.add(new WeightedRandomAffix("health1", 10));
+ prefixGen.add(new WeightedRandomAffix("health2", 7));
+ prefixGen.add(new WeightedRandomAffix("health3", 5));
+
+ suffixes.put("health1", health1);
+ suffixes.put("health2", health2);
+ suffixes.put("health3", health3);
+
+ suffixGen.add(new WeightedRandomAffix("health1", 10));
+ suffixGen.add(new WeightedRandomAffix("health2", 7));
+ suffixGen.add(new WeightedRandomAffix("health3", 5));
+ }
+
+ public static ModifierEffect getPrefix(String prefix) {
+ return prefixes.get(prefix);
+ }
+
+ public static ModifierEffect getSuffix(String suffix) {
+ return suffixes.get(suffix);
+ }
+
+ public static String pickPrefix(Random random) {
+ WeightedRandomAffix wra = ((WeightedRandomAffix) WeightedRandom.getRandomItem(random, prefixGen));
+
+ return wra.getAffix(random);
+ }
+
+ public static String pickSuffix(Random random) {
+ WeightedRandomAffix wra = ((WeightedRandomAffix) WeightedRandom.getRandomItem(random, suffixGen));
+
+ return wra.getAffix(random);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/affixes/DamageAffix.java b/src/main/java/darkknight/jewelrycraft/affixes/DamageAffix.java
new file mode 100644
index 0000000..30c89ae
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/affixes/DamageAffix.java
@@ -0,0 +1,16 @@
+package darkknight.jewelrycraft.affixes;
+
+import darkknight.jewelrycraft.api.ModifierEffect;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+
+public class DamageAffix extends ModifierEffect {
+
+ public DamageAffix() {
+ super(null);
+ }
+
+}
diff --git a/src/main/java/darkknight/jewelrycraft/affixes/HealthAffix.java b/src/main/java/darkknight/jewelrycraft/affixes/HealthAffix.java
new file mode 100644
index 0000000..56ec244
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/affixes/HealthAffix.java
@@ -0,0 +1,29 @@
+package darkknight.jewelrycraft.affixes;
+
+import darkknight.jewelrycraft.api.ModifierEffect;
+import net.minecraft.entity.SharedMonsterAttributes;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+public class HealthAffix extends ModifierEffect {
+ private int health;
+
+ public HealthAffix(int health) {
+ super(null);
+
+ this.health = health;
+ }
+
+ @Override
+ public void onJewelryEquipped(ItemStack item, Item jewelry, EntityPlayer player) {
+ player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + health);
+ player.setHealth(player.getHealth() + health);
+ }
+
+ @Override
+ public void onJewelryUnequipped(ItemStack item, Item jewelry, EntityPlayer player) {
+ player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + health);
+ player.setHealth(player.getHealth() + health);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/api/IJewelryItem.java b/src/main/java/darkknight/jewelrycraft/api/IJewelryItem.java
index 878ceee..34d32bf 100755
--- a/src/main/java/darkknight/jewelrycraft/api/IJewelryItem.java
+++ b/src/main/java/darkknight/jewelrycraft/api/IJewelryItem.java
@@ -7,6 +7,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
/**
@@ -58,10 +60,11 @@ public interface IJewelryItem {
* The attacking player
* @param entity
* The target entity
- * @param amount
+ * @param event
* The amount of damage dealt
*/
- public void onEntityAttackedByPlayer(ItemStack item, EntityPlayer player, EntityLivingBase entity, float amount);
+ public void onEntityAttackedByPlayer(ItemStack item, EntityPlayer player, EntityLivingBase entity,
+ LivingAttackEvent event);
/**
* This runs whenever a player dies
@@ -105,4 +108,6 @@ public interface IJewelryItem {
* metadata and nbt)
*/
public void onJewelryUnequipped(ItemStack item);
+
+ public void onLivingDropItems(ItemStack item, EntityPlayer player, LivingDropsEvent event);
}
diff --git a/src/main/java/darkknight/jewelrycraft/api/ModifierEffect.java b/src/main/java/darkknight/jewelrycraft/api/ModifierEffect.java
index 8e58f72..cbd740b 100755
--- a/src/main/java/darkknight/jewelrycraft/api/ModifierEffect.java
+++ b/src/main/java/darkknight/jewelrycraft/api/ModifierEffect.java
@@ -3,17 +3,20 @@ package darkknight.jewelrycraft.api;
import java.util.ArrayList;
import java.util.Random;
+import darkknight.jewelrycraft.item.ItemBaseJewelry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
public class ModifierEffect {
protected ItemStack modifier;
protected Random rand = new Random();
-
+
protected static ArrayList<ModifierEffect> effects = new ArrayList<>();
/**
@@ -22,7 +25,7 @@ public class ModifierEffect {
*/
public ModifierEffect(ItemStack modifier) {
this.modifier = modifier;
-
+
if (modifier != null) {
effects.add(this);
}
@@ -70,12 +73,12 @@ public class ModifierEffect {
* The attacked entity
* @param jewelry
* The actual jewelry item (aka item.getItem(), almost)
- * @param amount
+ * @param event
* The amount of damage the entity took
* @return The state of the event (true to cancel it, false to not)
*/
public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
- float amount) {
+ LivingAttackEvent event) {
return false;
}
@@ -113,10 +116,11 @@ public class ModifierEffect {
* The attacked entity
* @param jewelry
* The actual jewelry item (aka item.getItem(), almost)
- * @param amount
+ * @param event
* The amount of damage the entity took
*/
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) {
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
+ LivingAttackEvent event) {
// Do nothing
}
@@ -179,7 +183,7 @@ public class ModifierEffect {
* @param jewelry
* The actual jewelry item (aka item.getItem(), almost)
*/
- public void onJewelryEquipped(ItemStack item, Item jewelry) {
+ public void onJewelryEquipped(ItemStack item, Item jewelry, EntityPlayer player) {
// Do nothing
}
@@ -191,7 +195,13 @@ public class ModifierEffect {
* @param jewelry
* The actual jewelry item (aka item.getItem(), almost)
*/
- public void onJewelryUnequipped(ItemStack item, Item jewelry) {
+ public void onJewelryUnequipped(ItemStack item, Item jewelry, EntityPlayer player) {
// Do nothing
}
+
+ public void onLivingDropItems(ItemStack item, EntityPlayer player, LivingDropsEvent event,
+ ItemBaseJewelry jewelry) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/container/ContainerJewelryTab.java b/src/main/java/darkknight/jewelrycraft/client/gui/container/ContainerJewelryTab.java
index 6a118dc..344df7e 100755
--- a/src/main/java/darkknight/jewelrycraft/client/gui/container/ContainerJewelryTab.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/container/ContainerJewelryTab.java
@@ -46,14 +46,15 @@ public class ContainerJewelryTab extends Container {
if (slotID >= 0 && slotID <= 17 && !player.worldObj.isRemote) {
try {
if (player.inventory.getItemStack() == null && inventoryItemStacks.get(slotID) != null
- && ((ItemStack) inventoryItemStacks.get(slotID)).getItem() instanceof ItemBaseJewelry)
+ && ((ItemStack) inventoryItemStacks.get(slotID)).getItem() instanceof ItemBaseJewelry) {
((ItemBaseJewelry) ((ItemStack) inventoryItemStacks.get(slotID)).getItem())
- .onJewelryUnequipped((ItemStack) inventoryItemStacks.get(slotID));
- else if (player.inventory.getItemStack() != null
+ .onJewelryUnequipped((ItemStack) inventoryItemStacks.get(slotID), player);
+ } else if (player.inventory.getItemStack() != null
&& player.inventory.getItemStack().getItem() instanceof ItemBaseJewelry
- && inventoryItemStacks.get(slotID) == null)
+ && inventoryItemStacks.get(slotID) == null) {
((ItemBaseJewelry) player.inventory.getItemStack().getItem())
- .onJewelryEquipped(player.inventory.getItemStack());
+ .onJewelryEquipped(player.inventory.getItemStack(), player);
+ }
if (player.inventory.getItemStack() == null && inventoryItemStacks.get(slotID) != null
&& ((ItemStack) inventoryItemStacks.get(slotID)).getItem() instanceof IJewelryItem)
((IJewelryItem) ((ItemStack) inventoryItemStacks.get(slotID)).getItem())
diff --git a/src/main/java/darkknight/jewelrycraft/effects/AffixMods.java b/src/main/java/darkknight/jewelrycraft/effects/AffixMods.java
deleted file mode 100644
index b9ec06a..0000000
--- a/src/main/java/darkknight/jewelrycraft/effects/AffixMods.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package darkknight.jewelrycraft.effects;
-
-import darkknight.jewelrycraft.api.ModifierEffect;
-
-public class AffixMods {
- public static ModifierEffect getPrefix(String prefix) {
- return null;
- }
-
- public static ModifierEffect getSuffix(String suffix) {
- return null;
- }
-} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
index ca35754..f8ffd7a 100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
@@ -14,6 +14,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
public class EffectBlazePowder extends ModifierEffect {
public EffectBlazePowder() {
@@ -51,7 +52,8 @@ public class EffectBlazePowder extends ModifierEffect {
@Override
public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
- float amount) {
+ LivingAttackEvent event) {
+
// Balanced for ring
if (jewelry instanceof ItemRing && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
target.setFire(2);
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
index 01c045a..4e62471 100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
@@ -29,7 +29,7 @@ public class EffectEnderEye extends ModifierEffect {
}
@Override
- public void onJewelryEquipped(ItemStack item, Item jewelry) {
+ public void onJewelryEquipped(ItemStack item, Item jewelry, EntityPlayer player) {
if (jewelry instanceof ItemRing) {
int viewDistance;
@@ -44,7 +44,7 @@ public class EffectEnderEye extends ModifierEffect {
}
@Override
- public void onJewelryUnequipped(ItemStack item, Item jewelry) {
+ public void onJewelryUnequipped(ItemStack item, Item jewelry, EntityPlayer player) {
if (jewelry instanceof ItemRing)
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, getViewDistance(item));
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java
index fca9fe0..bff370b 100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java
@@ -20,6 +20,7 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
public class EffectEnderPearl extends ModifierEffect {
public EffectEnderPearl() {
@@ -77,7 +78,8 @@ public class EffectEnderPearl extends ModifierEffect {
}
@Override
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) {
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
+ LivingAttackEvent event) {
if (jewelry instanceof ItemRing) {
// Negative ring
if (target instanceof EntityEnderman)
@@ -88,10 +90,4 @@ public class EffectEnderPearl extends ModifierEffect {
target.posZ + rand.nextInt(16) - rand.nextInt(16));
}
}
-
- @Override
- public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
- float amount) {
- return false;
- }
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
index 14953e6..79d2184 100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
@@ -23,6 +23,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.*;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
public class EffectFeather extends ModifierEffect {
public EffectFeather() {
@@ -61,7 +62,9 @@ public class EffectFeather extends ModifierEffect {
@Override
public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
- float amount) {
+ LivingAttackEvent event) {
+ float amount = event.ammount;
+
NBTTagCompound enemyData = target.getEntityData();
if (jewelry instanceof ItemRing && !player.worldObj.isRemote) {
if (enemyData.getInteger("reAttacked") == 0) {
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
index 0d561e0..d7fcef8 100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
@@ -18,6 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
public class EffectObsidian extends ModifierEffect {
public EffectObsidian() {
@@ -90,7 +91,9 @@ public class EffectObsidian extends ModifierEffect {
@Override
public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
- float amount) {
+ LivingAttackEvent event) {
+ float amount = event.ammount;
+
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
NBTTagCompound enemyData = target.getEntityData();
// Positive ring
diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
index 355d041..6b30bb4 100755
--- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
@@ -237,13 +237,33 @@ public class EntityEventHandler {
@SubscribeEvent
public void onEntityLivingDropItems(LivingDropsEvent event) {
- if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
- EntityPlayer player = (EntityPlayer) event.source.getEntity();
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (ConfigHandler.CURSES_ENABLED)
- for (Curse curse : Curse.getCurseList())
- if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0)
- curse.entityDropItems(player, event.entityLiving, event.drops);
+ if (event.source.getEntity() != null) {
+ if (event.source.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.source.getEntity();
+
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+
+ if (ConfigHandler.CURSES_ENABLED) {
+ for (Curse curse : Curse.getCurseList()) {
+ boolean hasCurse = curse.canCurseBeActivated(player.worldObj)
+ && playerInfo.getInteger(curse.getName()) > 0;
+
+ if (hasCurse)
+ curse.entityDropItems(player, event.entityLiving, event.drops);
+ }
+ }
+
+ for (int i = 0; i < 18; i++) {
+ if (getJewelryItems(playerInfo, i) != null) {
+ if (getJewelryItems(playerInfo, i).getItem() instanceof ItemBaseJewelry)
+ ((ItemBaseJewelry) getJewelryItems(playerInfo, i).getItem())
+ .onLivingDropItems(getJewelryItems(playerInfo, i), player, event);
+ if (getJewelryItems(playerInfo, i).getItem() instanceof IJewelryItem)
+ ((IJewelryItem) getJewelryItems(playerInfo, i).getItem())
+ .onLivingDropItems(getJewelryItems(playerInfo, i), player, event);
+ }
+ }
+ }
}
}
@@ -296,28 +316,35 @@ public class EntityEventHandler {
if (event.source.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- for (int i = 0; i < 18; i++)
+
+ for (int i = 0; i < 18; i++) {
if (getJewelryItems(playerInfo, i) != null) {
if (getJewelryItems(playerInfo, i).getItem() instanceof ItemBaseJewelry) {
((ItemBaseJewelry) getJewelryItems(playerInfo, i).getItem())
- .onEntityAttacked(getJewelryItems(playerInfo, i), player, entity, event.ammount);
- if (((ItemBaseJewelry) getJewelryItems(playerInfo, i).getItem()).onEntityAttackedCacellable(
- getJewelryItems(playerInfo, i), player, entity, event.ammount))
+ .onEntityAttacked(getJewelryItems(playerInfo, i), player, entity, event);
+ if (((ItemBaseJewelry) getJewelryItems(playerInfo, i).getItem())
+ .onEntityAttackedCancellable(getJewelryItems(playerInfo, i), player, entity, event))
event.setCanceled(true);
}
if (getJewelryItems(playerInfo, i).getItem() instanceof IJewelryItem)
((IJewelryItem) getJewelryItems(playerInfo, i).getItem()).onEntityAttackedByPlayer(
- getJewelryItems(playerInfo, i), player, entity, event.ammount);
+ getJewelryItems(playerInfo, i), player, entity, event);
}
- if (ConfigHandler.CURSES_ENABLED)
+ }
+
+ if (ConfigHandler.CURSES_ENABLED) {
for (Curse curse : Curse.getCurseList())
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)
+ }
+
+ 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);
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
index b14a365..8b477c6 100755
--- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
@@ -6,10 +6,10 @@ import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.affixes.AffixMods;
import darkknight.jewelrycraft.api.IJewelryItem;
import darkknight.jewelrycraft.api.ModifierEffect;
import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.effects.AffixMods;
import darkknight.jewelrycraft.util.JewelryNBT;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.util.Variables;
@@ -20,6 +20,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -75,15 +77,18 @@ public abstract class ItemBaseJewelry extends Item {
String prefix = JewelryNBT.prefix(stack);
String suffix = JewelryNBT.suffix(stack);
-
+
if (prefix != null && !prefix.equals("")) {
- baseName = prefix + " " + baseName;
+ String translatedPrefix = StatCollector.translateToLocal("prefix." + Variables.MODID + "." + prefix);
+ baseName = translatedPrefix + " " + baseName;
}
-
+
if (suffix != null && !suffix.equals("")) {
- baseName = baseName + " of " + suffix;
+ String translatedSuffix = StatCollector.translateToLocal("suffix." + Variables.MODID + "." + suffix);
+
+ baseName = baseName + " " + translatedSuffix;
}
-
+
return baseName;
}
@@ -114,14 +119,39 @@ public abstract class ItemBaseJewelry extends Item {
+ EnumChatFormatting.BLUE + gem.getDisplayName());
}
- ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack);
+ if (player.isSneaking()) {
+ ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack);
- if (!modifier.isEmpty()) {
- list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": ");
- }
+ if (!modifier.isEmpty()) {
+ list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": ");
+ }
+
+ for (ItemStack is : modifier) {
+ list.add(EnumChatFormatting.DARK_PURPLE + is.getDisplayName() + " x" + is.stackSize);
+ }
- for (ItemStack is : modifier) {
- list.add(EnumChatFormatting.DARK_PURPLE + is.getDisplayName() + " x" + is.stackSize);
+ String prefix = JewelryNBT.prefix(stack);
+ String suffix = JewelryNBT.suffix(stack);
+
+ if (prefix != null && !prefix.equals("")) {
+ String translatedPrefix = StatCollector
+ .translateToLocal("prefix." + Variables.MODID + "." + prefix);
+ String translatedDesc = StatCollector
+ .translateToLocal("prefix." + Variables.MODID + "." + prefix + ".desc");
+
+ list.add(translatedPrefix + ": " + translatedDesc);
+ }
+
+ if (suffix != null && !suffix.equals("")) {
+ String translatedSuffix = StatCollector
+ .translateToLocal("suffix." + Variables.MODID + "." + prefix);
+ String translatedDesc = StatCollector
+ .translateToLocal("suffix." + Variables.MODID + "." + prefix + ".desc");
+
+ list.add(translatedSuffix + ": " + translatedDesc);
+ }
+ } else {
+ list.add("<Sneak to see modifier info>");
}
}
}
@@ -136,12 +166,14 @@ public abstract class ItemBaseJewelry extends Item {
mod.action(item, player, this);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.action(item, player, this);
- if (suffix != null) suffix.action(item, player, this);
+
+ if (prefix != null)
+ prefix.action(item, player, this);
+ if (suffix != null)
+ suffix.action(item, player, this);
}
/**
@@ -152,30 +184,33 @@ public abstract class ItemBaseJewelry extends Item {
*/
public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount) {
boolean cancelEvent = false;
-
+
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
cancelEvent = mod.onPlayerAttackedCancellable(item, player, source, this, amount);
-
- if (cancelEvent) return true;
+
+ if (cancelEvent)
+ return true;
}
}
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
+
if (prefix != null) {
cancelEvent = prefix.onPlayerAttackedCancellable(item, player, source, this, amount);
-
- if (cancelEvent) return true;
+
+ if (cancelEvent)
+ return true;
}
-
+
if (suffix != null) {
cancelEvent = suffix.onPlayerAttackedCancellable(item, player, source, this, amount);
-
- if (cancelEvent) return true;
+
+ if (cancelEvent)
+ return true;
}
-
+
return cancelEvent;
}
@@ -185,32 +220,36 @@ public abstract class ItemBaseJewelry extends Item {
* @param target
* @return
*/
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount) {
+ public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target,
+ LivingAttackEvent event) {
boolean cancelEvent = false;
-
+
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- cancelEvent = mod.onEntityAttackedCancellable(item, player, target, this, amount);
-
- if (cancelEvent) return true;
+ cancelEvent = mod.onEntityAttackedCancellable(item, player, target, this, event);
+
+ if (cancelEvent)
+ return true;
}
}
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
+
if (prefix != null) {
- cancelEvent = prefix.onEntityAttackedCancellable(item, player, target, this, amount);
-
- if (cancelEvent) return true;
+ cancelEvent = prefix.onEntityAttackedCancellable(item, player, target, this, event);
+
+ if (cancelEvent)
+ return true;
}
-
+
if (suffix != null) {
- cancelEvent = suffix.onEntityAttackedCancellable(item, player, target, this, amount);
-
- if (cancelEvent) return true;
+ cancelEvent = suffix.onEntityAttackedCancellable(item, player, target, this, event);
+
+ if (cancelEvent)
+ return true;
}
-
+
return cancelEvent;
}
@@ -226,12 +265,14 @@ public abstract class ItemBaseJewelry extends Item {
mod.onPlayerAttacked(item, player, source, this, amount);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onPlayerAttacked(item, player, source, this, amount);
- if (suffix != null) suffix.onPlayerAttacked(item, player, source, this, amount);
+
+ if (prefix != null)
+ prefix.onPlayerAttacked(item, player, source, this, amount);
+ if (suffix != null)
+ suffix.onPlayerAttacked(item, player, source, this, amount);
}
/**
@@ -240,18 +281,20 @@ public abstract class ItemBaseJewelry extends Item {
* @param target
* @return
*/
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount) {
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, LivingAttackEvent event) {
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- mod.onEntityAttacked(item, player, target, this, amount);
+ mod.onEntityAttacked(item, player, target, this, event);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onEntityAttacked(item, player, target, this, amount);
- if (suffix != null) suffix.onEntityAttacked(item, player, target, this, amount);
+
+ if (prefix != null)
+ prefix.onEntityAttacked(item, player, target, this, event);
+ if (suffix != null)
+ suffix.onEntityAttacked(item, player, target, this, event);
}
public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source) {
@@ -263,9 +306,11 @@ public abstract class ItemBaseJewelry extends Item {
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onPlayerDead(item, player, source, this);
- if (suffix != null) suffix.onPlayerDead(item, player, source, this);
+
+ if (prefix != null)
+ prefix.onPlayerDead(item, player, source, this);
+ if (suffix != null)
+ suffix.onPlayerDead(item, player, source, this);
}
public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event) {
@@ -277,36 +322,60 @@ public abstract class ItemBaseJewelry extends Item {
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onPlayerRespawn(item, event, this);
- if (suffix != null) suffix.onPlayerRespawn(item, event, this);
+
+ if (prefix != null)
+ prefix.onPlayerRespawn(item, event, this);
+ if (suffix != null)
+ suffix.onPlayerRespawn(item, event, this);
}
- public void onJewelryEquipped(ItemStack item) {
+ public void onJewelryEquipped(ItemStack item, EntityPlayer player) {
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- mod.onJewelryEquipped(item, this);
+ mod.onJewelryEquipped(item, this, player);
}
}
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onJewelryEquipped(item, this);
- if (suffix != null) suffix.onJewelryEquipped(item, this);
+
+ if (prefix != null)
+ prefix.onJewelryEquipped(item, this, player);
+ if (suffix != null)
+ suffix.onJewelryEquipped(item, this, player);
}
- public void onJewelryUnequipped(ItemStack item) {
+ public void onJewelryUnequipped(ItemStack item, EntityPlayer player) {
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- mod.onJewelryUnequipped(item, this);
+ mod.onJewelryUnequipped(item, this, player);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onJewelryUnequipped(item, this);
- if (suffix != null) suffix.onJewelryUnequipped(item, this);
+
+ if (prefix != null)
+ prefix.onJewelryUnequipped(item, this, player);
+
+ if (suffix != null)
+ suffix.onJewelryUnequipped(item, this, player);
+ }
+
+ public void onLivingDropItems(ItemStack item, EntityPlayer player, LivingDropsEvent event) {
+ for (ModifierEffect mod : ModifierEffect.getEffects()) {
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
+ mod.onLivingDropItems(item, player, event, this);
+ }
+ }
+
+ ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
+ ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
+
+ if (prefix != null)
+ prefix.onLivingDropItems(item, player, event, this);
+
+ if (suffix != null)
+ suffix.onLivingDropItems(item, player, event, this);
}
} \ No newline at end of file
diff --git a/src/main/java/darkknight/jewelrycraft/random/WeightedRandomAffix.java b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomAffix.java
new file mode 100644
index 0000000..e0ddaed
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomAffix.java
@@ -0,0 +1,18 @@
+package darkknight.jewelrycraft.random;
+
+import java.util.Random;
+
+import net.minecraft.util.WeightedRandom.Item;
+
+public class WeightedRandomAffix extends Item {
+ private final String affix;
+
+ public WeightedRandomAffix(String affix, int weight) {
+ super(weight);
+ this.affix = affix;
+ }
+
+ public String getAffix(Random random) {
+ return affix;
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java
index 351046b..dba4caa 100755
--- a/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java
+++ b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java
@@ -51,10 +51,15 @@ public class WeightedRandomItem extends WeightedRandom.Item {
public ItemStack getItem(Random random) {
ItemStack itemstack = this.item.copy();
- if (maxMeta > 0)
+
+ if (maxMeta > 0) {
itemstack.setItemDamage(minMeta + random.nextInt(maxMeta - minMeta));
- if (maxItem > 1)
+ }
+
+ 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/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index cdcdd12..1592609 100755
--- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -6,6 +6,7 @@ import java.util.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.affixes.AffixMods;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.item.ItemList;
@@ -45,14 +46,14 @@ public class JewelrycraftUtil {
public static ArrayList<String> jamcraftPlayers = new ArrayList<>();
- private static ArrayList<ItemStack> items = new ArrayList<>();
-
public static ArrayList<WorldGenStructure> structures = new ArrayList<>();
public static Random rand = new Random();
public static EnumCreatureAttribute HEARTS;
+ private static Item[] jewelryTypes;
+
/**
* Adds gems and jewelry to their appropriate lists
*/
@@ -111,9 +112,12 @@ public class JewelrycraftUtil {
@SideOnly(Side.CLIENT)
public static int getColor(ItemStack item) {
for (ItemStack stack : colors.keySet()) {
- if (item != null && item.getItem() != null && stack.getItem() != null
- && item.getItem().equals(stack.getItem()) && item.getItemDamage() == stack.getItemDamage()) {
- return colors.get(stack);
+ if (item != null && item.getItem() != null && stack.getItem() != null) {
+ if (item.getItem().equals(stack.getItem())) {
+ if (item.getItemDamage() == stack.getItemDamage()) {
+ return colors.get(stack);
+ }
+ }
}
}
@@ -123,9 +127,10 @@ public class JewelrycraftUtil {
@SideOnly(Side.CLIENT)
public static int color(ItemStack stack, int pass) {
if (stack != null) {
- if (Item.getIdFromItem(stack.getItem()) > 0
- && stack.getItem().getColorFromItemStack(stack, pass) == 16777215) {
- return (int) Math.random() * 16777215;
+ if (Item.getIdFromItem(stack.getItem()) > 0) {
+ if (stack.getItem().getColorFromItemStack(stack, pass) == 16777215) {
+ return (int) Math.random() * 16777215;
+ }
}
return stack.getItem().getColorFromItemStack(stack, pass);
@@ -159,7 +164,9 @@ public class JewelrycraftUtil {
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
- if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) {
+ String textureBase = texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString();
+
+ if (textureBase.contains("items")) {
textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture);
} else {
textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture);
@@ -169,8 +176,11 @@ public class JewelrycraftUtil {
}
private static boolean isValidBlockFromItem(ItemStack item) {
- return !(Block.getBlockFromItem(item.getItem()) instanceof BlockAir) && !Block.getBlockFromItem(item.getItem())
- .getIcon(0, item.getItemDamage()).getIconName().equals("soul_sand");
+ boolean isAirBlock = Block.getBlockFromItem(item.getItem()) instanceof BlockAir;
+ boolean isSoulSand = Block.getBlockFromItem(item.getItem()).getIcon(0, item.getItemDamage()).getIconName()
+ .equals("soul_sand");
+
+ return !(isAirBlock || isSoulSand);
}
@SideOnly(Side.CLIENT)
@@ -207,10 +217,11 @@ public class JewelrycraftUtil {
NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
int cursePoints;
- if (playerInfo.hasKey("cursePoints"))
+ if (playerInfo.hasKey("cursePoints")) {
cursePoints = (playerInfo.getInteger("cursePoints") + points);
- else
+ } else {
cursePoints = points;
+ }
playerInfo.setInteger("cursePoints", cursePoints);
@@ -257,7 +268,7 @@ public class JewelrycraftUtil {
ArrayList<ItemStack> list = new ArrayList<>();
for (int i = 0; i < 2 + randValue; i++) {
- ItemStack item = objects.get(new Random().nextInt(objects.size()));
+ ItemStack item = getRandomObject();
item.stackSize = 1 + new Random().nextInt(2);
@@ -310,6 +321,7 @@ public class JewelrycraftUtil {
private static boolean isItemStackIn(ItemStack item, Iterator<ItemStack> i) {
while (i.hasNext()) {
ItemStack temp = i.next();
+
if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) {
return true;
}
@@ -358,4 +370,59 @@ public class JewelrycraftUtil {
public static boolean isAchievementUnlocked(EntityPlayer player, Achievement achievement) {
return ((EntityPlayerMP) player).func_147099_x().hasAchievementUnlocked(achievement);
}
+
+ public static ItemStack generateJewelery(Random random) {
+ return generateJewelery(random.nextInt(4), random);
+ }
+
+ public static ItemStack generateJewelery(int type, Random random) {
+ if (jewelryTypes == null) {
+ jewelryTypes = new Item[] { ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings };
+ }
+
+ int effType = Math.max(0, Math.min(3, type));
+
+ ItemStack jewelry = new ItemStack(jewelryTypes[effType]);
+
+ if (JewelrycraftUtil.metal.size() > 0) {
+ ItemStack ingot = getRandomMetal(random);
+
+ JewelryNBT.addMetal(jewelry, ingot);
+ }
+
+ if (JewelrycraftUtil.objects.size() > 0 && random.nextInt(4) != 0) {
+ ArrayList<ItemStack> modifiers = JewelrycraftUtil.addRandomModifiers(random.nextInt(4));
+
+ JewelryNBT.addModifiers(jewelry, modifiers);
+ }
+
+ if (JewelrycraftUtil.gem.size() > 0 && random.nextInt(4) != 0) {
+ ItemStack gem = getRandomGem(random);
+
+ JewelryNBT.addGem(jewelry, gem);
+ }
+
+ String prefix = AffixMods.pickPrefix(random);
+ String suffix = AffixMods.pickSuffix(random);
+
+ if (random.nextBoolean())
+ JewelryNBT.addPrefix(jewelry, prefix);
+
+ if (random.nextBoolean())
+ JewelryNBT.addSuffix(jewelry, suffix);
+
+ return jewelry;
+ }
+
+ public static ItemStack getRandomGem(Random random) {
+ return JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()));
+ }
+
+ public static ItemStack getRandomMetal(Random random) {
+ return JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+ }
+
+ public static ItemStack getRandomObject() {
+ return objects.get(new Random().nextInt(objects.size()));
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java b/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java
index fca251c..59a850a 100755
--- a/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java
@@ -1,5 +1,6 @@
package darkknight.jewelrycraft.worldGen;
+import java.util.ArrayList;
import java.util.Random;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -22,35 +23,69 @@ public class ChestGeneration {
static Random random = new Random();
public static void preInit(FMLPreInitializationEvent e) {
- addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 2), true,
- true, false, false, true);
+ {
+ ItemStack gloves = new ItemStack(ItemList.thiefGloves);
- addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(ItemList.guide), 1, 1, 7), true, true,
- true, true, true, false, true, true);
+ WeightedRandomChestContent wrcc = new WeightedRandomChestContent(gloves, 1, 1, 2);
- addVillageBlacksmithLoot(new WeightedRandomChestContent(new ItemStack(ItemList.shadowIngot), 1, 4, 5));
-
- for (int i = 0; i < 16 && i % 3 == 0; i++)
- addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(BlockList.crystal, 1, i), 1, 3, 3),
- true, true, true, true);
+ addItemToDifferentPlaces(wrcc, true, true, false, false, true);
+ }
- ItemStack special = new ItemStack(jewelry[random.nextInt(4)]);
+ {
+ ItemStack guide = new ItemStack(ItemList.guide);
- int randValue = random.nextInt(4);
+ WeightedRandomChestContent wrcc = new WeightedRandomChestContent(guide, 1, 1, 7);
- if (JewelrycraftUtil.metal.size() > 0) {
- JewelryNBT.addMetal(special, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())));
+ addItemToDifferentPlaces(wrcc, true, true, true, true, true, false, true, true);
}
- if (JewelrycraftUtil.objects.size() > 0) {
- JewelryNBT.addModifiers(special, JewelrycraftUtil.addRandomModifiers(randValue));
+ {
+ ItemStack shadowIngot = new ItemStack(ItemList.shadowIngot);
+
+ addVillageBlacksmithLoot(new WeightedRandomChestContent(shadowIngot, 1, 4, 5));
}
- if (JewelrycraftUtil.gem.size() > 0) {
- JewelryNBT.addGem(special, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())));
+ for (int i = 0; i < 16 && i % 3 == 0; i++) {
+ {
+ ItemStack crystal = new ItemStack(BlockList.crystal, 1, i);
+
+ WeightedRandomChestContent wrcc = new WeightedRandomChestContent(crystal, 1, 3, 3);
+
+ addItemToDifferentPlaces(wrcc, true, true, true, true);
+ }
}
- addItemToDifferentPlaces(new WeightedRandomChestContent(special, 1, 1, 1), true, true, true, true);
+ for (int i = 0; i < 4; i++) {
+ ItemStack special = new ItemStack(jewelry[i]);
+
+ int randValue = random.nextInt(4);
+
+ if (JewelrycraftUtil.metal.size() > 0) {
+ int rint = random.nextInt(JewelrycraftUtil.metal.size());
+
+ ItemStack metal = JewelrycraftUtil.metal.get(rint);
+
+ JewelryNBT.addMetal(special, metal);
+ }
+
+ if (JewelrycraftUtil.objects.size() > 0) {
+ ArrayList<ItemStack> modifiers = JewelrycraftUtil.addRandomModifiers(randValue);
+
+ JewelryNBT.addModifiers(special, modifiers);
+ }
+
+ if (JewelrycraftUtil.gem.size() > 0) {
+ int rint = random.nextInt(JewelrycraftUtil.gem.size());
+
+ ItemStack gem = JewelrycraftUtil.gem.get(rint);
+
+ JewelryNBT.addGem(special, gem);
+ }
+
+ WeightedRandomChestContent wrcc = new WeightedRandomChestContent(special, 1, 1, 1);
+
+ addItemToDifferentPlaces(wrcc, true, true, true, true);
+ }
}
/**
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
index 0580f57..c9fb4be 100755
--- a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
@@ -45,77 +45,109 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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;
+
+ boolean canProceed = canVillageGoDeeper(structureboundingbox)
+ && StructureComponent.findIntersecting(pieces, structureboundingbox) == null;
+
+ return canProceed ? new ComponentJewelry(villagePiece, p5, random, structureboundingbox, p4) : null;
}
@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);
}
+
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++)
+ 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++)
+ }
+ }
+
+ 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++)
+ }
+ }
+
+ 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++)
+ }
+ }
+
+ 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++)
+
+ 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++)
+ 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++)
+
+ 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);
@@ -126,6 +158,7 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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);
@@ -136,16 +169,26 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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++)
+
+ 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,
@@ -158,48 +201,63 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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())
+
+ 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
+ } 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())
+ }
+
+ 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
+ } 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())
+ }
+
+ 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
+ } 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())
+ }
+
+ 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
+ } 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 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 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;
}
@@ -209,18 +267,26 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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)
+
+ 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)
+ } else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) {
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels);
+ }
+
t--;
}
}
@@ -232,18 +298,28 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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())
+
+ if (random.nextBoolean()) {
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), metal);
+ }
+
t--;
}
}
@@ -255,18 +331,28 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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())
+
+ if (random.nextBoolean()) {
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), ores);
+ }
+
t--;
}
}
@@ -278,19 +364,15 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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())));
+ ItemStack jewel = JewelrycraftUtil.generateJewelery(random);
+
displayer.object = jewel;
displayer.quantity = 1;
displayer.hasObject = true;
@@ -303,17 +385,24 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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)
+
+ if (smelter.hasMoltenMetal) {
smelter.quantity = quantity < 0.9F ? 0.1F + Math.round(quantity * 10) / 10
: Math.round(quantity * 10) / 10;
+ }
}
}
}
@@ -323,42 +412,52 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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 - 1);
- molder.mold = new ItemStack(ItemList.molds, 1, meta + 1);
- 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;
+
+ TileEntityMolder molder = (TileEntityMolder) world.getTileEntity(i1, j1, k1);
+
+ if (molder != null && !molder.hasMold)
+ if (hasMold) {
+ int meta = random.nextInt(ItemMolds.moldsItemNames.length - 1);
+
+ molder.mold = new ItemStack(ItemList.molds, 1, meta + 1);
+ molder.hasMold = true;
+
+ if (hasStuff && JewelrycraftUtil.metal.size() > 0) {
+ ItemStack ring = new ItemStack(ItemList.ring);
+ ItemStack necklace = new ItemStack(ItemList.necklace);
+ ItemStack bracelet = new ItemStack(ItemList.bracelet);
+ ItemStack earrings = new ItemStack(ItemList.earrings);
+
+ ItemStack metalIngot = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+
+ JewelryNBT.addMetal(ring, metalIngot.copy());
+ JewelryNBT.addMetal(necklace, metalIngot.copy());
+ JewelryNBT.addMetal(bracelet, metalIngot.copy());
+ JewelryNBT.addMetal(earrings, metalIngot.copy());
+
+ switch (meta) {
+ case 0:
+ molder.jewelBase = metalIngot;
+ break;
+ case 1:
+ molder.jewelBase = ring;
+ break;
+ case 2:
+ molder.jewelBase = necklace;
+ break;
+ case 3:
+ molder.jewelBase = bracelet;
+ break;
+ case 4:
+ molder.jewelBase = earrings;
+ break;
}
+
+ molder.hasJewelBase = true;
}
- }
+ }
}
public void generateFurnace(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb,
@@ -366,16 +465,24 @@ public class ComponentJewelry extends StructureVillagePieces.House1 {
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())
+ 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);
}
}
diff --git a/src/main/resources/assets/jewelrycraft2/lang/en_US.lang b/src/main/resources/assets/jewelrycraft2/lang/en_US.lang
index 35c6fda..9605fec 100755
--- a/src/main/resources/assets/jewelrycraft2/lang/en_US.lang
+++ b/src/main/resources/assets/jewelrycraft2/lang/en_US.lang
@@ -194,3 +194,17 @@ achievement.jewelrycraft.pentagram=Resist Temptation
achievement.jewelrycraft.pentagram.desc=§4Challenge:§7 Do not steal health from entities for a day when Pentagram curse is active. §aReward:§7 You permanently steal 1 extra heart from all entities when the curse is active.
challenge.failed=You failed the challenge:
+
+prefix.jewelrycraft2.health1=Bright
+prefix.jewelrycraft2.health1.desc=+1/2 Heart
+prefix.jewelrycraft2.health2=Solar
+prefix.jewelrycraft2.health2.desc=+1 Heart
+prefix.jewelrycraft2.health3=Vivid
+prefix.jewelrycraft2.health3.desc=+3/2 Hearts
+
+suffix.jewelrycraft2.health1=of the Jackal
+suffix.jewelrycraft2.health1.desc=+1/2 Heart
+suffix.jewelrycraft2.health2=of the Fox
+suffix.jewelrycraft2.health2=+1 Heart
+suffix.jewelrycraft2.health3=of the Wolf
+suffix.jewelrycraft2.health3.desc=+3/2 Hearts \ No newline at end of file