THE UPDATE

Merging months of dev work into master. The update is playable, but
untested.
This commit is contained in:
StevenRS11
2013-11-05 18:15:23 -05:00
parent be89913263
commit a04a266c17
154 changed files with 8826 additions and 8272 deletions

View File

@@ -58,7 +58,7 @@ public class DDLoot {
addContent(properties.DimensionalDoorLootEnabled, items, mod_pocketDim.itemDimDoor.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.WarpDoorLootEnabled, items, mod_pocketDim.itemExitDoor.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.TransTrapdoorLootEnabled, items, mod_pocketDim.dimHatch.blockID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.TransTrapdoorLootEnabled, items, mod_pocketDim.transTrapdoor.blockID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.RiftSignatureLootEnabled, items, mod_pocketDim.itemLinkSignature.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.StableFabricLootEnabled, items, mod_pocketDim.itemStableFabric.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.RiftRemoverLootEnabled, items, mod_pocketDim.itemRiftRemover.itemID, UNCOMMON_LOOT_WEIGHT);
@@ -78,9 +78,6 @@ public class DDLoot {
//because the items in that category have strange weights that are incompatible with all other
//chest categories.
//This function has a flaw. It treats items with the same item ID but different damage values as
//the same item. For instance, it cannot distinguish between different types of wood. That shouldn't
//matter for most chest loot, though. This could be fixed if we cared enough.
Random random = new Random();
HashMap<Integer, WeightedRandomChestContent> container = new HashMap<Integer, WeightedRandomChestContent>();
@@ -89,7 +86,9 @@ public class DDLoot {
WeightedRandomChestContent[] items = ChestGenHooks.getItems(category, random);
for (WeightedRandomChestContent item : items)
{
int id = item.theItemId.itemID;
ItemStack stack = item.theItemId;
int id = stack.itemID;
int subtype = stack.getItem().getHasSubtypes() ? stack.getItemDamage() : 0;
//Correct the weights of Vanilla dungeon chests (DUNGEON_CHEST)
//Comparing by String references is valid here since they should match!
@@ -100,20 +99,25 @@ public class DDLoot {
item.itemWeight /= DUNGEON_CHEST_WEIGHT_INFLATION;
if (item.itemWeight == 0)
item.itemWeight = 1;
}
if (!container.containsKey(id))
}
//Generate an identifier for this item using its item ID and damage value,
//if it has subtypes. This solves the issue of matching items that have
//the same item ID but different subtypes (e.g. wood planks, dyes).
int key = ((subtype & 0xFFFF) << 16) + ((id & 0xFFFF) << 16);
WeightedRandomChestContent other = container.get(key);
if (other == null)
{
//This item has not been seen before. Simply add it to the container.
container.put(id, item);
container.put(key, item);
}
else
{
//This item conflicts with an existing entry. Replace that entry
//if our current item has a lower weight.
WeightedRandomChestContent other = container.get(id);
if (item.itemWeight < other.itemWeight)
{
container.put(id, item);
container.put(key, item);
}
}
}
@@ -127,7 +131,7 @@ public class DDLoot {
{
if (item.theItemId.itemID == enchantedBookID)
{
item.itemWeight = 3;
item.itemWeight = 4;
break;
}
}