Overhauled Loot

Changed our loot generation. Instead of relying on Minecraft's built-in
loot categories, we now have our own static loot category. There are two
types of chests now. Regular chests contain randomly-picked coal, iron,
gold, diamonds, emeralds, quartz, enchanted books, and golden apples
(very rare). We also have a function for filling out "grave chests",
which occur in 1 out of every 7 chests. Those contain rotten flesh,
bones, and some armor pieces and equipment that are assigned random
damage values and occasionally also get level 1 enchantments. Small
changes were made to various files to incorporate this update.
This commit is contained in:
SenseiKiwi
2013-12-22 18:30:16 -04:00
parent 75e103aa65
commit a6048c6c29
5 changed files with 221 additions and 158 deletions

View File

@@ -170,7 +170,7 @@ public class DungeonSchematic extends Schematic {
return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds));
}
public void copyToWorld(World world, Point3D pocketCenter, int targetOrientation, DimLink entryLink, Random random)
public void copyToWorld(World world, Point3D pocketCenter, int targetOrientation, DimLink entryLink, Random random, DDProperties properties)
{
//TODO: This function is an improvised solution so we can get the release moving. In the future,
//we should generalize block transformations and implement support for them at the level of Schematic,
@@ -224,10 +224,10 @@ public class DungeonSchematic extends Schematic {
world.setBlockTileEntity(pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), TileEntity.createAndLoadEntity(tileTag));
}
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random);
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random, properties);
}
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, DimLink entryLink, Random random)
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, DimLink entryLink, Random random, DDProperties properties)
{
//Transform dungeon corners
Point3D minCorner = new Point3D(0, 0, 0);
@@ -235,7 +235,7 @@ public class DungeonSchematic extends Schematic {
transformCorners(entranceDoorLocation, pocketCenter, turnAngle, minCorner, maxCorner);
//Fill empty chests and dispensers
FillContainersOperation filler = new FillContainersOperation(random);
FillContainersOperation filler = new FillContainersOperation(random, properties);
filler.apply(world, minCorner, maxCorner);
//Set up entrance door rift
@@ -302,7 +302,7 @@ public class DungeonSchematic extends Schematic {
Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT,orientation);
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT, orientation);
//Replace the sandstone block under the exit door with the same block as the one underneath it
int x = location.getX();
int y = location.getY() - 3;
@@ -322,7 +322,7 @@ public class DungeonSchematic extends Schematic {
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON,orientation);
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON, orientation);
}
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, boolean canSpawn)

View File

@@ -12,16 +12,22 @@ import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityDispenser;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDLoot;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.schematic.WorldOperation;
public class FillContainersOperation extends WorldOperation
{
private Random random;
private DDProperties properties;
public FillContainersOperation(Random random)
private static final int GRAVE_CHEST_CHANCE = 100;
private static final int MAX_GRAVE_CHEST_CHANCE = 700;
public FillContainersOperation(Random random, DDProperties properties)
{
super("FillContainersOperation");
this.random = random;
this.properties = properties;
}
@Override
@@ -29,22 +35,30 @@ public class FillContainersOperation extends WorldOperation
{
int blockID = world.getBlockId(x, y, z);
//Fill empty chests and dispensers
// Fill empty chests and dispensers
if (Block.blocksList[blockID] instanceof BlockContainer)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
//Fill chests
// Fill chests
if (tileEntity instanceof TileEntityChest)
{
TileEntityChest chest = (TileEntityChest) tileEntity;
if (isInventoryEmpty(chest))
{
DDLoot.generateChestContents(DDLoot.DungeonChestInfo, chest, random);
// Randomly choose whether this will be a regular dungeon chest or a grave chest
if (random.nextInt(MAX_GRAVE_CHEST_CHANCE) < GRAVE_CHEST_CHANCE)
{
DDLoot.fillGraveChest(chest, random, properties);
}
else
{
DDLoot.generateChestContents(DDLoot.DungeonChestInfo, chest, random);
}
}
}
//Fill dispensers
// Fill dispensers
if (tileEntity instanceof TileEntityDispenser)
{
TileEntityDispenser dispenser = (TileEntityDispenser) tileEntity;