Guest User

Untitled

a guest
Mar 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.49 KB | None | 0 0
  1. package atomicstryker.battletowers.common;
  2.  
  3. import java.lang.reflect.Constructor;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.Iterator;
  7. import java.util.List;
  8. import java.util.Random;
  9.  
  10. import net.minecraft.block.Block;
  11. import net.minecraft.entity.EntityList;
  12. import net.minecraft.entity.monster.EntityCaveSpider;
  13. import net.minecraft.entity.monster.EntitySkeleton;
  14. import net.minecraft.entity.monster.EntitySpider;
  15. import net.minecraft.entity.monster.EntityZombie;
  16. import net.minecraft.init.Blocks;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.tileentity.TileEntity;
  19. import net.minecraft.tileentity.TileEntityChest;
  20. import net.minecraft.tileentity.TileEntityMobSpawner;
  21. import net.minecraft.util.ResourceLocation;
  22. import net.minecraft.util.math.BlockPos;
  23. import net.minecraft.world.World;
  24. import net.minecraftforge.common.MinecraftForge;
  25. import net.minecraftforge.fml.common.Loader;
  26. import net.minecraftforge.fml.common.eventhandler.Event;
  27.  
  28. public class AS_WorldGenTower {
  29.  
  30. public String failState;
  31.  
  32. private static int candidates[][] = {
  33. {
  34. 4,
  35. -5
  36. },
  37. {
  38. 4,
  39. 0
  40. },
  41. {
  42. 4,
  43. 5,
  44. },
  45. {
  46. 0,
  47. -5
  48. },
  49. {
  50. 0,
  51. 0
  52. },
  53. {
  54. 0,
  55. 5,
  56. },
  57. {-4,
  58. -5
  59. },
  60. {-4,
  61. 0,
  62. },
  63. {-4,
  64. 5
  65. }
  66. };
  67.  
  68. private static int candidatecount = candidates.length;
  69. private final static int maxHoleDepthInBase = 22;
  70.  
  71. /**
  72. * @param world
  73. * instance
  74. * @param random
  75. * gen
  76. * @param ix
  77. * coordinate
  78. * @param jy
  79. * coordinate
  80. * @param kz
  81. * coordinate
  82. * @return -1 when no tower should be able to spawn, else Towerchosen enum
  83. * ordinal
  84. */
  85. public int getChosenTowerOrdinal(World world, Random random, int ix, int jy, int kz) {
  86. TowerTypes towerChosen;
  87. int countWater = 0;
  88. int countSand = 0;
  89. int countSnow = 0;
  90. int countFoliage = 0;
  91. int countElse = 0;
  92.  
  93. for (int ccounter = 0; ccounter < candidatecount; ccounter++) {
  94. int pair[] = candidates[ccounter];
  95. int checkBlockY = getSurfaceBlockHeight(world, ix + pair[0], kz + pair[1]);
  96.  
  97. Block ID = world.getBlockState(new BlockPos(ix + pair[0], checkBlockY, kz + pair[1])).getBlock();
  98.  
  99. if (world.getBlockState(new BlockPos(ix + pair[0], checkBlockY + 1, kz + pair[1])).getBlock() == Blocks.SNOW || ID == Blocks.ICE) {
  100. countSnow++;
  101. } else if (ID == Blocks.SAND || ID == Blocks.SANDSTONE) {
  102. countSand++;
  103. } else if (ID == Blocks.WATER) {
  104. countWater++;
  105. } else if (ID == Blocks.LEAVES || ID == Blocks.WATERLILY || ID == Blocks.LOG || ID == Blocks.LOG2) {
  106. countFoliage++;
  107. } else
  108. countElse++;
  109.  
  110. if (Math.abs(checkBlockY - jy) > maxHoleDepthInBase) {
  111. failState = "Uneven Surface, diff value: " + Math.abs(checkBlockY - jy);
  112. return -1;
  113. }
  114.  
  115. for (int ycounter2 = 1; ycounter2 <= 3; ycounter2++) {
  116. ID = world.getBlockState(new BlockPos(ix + pair[0], (checkBlockY + ycounter2), kz + pair[1])).getBlock();
  117. if (isBannedBlockID(ID)) {
  118. failState = "Surface banned Block of ID: " + ID + " at height: " + ycounter2;
  119. return -1;
  120. }
  121. }
  122.  
  123. for (int ycounter = 1; ycounter <= 5; ycounter++) {
  124. ID = world.getBlockState(new BlockPos(ix + pair[0], checkBlockY - ycounter, kz + pair[1])).getBlock();
  125.  
  126. if (ID == Blocks.AIR || isBannedBlockID(ID)) {
  127. failState = "Depth check - Banned Block or hole, Depth: " + ycounter + " ID: " + ID;
  128. return -1;
  129. }
  130. }
  131. }
  132.  
  133. // System.err.println("Snow: "+countSnow+" Sand: "+countSand+" Water: "+countWater+" else: "+countElse);
  134.  
  135. int[] nums = {
  136. countWater,
  137. countSnow,
  138. countSand,
  139. countFoliage,
  140. countElse
  141. };
  142. Arrays.sort(nums);
  143. int result = nums[nums.length - 1];
  144.  
  145. // System.err.println("Picked max value of "+result);
  146.  
  147. if (countSand == result) {
  148. towerChosen = TowerTypes.SandStone;
  149. } else if (countSnow == result) {
  150. towerChosen = TowerTypes.Ice;
  151. } else if (countWater == result) {
  152. towerChosen = TowerTypes.CobbleStoneMossy;
  153. } else if (countFoliage == result) {
  154. towerChosen = TowerTypes.CobbleStoneMossy;
  155. } else // standard is cobblestone, really rare should be nether
  156. {
  157. if (random.nextInt(10) == 0) {
  158. towerChosen = TowerTypes.Netherrack;
  159. } else {
  160. towerChosen = (random.nextInt(5) == 0) ? TowerTypes.SmoothStone : TowerTypes.CobbleStone;
  161. }
  162. }
  163.  
  164. return towerChosen.ordinal();
  165. }
  166.  
  167. @SuppressWarnings("deprecation") // is needed because getDefaultState on stairs does not work
  168. public void generate(World world, int ix, int jy, int kz, int towerchoice, boolean underground) {
  169. TowerTypes towerChosen = TowerTypes.values()[towerchoice];
  170.  
  171. Block towerWallBlockID = towerChosen.getWallBlockID();
  172. Block towerLightBlockID = towerChosen.getLightBlockID();
  173. Block towerFloorBlockID = towerChosen.getFloorBlockID();
  174. int towerFloorMeta = towerChosen.getFloorBlockMetaData();
  175.  
  176. int startingHeight = underground ? Math.max(jy - 70, 15) : jy - 6;
  177. int maximumHeight = underground ? jy + 7 : 120;
  178.  
  179. int floor = 1;
  180. boolean topFloor = false;
  181. int builderHeight = startingHeight;
  182. for (; builderHeight < maximumHeight; builderHeight += 7) // builderHeight jumps floors
  183. {
  184. if (builderHeight + 7 >= maximumHeight) {
  185. topFloor = true;
  186. }
  187.  
  188. for (int floorIterator = 0; floorIterator < 7; floorIterator++) // build each floor height block till next floor
  189. {
  190. if (floor == 1 && floorIterator < 4) // initial floor
  191. {
  192. floorIterator = 4;
  193. }
  194. for (int xIterator = -7; xIterator < 7; xIterator++) // do each X
  195. {
  196. for (int zIterator = -7; zIterator < 7; zIterator++) // do each Z
  197. {
  198. int iCurrent = xIterator + ix;
  199. int jCurrent = floorIterator + builderHeight;
  200. int zCurrent = zIterator + kz;
  201.  
  202. if (zIterator == -7) // last row, 14
  203. {
  204. if (xIterator > -5 && xIterator < 4) // rear outer wall
  205. {
  206. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  207. }
  208. continue;
  209. }
  210. if (zIterator == -6 || zIterator == -5) // rows 12 and 13
  211. {
  212. if (xIterator == -5 || xIterator == 4) // outer wall parts
  213. {
  214. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  215. continue;
  216. }
  217. if (zIterator == -6) // row 13 extra
  218. {
  219. if (xIterator == (floorIterator + 1) % 7 - 3) // stairwell!!
  220. {
  221. if (!(underground && floor == 1)) {
  222. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), towerChosen.getStairBlockID().getStateFromMeta(0));
  223. }
  224. if (floorIterator == 5) {
  225. world.setBlockState(new BlockPos(iCurrent - 7, jCurrent, zCurrent), towerFloorBlockID.getDefaultState());
  226. }
  227. if (floorIterator == 6 && topFloor) // top ledge part
  228. {
  229. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  230. }
  231. continue;
  232. }
  233. if (xIterator < 4 && xIterator > -5) // tower insides
  234. {
  235. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), Blocks.AIR.getDefaultState());
  236. }
  237. continue;
  238. }
  239. if (zIterator != -5 || xIterator <= -5 || xIterator >= 5) // outside tower
  240. {
  241. continue;
  242. }
  243. if (floorIterator != 0 && floorIterator != 6 || xIterator != -4 && xIterator != 3) {
  244. if (floorIterator == 5 && (xIterator == 3 || xIterator == -4)) {
  245. buildFloorPiece(world, iCurrent, jCurrent, zCurrent, towerFloorBlockID, towerFloorMeta);
  246. } else {
  247. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator); // under stairwell
  248. }
  249. } else {
  250. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), Blocks.AIR.getDefaultState()); // stairwell space
  251. }
  252. continue;
  253. }
  254. if (zIterator == -4 || zIterator == -3 || zIterator == 2 || zIterator == 3) // rows 11, 10, 5, 4
  255. {
  256. if (xIterator == -6 || xIterator == 5) // outer wall parts
  257. {
  258. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  259. continue;
  260. }
  261. if (xIterator <= -6 || xIterator >= 5) // outside tower
  262. {
  263. continue;
  264. }
  265. if (floorIterator == 5) {
  266. buildFloorPiece(world, iCurrent, jCurrent, zCurrent, towerFloorBlockID, towerFloorMeta);
  267. continue;
  268. }
  269. if (world.getBlockState(new BlockPos(iCurrent, jCurrent, zCurrent)).getBlock() != Blocks.CHEST) // tower inside space
  270. {
  271. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), Blocks.AIR.getDefaultState());
  272. }
  273. continue;
  274. }
  275. if (zIterator > -3 && zIterator < 2) // rows 10 to 5
  276. {
  277. if (xIterator == -7 || xIterator == 6) {
  278. if (floorIterator < 0 || floorIterator > 3 || ((xIterator != -7 && xIterator != 6) || underground) || zIterator != -1 && zIterator != 0) // wall, short of window
  279. {
  280. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  281. } else {
  282. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), Blocks.AIR.getDefaultState());
  283. }
  284. continue;
  285. }
  286. if (xIterator <= -7 || xIterator >= 6) {
  287. continue;
  288. }
  289. if (floorIterator == 5) {
  290. buildFloorPiece(world, iCurrent, jCurrent, zCurrent, towerFloorBlockID, towerFloorMeta);
  291. } else {
  292. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), Blocks.AIR.getDefaultState());
  293. }
  294. continue;
  295. }
  296. if (zIterator == 4) // row 3
  297. {
  298. if (xIterator == -5 || xIterator == 4) {
  299. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  300. continue;
  301. }
  302. if (xIterator <= -5 || xIterator >= 4) {
  303. continue;
  304. }
  305. if (floorIterator == 5) {
  306. buildFloorPiece(world, iCurrent, jCurrent, zCurrent, towerFloorBlockID, towerFloorMeta);
  307. } else {
  308. world.setBlockState(new BlockPos(iCurrent, jCurrent, zCurrent), Blocks.AIR.getDefaultState());
  309. }
  310. continue;
  311. }
  312. if (zIterator == 5) // row 2
  313. {
  314. if (xIterator == -4 || xIterator == -3 || xIterator == 2 || xIterator == 3) {
  315. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  316. continue;
  317. }
  318. if (xIterator <= -3 || xIterator >= 2) {
  319. continue;
  320. }
  321. if (floorIterator == 5) {
  322. buildFloorPiece(world, iCurrent, jCurrent, zCurrent, towerFloorBlockID, towerFloorMeta);
  323. } else {
  324. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  325. }
  326. continue;
  327. }
  328. if (zIterator != 6 || xIterator <= -3 || xIterator >= 2) {
  329. continue;
  330. }
  331. if (floorIterator < 0 || floorIterator > 3 || xIterator != -1 && xIterator != 0) {
  332. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  333. } else {
  334. buildWallPiece(world, iCurrent, jCurrent, zCurrent, towerWallBlockID, floor, floorIterator);
  335. }
  336. }
  337.  
  338. }
  339. }
  340.  
  341. if (floor == 2) {
  342. world.setBlockState(new BlockPos(ix + 3, builderHeight, kz - 5), towerWallBlockID.getDefaultState());
  343. world.setBlockState(new BlockPos(ix + 3, builderHeight - 1, kz - 5), towerWallBlockID.getDefaultState());
  344. }
  345. if ((!underground && topFloor) || (underground && floor == 1)) {
  346. if (towerChosen != TowerTypes.Null) {
  347. AS_EntityGolem entitygolem = new AS_EntityGolem(world, towerChosen.ordinal());
  348. entitygolem.setLocationAndAngles(ix + 0.5 D, builderHeight + 6, kz + 0.5 D, world.rand.nextFloat() * 360 F, 0.0 F);
  349. world.spawnEntity(entitygolem);
  350. }
  351. } else {
  352. if (towerChosen != TowerTypes.Null) {
  353. world.setBlockState(new BlockPos(ix + 2, builderHeight + 6, kz + 2), Blocks.MOB_SPAWNER.getDefaultState());
  354. TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world.getTileEntity(new BlockPos(ix + 2, builderHeight + 6, kz + 2));
  355. if (tileentitymobspawner != null) {
  356. if (!Loader.isModLoaded("dungeontweaks")) {
  357. tileentitymobspawner.getSpawnerBaseLogic().setEntityId(getMobType(world.rand));
  358. } else {
  359. try {
  360. Constructor << ? extends Event > constructor = (Constructor << ? extends Event > ) Class.forName("com.EvilNotch.dungeontweeks.main.Events.EventDungeon$Post").getConstructor(TileEntity.class, BlockPos.class, Random.class, ResourceLocation.class, World.class);
  361. Event event = constructor.newInstance(tileentitymobspawner, tileentitymobspawner.getPos(), world.rand, new ResourceLocation("battletowers:" + towerChosen.getName()), world);
  362. MinecraftForge.EVENT_BUS.post(event);
  363. } catch (Throwable t) {
  364. t.printStackTrace();
  365. }
  366. }
  367. }
  368.  
  369. world.setBlockState(new BlockPos(ix - 3, builderHeight + 6, kz + 2), Blocks.MOB_SPAWNER.getDefaultState());
  370. tileentitymobspawner = (TileEntityMobSpawner) world.getTileEntity(new BlockPos(ix - 3, builderHeight + 6, kz + 2));
  371. if (tileentitymobspawner != null) {
  372. if (!Loader.isModLoaded("dungeontweaks")) {
  373. tileentitymobspawner.getSpawnerBaseLogic().setEntityId(getMobType(world.rand));
  374. } else {
  375. try {
  376. Constructor << ? extends Event > constructor = (Constructor << ? extends Event > ) Class.forName("com.EvilNotch.dungeontweeks.main.Events.EventDungeon$Post").getConstructor(TileEntity.class, BlockPos.class, Random.class, ResourceLocation.class, World.class);
  377. Event event = constructor.newInstance(tileentitymobspawner, tileentitymobspawner.getPos(), world.rand, new ResourceLocation("battletowers:" + towerChosen.getName()), world);
  378. MinecraftForge.EVENT_BUS.post(event);
  379. } catch (Throwable t) {
  380. t.printStackTrace();
  381. }
  382. }
  383. }
  384. } else {
  385. world.setBlockState(new BlockPos(ix + 2, builderHeight + 6, kz + 2), Blocks.AIR.getDefaultState());
  386. world.setBlockState(new BlockPos(ix - 3, builderHeight + 6, kz + 2), Blocks.AIR.getDefaultState());
  387. }
  388. }
  389. // chest pedestal
  390. world.setBlockState(new BlockPos(ix, builderHeight + 6, kz + 3), towerFloorBlockID.getDefaultState());
  391. world.setBlockState(new BlockPos(ix - 1, builderHeight + 6, kz + 3), towerFloorBlockID.getDefaultState());
  392.  
  393. if (builderHeight + 56 >= 120 && floor == 1) {
  394. floor = 2;
  395. }
  396.  
  397. if (towerChosen != TowerTypes.Null) {
  398. // chest
  399. TowerStageItemManager floorChestManager;
  400. if (!underground) {
  401. floorChestManager = topFloor ? WorldGenHandler.getTowerStageManagerForFloor(10) : WorldGenHandler.getTowerStageManagerForFloor(floor);
  402. } else {
  403. floorChestManager = floor == 1 ? WorldGenHandler.getTowerStageManagerForFloor(10) : WorldGenHandler.getTowerStageManagerForFloor(Math.abs(11 - floor));
  404. }
  405.  
  406. for (int chestlength = 0; chestlength < 2; chestlength++) {
  407. world.setBlockState(new BlockPos(ix - chestlength, builderHeight + 7, kz + 3), Blocks.CHEST.getStateFromMeta(2));
  408. TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(new BlockPos(ix - chestlength, builderHeight + 7, kz + 3));
  409. if (tileentitychest != null) {
  410. int count = underground ? AS_BattleTowersCore.instance.itemGenerateAttemptsPerFloor * 2 : AS_BattleTowersCore.instance.itemGenerateAttemptsPerFloor;
  411. List < ItemStack > generatedStacks = floorChestManager.getStageItemStacks(world, world.rand, tileentitychest, count);
  412. List < Integer > freeSlots = new ArrayList < > (tileentitychest.getSizeInventory());
  413. for (int i = 0; i < tileentitychest.getSizeInventory(); i++) {
  414. freeSlots.add(i);
  415. }
  416. Iterator < ItemStack > iterator = generatedStacks.iterator();
  417. while (iterator.hasNext() && !freeSlots.isEmpty()) {
  418. Integer slot = freeSlots.get(world.rand.nextInt(freeSlots.size()));
  419. freeSlots.remove(slot);
  420. tileentitychest.setInventorySlotContents(slot, iterator.next());
  421. }
  422. }
  423. }
  424. } else {
  425. for (int chestlength = 0; chestlength < 2; chestlength++) {
  426. world.setBlockState(new BlockPos(ix - chestlength, builderHeight + 7, kz + 3), Blocks.CHEST.getStateFromMeta(2));
  427. }
  428. }
  429.  
  430. // move lights builder a bit higher, to support non-opaque lights such as lamps
  431. world.setBlockState(new BlockPos(ix + 3, builderHeight + 2, kz - 6), towerLightBlockID.getDefaultState());
  432. world.setBlockState(new BlockPos(ix - 4, builderHeight + 2, kz - 6), towerLightBlockID.getDefaultState());
  433. world.setBlockState(new BlockPos(ix + 1, builderHeight + 2, kz - 4), towerLightBlockID.getDefaultState());
  434. world.setBlockState(new BlockPos(ix - 2, builderHeight + 2, kz - 4), towerLightBlockID.getDefaultState());
  435.  
  436. if (towerChosen != TowerTypes.Null) {
  437. for (int l3 = 0; l3 < (floor * 4 + towerChosen.ordinal()) - 8 && !topFloor; l3++) // random hole poker
  438. {
  439. int k4 = 5 - world.rand.nextInt(12);
  440. int k5 = builderHeight + 5;
  441. int j6 = 5 - world.rand.nextInt(10);
  442. if (j6 < -2 && k4 < 4 && k4 > -5 && k4 != 1 && k4 != -2) {
  443. continue;
  444. }
  445. k4 += ix;
  446. j6 += kz;
  447. if (world.getBlockState(new BlockPos(k4, k5, j6)).getBlock() == towerFloorBlockID && world.getBlockState(new BlockPos(k4, k5 + 1, j6)).getBlock() != Blocks.MOB_SPAWNER) {
  448. world.setBlockState(new BlockPos(k4, k5, j6), Blocks.AIR.getDefaultState());
  449. }
  450. }
  451. }
  452.  
  453. floor++;
  454. }
  455.  
  456. System.out.println("Battle Tower type " + towerChosen + " spawned at [ " + ix + " | " + kz + " ], underground: " + underground);
  457. }
  458.  
  459. @SuppressWarnings("deprecation")
  460. private void buildFloorPiece(World world, int i, int j, int k, Block towerFloorBlockID, int towerFloorMeta) {
  461. world.setBlockState(new BlockPos(i, j, k), towerFloorBlockID.getStateFromMeta(towerFloorMeta));
  462. }
  463.  
  464. private void buildWallPiece(World world, int i, int j, int k, Block towerWallBlockID, int floor, int floorIterator) {
  465. world.setBlockState(new BlockPos(i, j, k), towerWallBlockID.getDefaultState());
  466. if (floor == 1 && floorIterator == 4) {
  467. fillTowerBaseToGround(world, i, j, k, towerWallBlockID);
  468. }
  469. }
  470.  
  471. private void fillTowerBaseToGround(World world, int i, int j, int k, Block blocktype) {
  472. int y = j - 1;
  473. while (y > 0 && !isBuildableBlockID(world.getBlockState(new BlockPos(i, y, k)).getBlock())) {
  474. world.setBlockState(new BlockPos(i, y, k), blocktype.getDefaultState());
  475. y--;
  476. }
  477. }
  478.  
  479. private int getSurfaceBlockHeight(World world, int x, int z) {
  480. int h = 50;
  481.  
  482. do {
  483. h++;
  484. }
  485. while (world.getBlockState(new BlockPos(x, h, z)).getBlock() != Blocks.AIR && !isFoliageBlockID(world.getBlockState(new BlockPos(x, h, z)).getBlock()));
  486.  
  487. return h - 1;
  488. }
  489.  
  490. private boolean isFoliageBlockID(Block ID) {
  491. return (ID == Blocks.SNOW || ID == Blocks.TALLGRASS || ID == Blocks.DEADBUSH || ID == Blocks.LOG || ID == Blocks.LOG2 || ID == Blocks.LEAVES);
  492. }
  493.  
  494. private boolean isBuildableBlockID(Block ID) {
  495. return (ID == Blocks.STONE || ID == Blocks.GRASS || ID == Blocks.SAND || ID == Blocks.SANDSTONE || ID == Blocks.GRAVEL || ID == Blocks.DIRT);
  496. }
  497.  
  498. private boolean isBannedBlockID(Block iD) {
  499. return (iD == Blocks.YELLOW_FLOWER || iD == Blocks.RED_FLOWER || iD == Blocks.BROWN_MUSHROOM_BLOCK || iD == Blocks.RED_MUSHROOM_BLOCK || iD == Blocks.CACTUS || iD == Blocks.PUMPKIN ||
  500. iD == Blocks.LAVA);
  501. }
  502.  
  503. private ResourceLocation getMobType(Random random) {
  504. switch (random.nextInt(10)) {
  505. case 0:
  506. case 1:
  507. case 2:
  508. {
  509. return EntityList.getKey(EntitySkeleton.class);
  510. }
  511. case 3:
  512. case 4:
  513. case 5:
  514. case 6:
  515. {
  516. return EntityList.getKey(EntityZombie.class);
  517. }
  518. case 7:
  519. case 8:
  520. {
  521. EntityList.getKey(EntitySpider.class);
  522. }
  523. case 9:
  524. {
  525. return EntityList.getKey(EntityCaveSpider.class);
  526. }
  527. default:
  528. return EntityList.getKey(EntityZombie.class);
  529. }
  530. }
  531.  
  532. public enum TowerTypes {
  533. Null("null", Blocks.AIR, Blocks.AIR, Blocks.AIR, 0, Blocks.AIR),
  534. CobbleStone("cobblestone", Blocks.COBBLESTONE, Blocks.TORCH, Blocks.DOUBLE_STONE_SLAB, 0, Blocks.STONE_STAIRS),
  535. CobbleStoneMossy("cobblestonemossy", Blocks.MOSSY_COBBLESTONE, Blocks.TORCH, Blocks.DOUBLE_STONE_SLAB, 0, Blocks.STONE_STAIRS),
  536. SandStone("sandstone", Blocks.SANDSTONE, Blocks.TORCH, Blocks.DOUBLE_STONE_SLAB, 1, Blocks.SANDSTONE_STAIRS),
  537. Ice("ice", Blocks.ICE, Blocks.AIR /* Blocks.GLOWSTONE */ , Blocks.CLAY, 2, Blocks.OAK_STAIRS), // since when does glowstone melt ice
  538. SmoothStone("smoothstone", Blocks.STONE, Blocks.TORCH, Blocks.DOUBLE_STONE_SLAB, 3, Blocks.STONE_STAIRS),
  539. Netherrack("netherrack", Blocks.NETHERRACK, Blocks.GLOWSTONE, Blocks.SOUL_SAND, 0, Blocks.NETHER_BRICK_STAIRS),
  540. Jungle("jungle", Blocks.MOSSY_COBBLESTONE, Blocks.WEB, Blocks.DIRT, 0, Blocks.JUNGLE_STAIRS);
  541.  
  542. private Block wallBlockID;
  543. private Block lightBlockID;
  544. private Block floorBlockID;
  545. private int floorBlockMetaData;
  546. private Block stairBlockID;
  547. private String typeName;
  548.  
  549. TowerTypes(String t, Block a, Block b, Block c, int d, Block e) {
  550. this.wallBlockID = a;
  551. this.lightBlockID = b;
  552. this.floorBlockID = c;
  553. this.floorBlockMetaData = d;
  554. this.stairBlockID = e;
  555. this.typeName = t;
  556. }
  557.  
  558. Block getWallBlockID() {
  559. return wallBlockID;
  560. }
  561.  
  562. Block getLightBlockID() {
  563. return lightBlockID;
  564. }
  565.  
  566. Block getFloorBlockID() {
  567. return floorBlockID;
  568. }
  569.  
  570. int getFloorBlockMetaData() {
  571. return floorBlockMetaData;
  572. }
  573.  
  574. Block getStairBlockID() {
  575. return stairBlockID;
  576. }
  577. public String getName() {
  578. return this.typeName;
  579. }
  580. }
  581.  
  582. }
Add Comment
Please, Sign In to add comment