Created
September 24, 2012 20:24
-
-
Save Vazkii/3778140 to your computer and use it in GitHub Desktop.
Well Dungeons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.minecraft.src; | |
import java.util.List; | |
import java.util.Random; | |
import net.minecraftforge.common.MinecraftForge; | |
import net.minecraftforge.common.DungeonHooks; | |
public class ComponentVillageWell extends ComponentVillage | |
{ | |
private final boolean field_35104_a = true; | |
private int averageGroundLevel = -1; | |
public ComponentVillageWell(ComponentVillageStartPiece par1ComponentVillageStartPiece, int par2, Random par3Random, int par4, int par5) | |
{ | |
super(par1ComponentVillageStartPiece, par2); | |
this.coordBaseMode = par3Random.nextInt(4); | |
switch (this.coordBaseMode) | |
{ | |
case 0: | |
case 2: | |
this.boundingBox = new StructureBoundingBox(par4, 64, par5, par4 + 6 - 1, 78, par5 + 6 - 1); | |
break; | |
default: | |
this.boundingBox = new StructureBoundingBox(par4, 64, par5, par4 + 6 - 1, 78, par5 + 6 - 1); | |
} | |
} | |
/** | |
* Initiates construction of the Structure Component picked, at the current Location of StructGen | |
*/ | |
public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) | |
{ | |
StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.maxY - 4, this.boundingBox.minZ + 1, 1, this.getComponentType()); | |
StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.maxY - 4, this.boundingBox.minZ + 1, 3, this.getComponentType()); | |
StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.maxY - 4, this.boundingBox.minZ - 1, 2, this.getComponentType()); | |
StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.maxY - 4, this.boundingBox.maxZ + 1, 0, this.getComponentType()); | |
} | |
/** | |
* second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at | |
* the end, it adds Fences... | |
*/ | |
public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) | |
{ | |
if (this.averageGroundLevel < 0) | |
{ | |
this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); | |
if (this.averageGroundLevel < 0) | |
{ | |
return true; | |
} | |
this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 3, 0); | |
} | |
if (this.field_35104_a) | |
{ | |
; | |
} | |
this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 4, 12, 4, Block.cobblestone.blockID, Block.waterMoving.blockID, false); | |
this.placeBlockAtCurrentPosition(par1World, 0, 0, 2, 12, 2, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, 0, 0, 3, 12, 2, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, 0, 0, 2, 12, 3, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, 0, 0, 3, 12, 3, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 1, 13, 1, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 1, 14, 1, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 4, 13, 1, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 4, 14, 1, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 1, 13, 4, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 1, 14, 4, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 4, 13, 4, par3StructureBoundingBox); | |
this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 4, 14, 4, par3StructureBoundingBox); | |
this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 15, 1, 4, 15, 4, Block.cobblestone.blockID, Block.cobblestone.blockID, false); | |
for (int var4 = 0; var4 <= 5; ++var4) | |
{ | |
for (int var5 = 0; var5 <= 5; ++var5) | |
{ | |
if (var5 == 0 || var5 == 5 || var4 == 0 || var4 == 5) | |
{ | |
this.placeBlockAtCurrentPosition(par1World, Block.gravel.blockID, 0, var5, 11, var4, par3StructureBoundingBox); | |
this.clearCurrentPositionBlocksUpwards(par1World, var5, 12, var4, par3StructureBoundingBox); | |
} | |
} | |
} | |
//XXX Villager Dungeons mod - Start here! | |
//XXX Test Seed: -6313918071622485861 | |
int height = 5; | |
Random r = new Random(); | |
for(int i = -7; i < 13; i++){ | |
for(int j = -7; j < 13; j++) | |
for(int k = 0; k < height; k++){ | |
placeBlockAtPos(par1World, 0, i, k-5, j); | |
} | |
} | |
for(int i = -7; i < 13; i++){ | |
for (int j = -7; j < 13; j++){ | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, r.nextInt(3), i, -1, j); | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, r.nextInt(3), i, -6, j); | |
} | |
} | |
for(int i = -7; i < 13; i++){ | |
for(int j = 0; j < 4; j++){ | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, r.nextInt(3), -8, -5+j, i); // Top Wall | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, r.nextInt(3), 13, -5+j, i); // Bottom Wall | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, r.nextInt(3), i, -5+j, -8); // Left Wall | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, r.nextInt(3), i, -5+j, 13); // Right Wall | |
} | |
} | |
zJailNegative(par1World, -8, -5, 8); | |
zJailNegative(par1World, -8, -5, 4); | |
zJailNegative(par1World, -8, -5, -1); | |
zJailNegative(par1World, -8, -5, -5); | |
zJail(par1World, 13, -5, 8); | |
zJail(par1World, 13, -5, 4); | |
zJail(par1World, 13, -5, -1); | |
zJail(par1World, 13, -5, -5); | |
xJailNegative(par1World, 8, -5, -8); | |
xJailNegative(par1World, 4, -5, -8); | |
xJailNegative(par1World, -1, -5, -8); | |
xJailNegative(par1World, -5, -5, -8); | |
xJail(par1World, 8, -5, 13); | |
xJail(par1World, 4, -5, 13); | |
xJail(par1World, -1, -5, 13); | |
xJail(par1World, -5, -5, 13); | |
makeSpawner(par1World, 9, -4, -4); | |
makeSpawner(par1World, -4, -4, 9); | |
makeSpawner(par1World, 9, -4, 9); | |
makeSpawner(par1World, -4, -4, -4); | |
return true; | |
} | |
public void xJail(World par1World, int rootX, int rootY, int rootZ){ | |
Random rand = new Random(); | |
for(int i = 0; i < 3; i++){ | |
for (int j = 0; j < 3; j++){ | |
placeBlockAtPos(par1World, Block.fenceIron.blockID, rootX+i, rootY+j, rootZ); | |
for(int k = 0; k < 3; k++){ | |
placeBlockAtPos(par1World, 0, rootX+i, rootY+j, rootZ+1+k); | |
} | |
} | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, rand.nextInt(3), rootX+i, rootY-1, rootZ); | |
} | |
spawnVillager(par1World, rootX+2, rootY+1, rootZ+2); | |
if(rand.nextInt(2)>0){ | |
placeChest(par1World, rootX+1, rootY, rootZ+3); | |
} | |
} | |
public void zJail(World par1World, int rootX, int rootY, int rootZ){ | |
Random rand = new Random(); | |
for(int i = 0; i < 3; i++){ | |
for (int j = 0; j < 3; j++){ | |
placeBlockAtPos(par1World, Block.fenceIron.blockID, rootX, rootY+j, rootZ+i); | |
for(int k = 0; k < 3; k++){ | |
placeBlockAtPos(par1World, 0, rootX+1+i, rootY+j, rootZ+k); | |
} | |
} | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, rand.nextInt(3), rootX, rootY-1, rootZ+i); | |
} | |
spawnVillager(par1World, rootX+2, rootY+1, rootZ+2); | |
if(rand.nextInt(2)>0){ | |
placeChest(par1World, rootX+3, rootY, rootZ+1); | |
} | |
} | |
public void xJailNegative(World par1World, int rootX, int rootY, int rootZ){ | |
Random rand = new Random(); | |
for(int i = 0; i < 3; i++){ | |
for (int j = 0; j < 3; j++){ | |
placeBlockAtPos(par1World, Block.fenceIron.blockID, rootX+i, rootY+j, rootZ); | |
for(int k = 0; k < 3; k++){ | |
placeBlockAtPos(par1World, 0, rootX+i, rootY+j, rootZ-1-k); | |
} | |
} | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, rand.nextInt(3), rootX+i, rootY-1, rootZ); | |
} | |
spawnVillager(par1World, rootX+2, rootY+1, rootZ-2); | |
if(rand.nextInt(2)>0){ | |
placeChest(par1World, rootX+1, rootY, rootZ-3); | |
} | |
} | |
public void zJailNegative(World par1World, int rootX, int rootY, int rootZ){ | |
Random rand = new Random(); | |
for(int i = 0; i < 3; i++){ | |
for (int j = 0; j < 3; j++){ | |
placeBlockAtPos(par1World, Block.fenceIron.blockID, rootX, rootY+j, rootZ+i); | |
for(int k = 0; k < 3; k++){ | |
placeBlockAtPos(par1World, 0, rootX-1-i, rootY+j, rootZ+k); | |
} | |
} | |
placeBlockAtPos(par1World, Block.stoneBrick.blockID, rand.nextInt(3), rootX, rootY-1, rootZ+i); | |
} | |
spawnVillager(par1World, rootX-2, rootY+1, rootZ+2); | |
if(rand.nextInt(2)>0){ | |
placeChest(par1World, rootX-3, rootY, rootZ+1); | |
} | |
} | |
public void placeChest(World par1World, int x, int y, int z){ | |
int xPos, yPos, zPos; | |
xPos = boundingBox.minX + x; | |
zPos = boundingBox.minZ + z; | |
yPos = boundingBox.minY + y; | |
placeBlockAtPos(par1World, Block.chest.blockID, x, y, z); | |
TileEntityChest tile = (TileEntityChest)par1World.getBlockTileEntity(xPos, yPos, zPos); | |
Random rand = new Random(); | |
if(tile != null) | |
try{ | |
for (int var17 = 0; var17 < DungeonHooks.getDungeonLootTries(); ++var17) | |
{ | |
ItemStack var18 = DungeonHooks.getRandomDungeonLoot(rand); | |
if (var18 != null) | |
{ | |
tile.setInventorySlotContents(rand.nextInt(tile.getSizeInventory()), var18); | |
} | |
} | |
}catch(Exception e){ | |
for(int i = 0; i<rand.nextInt(5)+4; i++){ | |
tile.setInventorySlotContents(rand.nextInt(tile.getSizeInventory()), pickCheckLootItem(rand)); | |
} | |
} | |
} | |
private ItemStack pickCheckLootItem(Random par1Random) | |
{ | |
int var2 = par1Random.nextInt(11); | |
return var2 == 0 ? new ItemStack(Item.saddle) : (var2 == 1 ? new ItemStack(Item.ingotIron, par1Random.nextInt(4) + 1) : (var2 == 2 ? new ItemStack(Item.bread) : (var2 == 3 ? new ItemStack(Item.wheat, par1Random.nextInt(4) + 1) : (var2 == 4 ? new ItemStack(Item.gunpowder, par1Random.nextInt(4) + 1) : (var2 == 5 ? new ItemStack(Item.silk, par1Random.nextInt(4) + 1) : (var2 == 6 ? new ItemStack(Item.bucketEmpty) : (var2 == 7 && par1Random.nextInt(100) == 0 ? new ItemStack(Item.appleGold) : (var2 == 8 && par1Random.nextInt(2) == 0 ? new ItemStack(Item.redstone, par1Random.nextInt(4) + 1) : (var2 == 9 && par1Random.nextInt(10) == 0 ? new ItemStack(Item.itemsList[Item.record13.shiftedIndex + par1Random.nextInt(2)]) : (var2 == 10 ? new ItemStack(Item.dyePowder, 1, 3) : null)))))))))); | |
} | |
public void placeBlockAtPos(World par1World, int id, int xOffset, int yOffset, int zOffset){ | |
placeBlockAtPos(par1World, id, 0, xOffset, yOffset, zOffset); | |
} | |
public void placeBlockAtPos(World par1World, int id, int meta, int xOffset, int yOffset, int zOffset){ | |
int xPos, zPos, yPos; | |
xPos = boundingBox.minX + xOffset; | |
zPos = boundingBox.minZ + zOffset; | |
yPos = boundingBox.minY + yOffset; | |
par1World.setBlockAndMetadata(xPos, yPos, zPos, id, meta); | |
} | |
public void spawnVillager(World par1World, double xOffset, double yOffset, double zOffset){ | |
double xPos, zPos, yPos; | |
xPos = boundingBox.minX + xOffset; | |
zPos = boundingBox.minZ + zOffset; | |
yPos = boundingBox.minY + yOffset; | |
Entity entity = EntityList.createEntityByName("Villager", par1World); | |
entity.setLocationAndAngles(xPos, yPos, zPos, 0F, 0F); | |
((EntityVillager)entity).setProfession(new Random().nextInt(5)); | |
par1World.spawnEntityInWorld(entity); | |
} | |
public void makeSpawner(World par1World, int x, int y, int z){ | |
placeBlockAtPos(par1World, Block.fenceIron.blockID, x, y+2, z); | |
placeBlockAtPos(par1World, Block.fenceIron.blockID, x, y+1, z); | |
placeBlockAtPos(par1World, Block.mobSpawner.blockID, x, y, z); | |
Random rand = new Random(); | |
int seed = rand.nextInt(3); | |
TileEntityMobSpawner tile = (TileEntityMobSpawner)par1World.getBlockTileEntity(boundingBox.minX + x, boundingBox.minY + y, boundingBox.minZ + z); | |
if(tile != null) | |
tile.setMobID(seed == 0 ? "Zombie" : (seed == 1 ? "Skeleton" : "Spider")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment