Added new hooks for modifying the items generated in chests during world gen.
This commit is contained in:
parent
cf3bc6a9d9
commit
c3f9fed484
13 changed files with 496 additions and 13 deletions
|
@ -59,7 +59,18 @@ public rq.<init>()V # constructor
|
|||
# RailLogic
|
||||
public ahi
|
||||
public ahi.a(Lahi;)I # getNAdjacentTiles
|
||||
#EntityPlayer
|
||||
# EntityPlayer
|
||||
public og.a(Lnj;)V # joinEntityItemWithWorld
|
||||
#EntityPlayerMP
|
||||
public og.j()V # closeScreen
|
||||
# EntityPlayerMP
|
||||
public atg.a(Lnj;)V # joinEntityItemWithWorld
|
||||
# World Gen Chests Related
|
||||
public gr.T # WorldServer.bonusChestContent
|
||||
public yz.a # StructureMineshaftPieces.mineshaftChestContents
|
||||
public aad.i # ComponentScatteredFeatureDesertPyramid.itemsToGenerateInTemple
|
||||
public aae.l # ComponentScatteredFeatureJunglePyramid.junglePyramidsChestContents
|
||||
public aae.m # ComponentScatteredFeatureJunglePyramid.junglePyramidsDispenserContents
|
||||
public aan.a # ComponentStrongholdChestCorridor.strongholdChestContents
|
||||
public aar.b # ComponentStrongholdLibrary.strongholdLibraryChestContents
|
||||
public aaw.c # ComponentStrongholdRoomCrossing.field_75014_c
|
||||
public abu.a # ComponentVillageHouse2.villageBlacksmithChestContents
|
184
common/net/minecraftforge/common/ChestGenHooks.java
Normal file
184
common/net/minecraftforge/common/ChestGenHooks.java
Normal file
|
@ -0,0 +1,184 @@
|
|||
package net.minecraftforge.common;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ChestGenHooks
|
||||
{
|
||||
//Currently implemented categories for chests/dispensers, Dungeon loot is still in DungeonHooks
|
||||
public static final String MINESHAFT_CORRIDOR = "mineshaftCorridor";
|
||||
public static final String PYRAMID_DESERT_CHEST = "pyramidDesertyChest";
|
||||
public static final String PYRAMID_JUNGLE_CHEST = "pyramidJungleChest";
|
||||
public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser";
|
||||
public static final String STRONGHOLD_CORRIDOR = "strongholdCorridor";
|
||||
public static final String STRONGHOLD_LIBRARY = "strongholdLibrary";
|
||||
public static final String STRONGHOLD_CROSSING = "strongholdCrossing";
|
||||
public static final String VILLAGE_BLACKSMITH = "villageBlacksmith";
|
||||
public static final String BONUS_CHEST = "bonusChest";
|
||||
|
||||
private static final HashMap<String, ChestGenHooks> chestInfo = new HashMap<String, ChestGenHooks>();
|
||||
private static boolean hasInit = false;
|
||||
static
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
private static void init()
|
||||
{
|
||||
if (hasInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
addInfo(MINESHAFT_CORRIDOR, StructureMineshaftPieces.mineshaftChestContents, 3, 7);
|
||||
addInfo(PYRAMID_DESERT_CHEST, ComponentScatteredFeatureDesertPyramid.itemsToGenerateInTemple, 2, 7);
|
||||
addInfo(PYRAMID_JUNGLE_CHEST, ComponentScatteredFeatureJunglePyramid.junglePyramidsChestContents, 2, 7);
|
||||
addInfo(PYRAMID_JUNGLE_DISPENSER, ComponentScatteredFeatureJunglePyramid.junglePyramidsDispenserContents, 2, 2);
|
||||
addInfo(STRONGHOLD_CORRIDOR, ComponentStrongholdChestCorridor.strongholdChestContents, 2, 4);
|
||||
addInfo(STRONGHOLD_LIBRARY, ComponentStrongholdLibrary.strongholdLibraryChestContents, 1, 5);
|
||||
addInfo(STRONGHOLD_CROSSING, ComponentStrongholdRoomCrossing.field_75014_c, 1, 5);
|
||||
addInfo(VILLAGE_BLACKSMITH, ComponentVillageHouse2.villageBlacksmithChestContents, 3, 9);
|
||||
addInfo(BONUS_CHEST, WorldServer.bonusChestContent, 10, 10);
|
||||
}
|
||||
|
||||
private static void addInfo(String category, WeightedRandomChestContent[] items, int min, int max)
|
||||
{
|
||||
chestInfo.put(category, new ChestGenHooks(category, items, min, max));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves, or creates the info class for the specified category.
|
||||
*
|
||||
* @param category The category name
|
||||
* @return A instance of ChestGenHooks for the specified category.
|
||||
*/
|
||||
public static ChestGenHooks getInfo(String category)
|
||||
{
|
||||
if (!chestInfo.containsKey(category))
|
||||
{
|
||||
chestInfo.put(category, new ChestGenHooks(category));
|
||||
}
|
||||
return chestInfo.get(category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an array of items based on the input min/max count.
|
||||
* If the stack can not hold the total amount, it will be split into
|
||||
* stacks of size 1.
|
||||
*
|
||||
* @param rand A random number generator
|
||||
* @param source Source item stack
|
||||
* @param min Minimum number of items
|
||||
* @param max Maximum number of items
|
||||
* @return An array containing the generated item stacks
|
||||
*/
|
||||
public static ItemStack[] generateStacks(Random rand, ItemStack source, int min, int max)
|
||||
{
|
||||
int count = min + (rand.nextInt(max - min + 1));
|
||||
|
||||
ItemStack[] ret;
|
||||
if (source.getItem() == null)
|
||||
{
|
||||
ret = new ItemStack[0];
|
||||
}
|
||||
else if (count > source.getItem().getItemStackLimit())
|
||||
{
|
||||
ret = new ItemStack[count];
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
ret[x] = source.copy();
|
||||
ret[x].stackSize = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = new ItemStack[1];
|
||||
ret[0] = source.copy();
|
||||
ret[0].stackSize = count;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//shortcut functions, See the non-static versions below
|
||||
public static WeightedRandomChestContent[] getItems(String category){ return getInfo(category).getItems(); }
|
||||
public static int getCount(String category, Random rand){ return getInfo(category).getCount(rand); }
|
||||
public static void addItem(String category, WeightedRandomChestContent item){ getInfo(category).addItem(item); }
|
||||
public static void removeItem(String category, ItemStack item){ getInfo(category).removeItem(item); }
|
||||
|
||||
private String category;
|
||||
private int countMin = 0;
|
||||
private int countMax = 0;
|
||||
private ArrayList<WeightedRandomChestContent> contents = new ArrayList<WeightedRandomChestContent>();
|
||||
|
||||
public ChestGenHooks(String category)
|
||||
{
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public ChestGenHooks(String category, WeightedRandomChestContent[] items, int min, int max)
|
||||
{
|
||||
this(category);
|
||||
for (WeightedRandomChestContent item : items)
|
||||
{
|
||||
contents.add(item);
|
||||
}
|
||||
countMin = min;
|
||||
countMax = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new entry into the possible items to generate.
|
||||
*
|
||||
* @param item The item to add.
|
||||
*/
|
||||
public void addItem(WeightedRandomChestContent item)
|
||||
{
|
||||
contents.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all items that match the input item stack, Only metadata and item ID are checked.
|
||||
* If the input item has a metadata of -1, all metadatas will match.
|
||||
*
|
||||
* @param item The item to check
|
||||
*/
|
||||
public void removeItem(ItemStack item)
|
||||
{
|
||||
Iterator<WeightedRandomChestContent> itr = contents.iterator();
|
||||
while(itr.hasNext())
|
||||
{
|
||||
WeightedRandomChestContent cont = itr.next();
|
||||
if (item.isItemEqual(cont.itemStack) || (item.getItemDamage() == -1 && item.itemID == cont.itemStack.itemID))
|
||||
{
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of all random objects that are associated with this category.
|
||||
*
|
||||
* @return The random objects
|
||||
*/
|
||||
public WeightedRandomChestContent[] getItems()
|
||||
{
|
||||
return contents.toArray(new WeightedRandomChestContent[contents.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a random number between countMin and countMax.
|
||||
*
|
||||
* @param rand A RNG
|
||||
* @return A random number where countMin <= num <= countMax
|
||||
*/
|
||||
public int getCount(Random rand)
|
||||
{
|
||||
return countMin < countMax ? countMin + rand.nextInt(countMax - countMin) : countMin;
|
||||
}
|
||||
|
||||
//Accessors
|
||||
public int getMin(){ return countMin; }
|
||||
public int getMax(){ return countMax; }
|
||||
public void setMin(int value){ countMin = value; }
|
||||
public void setMax(int value){ countMax = value; }
|
||||
}
|
|
@ -12,7 +12,7 @@ public class ForgeVersion
|
|||
//This number is incremented every official release, and reset every Minecraft version
|
||||
public static final int minorVersion = 1;
|
||||
//This number is incremented every time a interface changes, and reset every Minecraft version
|
||||
public static final int revisionVersion = 2;
|
||||
public static final int revisionVersion = 3;
|
||||
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
|
||||
public static final int buildVersion = 0;
|
||||
|
||||
|
|
|
@ -3,5 +3,4 @@ de.fu_berlin.inf.dpp.annotations.contribution.color.2=171,168,117
|
|||
eclipse.preferences.version=1
|
||||
lineNumberRuler=true
|
||||
overviewRuler_migration=migrated_3.1
|
||||
showWhitespaceCharacters=true
|
||||
spacesForTabs=true
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentMineshaftCorridor.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentMineshaftCorridor.java
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentMineshaftCorridor extends StructureComponent
|
||||
{
|
||||
@@ -231,14 +234,16 @@
|
||||
this.randomlyPlaceBlock(par1World, par3StructureBoundingBox, par2Random, 0.05F, 1, 2, var10 - 1, Block.torchWood.blockID, 0);
|
||||
this.randomlyPlaceBlock(par1World, par3StructureBoundingBox, par2Random, 0.05F, 1, 2, var10 + 1, Block.torchWood.blockID, 0);
|
||||
|
||||
+ ChestGenHooks info = ChestGenHooks.getInfo(MINESHAFT_CORRIDOR);
|
||||
+
|
||||
if (par2Random.nextInt(100) == 0)
|
||||
{
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 2, 0, var10 - 1, StructureMineshaftPieces.func_78816_a(), 3 + par2Random.nextInt(4));
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 2, 0, var10 - 1, info.getItems(), info.getCount(par2Random));
|
||||
}
|
||||
|
||||
if (par2Random.nextInt(100) == 0)
|
||||
{
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 0, 0, var10 + 1, StructureMineshaftPieces.func_78816_a(), 3 + par2Random.nextInt(4));
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 0, 0, var10 + 1, info.getItems(), info.getCount(par2Random));
|
||||
}
|
||||
|
||||
if (this.hasSpiders && !this.spawnerPlaced)
|
|
@ -0,0 +1,21 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentScatteredFeatureDesertPyramid.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentScatteredFeatureDesertPyramid.java
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentScatteredFeatureDesertPyramid extends ComponentScatteredFeature
|
||||
{
|
||||
@@ -216,7 +219,7 @@
|
||||
{
|
||||
int var11 = Direction.offsetX[var10] * 2;
|
||||
int var12 = Direction.offsetZ[var10] * 2;
|
||||
- this.field_74940_h[var10] = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 10 + var11, -11, 10 + var12, itemsToGenerateInTemple, 2 + par2Random.nextInt(5));
|
||||
+ this.field_74940_h[var10] = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 10 + var11, -11, 10 + var12, ChestGenHooks.getItems(PYRAMID_DESERT_CHEST), ChestGenHooks.getCount(PYRAMID_DESERT_CHEST, par2Random));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentScatteredFeatureJunglePyramid.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentScatteredFeatureJunglePyramid.java
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentScatteredFeatureJunglePyramid extends ComponentScatteredFeature
|
||||
{
|
||||
@@ -159,9 +162,12 @@
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.redstoneWire.blockID, 0, 4, -3, 1, par3StructureBoundingBox);
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.cobblestoneMossy.blockID, 0, 3, -3, 1, par3StructureBoundingBox);
|
||||
|
||||
+ ChestGenHooks dispenser = ChestGenHooks.getInfo(PYRAMID_JUNGLE_DISPENSER);
|
||||
+ ChestGenHooks chest = ChestGenHooks.getInfo(PYRAMID_JUNGLE_CHEST);
|
||||
+
|
||||
if (!this.field_74945_j)
|
||||
{
|
||||
- this.field_74945_j = this.generateStructureDispenserContents(par1World, par3StructureBoundingBox, par2Random, 3, -2, 1, 2, junglePyramidsDispenserContents, 2);
|
||||
+ this.field_74945_j = this.generateStructureDispenserContents(par1World, par3StructureBoundingBox, par2Random, 3, -2, 1, 2, dispenser.getItems(), dispenser.getCount(par2Random));
|
||||
}
|
||||
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.vine.blockID, 15, 3, -2, 2, par3StructureBoundingBox);
|
||||
@@ -178,7 +184,7 @@
|
||||
|
||||
if (!this.field_74946_k)
|
||||
{
|
||||
- this.field_74946_k = this.generateStructureDispenserContents(par1World, par3StructureBoundingBox, par2Random, 9, -2, 3, 4, junglePyramidsDispenserContents, 2);
|
||||
+ this.field_74946_k = this.generateStructureDispenserContents(par1World, par3StructureBoundingBox, par2Random, 9, -2, 3, 4, dispenser.getItems(), dispenser.getCount(par2Random));
|
||||
}
|
||||
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.vine.blockID, 15, 8, -1, 3, par3StructureBoundingBox);
|
||||
@@ -186,7 +192,7 @@
|
||||
|
||||
if (!this.field_74947_h)
|
||||
{
|
||||
- this.field_74947_h = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 8, -3, 3, junglePyramidsChestContents, 2 + par2Random.nextInt(5));
|
||||
+ this.field_74947_h = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 8, -3, 3, chest.getItems(), chest.getCount(par2Random));
|
||||
}
|
||||
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.cobblestoneMossy.blockID, 0, 9, -3, 2, par3StructureBoundingBox);
|
||||
@@ -219,7 +225,7 @@
|
||||
|
||||
if (!this.field_74948_i)
|
||||
{
|
||||
- this.field_74948_i = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 9, -3, 10, junglePyramidsChestContents, 2 + par2Random.nextInt(5));
|
||||
+ this.field_74948_i = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 9, -3, 10, chest.getItems(), chest.getCount(par2Random));
|
||||
}
|
||||
|
||||
return true;
|
|
@ -0,0 +1,21 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentStrongholdChestCorridor.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentStrongholdChestCorridor.java
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentStrongholdChestCorridor extends ComponentStronghold
|
||||
{
|
||||
@@ -68,7 +71,7 @@
|
||||
if (par3StructureBoundingBox.isVecInside(var5, var4, var6))
|
||||
{
|
||||
this.hasMadeChest = true;
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 2, 3, strongholdChestContents, 2 + par2Random.nextInt(2));
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 2, 3, ChestGenHooks.getItems(STRONGHOLD_CORRIDOR), ChestGenHooks.getCount(STRONGHOLD_CORRIDOR, par2Random));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentStrongholdLibrary.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentStrongholdLibrary.java
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentStrongholdLibrary extends ComponentStronghold
|
||||
{
|
||||
@@ -141,12 +144,13 @@
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.torchWood.blockID, 0, var8, 8, var9 + 1, par3StructureBoundingBox);
|
||||
}
|
||||
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 3, 5, strongholdLibraryChestContents, 1 + par2Random.nextInt(4));
|
||||
+ ChestGenHooks info = ChestGenHooks.getInfo(STRONGHOLD_LIBRARY);
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 3, 5, info.getItems(), info.getCount(par2Random));
|
||||
|
||||
if (this.isLargeRoom)
|
||||
{
|
||||
this.placeBlockAtCurrentPosition(par1World, 0, 0, 12, 9, 1, par3StructureBoundingBox);
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 12, 8, 1, strongholdLibraryChestContents, 1 + par2Random.nextInt(4));
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 12, 8, 1, info.getItems(), info.getCount(par2Random));
|
||||
}
|
||||
|
||||
return true;
|
|
@ -0,0 +1,21 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentStrongholdRoomCrossing.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentStrongholdRoomCrossing.java
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentStrongholdRoomCrossing extends ComponentStronghold
|
||||
{
|
||||
@@ -137,7 +140,7 @@
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.ladder.blockID, this.getMetadataWithOffset(Block.ladder.blockID, 4), 9, 1, 3, par3StructureBoundingBox);
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.ladder.blockID, this.getMetadataWithOffset(Block.ladder.blockID, 4), 9, 2, 3, par3StructureBoundingBox);
|
||||
this.placeBlockAtCurrentPosition(par1World, Block.ladder.blockID, this.getMetadataWithOffset(Block.ladder.blockID, 4), 9, 3, 3, par3StructureBoundingBox);
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 4, 8, field_75014_c, 1 + par2Random.nextInt(4));
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 4, 8, ChestGenHooks.getItems(STRONGHOLD_CROSSING), ChestGenHooks.getCount(STRONGHOLD_CROSSING, par2Random));
|
||||
}
|
||||
|
||||
return true;
|
|
@ -0,0 +1,21 @@
|
|||
--- ../src_base/common/net/minecraft/src/ComponentVillageHouse2.java
|
||||
+++ ../src_work/common/net/minecraft/src/ComponentVillageHouse2.java
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
|
||||
public class ComponentVillageHouse2 extends ComponentVillage
|
||||
{
|
||||
@@ -88,7 +91,7 @@
|
||||
if (par3StructureBoundingBox.isVecInside(var5, var4, var6))
|
||||
{
|
||||
this.hasMadeChest = true;
|
||||
- this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 5, 1, 5, villageBlacksmithChestContents, 3 + par2Random.nextInt(6));
|
||||
+ this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 5, 1, 5, ChestGenHooks.getItems(VILLAGE_BLACKSMITH), ChestGenHooks.getCount(VILLAGE_BLACKSMITH, par2Random));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
--- ../src_base/common/net/minecraft/src/WeightedRandomChestContent.java
|
||||
+++ ../src_work/common/net/minecraft/src/WeightedRandomChestContent.java
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
+
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
|
||||
public class WeightedRandomChestContent extends WeightedRandomItem
|
||||
{
|
||||
@@ -15,6 +17,8 @@
|
||||
|
||||
/** The maximum chance of item generating. */
|
||||
private int theMaximumChanceToGenerateItem;
|
||||
+
|
||||
+ public final ItemStack itemStack;
|
||||
|
||||
public WeightedRandomChestContent(int par1, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
@@ -23,8 +27,16 @@
|
||||
this.theItemDamage = par2;
|
||||
this.theMinimumChanceToGenerateItem = par3;
|
||||
this.theMaximumChanceToGenerateItem = par4;
|
||||
+ itemStack = new ItemStack(par1, 1, par2);
|
||||
}
|
||||
-
|
||||
+
|
||||
+ public WeightedRandomChestContent(ItemStack stack, int min, int max, int weight)
|
||||
+ {
|
||||
+ super(weight);
|
||||
+ itemStack = stack;
|
||||
+ theMinimumChanceToGenerateItem = min;
|
||||
+ theMaximumChanceToGenerateItem = max;
|
||||
+ }
|
||||
/**
|
||||
* Generates the Chest contents.
|
||||
*/
|
||||
@@ -33,18 +45,11 @@
|
||||
for (int var4 = 0; var4 < par3; ++var4)
|
||||
{
|
||||
WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent);
|
||||
- int var6 = var5.theMinimumChanceToGenerateItem + par0Random.nextInt(var5.theMaximumChanceToGenerateItem - var5.theMinimumChanceToGenerateItem + 1);
|
||||
+ ItemStack[] stacks = ChestGenHooks.generateStacks(par0Random, var5.itemStack, var5.theMinimumChanceToGenerateItem, var5.theMinimumChanceToGenerateItem);
|
||||
|
||||
- if (Item.itemsList[var5.theItemId].getItemStackLimit() >= var6)
|
||||
+ for (ItemStack item : stacks)
|
||||
{
|
||||
- par2TileEntityChest.setInventorySlotContents(par0Random.nextInt(par2TileEntityChest.getSizeInventory()), new ItemStack(var5.theItemId, var6, var5.theItemDamage));
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- for (int var7 = 0; var7 < var6; ++var7)
|
||||
- {
|
||||
- par2TileEntityChest.setInventorySlotContents(par0Random.nextInt(par2TileEntityChest.getSizeInventory()), new ItemStack(var5.theItemId, 1, var5.theItemDamage));
|
||||
- }
|
||||
+ par2TileEntityChest.setInventorySlotContents(par0Random.nextInt(par2TileEntityChest.getSizeInventory()), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,18 +62,11 @@
|
||||
for (int var4 = 0; var4 < par3; ++var4)
|
||||
{
|
||||
WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent);
|
||||
- int var6 = var5.theMinimumChanceToGenerateItem + par0Random.nextInt(var5.theMaximumChanceToGenerateItem - var5.theMinimumChanceToGenerateItem + 1);
|
||||
+ ItemStack[] stacks = ChestGenHooks.generateStacks(par0Random, var5.itemStack, var5.theMinimumChanceToGenerateItem, var5.theMinimumChanceToGenerateItem);
|
||||
|
||||
- if (Item.itemsList[var5.theItemId].getItemStackLimit() >= var6)
|
||||
+ for (ItemStack item : stacks)
|
||||
{
|
||||
- par2TileEntityDispenser.setInventorySlotContents(par0Random.nextInt(par2TileEntityDispenser.getSizeInventory()), new ItemStack(var5.theItemId, var6, var5.theItemDamage));
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- for (int var7 = 0; var7 < var6; ++var7)
|
||||
- {
|
||||
- par2TileEntityDispenser.setInventorySlotContents(par0Random.nextInt(par2TileEntityDispenser.getSizeInventory()), new ItemStack(var5.theItemId, 1, var5.theItemDamage));
|
||||
- }
|
||||
+ par2TileEntityDispenser.setInventorySlotContents(par0Random.nextInt(par2TileEntityDispenser.getSizeInventory()), item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,18 @@
|
|||
--- ../src_base/common/net/minecraft/src/WorldServer.java
|
||||
+++ ../src_work/common/net/minecraft/src/WorldServer.java
|
||||
@@ -10,6 +10,9 @@
|
||||
@@ -10,6 +10,11 @@
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraftforge.common.ChestGenHooks;
|
||||
+import static net.minecraftforge.common.ChestGenHooks.*;
|
||||
+import net.minecraftforge.common.DimensionManager;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
public class WorldServer extends World
|
||||
{
|
||||
@@ -71,6 +74,7 @@
|
||||
@@ -71,6 +76,7 @@
|
||||
{
|
||||
this.pendingTickListEntries = new TreeSet();
|
||||
}
|
||||
|
@ -18,7 +20,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -179,10 +183,7 @@
|
||||
@@ -179,10 +185,7 @@
|
||||
|
||||
private void resetRainAndThunder()
|
||||
{
|
||||
|
@ -30,7 +32,7 @@
|
|||
}
|
||||
|
||||
public boolean areAllPlayersAsleep()
|
||||
@@ -270,7 +271,7 @@
|
||||
@@ -270,7 +273,7 @@
|
||||
int var10;
|
||||
int var11;
|
||||
|
||||
|
@ -39,7 +41,7 @@
|
|||
{
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
var8 = this.updateLCG >> 2;
|
||||
@@ -288,7 +289,7 @@
|
||||
@@ -288,7 +291,7 @@
|
||||
this.theProfiler.endStartSection("iceandsnow");
|
||||
int var13;
|
||||
|
||||
|
@ -48,7 +50,7 @@
|
|||
{
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
var8 = this.updateLCG >> 2;
|
||||
@@ -559,15 +560,27 @@
|
||||
@@ -559,15 +562,27 @@
|
||||
public List getAllTileEntityInBox(int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
ArrayList var7 = new ArrayList();
|
||||
|
@ -85,7 +87,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -578,6 +591,11 @@
|
||||
@@ -578,6 +593,11 @@
|
||||
* Called when checking if a certain block can be mined or not. The 'spawn safe zone' check is located here.
|
||||
*/
|
||||
public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4)
|
||||
|
@ -97,7 +99,7 @@
|
|||
{
|
||||
int var5 = MathHelper.abs_int(par2 - this.worldInfo.getSpawnX());
|
||||
int var6 = MathHelper.abs_int(par4 - this.worldInfo.getSpawnZ());
|
||||
@@ -587,7 +605,7 @@
|
||||
@@ -587,7 +607,7 @@
|
||||
var6 = var5;
|
||||
}
|
||||
|
||||
|
@ -106,7 +108,16 @@
|
|||
}
|
||||
|
||||
protected void initialize(WorldSettings par1WorldSettings)
|
||||
@@ -713,6 +731,7 @@
|
||||
@@ -670,7 +690,7 @@
|
||||
*/
|
||||
protected void createBonusChest()
|
||||
{
|
||||
- WorldGeneratorBonusChest var1 = new WorldGeneratorBonusChest(bonusChestContent, 10);
|
||||
+ WorldGeneratorBonusChest var1 = new WorldGeneratorBonusChest(ChestGenHooks.getItems(BONUS_CHEST), ChestGenHooks.getCount(BONUS_CHEST, rand));
|
||||
|
||||
for (int var2 = 0; var2 < 10; ++var2)
|
||||
{
|
||||
@@ -713,6 +733,7 @@
|
||||
}
|
||||
|
||||
this.chunkProvider.saveChunks(par1, par2IProgressUpdate);
|
||||
|
|
Loading…
Reference in a new issue