Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
- // Jad home page: http://www.kpdus.com/jad.html
- // Decompiler options: packimports(3) braces deadcode
- import java.util.Random;
- public class WorldGenPyramid extends WorldGenerator {
- public WorldGenPyramid() {
- }
- public boolean generate(World world, Random random, int i, int j, int k) {
- //if(world.getBlockId(i + random.nextInt(16), j, k + random.nextInt(16)) == Block.sand.blockID )
- // mummy pyramid init
- pyramids = 298;
- rows = 35;
- columns = 35;
- backgroundCode = 0;
- wallCode = 20; //7
- pathCode = 15;
- emptyCode = 0;
- visitedCode = 4;
- maze = new int[rows+1][columns+1];
- /*
- int area = 0;
- for(int c = 0; c < 20; c++)
- {
- area += world.getBlockId(i, j + c + 1, k);
- }
- */
- int area = 0;
- for(int ii = 0; ii < 20; ii += 2) {
- for(int i1 = -2 + ii; i1 < rows - ii + 2; i1 += 2) {
- for(int j1 = -2 + ii; j1 < columns - ii + 2; j1 += 2) {
- if(world.getBlockId(i + i1, j + ii, k + j1) !=0) area++;
- }
- }
- }
- ModLoader.getMinecraftInstance().ingameGUI.addChatMessage("PYARMID RESULTS :" + String.valueOf(area));
- if(world.getBlockId(i + random.nextInt(16), j-1, k + random.nextInt(16)) == 12 && area < 200)
- //if(world.getBlockId(i + random.nextInt(16), j, k + random.nextInt(16)) != 0 && area < 200)
- //&& world.canExistingBlockSeeTheSky(i + random.nextInt(16), j + 1, k + random.nextInt(16))
- {
- makeMaze();
- ModLoader.getMinecraftInstance().ingameGUI.addChatMessage("BUILT A PYRAMID!!!");
- // create pyramid out of sandstone
- for(int ii = -2; ii < 21; ii++) {
- for(int i1 = -2 + ii; i1 < rows - ii + 2; i1++) {
- for(int j1 = -2 + ii; j1 < columns - ii + 2; j1++) {
- world.setBlock(i + i1, j + ii, k + j1, 24); // 24
- }
- }
- }
- // place maze
- for(int i1 = 0; i1 < rows; i1++) {
- for(int j1 = 0; j1 < columns; j1++) {
- // create blocks
- //j = 70;
- //i = 6;
- //k = 6;
- world.setBlock(i + i1, j, k + j1, maze[i1][j1]);
- world.setBlock(i + i1, j - 1, k + j1, maze[i1][j1]);
- world.setBlock(i + i1, j - 2, k + j1, Block.bedrock.blockID);
- }
- }
- // make some adjustments to pyramid
- // add glass
- for(int pp = 0; pp < 30; pp++) {
- int rx = rand.nextInt(rows -6)+3;
- int ry = rand.nextInt(columns -6)+3;
- if(maze[rx][ry] == 7) {
- world.setBlock(i + rx, j, k + ry, Block.glass.blockID);
- }
- }
- // add sandstone
- for(int pq = 0; pq < 30; pq++) {
- int rx = rand.nextInt(rows -6)+3;
- int ry = rand.nextInt(columns -6)+3;
- if(maze[rx][ry] == 7) {
- world.setBlock(i + rx, j-1, k + ry, Block.sandStone.blockID);
- }
- }
- // add torches
- for(int pq = 0; pq < 30; pq++) {
- int rx = rand.nextInt(rows -6)+3;
- int ry = rand.nextInt(columns -6)+3;
- if(maze[rx][ry] == 7) {
- world.setBlock(i + rx, j, k + ry, Block.torchWood.blockID);
- }
- }
- // spawners
- int spawnbox = 0;
- while(spawnbox < 6) {
- int xx = rand.nextInt(rows-3);
- int yy = rand.nextInt(columns-3);
- xx++;
- yy++;
- if(maze[xx][yy] == wallCode) { //7
- spawnbox++;
- world.setBlock(i+xx, j-1, k+yy,0);
- world.setBlockWithNotify(i+xx, j-1, k+yy, Block.mobSpawner.blockID);
- TileEntityMobSpawner spawner = new TileEntityMobSpawner();
- world.setBlockTileEntity(i+xx, j-1, k+yy, spawner);
- if(rand.nextInt(5)==0) {
- spawner.setMobID("BlackSoul");
- } else {
- spawner.setMobID("Mummy");
- }
- }
- }
- // entrance
- world.setBlock(i+1, j-1, k, 0);
- world.setBlock(i+1, j, k, 0);
- for(int t=0; t<5; t++) {
- world.setBlock(i+1, j-1, k-t, 0);
- world.setBlock(i+1, j, k-t, 0);
- world.setBlock(i+1, j, k-t, Block.torchWood.blockID);
- }
- world.setBlock(i-1, j, k-5, Block.torchWood.blockID);
- world.setBlock(i+1, j, k-5, Block.torchWood.blockID);
- world.setBlock(i, j, k-5, Block.torchWood.blockID);
- // clear to surface obstructions
- for(int w = 1; w< 25; w++) {
- world.setBlock(i-1, j+w, k-5, 0);
- world.setBlock(i+1, j+w, k-5, 0);
- world.setBlock(i, j+w, k-5, 0);
- }
- world.setBlock(i, j+26, k-5, Block.torchWood.blockID);
- /*
- EntityFX fx = new EntitySlimeFX(world, i+1, j, k -5, Item.slimeBall);
- fx.renderDistanceWeight = 10D;
- fx.particleTextureIndex = 94;
- ModLoader.getMinecraftInstance().effectRenderer.addEffect(fx);
- */
- int i5 = Item.bone.shiftedIndex;
- float f = 0.7F;
- double d = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
- double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.20000000000000001D + 0.59999999999999998D;
- double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
- EntityItem entityitem = new EntityItem(world, (double)i + d - 2, (double)j + d1, (double)k + d2 - 2, new ItemStack(i5, 5, 0));
- entityitem.delayBeforeCanPickup = 10;
- world.entityJoinedWorld(entityitem);
- // treasure
- world.setBlock(i + rows - 2, j-1, k + columns - 2, 54);
- TileEntityChest chest = new TileEntityChest();
- world.setBlockTileEntity(i + rows - 2, j-1, k + columns - 2, chest);
- // set other slots with goodies!
- for(int x = 1; x < chest.getSizeInventory(); x++) {
- int b = rand.nextInt(30);
- if(b==0) {
- chest.setInventorySlotContents(x, new ItemStack(mod_MoreCreepsAndWeirdos.goodonut.shiftedIndex, rand.nextInt(16), 0));
- }
- if(b==1) {
- chest.setInventorySlotContents(x, new ItemStack(mod_MoreCreepsAndWeirdos.bandaid.shiftedIndex, rand.nextInt(16), 0));
- }
- if(b==2) {
- chest.setInventorySlotContents(x, new ItemStack(mod_MoreCreepsAndWeirdos.raygun.shiftedIndex, rand.nextInt(4), 0));
- }
- if(b==3) {
- chest.setInventorySlotContents(x, new ItemStack(mod_MoreCreepsAndWeirdos.money.shiftedIndex, rand.nextInt(16), 0));
- }
- if(b==4) {
- chest.setInventorySlotContents(x, new ItemStack(mod_MoreCreepsAndWeirdos.blorpcola.shiftedIndex, rand.nextInt(10), 0));
- }
- if(b==5) {
- chest.setInventorySlotContents(x, new ItemStack(Item.bread, 1, 0));
- }
- if(b==6) {
- chest.setInventorySlotContents(x, new ItemStack(Item.appleGold, 1, 0));
- }
- if(b==7) {
- chest.setInventorySlotContents(x, new ItemStack(Item.ingotGold, rand.nextInt(3), 0));
- }
- if(b==8) {
- chest.setInventorySlotContents(x, new ItemStack(Item.ingotIron, rand.nextInt(5), 0));
- }
- if(b==9) {
- chest.setInventorySlotContents(x, new ItemStack(Item.gunpowder, rand.nextInt(4), 0));
- }
- if(b==10) {
- chest.setInventorySlotContents(x, new ItemStack(Item.egg, rand.nextInt(3), 0));
- }
- if(b==11) {
- chest.setInventorySlotContents(x, new ItemStack(Item.wheat, rand.nextInt(12), 0));
- }
- if(b==12) {
- chest.setInventorySlotContents(x, new ItemStack(mod_MoreCreepsAndWeirdos.goodonut.shiftedIndex, rand.nextInt(16), 0));
- }
- if(b==13) {
- chest.setInventorySlotContents(x, new ItemStack(Item.diamond, rand.nextInt(2), 0));
- }
- }
- // PyramidGuardian
- // clear space
- world.setBlockWithNotify(i + rows - 3, j-1, k + columns - 3, 0);
- world.setBlockWithNotify(i + rows - 3, j, k + columns - 3, 0);
- // set guardian
- EntityPyramidGuardian entitypyramidguardian = new EntityPyramidGuardian(world);
- entitypyramidguardian.setLocationAndAngles(i + rows - 3, j-1, k + columns - 3, 360F, 0.0F);
- entitypyramidguardian.motionX = 0;
- entitypyramidguardian.motionY = 0;
- entitypyramidguardian.motionZ = 0;
- world.entityJoinedWorld(entitypyramidguardian);
- // seal top of maze
- for(int i1 = 0; i1 < rows; i1++) {
- for(int j1 = 0; j1 < columns; j1++) {
- world.setBlock(i + i1, j + 1, k + j1, 7); // 7
- }
- }
- pyramids = 0;
- return true;
- }
- return false;
- }
- public void makeMaze() {
- int i,j;
- int emptyCt = 0; // number of rooms
- int wallCt = 0; // number of walls
- int[] wallrow = new int[(rows*columns)/2]; // position of walls between rooms
- int[] wallcol = new int[(rows*columns)/2];
- for (i = 0; i<rows; i++) // start with everything being a wall
- for (j = 0; j < columns; j++)
- maze[i][j] = wallCode;
- for (i = 1; i<rows-1; i += 2) // make a grid of empty rooms
- for (j = 1; j<columns-1; j += 2) {
- emptyCt++;
- maze[i][j] = -emptyCt; // each room is represented by a different negative number
- if (i < rows-2) { // record info about wall below this room
- wallrow[wallCt] = i+1;
- wallcol[wallCt] = j;
- wallCt++;
- }
- if (j < columns-2) { // record info about wall to right of this room
- wallrow[wallCt] = i;
- wallcol[wallCt] = j+1;
- wallCt++;
- }
- }
- int r;
- for (i=wallCt-1; i>0; i--) {
- r = (int)(Math.random() * i); // choose a wall randomly and maybe tear it down
- // tearDown(wallrow[r],wallcol[r]);
- if (wallrow[r] % 2 == 1 && maze[wallrow[r]][wallcol[r]-1] != maze[wallrow[r]][wallcol[r]+1]) {
- // row is odd; wall separates rooms horizontally
- fill(wallrow[r], wallcol[r]-1, maze[wallrow[r]][wallcol[r]-1], maze[wallrow[r]][wallcol[r]+1]);
- maze[wallrow[r]][wallcol[r]] = maze[wallrow[r]][wallcol[r]+1];
- //putSquare(row,col,emptyCode);
- // try { wait(speedSleep); }
- // catch (InterruptedException e) { }
- } else if (wallrow[r] % 2 == 0 && maze[wallrow[r]-1][wallcol[r]] != maze[wallrow[r]+1][wallcol[r]]) {
- // row is even; wall separates rooms vertically
- fill(wallrow[r]-1, wallcol[r], maze[wallrow[r]-1][wallcol[r]], maze[wallrow[r]+1][wallcol[r]]);
- maze[wallrow[r]][wallcol[r]] = maze[wallrow[r]+1][wallcol[r]];
- // putSquare(row,col,emptyCode);
- // try { wait(speedSleep); }
- // catch (InterruptedException e) { }
- }
- wallrow[r] = wallrow[i];
- wallcol[r] = wallcol[i];
- }
- for (i=1; i<rows-1; i++) // replace negative values in maze[][] with emptyCode
- for (j=1; j<columns-1; j++)
- if (maze[i][j] < 0)
- maze[i][j] = emptyCode;
- }
- public void tearDown(int row, int col) {
- if (row % 2 == 1 && maze[row][col-1] != maze[row][col+1]) {
- // row is odd; wall separates rooms horizontally
- fill(row, col-1, maze[row][col-1], maze[row][col+1]);
- maze[row][col] = maze[row][col+1];
- //putSquare(row,col,emptyCode);
- // try { wait(speedSleep); }
- // catch (InterruptedException e) { }
- } else if (row % 2 == 0 && maze[row-1][col] != maze[row+1][col]) {
- // row is even; wall separates rooms vertically
- fill(row-1, col, maze[row-1][col], maze[row+1][col]);
- maze[row][col] = maze[row+1][col];
- // putSquare(row,col,emptyCode);
- // try { wait(speedSleep); }
- // catch (InterruptedException e) { }
- }
- }
- public void fill(int row, int col, int replace, int replaceWith) {
- // called by tearDown() to change "room codes".
- if(row < 0) {
- row = 0;
- }
- if(col < 0) {
- row = 0;
- }
- if(row > rows ) {
- row = rows;
- }
- if(col > columns) {
- col = columns;
- }
- if (maze[row][col] == replace) {
- maze[row][col] = replaceWith;
- fill(row+1,col,replace,replaceWith);
- fill(row-1,col,replace,replaceWith);
- fill(row,col+1,replace,replaceWith);
- fill(row,col-1,replace,replaceWith);
- }
- }
- public static Random rand = new Random();
- public static final int blockIDs[] = new int[] {
- Block.crops.blockID, Block.sapling.blockID, Block.pumpkin.blockID, Block.plantRed.blockID, Block.plantYellow.blockID,
- Block.mushroomBrown.blockID, Block.mushroomRed.blockID
- };
- private int count;
- private int pyramids;
- public int rows;
- public int columns;
- public int maze[][];
- public static int backgroundCode;
- public static int wallCode;
- public static int pathCode;
- public static int emptyCode;
- public static int visitedCode;
- public TileEntityChest chest;
- }
Advertisement
Add Comment
Please, Sign In to add comment