001 package net.minecraft.src; 002 003 import java.util.Iterator; 004 import java.util.LinkedList; 005 import java.util.Random; 006 007 public abstract class StructureStart 008 { 009 /** List of all StructureComponents that are part of this structure */ 010 protected LinkedList components = new LinkedList(); 011 protected StructureBoundingBox boundingBox; 012 013 public StructureBoundingBox getBoundingBox() 014 { 015 return this.boundingBox; 016 } 017 018 public LinkedList getComponents() 019 { 020 return this.components; 021 } 022 023 /** 024 * Keeps iterating Structure Pieces and spawning them until the checks tell it to stop 025 */ 026 public void generateStructure(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) 027 { 028 Iterator var4 = this.components.iterator(); 029 030 while (var4.hasNext()) 031 { 032 StructureComponent var5 = (StructureComponent)var4.next(); 033 034 if (var5.getBoundingBox().intersectsWith(par3StructureBoundingBox) && !var5.addComponentParts(par1World, par2Random, par3StructureBoundingBox)) 035 { 036 var4.remove(); 037 } 038 } 039 } 040 041 /** 042 * Calculates total bounding box based on components' bounding boxes and saves it to boundingBox 043 */ 044 protected void updateBoundingBox() 045 { 046 this.boundingBox = StructureBoundingBox.getNewBoundingBox(); 047 Iterator var1 = this.components.iterator(); 048 049 while (var1.hasNext()) 050 { 051 StructureComponent var2 = (StructureComponent)var1.next(); 052 this.boundingBox.expandTo(var2.getBoundingBox()); 053 } 054 } 055 056 /** 057 * offsets the structure Bounding Boxes up to a certain height, typically 63 - 10 058 */ 059 protected void markAvailableHeight(World par1World, Random par2Random, int par3) 060 { 061 int var4 = 63 - par3; 062 int var5 = this.boundingBox.getYSize() + 1; 063 064 if (var5 < var4) 065 { 066 var5 += par2Random.nextInt(var4 - var5); 067 } 068 069 int var6 = var5 - this.boundingBox.maxY; 070 this.boundingBox.offset(0, var6, 0); 071 Iterator var7 = this.components.iterator(); 072 073 while (var7.hasNext()) 074 { 075 StructureComponent var8 = (StructureComponent)var7.next(); 076 var8.getBoundingBox().offset(0, var6, 0); 077 } 078 } 079 080 protected void setRandomHeight(World par1World, Random par2Random, int par3, int par4) 081 { 082 int var5 = par4 - par3 + 1 - this.boundingBox.getYSize(); 083 boolean var6 = true; 084 int var10; 085 086 if (var5 > 1) 087 { 088 var10 = par3 + par2Random.nextInt(var5); 089 } 090 else 091 { 092 var10 = par3; 093 } 094 095 int var7 = var10 - this.boundingBox.minY; 096 this.boundingBox.offset(0, var7, 0); 097 Iterator var8 = this.components.iterator(); 098 099 while (var8.hasNext()) 100 { 101 StructureComponent var9 = (StructureComponent)var8.next(); 102 var9.getBoundingBox().offset(0, var7, 0); 103 } 104 } 105 106 /** 107 * currently only defined for Villages, returns true if Village has more than 2 non-road components 108 */ 109 public boolean isSizeableStructure() 110 { 111 return true; 112 } 113 }