Remove more chestgenhooks stuff. Clean up some more ATs
This commit is contained in:
parent
25256c8ddd
commit
56a0d125bd
|
@ -1,32 +0,0 @@
|
||||||
--- ../src-base/minecraft/net/minecraft/util/WeightedRandomChestContent.java
|
|
||||||
+++ ../src-work/minecraft/net/minecraft/util/WeightedRandomChestContent.java
|
|
||||||
@@ -20,11 +20,29 @@
|
|
||||||
this.maxStackSize = maximumChance;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // -- Forge hooks
|
|
||||||
+ /**
|
|
||||||
+ * Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup
|
|
||||||
+ *
|
|
||||||
+ * @param random The current random for generation
|
|
||||||
+ * @param newInventory The inventory being generated (do not populate it, but you can refer to it)
|
|
||||||
+ * @return An array of {@link ItemStack} to put into the chest
|
|
||||||
+ */
|
|
||||||
+ @Deprecated // New loottable system shouldn't need this. Need to research more.
|
|
||||||
+ protected ItemStack[] generateChestContent(Random random, net.minecraft.inventory.IInventory newInventory)
|
|
||||||
+ {
|
|
||||||
+ return net.minecraftforge.common.ChestGenHooks.generateStacks(random, theItemId, minStackSize, maxStackSize);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
public static void generateDispenserContents(Random random, List<WeightedRandomChestContent> listIn, TileEntityDispenser dispenser, int max)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < max; ++i)
|
|
||||||
{
|
|
||||||
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, listIn);
|
|
||||||
+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(random, dispenser);
|
|
||||||
+ for (ItemStack stack : stacks)
|
|
||||||
+ dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), stack);
|
|
||||||
+ if (true) continue; // Forge: Skip the rest we replace it.
|
|
||||||
int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1);
|
|
||||||
|
|
||||||
if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j)
|
|
|
@ -1,35 +0,0 @@
|
||||||
--- ../src-base/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java
|
|
||||||
+++ ../src-work/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java
|
|
||||||
@@ -451,6 +451,11 @@
|
|
||||||
private static final List<WeightedRandomChestContent> field_175815_j = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.arrow, 0, 2, 7, 30)});
|
|
||||||
private static ComponentScatteredFeaturePieces.JunglePyramid.Stones junglePyramidsRandomScatteredStones = new ComponentScatteredFeaturePieces.JunglePyramid.Stones();
|
|
||||||
|
|
||||||
+ static
|
|
||||||
+ {
|
|
||||||
+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, field_175815_j, 2, 2);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
public JunglePyramid()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -607,9 +612,10 @@
|
|
||||||
this.setBlockState(worldIn, Blocks.redstone_wire.getDefaultState(), 4, -3, 1, structureBoundingBoxIn);
|
|
||||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getDefaultState(), 3, -3, 1, structureBoundingBoxIn);
|
|
||||||
|
|
||||||
+ net.minecraftforge.common.ChestGenHooks dispenser = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER);
|
|
||||||
if (!this.field_74945_j)
|
|
||||||
{
|
|
||||||
- this.field_74945_j = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, EnumFacing.NORTH, field_175815_j, 2);
|
|
||||||
+ this.field_74945_j = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, EnumFacing.NORTH, dispenser.getItems(randomIn), dispenser.getCount(randomIn));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setBlockState(worldIn, Blocks.vine.getDefaultState().withProperty(BlockVine.SOUTH, Boolean.valueOf(true)), 3, -2, 2, structureBoundingBoxIn);
|
|
||||||
@@ -626,7 +632,7 @@
|
|
||||||
|
|
||||||
if (!this.field_74946_k)
|
|
||||||
{
|
|
||||||
- this.field_74946_k = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, EnumFacing.WEST, field_175815_j, 2);
|
|
||||||
+ this.field_74946_k = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, EnumFacing.WEST, dispenser.getItems(randomIn), dispenser.getCount(randomIn));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setBlockState(worldIn, Blocks.vine.getDefaultState().withProperty(BlockVine.EAST, Boolean.valueOf(true)), 8, -1, 3, structureBoundingBoxIn);
|
|
|
@ -1,230 +0,0 @@
|
||||||
package net.minecraftforge.common;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.WeightedRandom;
|
|
||||||
import net.minecraft.util.WeightedRandomChestContent;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraft.world.gen.feature.WorldGenDungeons;
|
|
||||||
import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.DesertPyramid;
|
|
||||||
import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.JunglePyramid;
|
|
||||||
import net.minecraft.world.gen.structure.StructureMineshaftPieces;
|
|
||||||
import net.minecraft.world.gen.structure.StructureNetherBridgePieces;
|
|
||||||
import net.minecraft.world.gen.structure.StructureOceanMonument;
|
|
||||||
import net.minecraft.world.gen.structure.StructureStrongholdPieces;
|
|
||||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
public class ChestGenHooks
|
|
||||||
{
|
|
||||||
//Currently implemented categories for chests/dispensers, Dungeon loot is still in DungeonHooks
|
|
||||||
public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser"; // TODO: Convert to a Loot Table
|
|
||||||
public static final String BONUS_CHEST = "bonusChest";
|
|
||||||
public static final String DUNGEON_CHEST = "dungeonChest";
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasInit = true;
|
|
||||||
// This causes the classes static initializers to run
|
|
||||||
new WorldGenDungeons();
|
|
||||||
new JunglePyramid();
|
|
||||||
WorldServer.fillChestHook();
|
|
||||||
}
|
|
||||||
|
|
||||||
// INTERNAL DO NO USE
|
|
||||||
public static void init(String category, List<WeightedRandomChestContent> items, int min, int max)
|
|
||||||
{
|
|
||||||
chestInfo.put(category, new ChestGenHooks(category, items, min, max));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void addDungeonLoot(ChestGenHooks dungeon, ItemStack item, int weight, int min, int max)
|
|
||||||
{
|
|
||||||
dungeon.addItem(new WeightedRandomChestContent(item, min, max, weight));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.getMaxStackSize())
|
|
||||||
{
|
|
||||||
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 List<WeightedRandomChestContent> getItems(String category, Random rnd){ return getInfo(category).getItems(rnd); }
|
|
||||||
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); }
|
|
||||||
public static ItemStack getOneItem(String category, Random rand){ return getInfo(category).getOneItem(rand); }
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
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, List<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.theItemId) || (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() == cont.theItemId.getItem()))
|
|
||||||
{
|
|
||||||
itr.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an array of all random objects that are associated with this category.
|
|
||||||
*
|
|
||||||
* @return The random objects
|
|
||||||
*/
|
|
||||||
public List<WeightedRandomChestContent> getItems(Random rnd)
|
|
||||||
{
|
|
||||||
ArrayList<WeightedRandomChestContent> ret = new ArrayList<WeightedRandomChestContent>();
|
|
||||||
|
|
||||||
for (WeightedRandomChestContent orig : contents)
|
|
||||||
{
|
|
||||||
Item item = orig.theItemId.getItem();
|
|
||||||
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
WeightedRandomChestContent n = item.getChestGenBase(this, rnd, orig);
|
|
||||||
if (n != null)
|
|
||||||
{
|
|
||||||
ret.add(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a single ItemStack from the possible items in this registry,
|
|
||||||
* Useful if you just want a quick and dirty random Item.
|
|
||||||
*
|
|
||||||
* @param rand A Random Number gen
|
|
||||||
* @return A single ItemStack, or null if it could not get one.
|
|
||||||
*/
|
|
||||||
public ItemStack getOneItem(Random rand)
|
|
||||||
{
|
|
||||||
WeightedRandomChestContent item = (WeightedRandomChestContent)WeightedRandom.getRandomItem(rand, getItems(rand));
|
|
||||||
ItemStack[] stacks = ChestGenHooks.generateStacks(rand, item.theItemId, item.minStackSize, item.maxStackSize);
|
|
||||||
return (stacks.length > 0 ? stacks[0] : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
//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; }
|
|
||||||
}
|
|
|
@ -45,11 +45,11 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
|
||||||
queuedChunk.provider.loadedChunks.add(chunk);
|
queuedChunk.provider.loadedChunks.add(chunk);
|
||||||
chunk.onChunkLoad();
|
chunk.onChunkLoad();
|
||||||
|
|
||||||
if (queuedChunk.provider.serverChunkGenerator != null) {
|
if (queuedChunk.provider.field_186029_c != null) {
|
||||||
queuedChunk.provider.serverChunkGenerator.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
|
queuedChunk.provider.field_186029_c.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
|
chunk.func_186030_a(queuedChunk.provider, queuedChunk.provider.field_186029_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callStage3(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk, Runnable runnable) throws RuntimeException {
|
public void callStage3(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk, Runnable runnable) throws RuntimeException {
|
||||||
|
|
|
@ -87,7 +87,7 @@ public net.minecraft.world.gen.structure.MapGenStructureIO func_143031_a(Ljava/l
|
||||||
# Stronghold
|
# Stronghold
|
||||||
public net.minecraft.world.gen.structure.StructureStrongholdPieces$Stronghold
|
public net.minecraft.world.gen.structure.StructureStrongholdPieces$Stronghold
|
||||||
# Packets
|
# Packets
|
||||||
#public net.minecraft.network.play.server.S23PacketBlockChange field_148883_d # Block
|
public net.minecraft.network.play.server.SPacketBlockChange field_148883_d # blockState
|
||||||
# WorldType
|
# WorldType
|
||||||
public-f net.minecraft.world.WorldType field_77139_a #worldTypes
|
public-f net.minecraft.world.WorldType field_77139_a #worldTypes
|
||||||
# DamageSource
|
# DamageSource
|
||||||
|
@ -101,10 +101,11 @@ public net.minecraft.world.gen.structure.StructureVillagePieces$Village
|
||||||
# RenderPlayer
|
# RenderPlayer
|
||||||
public net.minecraft.client.renderer.entity.RenderBiped field_77071_a #modelBipedMain
|
public net.minecraft.client.renderer.entity.RenderBiped field_77071_a #modelBipedMain
|
||||||
# ChunkProviderServer
|
# ChunkProviderServer
|
||||||
#public net.minecraft.world.gen.ChunkProviderServer field_73246_d # currentChunkProvider
|
public net.minecraft.world.gen.ChunkProviderServer field_186029_c # chunkGenerator
|
||||||
public net.minecraft.world.gen.ChunkProviderServer field_73244_f # loadedChunkHashMap
|
public net.minecraft.world.gen.ChunkProviderServer field_73244_f # loadedChunkHashMap
|
||||||
public net.minecraft.world.gen.ChunkProviderServer field_73245_g # loadedChunks
|
public net.minecraft.world.gen.ChunkProviderServer field_73245_g # loadedChunks
|
||||||
public net.minecraft.world.gen.ChunkProviderServer field_73251_h # worldObj
|
public net.minecraft.world.gen.ChunkProviderServer field_73251_h # worldObj
|
||||||
|
|
||||||
# RenderEntityItem
|
# RenderEntityItem
|
||||||
protected net.minecraft.client.renderer.entity.RenderEntityItem func_177078_a(Lnet/minecraft/item/ItemStack;)I # getMiniItemCount
|
protected net.minecraft.client.renderer.entity.RenderEntityItem func_177078_a(Lnet/minecraft/item/ItemStack;)I # getMiniItemCount
|
||||||
public net.minecraft.item.crafting.RecipesBanners$RecipeAddPattern
|
public net.minecraft.item.crafting.RecipesBanners$RecipeAddPattern
|
||||||
|
@ -236,6 +237,7 @@ protected net.minecraft.client.gui.FontRenderer func_78277_a(CZ)F # renderUnicod
|
||||||
#public net.minecraft.server.management.ServerConfigurationManager field_72404_b #playerEntityList - private in 1.8.8
|
#public net.minecraft.server.management.ServerConfigurationManager field_72404_b #playerEntityList - private in 1.8.8
|
||||||
#public net.minecraft.server.management.ServerConfigurationManager field_177454_f #uuidToPlayerMap - private in 1.8.8
|
#public net.minecraft.server.management.ServerConfigurationManager field_177454_f #uuidToPlayerMap - private in 1.8.8
|
||||||
|
|
||||||
|
# ChunkProviderServer
|
||||||
# ChunkProviderEnd
|
# ChunkProviderEnd
|
||||||
private-f net/minecraft/world/gen/ChunkProviderEnd/field_185969_i #lperlin1
|
private-f net/minecraft/world/gen/ChunkProviderEnd/field_185969_i #lperlin1
|
||||||
private-f net/minecraft/world/gen/ChunkProviderEnd/field_185970_j #lperlin2
|
private-f net/minecraft/world/gen/ChunkProviderEnd/field_185970_j #lperlin2
|
||||||
|
|
Loading…
Reference in New Issue