diff --git a/src/main/java/net/boatcake/MyWorldGen/BlockPlacementOption.java b/src/main/java/net/boatcake/MyWorldGen/BlockPlacementOption.java index 81caa88..b769a74 100644 --- a/src/main/java/net/boatcake/MyWorldGen/BlockPlacementOption.java +++ b/src/main/java/net/boatcake/MyWorldGen/BlockPlacementOption.java @@ -1,8 +1,8 @@ package net.boatcake.MyWorldGen; public enum BlockPlacementOption { - ASGENERATED("gui.placement.asgenerated", 0, true, true, true), LOSSLESS( - "gui.placement.lossless", 1, false, false, false); + ASGENERATED("gui.placement.asgenerated", 0, true, true, true), LOSSLESS("gui.placement.lossless", 1, false, false, + false); public String text; public BlockPlacementOption next; @@ -16,8 +16,8 @@ public enum BlockPlacementOption { LOSSLESS.next = ASGENERATED; } - private BlockPlacementOption(String text, int id, boolean generateChests, - boolean generateSpawners, boolean followPlacementRules) { + private BlockPlacementOption(String text, int id, boolean generateChests, boolean generateSpawners, + boolean followPlacementRules) { this.text = text; this.id = id; this.generateChests = generateChests; diff --git a/src/main/java/net/boatcake/MyWorldGen/CommonProxy.java b/src/main/java/net/boatcake/MyWorldGen/CommonProxy.java index 54fb8a9..9fa33ee 100644 --- a/src/main/java/net/boatcake/MyWorldGen/CommonProxy.java +++ b/src/main/java/net/boatcake/MyWorldGen/CommonProxy.java @@ -13,9 +13,7 @@ public abstract class CommonProxy { public abstract void registerItem(Item item, int metadata, String itemName); - public abstract void registerBlock(Block block, int metadata, - String blockName); + public abstract void registerBlock(Block block, int metadata, String blockName); - public abstract void registerVariants(Block block, PropertyEnum prop, - String postfix); + public abstract void registerVariants(Block block, PropertyEnum prop, String postfix); } diff --git a/src/main/java/net/boatcake/MyWorldGen/ContainerAnchorInventory.java b/src/main/java/net/boatcake/MyWorldGen/ContainerAnchorInventory.java index 60759e9..ac257db 100644 --- a/src/main/java/net/boatcake/MyWorldGen/ContainerAnchorInventory.java +++ b/src/main/java/net/boatcake/MyWorldGen/ContainerAnchorInventory.java @@ -10,8 +10,7 @@ public class ContainerAnchorInventory extends Container { protected TileEntityAnchorInventory tileEntity; - public ContainerAnchorInventory(InventoryPlayer inventoryPlayer, - TileEntityAnchorInventory te) { + public ContainerAnchorInventory(InventoryPlayer inventoryPlayer, TileEntityAnchorInventory te) { tileEntity = te; /* @@ -20,8 +19,7 @@ public ContainerAnchorInventory(InventoryPlayer inventoryPlayer, */ for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - addSlotToContainer(new SlotPhantomBlock(tileEntity, j + i * 3, - 62 + j * 18, 17 + i * 18)); + addSlotToContainer(new SlotPhantomBlock(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18)); } } bindPlayerInventory(inventoryPlayer); @@ -30,8 +28,7 @@ public ContainerAnchorInventory(InventoryPlayer inventoryPlayer, protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, - 8 + j * 18, 84 + i * 18)); + addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } @@ -48,7 +45,7 @@ public boolean canInteractWith(EntityPlayer entityplayer) { @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotIdx) { ItemStack stackCopy = null; - Slot slot = (Slot) inventorySlots.get(slotIdx); + Slot slot = inventorySlots.get(slotIdx); // null checks and checks if the item can be stacked (maxStackSize > 1) if (slot != null && slot.getHasStack()) { @@ -63,8 +60,7 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slotIdx) { } // places it into the tileEntity is possible since its in the player // inventory - else if (!slot.isItemValid(stackInSlot) - || !this.mergeItemStack(stackInSlot, 0, 9, false)) { + else if (!slot.isItemValid(stackInSlot) || !this.mergeItemStack(stackInSlot, 0, 9, false)) { return null; } diff --git a/src/main/java/net/boatcake/MyWorldGen/GuiHandler.java b/src/main/java/net/boatcake/MyWorldGen/GuiHandler.java index 8868c1c..d24cf17 100644 --- a/src/main/java/net/boatcake/MyWorldGen/GuiHandler.java +++ b/src/main/java/net/boatcake/MyWorldGen/GuiHandler.java @@ -16,8 +16,7 @@ public class GuiHandler implements IGuiHandler { @Override - public Object getClientGuiElement(int id, EntityPlayer player, World world, - int x, int y, int z) { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { if (FMLCommonHandler.instance().getSide() != Side.CLIENT) { return null; } @@ -25,13 +24,11 @@ public Object getClientGuiElement(int id, EntityPlayer player, World world, case 0: return new GuiSaveSchematic(); case 1: - return new GuiLoadSchematic(new BlockPos(x, y, z), - DirectionUtils.getDirectionFromYaw(player.rotationYaw)); + return new GuiLoadSchematic(new BlockPos(x, y, z), DirectionUtils.getDirectionFromYaw(player.rotationYaw)); case 2: TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); if (tileEntity instanceof TileEntityAnchorInventory) { - return new GuiAnchorInventory(player.inventory, - (TileEntityAnchorInventory) tileEntity); + return new GuiAnchorInventory(player.inventory, (TileEntityAnchorInventory) tileEntity); } return null; default: @@ -40,13 +37,11 @@ public Object getClientGuiElement(int id, EntityPlayer player, World world, } @Override - public Object getServerGuiElement(int id, EntityPlayer player, World world, - int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { if (id == 2) { TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); if (tileEntity instanceof TileEntityAnchorInventory) { - return new ContainerAnchorInventory(player.inventory, - (TileEntityAnchorInventory) tileEntity); + return new ContainerAnchorInventory(player.inventory, (TileEntityAnchorInventory) tileEntity); } } return null; diff --git a/src/main/java/net/boatcake/MyWorldGen/MyWorldGen.java b/src/main/java/net/boatcake/MyWorldGen/MyWorldGen.java index 99e7d96..176535a 100644 --- a/src/main/java/net/boatcake/MyWorldGen/MyWorldGen.java +++ b/src/main/java/net/boatcake/MyWorldGen/MyWorldGen.java @@ -80,27 +80,21 @@ public void postInit(FMLPostInitializationEvent event) { FileUtils.extractSchematics(sourceFile); } - FMLInterModComms - .sendMessage( - "OpenBlocks", - "donateUrl", - "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=UHDDACLRN2T46&lc=US&item_name=MyWorldGen¤cy_code=USD&bn=PP-DonationsBF:btn_donate_SM.gif:NonHosted"); + FMLInterModComms.sendMessage("OpenBlocks", "donateUrl", + "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=UHDDACLRN2T46&lc=US&item_name=MyWorldGen¤cy_code=USD&bn=PP-DonationsBF:btn_donate_SM.gif:NonHosted"); sidedProxy.registerResourceHandler(worldGen); if (materialAnchorBlock != null) { - for (BlockAnchorMaterial.AnchorType type : BlockAnchorMaterial.AnchorType - .values()) { - sidedProxy.registerBlock(materialAnchorBlock, type.id, MODID - + ":" + type.name + "_anchor"); + for (BlockAnchorMaterial.AnchorType type : BlockAnchorMaterial.AnchorType.values()) { + sidedProxy.registerBlock(materialAnchorBlock, type.id, MODID + ":" + type.name + "_anchor"); } } if (ignoreBlock != null) { sidedProxy.registerBlock(ignoreBlock, 0, MODID + ":ignore"); } if (inventoryAnchorBlock != null) { - sidedProxy.registerBlock(inventoryAnchorBlock, 0, MODID - + ":anchorInventory"); + sidedProxy.registerBlock(inventoryAnchorBlock, 0, MODID + ":anchorInventory"); } if (wandLoad != null) { sidedProxy.registerItem(wandLoad, 0, MODID + ":wandLoad"); @@ -122,9 +116,7 @@ public void init(FMLInitializationEvent event) throws Exception { cfg.load(); enableItemsAndBlocks = cfg - .get("configuration", - "enableItemsAndBlocks", - true, + .get("configuration", "enableItemsAndBlocks", true, "Turn this off if you're running a server and the clients don't have the mod installed") .getBoolean(true); if (!enableItemsAndBlocks) { @@ -135,35 +127,29 @@ public void init(FMLInitializationEvent event) throws Exception { creativeTab = new CreativeTabs("tabMyWorldGen") { @Override public Item getTabIconItem() { - return Item - .getItemFromBlock(materialAnchorBlock == null ? Blocks.grass - : materialAnchorBlock); + return Item.getItemFromBlock(materialAnchorBlock == null ? Blocks.grass : materialAnchorBlock); } }; } try { Property prop; - materialAnchorBlock = registerBlock("anchor", - BlockAnchorMaterial.class, BlockAnchorItem.class, + materialAnchorBlock = registerBlock("anchor", BlockAnchorMaterial.class, BlockAnchorItem.class, BlockAnchorMaterialLogic.class); new BlockPlacementMaterialAnchor(MODID + ":anchor"); if (materialAnchorBlock != null) { - sidedProxy.registerVariants(materialAnchorBlock, - BlockAnchorMaterial.TYPE_PROP, "_anchor"); + sidedProxy.registerVariants(materialAnchorBlock, BlockAnchorMaterial.TYPE_PROP, "_anchor"); } int defaultId; if (materialAnchorBlock == null) { defaultId = 1575; } else { - defaultId = GameData.getBlockRegistry().getId( - materialAnchorBlock); + defaultId = GameData.getBlockRegistry().getId(materialAnchorBlock); } - prop = cfg - .get("blocks", "materialAnchorBlock", defaultId, - "Default ID for when an ID map is not found in a schematic"); + prop = cfg.get("blocks", "materialAnchorBlock", defaultId, + "Default ID for when an ID map is not found in a schematic"); materialAnchorBlockId = prop.getInt(defaultId); ignoreBlock = registerBlock("ignore", BlockIgnore.class); @@ -173,24 +159,20 @@ public Item getTabIconItem() { } else { defaultId = GameData.getBlockRegistry().getId(ignoreBlock); } - prop = cfg - .get("blocks", "ignoreBlock", defaultId, - "Default ID for when an ID map is not found in a schematic"); + prop = cfg.get("blocks", "ignoreBlock", defaultId, + "Default ID for when an ID map is not found in a schematic"); ignoreBlockId = prop.getInt(defaultId); - inventoryAnchorBlock = registerBlock("anchorInventory", - BlockAnchorInventory.class, ItemBlock.class, + inventoryAnchorBlock = registerBlock("anchorInventory", BlockAnchorInventory.class, ItemBlock.class, BlockAnchorInventoryLogic.class); new BlockPlacementIgnore(MODID + ":anchorInventory"); if (inventoryAnchorBlock == null) { defaultId = 1577; } else { - defaultId = GameData.getBlockRegistry().getId( - inventoryAnchorBlock); + defaultId = GameData.getBlockRegistry().getId(inventoryAnchorBlock); } - prop = cfg - .get("blocks", "inventoryAnchorBlock", defaultId, - "Default ID for when an ID map is not found in a schematic"); + prop = cfg.get("blocks", "inventoryAnchorBlock", defaultId, + "Default ID for when an ID map is not found in a schematic"); inventoryAnchorBlockId = prop.getInt(defaultId); wandSave = registerItem("wandSave", ItemWandSave.class, cfg); @@ -201,27 +183,21 @@ public Item getTabIconItem() { throw new Exception("Self-reflection failed. Is the mod intact?", e); } - String worldGenDir = cfg.get("configuration", "schematicDirectory", - "worldgen", "Subdirectory of .minecraft").getString(); + String worldGenDir = cfg.get("configuration", "schematicDirectory", "worldgen", "Subdirectory of .minecraft") + .getString(); globalSchemDir = sidedProxy.getGlobalSchemDir(worldGenDir); - generateNothingWeight = cfg - .get("configuration", "generateNothingWeight", 10, - "Increase this number to generate fewer structures, decrease to generate more.") - .getInt(10); + generateNothingWeight = cfg.get("configuration", "generateNothingWeight", 10, + "Increase this number to generate fewer structures, decrease to generate more.").getInt(10); generateTries = cfg - .get("configuration", - "generateTries", - 128, + .get("configuration", "generateTries", 128, "Increase this if you have structures with complex anchor block layouts. Higher numbers will make longer load times.") .getInt(128); baseGenerateChance = cfg - .get("configuration", - "baseGenerateChance", - 1.0, - "Base chance for generating in a given chunk. Compounds with generateNothingWeight.", - 0.0, 1.0).getDouble(1.0); + .get("configuration", "baseGenerateChance", 1.0, + "Base chance for generating in a given chunk. Compounds with generateNothingWeight.", 0.0, 1.0) + .getDouble(1.0); if (cfg.hasChanged()) { cfg.save(); @@ -229,39 +205,31 @@ public Item getTabIconItem() { worldGen = new WorldGenerator(); - GameRegistry.registerTileEntity(TileEntityAnchorInventory.class, - "anchorInventory"); + GameRegistry.registerTileEntity(TileEntityAnchorInventory.class, "anchorInventory"); GameRegistry.registerWorldGenerator(worldGen, 0); } private Block registerBlock(String name, Class blockClass, - Class itemBlockClass, - Class matching, Object... itemCtorArgs) - throws Exception { + Class itemBlockClass, Class matching, + Object... itemCtorArgs) throws Exception { Block block = null; if (enableItemsAndBlocks) { - block = blockClass.getConstructor(Material.class).newInstance( - Material.circuits); + block = blockClass.getConstructor(Material.class).newInstance(Material.circuits); block.setUnlocalizedName(name); block.setCreativeTab(creativeTab); - GameRegistry.registerBlock(block, itemBlockClass, name, - itemCtorArgs); + GameRegistry.registerBlock(block, itemBlockClass, name, itemCtorArgs); } if (matching != null) { - matching.getConstructor(String.class).newInstance( - MyWorldGen.MODID + ":" + name); + matching.getConstructor(String.class).newInstance(MyWorldGen.MODID + ":" + name); } return block; } - private Block registerBlock(String name, Class blockClass) - throws Exception { - return registerBlock(name, blockClass, ItemBlock.class, null, - new Object[] {}); + private Block registerBlock(String name, Class blockClass) throws Exception { + return registerBlock(name, blockClass, ItemBlock.class, null, new Object[] {}); } - private Item registerItem(String name, Class itemClass, - Configuration cfg) throws Exception { + private Item registerItem(String name, Class itemClass, Configuration cfg) throws Exception { Item item = null; if (enableItemsAndBlocks) { item = itemClass.getConstructor().newInstance(); diff --git a/src/main/java/net/boatcake/MyWorldGen/Schematic.java b/src/main/java/net/boatcake/MyWorldGen/Schematic.java index 3af065d..c6f4fa8 100644 --- a/src/main/java/net/boatcake/MyWorldGen/Schematic.java +++ b/src/main/java/net/boatcake/MyWorldGen/Schematic.java @@ -92,8 +92,7 @@ public Schematic(NBTTagCompound tag, String n) { public void readFromNBT(NBTTagCompound tag, String n) { info.name = n; if (!tag.getString("Materials").equals("Alpha")) { - throw new RuntimeException( - "Non-Alpha schematics are not supported!"); + throw new RuntimeException("Non-Alpha schematics are not supported!"); } width = tag.getShort("Width"); height = tag.getShort("Height"); @@ -109,8 +108,7 @@ public void readFromNBT(NBTTagCompound tag, String n) { idMap.put(id, block); } else if (!BlockAnchorLogic.isAnchorBlock(blockName) && !BlockPlacementLogic.placementLogicExists(blockName)) { - MyWorldGen.log.log(Level.WARN, - "Can't find a block named {}", blockName); + MyWorldGen.log.log(Level.WARN, "Can't find a block named {}", blockName); } if (BlockAnchorLogic.isAnchorBlock(blockName)) { matchingMap.put(id, BlockAnchorLogic.get(blockName)); @@ -125,22 +123,15 @@ public void readFromNBT(NBTTagCompound tag, String n) { if (MyWorldGen.ignoreBlock != null) { idMap.put(id, MyWorldGen.ignoreBlock); } - placingMap.put(id, - BlockPlacementLogic.get(MyWorldGen.MODID + ":ignore")); + placingMap.put(id, BlockPlacementLogic.get(MyWorldGen.MODID + ":ignore")); } else { - MyWorldGen.log - .log(Level.WARN, - "Schematic file {} has no ignoreBlockId tag, defaulting to ID from config", - info.name); + MyWorldGen.log.log(Level.WARN, + "Schematic file {} has no ignoreBlockId tag, defaulting to ID from config", info.name); if (MyWorldGen.ignoreBlock != null) { - placingMap.put( - GameData.getBlockRegistry().getId( - MyWorldGen.ignoreBlock), - BlockPlacementLogic.get(MyWorldGen.MODID - + ":ignore")); + placingMap.put(GameData.getBlockRegistry().getId(MyWorldGen.ignoreBlock), + BlockPlacementLogic.get(MyWorldGen.MODID + ":ignore")); } - placingMap.put(MyWorldGen.ignoreBlockId, - BlockPlacementLogic.get(MyWorldGen.MODID + ":ignore")); + placingMap.put(MyWorldGen.ignoreBlockId, BlockPlacementLogic.get(MyWorldGen.MODID + ":ignore")); } if (tag.hasKey("anchorBlockId")) { @@ -148,52 +139,31 @@ public void readFromNBT(NBTTagCompound tag, String n) { if (MyWorldGen.materialAnchorBlock != null) { idMap.put(id, MyWorldGen.materialAnchorBlock); } - placingMap.put(id, - BlockPlacementLogic.get(MyWorldGen.MODID + ":anchor")); - matchingMap.put(id, - BlockAnchorLogic.get(MyWorldGen.MODID + ":anchor")); + placingMap.put(id, BlockPlacementLogic.get(MyWorldGen.MODID + ":anchor")); + matchingMap.put(id, BlockAnchorLogic.get(MyWorldGen.MODID + ":anchor")); } else { - MyWorldGen.log - .log(Level.WARN, - "Schematic file {} has no anchorBlockId tag, defaulting to ID from config", - info.name); + MyWorldGen.log.log(Level.WARN, + "Schematic file {} has no anchorBlockId tag, defaulting to ID from config", info.name); if (MyWorldGen.materialAnchorBlock != null) { - placingMap.put( - GameData.getBlockRegistry().getId( - MyWorldGen.materialAnchorBlock), - BlockPlacementLogic.get(MyWorldGen.MODID - + ":anchor")); - matchingMap.put( - GameData.getBlockRegistry().getId( - MyWorldGen.materialAnchorBlock), + placingMap.put(GameData.getBlockRegistry().getId(MyWorldGen.materialAnchorBlock), + BlockPlacementLogic.get(MyWorldGen.MODID + ":anchor")); + matchingMap.put(GameData.getBlockRegistry().getId(MyWorldGen.materialAnchorBlock), BlockAnchorLogic.get(MyWorldGen.MODID + ":anchor")); } - placingMap.put(MyWorldGen.materialAnchorBlockId, - BlockPlacementLogic.get(MyWorldGen.MODID + ":anchor")); - matchingMap.put(MyWorldGen.materialAnchorBlockId, - BlockAnchorLogic.get(MyWorldGen.MODID + ":anchor")); + placingMap.put(MyWorldGen.materialAnchorBlockId, BlockPlacementLogic.get(MyWorldGen.MODID + ":anchor")); + matchingMap.put(MyWorldGen.materialAnchorBlockId, BlockAnchorLogic.get(MyWorldGen.MODID + ":anchor")); } if (MyWorldGen.inventoryAnchorBlock != null) { - placingMap.put( - GameData.getBlockRegistry().getId( - MyWorldGen.inventoryAnchorBlock), - BlockPlacementLogic.get(MyWorldGen.MODID - + ":anchorInventory")); - matchingMap.put( - GameData.getBlockRegistry().getId( - MyWorldGen.inventoryAnchorBlock), - BlockAnchorLogic.get(MyWorldGen.MODID - + ":anchorInventory")); + placingMap.put(GameData.getBlockRegistry().getId(MyWorldGen.inventoryAnchorBlock), + BlockPlacementLogic.get(MyWorldGen.MODID + ":anchorInventory")); + matchingMap.put(GameData.getBlockRegistry().getId(MyWorldGen.inventoryAnchorBlock), + BlockAnchorLogic.get(MyWorldGen.MODID + ":anchorInventory")); } - placingMap.put( - MyWorldGen.inventoryAnchorBlockId, - BlockPlacementLogic.get(MyWorldGen.MODID - + ":anchorInventory")); - matchingMap - .put(MyWorldGen.inventoryAnchorBlockId, - BlockAnchorLogic.get(MyWorldGen.MODID - + ":anchorInventory")); + placingMap.put(MyWorldGen.inventoryAnchorBlockId, + BlockPlacementLogic.get(MyWorldGen.MODID + ":anchorInventory")); + matchingMap.put(MyWorldGen.inventoryAnchorBlockId, + BlockAnchorLogic.get(MyWorldGen.MODID + ":anchorInventory")); } anchorBlockLocations.clear(); @@ -214,8 +184,7 @@ public void readFromNBT(NBTTagCompound tag, String n) { blocks[x][y][z] = (blockBytes[blockIdx]) & 0xFF; meta[x][y][z] = (metaBytes[blockIdx]) & 0x0F; if (blockUpperBits != null) { - blocks[x][y][z] |= (blockUpperBits[blockIdx >> 1] << ((blockIdx % 2 == 0) ? 4 - : 8)) & 0xF00; + blocks[x][y][z] |= (blockUpperBits[blockIdx >> 1] << ((blockIdx % 2 == 0) ? 4 : 8)) & 0xF00; } if (matchingMap.containsKey(blocks[x][y][z])) { anchorBlockLocations.add(new BlockPos(x, y, z)); @@ -228,25 +197,21 @@ public void readFromNBT(NBTTagCompound tag, String n) { tileEntities = (NBTTagList) tag.getTag("TileEntities"); if (anchorBlockLocations.isEmpty() && info.name != null) { - MyWorldGen.log.log(Level.WARN, "No anchors found in schematic {}", - info.name); + MyWorldGen.log.log(Level.WARN, "No anchors found in schematic {}", info.name); } info.readFromNBT(tag); } public Schematic(World world, BlockPos pos1, BlockPos pos2) { - this((short) (Math.abs(pos2.getX() - pos1.getX()) + 1), (short) (Math - .abs(pos2.getY() - pos1.getY()) + 1), (short) (Math.abs(pos2 - .getZ() - pos1.getZ()) + 1), null); + this((short) (Math.abs(pos2.getX() - pos1.getX()) + 1), (short) (Math.abs(pos2.getY() - pos1.getY()) + 1), + (short) (Math.abs(pos2.getZ() - pos1.getZ()) + 1), null); - BlockPos min = new BlockPos(Math.min(pos1.getX(), pos2.getX()), - Math.min(pos1.getY(), pos2.getY()), Math.min(pos1.getZ(), - pos2.getZ())); + BlockPos min = new BlockPos(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()), + Math.min(pos1.getZ(), pos2.getZ())); Vec3i minVec = new Vec3i(min.getX(), min.getY(), min.getZ()); - BlockPos max = new BlockPos(Math.max(pos1.getX(), pos2.getX()), - Math.max(pos1.getY(), pos2.getY()), Math.max(pos1.getZ(), - pos2.getZ())); + BlockPos max = new BlockPos(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()), + Math.max(pos1.getZ(), pos2.getZ())); for (Object o : BlockPos.getAllInBox(min, max)) { BlockPos pos = (BlockPos) o; @@ -256,8 +221,7 @@ public Schematic(World world, BlockPos pos1, BlockPos pos2) { BlockPos offset = pos.subtract(minVec); blocks[offset.getX()][offset.getY()][offset.getZ()] = id; idMap.put(id, block); - meta[offset.getX()][offset.getY()][offset.getZ()] = block - .getMetaFromState(blockState); + meta[offset.getX()][offset.getY()][offset.getZ()] = block.getMetaFromState(blockState); } if (!world.isRemote) { this.entities = WorldUtils.getEntities(world, min, max); @@ -265,37 +229,28 @@ public Schematic(World world, BlockPos pos1, BlockPos pos2) { } } - public boolean fitsIntoWorldAt(World world, BlockPos at, - Rotation rotation) { + public boolean fitsIntoWorldAt(World world, BlockPos at, Rotation rotation) { // used for world generation to determine if all anchor blocks in the // schematic match up with the world Vec3d offset = new Vec3d(at.getX(), at.getY(), at.getZ()); if (anchorBlockLocations.isEmpty()) { - Vec3d middle = DirectionUtils.rotateCoords(new Vec3d(width / 2, 0, - length / 2), offset, rotation); + Vec3d middle = DirectionUtils.rotateCoords(new Vec3d(width / 2, 0, length / 2), offset, rotation); BlockPos mid = new BlockPos(middle); BlockPos midDown = mid.down(); IBlockState otherBlockBelow = world.getBlockState(mid); IBlockState otherBlockAbove = world.getBlockState(midDown); BiomeGenBase biome = world.getBiomeGenForCoords(mid); - return BlockAnchorMaterialLogic.matchesStatic( - BlockAnchorMaterial.AnchorType.GROUND, otherBlockBelow, - biome) - && BlockAnchorMaterialLogic.matchesStatic( - BlockAnchorMaterial.AnchorType.AIR, - otherBlockAbove, biome); + return BlockAnchorMaterialLogic.matchesStatic(BlockAnchorMaterial.AnchorType.GROUND, otherBlockBelow, biome) + && BlockAnchorMaterialLogic.matchesStatic(BlockAnchorMaterial.AnchorType.AIR, otherBlockAbove, + biome); } else { for (int i = 0; i < anchorBlockLocations.size(); i++) { BlockPos origCoords = anchorBlockLocations.get(i); - Vec3d rotatedCoords = DirectionUtils.rotateCoords(origCoords, - offset, rotation); + Vec3d rotatedCoords = DirectionUtils.rotateCoords(origCoords, offset, rotation); BlockPos rotatedPos = new BlockPos(rotatedCoords); - int blockId = blocks[origCoords.getX()][origCoords.getY()][origCoords - .getZ()]; - if (!(matchingMap.get(blockId)).matches( - meta[origCoords.getX()][origCoords.getY()][origCoords - .getZ()], getTileEntityAt(world.getMinecraftServer(), origCoords), world, - rotatedPos)) { + int blockId = blocks[origCoords.getX()][origCoords.getY()][origCoords.getZ()]; + if (!(matchingMap.get(blockId)).matches(meta[origCoords.getX()][origCoords.getY()][origCoords.getZ()], + getTileEntityAt(world.getMinecraftServer(), origCoords), world, rotatedPos)) { return false; } } @@ -345,9 +300,7 @@ public NBTTagCompound getNBT() { NBTTagCompound idMapTag = new NBTTagCompound(); for (Entry entry : idMap.entrySet()) { - idMapTag.setInteger( - Block.blockRegistry.getNameForObject(entry.getValue()) - .toString(), entry.getKey()); + idMapTag.setInteger(Block.blockRegistry.getNameForObject(entry.getValue()).toString(), entry.getKey()); } base.setTag("MWGIDMap", idMapTag); @@ -359,8 +312,7 @@ public NBTTagCompound getNBT() { public TileEntity getTileEntityAt(MinecraftServer server, BlockPos pos) { for (int i = 0; i < tileEntities.tagCount(); i++) { NBTTagCompound tileEntityTag = tileEntities.getCompoundTagAt(i); - if (tileEntityTag.getInteger("x") == pos.getX() - && tileEntityTag.getInteger("y") == pos.getY() + if (tileEntityTag.getInteger("x") == pos.getX() && tileEntityTag.getInteger("y") == pos.getY() && tileEntityTag.getInteger("z") == pos.getZ()) { TileEntity e = TileEntity.createTileEntity(server, tileEntityTag); return e; @@ -369,34 +321,30 @@ public TileEntity getTileEntityAt(MinecraftServer server, BlockPos pos) { return null; } - private static final List jungleDispenserContents = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.arrow, 0, 2, 7, 30)}); - - public void placeInWorld(World world, BlockPos at, - Rotation rot, boolean generateChests, - boolean generateSpawners, boolean followPlacementRules, Random rand) { - float yawOffset = DirectionUtils - .yawOffsetForRotation(rot); + private static final List jungleDispenserContents = Lists.newArrayList( + new WeightedRandomChestContent[] { new WeightedRandomChestContent(Items.arrow, 0, 2, 7, 30) }); + + public void placeInWorld(World world, BlockPos at, Rotation rot, boolean generateChests, boolean generateSpawners, + boolean followPlacementRules, Random rand) { + float yawOffset = DirectionUtils.yawOffsetForRotation(rot); Vec3d offset = new Vec3d(at.getX(), at.getY(), at.getZ()); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { for (int z = 0; z < length; z++) { BlockPos pos = new BlockPos(x, y, z); - Vec3d rotatedCoords = DirectionUtils.rotateCoords(pos, - offset, rot); + Vec3d rotatedCoords = DirectionUtils.rotateCoords(pos, offset, rot); BlockPos rotatedPos = new BlockPos(rotatedCoords); - if (placingMap.containsKey(blocks[x][y][z]) - && followPlacementRules) { - placingMap.get(blocks[x][y][z]).affectWorld( - meta[x][y][z], getTileEntityAt(world.getMinecraftServer(), pos), world, - rotatedPos, info.terrainSmoothing); + if (placingMap.containsKey(blocks[x][y][z]) && followPlacementRules) { + placingMap.get(blocks[x][y][z]).affectWorld(meta[x][y][z], + getTileEntityAt(world.getMinecraftServer(), pos), world, rotatedPos, + info.terrainSmoothing); } else if (idMap.containsKey(blocks[x][y][z])) { - IBlockState blockState = idMap.get(blocks[x][y][z]) - .getStateFromMeta(meta[x][y][z]).withRotation(rot); + IBlockState blockState = idMap.get(blocks[x][y][z]).getStateFromMeta(meta[x][y][z]) + .withRotation(rot); world.setBlockState(rotatedPos, blockState, 0x3); } else { - IBlockState blockState = Block.getBlockById( - blocks[x][y][z]) - .getStateFromMeta(meta[x][y][z]).withRotation(rot); + IBlockState blockState = Block.getBlockById(blocks[x][y][z]).getStateFromMeta(meta[x][y][z]) + .withRotation(rot); world.setBlockState(rotatedPos, blockState, 0x3); } } @@ -408,13 +356,11 @@ meta[x][y][z], getTileEntityAt(world.getMinecraftServer(), pos), world, NBTTagCompound entityTag = entities.getCompoundTagAt(i); Entity e = EntityList.createEntityFromNBT(entityTag, world); if (e == null) { - MyWorldGen.log.log(Level.WARN, "Not loading entity ID {}", - entityTag.getString("id")); + MyWorldGen.log.log(Level.WARN, "Not loading entity ID {}", entityTag.getString("id")); } else { - Vec3d newCoords = DirectionUtils.rotateCoords(new Vec3d( - e.posX, e.posY, e.posZ), offset, rot); - e.setPositionAndRotation(newCoords.xCoord, - newCoords.yCoord, newCoords.zCoord, e.rotationPitch, e.rotationYaw + yawOffset); + Vec3d newCoords = DirectionUtils.rotateCoords(new Vec3d(e.posX, e.posY, e.posZ), offset, rot); + e.setPositionAndRotation(newCoords.xCoord, newCoords.yCoord, newCoords.zCoord, e.rotationPitch, + e.rotationYaw + yawOffset); world.spawnEntityInWorld(e); } } @@ -425,12 +371,9 @@ meta[x][y][z], getTileEntityAt(world.getMinecraftServer(), pos), world, NBTTagCompound tileEntityTag = tileEntities.getCompoundTagAt(i); TileEntity e = TileEntity.createTileEntity(world.getMinecraftServer(), tileEntityTag); if (e == null) { - MyWorldGen.log.log(Level.WARN, - "Not loading tile entity ID {}", - tileEntityTag.getString("id")); + MyWorldGen.log.log(Level.WARN, "Not loading tile entity ID {}", tileEntityTag.getString("id")); } else { - BlockPos newPos = new BlockPos(DirectionUtils.rotateCoords( - e.getPos(), offset, rot)); + BlockPos newPos = new BlockPos(DirectionUtils.rotateCoords(e.getPos(), offset, rot)); e.setPos(newPos); world.addTileEntity(e); } @@ -438,54 +381,42 @@ meta[x][y][z], getTileEntityAt(world.getMinecraftServer(), pos), world, } ResourceLocation chestLootTable = new ResourceLocation(info.chestLootTable); - + // Check for chests *after* we place the ones from the schematic, // because the schematic may not have defined the tile entities // properly. for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { for (int z = 0; z < length; z++) { - BlockPos rotatedPos = new BlockPos( - DirectionUtils.rotateCoords(new Vec3d(x, y, z), - offset, rot)); + BlockPos rotatedPos = new BlockPos(DirectionUtils.rotateCoords(new Vec3d(x, y, z), offset, rot)); Block block = world.getBlockState(rotatedPos).getBlock(); TileEntity e = world.getTileEntity(rotatedPos); if (generateChests && !info.chestLootTable.isEmpty()) { if (e instanceof TileEntityChest) { - ((TileEntityChest)e).setLoot(chestLootTable, rand.nextLong()); + ((TileEntityChest) e).setLoot(chestLootTable, rand.nextLong()); } else if (e instanceof TileEntityDispenser) { - WeightedRandomChestContent.generateDispenserContents(rand, - jungleDispenserContents, - (TileEntityDispenser) e, - 2); + WeightedRandomChestContent.generateDispenserContents(rand, jungleDispenserContents, + (TileEntityDispenser) e, 2); } } - if (info.generateSpawners && generateSpawners - && block == Blocks.mob_spawner + if (info.generateSpawners && generateSpawners && block == Blocks.mob_spawner && e instanceof TileEntityMobSpawner) { ((TileEntityMobSpawner) e).getSpawnerBaseLogic() - .setEntityName( - DungeonHooks.getRandomDungeonMob(rand)); + .setEntityName(DungeonHooks.getRandomDungeonMob(rand)); } } } } } - public BlockPos getFuzzyMatchingLocation(Chunk chunk, - Rotation rotation, Random rand) { - ArrayList shuffledAnchors = (ArrayList) anchorBlockLocations - .clone(); + public BlockPos getFuzzyMatchingLocation(Chunk chunk, Rotation rotation, Random rand) { + ArrayList shuffledAnchors = (ArrayList) anchorBlockLocations.clone(); Collections.shuffle(shuffledAnchors, rand); for (BlockPos anchorPos : shuffledAnchors) { - BlockAnchorLogic matching = matchingMap - .get(blocks[anchorPos.getX()][anchorPos.getY()][anchorPos - .getZ()]); - int anchorMeta = meta[anchorPos.getX()][anchorPos.getY()][anchorPos - .getZ()]; + BlockAnchorLogic matching = matchingMap.get(blocks[anchorPos.getX()][anchorPos.getY()][anchorPos.getZ()]); + int anchorMeta = meta[anchorPos.getX()][anchorPos.getY()][anchorPos.getZ()]; TileEntity anchorEntity = getTileEntityAt(chunk.getWorld().getMinecraftServer(), anchorPos); - BlockPos worldAnchorPos = matching.getQuickMatchingBlockInChunk( - anchorMeta, anchorEntity, chunk, rand); + BlockPos worldAnchorPos = matching.getQuickMatchingBlockInChunk(anchorMeta, anchorEntity, chunk, rand); if (worldAnchorPos != null) { Vec3d worldSchematicPos = DirectionUtils.rotateCoords(new BlockPos(0, 0, 0).subtract(anchorPos), new Vec3d(worldAnchorPos), rotation); diff --git a/src/main/java/net/boatcake/MyWorldGen/SchematicInfo.java b/src/main/java/net/boatcake/MyWorldGen/SchematicInfo.java index 1daf19b..7c93901 100644 --- a/src/main/java/net/boatcake/MyWorldGen/SchematicInfo.java +++ b/src/main/java/net/boatcake/MyWorldGen/SchematicInfo.java @@ -36,12 +36,10 @@ public SchematicInfo() { } public boolean matchesBiome(BiomeGenBase biome) { - if ((excludeBiomes != null) - && (containsIgnoreCase(excludeBiomes, biome.getBiomeName()))) { + if ((excludeBiomes != null) && (containsIgnoreCase(excludeBiomes, biome.getBiomeName()))) { return false; } - if ((onlyIncludeBiomes != null) - && (!containsIgnoreCase(onlyIncludeBiomes, biome.getBiomeName()))) { + if ((onlyIncludeBiomes != null) && (!containsIgnoreCase(onlyIncludeBiomes, biome.getBiomeName()))) { return false; } return true; @@ -154,8 +152,7 @@ public void readFromJson(JsonObject jsonobject) { } if (jsonobject.has("generateSpawners")) { - this.generateSpawners = jsonobject.get("generateSpawners") - .getAsBoolean(); + this.generateSpawners = jsonobject.get("generateSpawners").getAsBoolean(); } if (jsonobject.has("fuzzyMatching")) { @@ -163,8 +160,7 @@ public void readFromJson(JsonObject jsonobject) { } if (jsonobject.has("terrainSmoothing")) { - this.terrainSmoothing = jsonobject.get("terrainSmoothing") - .getAsBoolean(); + this.terrainSmoothing = jsonobject.get("terrainSmoothing").getAsBoolean(); } } } \ No newline at end of file diff --git a/src/main/java/net/boatcake/MyWorldGen/SlotPhantomBlock.java b/src/main/java/net/boatcake/MyWorldGen/SlotPhantomBlock.java index aeea8e8..9f5f483 100644 --- a/src/main/java/net/boatcake/MyWorldGen/SlotPhantomBlock.java +++ b/src/main/java/net/boatcake/MyWorldGen/SlotPhantomBlock.java @@ -7,8 +7,7 @@ public class SlotPhantomBlock extends Slot { - public SlotPhantomBlock(IInventory inventory, int slotIndex, int posX, - int posY) { + public SlotPhantomBlock(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); } diff --git a/src/main/java/net/boatcake/MyWorldGen/WorldGenerator.java b/src/main/java/net/boatcake/MyWorldGen/WorldGenerator.java index ecd6bc2..0009ec7 100644 --- a/src/main/java/net/boatcake/MyWorldGen/WorldGenerator.java +++ b/src/main/java/net/boatcake/MyWorldGen/WorldGenerator.java @@ -33,34 +33,29 @@ public WorldGenerator() { } public void addSchematicsFromDirectory(File schemDirectory) { - File[] schemFiles = schemDirectory - .listFiles(new SchematicFilenameFilter()); + File[] schemFiles = schemDirectory.listFiles(new SchematicFilenameFilter()); Arrays.sort(schemFiles); worldgenFolderSchemList.clear(); for (File schemFile : schemFiles) { try { - addSchemFromStream(worldgenFolderSchemList, - new FileInputStream(schemFile), schemFile.getName()); + addSchemFromStream(worldgenFolderSchemList, new FileInputStream(schemFile), schemFile.getName()); } catch (Throwable e) { e.printStackTrace(); } } - MyWorldGen.log.log(Level.INFO, "Loaded {} schematics from {}", - worldgenFolderSchemList.size(), schemDirectory.toString()); + MyWorldGen.log.log(Level.INFO, "Loaded {} schematics from {}", worldgenFolderSchemList.size(), + schemDirectory.toString()); } - public void addSchemFromStream(Collection section, - InputStream stream, String name) throws IOException { - Schematic newSchem = new Schematic( - CompressedStreamTools.readCompressed(stream), name); + public void addSchemFromStream(Collection section, InputStream stream, String name) throws IOException { + Schematic newSchem = new Schematic(CompressedStreamTools.readCompressed(stream), name); section.add(newSchem); } @Override - public void generate(Random random, int chunkX, int chunkZ, World world, - IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { - if (world.getWorldInfo().isMapFeaturesEnabled() - && random.nextDouble() < MyWorldGen.baseGenerateChance) { + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, + IChunkProvider chunkProvider) { + if (world.getWorldInfo().isMapFeaturesEnabled() && random.nextDouble() < MyWorldGen.baseGenerateChance) { List applicableSchematics = new ArrayList(); BlockPos chunkPos = new BlockPos(chunkX * 16, 0, chunkZ * 16); for (Schematic s : worldgenFolderSchemList) { @@ -74,35 +69,24 @@ public void generate(Random random, int chunkX, int chunkZ, World world, } } if (!applicableSchematics.isEmpty()) { - WeightedRandom.Item noStructureItem = new WeightedRandom.Item( - MyWorldGen.generateNothingWeight); + WeightedRandom.Item noStructureItem = new WeightedRandom.Item(MyWorldGen.generateNothingWeight); applicableSchematics.add(noStructureItem); - WeightedRandom.Item selectedItem = WeightedRandom - .getRandomItem(random, applicableSchematics); + WeightedRandom.Item selectedItem = WeightedRandom.getRandomItem(random, applicableSchematics); if (selectedItem != noStructureItem) { Schematic schemToGenerate = ((WeightedRandomSchematic) selectedItem).schematic; if (schemToGenerate.info.fuzzyMatching) { - Chunk chunk = world.getChunkFromChunkCoords(chunkX, - chunkZ); + Chunk chunk = world.getChunkFromChunkCoords(chunkX, chunkZ); Rotation randomRotation; if (schemToGenerate.info.lockRotation) { randomRotation = Rotation.NONE; } else { randomRotation = Rotation.values()[random.nextInt(4)]; } - BlockPos pos = schemToGenerate - .getFuzzyMatchingLocation(chunk, - randomRotation, random); + BlockPos pos = schemToGenerate.getFuzzyMatchingLocation(chunk, randomRotation, random); if (pos != null) { - schemToGenerate.placeInWorld(world, pos, - randomRotation, true, true, true, random); - MyWorldGen.log - .log(Level.DEBUG, - "Generated {} at {}, {}, {}", - new Object[] { - schemToGenerate.info.name, - pos.getX(), pos.getY(), - pos.getZ() }); + schemToGenerate.placeInWorld(world, pos, randomRotation, true, true, true, random); + MyWorldGen.log.log(Level.DEBUG, "Generated {} at {}, {}, {}", + new Object[] { schemToGenerate.info.name, pos.getX(), pos.getY(), pos.getZ() }); } } else { for (int i = 0; i < MyWorldGen.generateTries; i++) { @@ -116,17 +100,10 @@ public void generate(Random random, int chunkX, int chunkZ, World world, } else { randomRotation = Rotation.values()[random.nextInt(4)]; } - if (schemToGenerate.fitsIntoWorldAt(world, pos, - randomRotation)) { - schemToGenerate.placeInWorld(world, pos, - randomRotation, true, true, true, - random); - MyWorldGen.log - .log(Level.DEBUG, - "Generated {} at {}, {}, {}; took {} tries", - new Object[] { - schemToGenerate.info.name, - x, y, z, i + 1 }); + if (schemToGenerate.fitsIntoWorldAt(world, pos, randomRotation)) { + schemToGenerate.placeInWorld(world, pos, randomRotation, true, true, true, random); + MyWorldGen.log.log(Level.DEBUG, "Generated {} at {}, {}, {}; took {} tries", + new Object[] { schemToGenerate.info.name, x, y, z, i + 1 }); return; } } diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventory.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventory.java index 6a882e4..d3f6c66 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventory.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventory.java @@ -15,8 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockAnchorInventory extends BlockContainer implements - BlockAnchorBase, ITileEntityProvider { +public class BlockAnchorInventory extends BlockContainer implements BlockAnchorBase, ITileEntityProvider { public BlockAnchorInventory(Material par2Material) { super(par2Material); @@ -31,17 +30,14 @@ public TileEntity createNewTileEntity(World world, int var2) { } @Override - public boolean onBlockActivated(World world, BlockPos pos, - IBlockState blockState, EntityPlayer player, EnumHand hand, - ItemStack stack, EnumFacing side, - float par7, float par8, float par9) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState blockState, EntityPlayer player, + EnumHand hand, ItemStack stack, EnumFacing side, float par7, float par8, float par9) { TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity == null || player.isSneaking()) { return false; } // code to open gui explained later - player.openGui(MyWorldGen.instance, 2, world, pos.getX(), pos.getY(), - pos.getZ()); + player.openGui(MyWorldGen.instance, 2, world, pos.getX(), pos.getY(), pos.getZ()); return true; } diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventoryLogic.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventoryLogic.java index a3481a4..540a3d4 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventoryLogic.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorInventoryLogic.java @@ -14,15 +14,12 @@ public BlockAnchorInventoryLogic(String blockName) { } @Override - public boolean matches(int myMeta, TileEntity myTileEntity, World world, - BlockPos pos) { - return ((TileEntityAnchorInventory) myTileEntity).matches(world - .getBlockState(pos)); + public boolean matches(int myMeta, TileEntity myTileEntity, World world, BlockPos pos) { + return ((TileEntityAnchorInventory) myTileEntity).matches(world.getBlockState(pos)); } @Override - public BlockPos getQuickMatchingBlockInChunk(int myMeta, - TileEntity myTileEntity, Chunk chunk, Random rand) { + public BlockPos getQuickMatchingBlockInChunk(int myMeta, TileEntity myTileEntity, Chunk chunk, Random rand) { return null; } diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorLogic.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorLogic.java index 5a6677c..524ce29 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorLogic.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorLogic.java @@ -25,9 +25,8 @@ public BlockAnchorLogic(String blockName) { blockNameToLogic.put(blockName.toLowerCase(Locale.ROOT), this); } - public abstract boolean matches(int myMeta, TileEntity myTileEntity, - World world, BlockPos pos); + public abstract boolean matches(int myMeta, TileEntity myTileEntity, World world, BlockPos pos); - public abstract BlockPos getQuickMatchingBlockInChunk(int myMeta, - TileEntity myTileEntity, Chunk chunk, Random rand); + public abstract BlockPos getQuickMatchingBlockInChunk(int myMeta, TileEntity myTileEntity, Chunk chunk, + Random rand); } diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterial.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterial.java index 7eb4b01..eb34f4b 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterial.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterial.java @@ -18,11 +18,9 @@ public class BlockAnchorMaterial extends Block implements BlockAnchorBase { public enum AnchorType implements IStringSerializable { - GROUND(0, "ground", null), AIR(1, "air", null), STONE(2, "stone", - Material.rock), WATER(3, "water", Material.water), LAVA(4, - "lava", Material.lava), DIRT(5, "dirt", Material.ground), WOOD( - 6, "wood", Material.wood), LEAVES(7, "leaves", Material.leaves), SAND( - 8, "sand", Material.sand); + GROUND(0, "ground", null), AIR(1, "air", null), STONE(2, "stone", Material.rock), WATER(3, "water", + Material.water), LAVA(4, "lava", Material.lava), DIRT(5, "dirt", Material.ground), WOOD(6, "wood", + Material.wood), LEAVES(7, "leaves", Material.leaves), SAND(8, "sand", Material.sand); public static AnchorType get(int id) { for (AnchorType a : AnchorType.values()) { @@ -49,27 +47,24 @@ public String getName() { } } - public static final PropertyEnum TYPE_PROP = PropertyEnum.create("type", - AnchorType.class); + public static final PropertyEnum TYPE_PROP = PropertyEnum.create("type", AnchorType.class); public BlockAnchorMaterial(Material par2Material) { super(par2Material); setBlockUnbreakable(); setResistance(6000000.0F); setStepSound(SoundType.STONE); - setDefaultState(blockState.getBaseState().withProperty(TYPE_PROP, - AnchorType.GROUND)); + setDefaultState(blockState.getBaseState().withProperty(TYPE_PROP, AnchorType.GROUND)); } @Override public int damageDropped(IBlockState state) { - return ((AnchorType) state.getValue(TYPE_PROP)).id; + return state.getValue(TYPE_PROP).id; } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, - List subBlockList) { + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List subBlockList) { for (AnchorType a : AnchorType.values()) { subBlockList.add(new ItemStack(item, 1, a.id)); } @@ -82,7 +77,7 @@ public IBlockState getStateFromMeta(int meta) { @Override public int getMetaFromState(IBlockState state) { - return ((AnchorType) state.getValue(TYPE_PROP)).id; + return state.getValue(TYPE_PROP).id; } @Override diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterialLogic.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterialLogic.java index 910f077..576e651 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterialLogic.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockAnchorMaterialLogic.java @@ -13,18 +13,15 @@ public class BlockAnchorMaterialLogic extends BlockAnchorLogic { - public static boolean matchesStatic(AnchorType myType, - IBlockState otherState, BiomeGenBase currentBiome) { + public static boolean matchesStatic(AnchorType myType, IBlockState otherState, BiomeGenBase currentBiome) { switch (myType) { case GROUND: return otherState.equals(currentBiome.topBlock); case AIR: return otherState.getBlock() instanceof BlockAir - || (otherState.getMaterial().isReplaceable() && !otherState - .getMaterial().isLiquid()); + || (otherState.getMaterial().isReplaceable() && !otherState.getMaterial().isLiquid()); default: - return !(otherState.getBlock() instanceof BlockAir) - && myType != null && myType.material != null + return !(otherState.getBlock() instanceof BlockAir) && myType != null && myType.material != null && otherState.getMaterial() == myType.material; } } @@ -34,15 +31,12 @@ public BlockAnchorMaterialLogic(String blockName) { } @Override - public boolean matches(int myMeta, TileEntity myTileEntity, World world, - BlockPos pos) { - return matchesStatic(AnchorType.get(myMeta), world.getBlockState(pos), - world.getBiomeGenForCoords(pos)); + public boolean matches(int myMeta, TileEntity myTileEntity, World world, BlockPos pos) { + return matchesStatic(AnchorType.get(myMeta), world.getBlockState(pos), world.getBiomeGenForCoords(pos)); } @Override - public BlockPos getQuickMatchingBlockInChunk(int myMeta, - TileEntity myTileEntity, Chunk chunk, Random rand) { + public BlockPos getQuickMatchingBlockInChunk(int myMeta, TileEntity myTileEntity, Chunk chunk, Random rand) { int xPosInChunk = rand.nextInt(16); int zPosInChunk = rand.nextInt(16); int height = chunk.getHeightValue(xPosInChunk, zPosInChunk); @@ -52,15 +46,12 @@ public BlockPos getQuickMatchingBlockInChunk(int myMeta, BlockPos pos = new BlockPos(xPos, 0, zPos); BiomeGenBase currentBiome = world.getBiomeGenForCoords(pos); AnchorType type = AnchorType.get(myMeta); - boolean isHell = chunk.getWorld().getChunkProvider().makeString() - .equals("HellRandomLevelSource"); + boolean isHell = chunk.getWorld().getChunkProvider().makeString().equals("HellRandomLevelSource"); do { switch (type) { case AIR: // Anywhere between the ground and the top of the world - pos = new BlockPos(xPos, rand.nextInt(world.getActualHeight() - - height) - + height, zPos); + pos = new BlockPos(xPos, rand.nextInt(world.getActualHeight() - height) + height, zPos); break; case GROUND: // Ground level. @@ -91,8 +82,7 @@ public BlockPos getQuickMatchingBlockInChunk(int myMeta, default: return null; } - if (BlockAnchorMaterialLogic.matchesStatic(type, - chunk.getBlockState(pos), currentBiome)) { + if (BlockAnchorMaterialLogic.matchesStatic(type, chunk.getBlockState(pos), currentBiome)) { return pos; } } while (height >= 62); diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockIgnore.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockIgnore.java index 47b4f90..9bab85f 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockIgnore.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockIgnore.java @@ -18,9 +18,9 @@ public BlockIgnore(Material par2Material) { } @Override - public AxisAlignedBB getSelectedBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { - return NULL_AABB; - } + public AxisAlignedBB getSelectedBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { + return NULL_AABB; + } @Override public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementIgnore.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementIgnore.java index bce8e37..8164ce7 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementIgnore.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementIgnore.java @@ -11,8 +11,7 @@ public BlockPlacementIgnore(String blockName) { } @Override - public void affectWorld(int myMeta, TileEntity myTileEntity, World world, - BlockPos pos, boolean matchTerrain) { + public void affectWorld(int myMeta, TileEntity myTileEntity, World world, BlockPos pos, boolean matchTerrain) { // do nothing! } } diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementLogic.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementLogic.java index dee3164..946f34c 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementLogic.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementLogic.java @@ -23,6 +23,6 @@ public BlockPlacementLogic(String blockName) { blockNameToLogic.put(blockName.toLowerCase(Locale.ROOT), this); } - public abstract void affectWorld(int myMeta, TileEntity myTileEntity, - World world, BlockPos pos, boolean matchTerrain); + public abstract void affectWorld(int myMeta, TileEntity myTileEntity, World world, BlockPos pos, + boolean matchTerrain); } diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementMaterialAnchor.java b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementMaterialAnchor.java index 1a0b2b4..411d5c8 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementMaterialAnchor.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/BlockPlacementMaterialAnchor.java @@ -15,8 +15,7 @@ public BlockPlacementMaterialAnchor(String blockName) { } @Override - public void affectWorld(int myMeta, TileEntity myTileEntity, World world, - BlockPos pos, boolean matchTerrain) { + public void affectWorld(int myMeta, TileEntity myTileEntity, World world, BlockPos pos, boolean matchTerrain) { if (matchTerrain) { switch (AnchorType.get(myMeta)) { case AIR: @@ -50,8 +49,7 @@ public void affectWorld(int myMeta, TileEntity myTileEntity, World world, } } - private void setBlocksDownward(World world, BlockPos pos, - IBlockState blockState) { + private void setBlocksDownward(World world, BlockPos pos, IBlockState blockState) { while (!world.getBlockState(pos).isFullCube()) { world.setBlockState(pos, blockState); pos = pos.down(); diff --git a/src/main/java/net/boatcake/MyWorldGen/blocks/TileEntityAnchorInventory.java b/src/main/java/net/boatcake/MyWorldGen/blocks/TileEntityAnchorInventory.java index 063dca6..1e3031a 100644 --- a/src/main/java/net/boatcake/MyWorldGen/blocks/TileEntityAnchorInventory.java +++ b/src/main/java/net/boatcake/MyWorldGen/blocks/TileEntityAnchorInventory.java @@ -80,16 +80,13 @@ public boolean isItemValidForSlot(int i, ItemStack itemstack) { @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getTileEntity(getPos()) == this - && player.getDistanceSq(getPos().getX() + 0.5, - getPos().getY() + 0.5, getPos().getZ() + 0.5) < 64; + && player.getDistanceSq(getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5) < 64; } public boolean matches(IBlockState blockState) { for (int i = 0; i < inv.length; i++) { - if (inv[i] != null - && (inv[i].getItem() instanceof ItemBlock) - && ((ItemBlock) inv[i].getItem()).block == blockState - .getBlock()) { + if (inv[i] != null && (inv[i].getItem() instanceof ItemBlock) + && ((ItemBlock) inv[i].getItem()).block == blockState.getBlock()) { return true; } } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/ClientProxy.java b/src/main/java/net/boatcake/MyWorldGen/client/ClientProxy.java index 8c4bcf8..5f831ed 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/ClientProxy.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/ClientProxy.java @@ -30,12 +30,8 @@ public void registerResourceHandler(WorldGenerator worldGen) { @Override public void registerItem(Item item, int metadata, String itemName) { - Minecraft - .getMinecraft() - .getRenderItem() - .getItemModelMesher() - .register(item, metadata, - new ModelResourceLocation(itemName, "inventory")); + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, metadata, + new ModelResourceLocation(itemName, "inventory")); } @Override @@ -47,12 +43,10 @@ public void registerBlock(Block block, int metadata, String blockName) { public void registerVariants(Block block, PropertyEnum prop, String postfix) { ResourceLocation[] resLocs = new ResourceLocation[BlockAnchorMaterial.AnchorType.values().length]; for (int i = 0; i < resLocs.length; i++) { - resLocs[i] = new ResourceLocation(MyWorldGen.MODID, - BlockAnchorMaterial.AnchorType.get(i).name + postfix); + resLocs[i] = new ResourceLocation(MyWorldGen.MODID, BlockAnchorMaterial.AnchorType.get(i).name + postfix); } ModelBakery.registerItemVariants(Item.getItemFromBlock(block), resLocs); - Minecraft.getMinecraft().getRenderItem().getItemModelMesher() - .getModelManager().getBlockModelShapes() + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getBlockModelShapes() .registerBlockWithStateMapper(block, new NamespacedStateMap(prop, postfix)); } } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiAnchorInventory.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiAnchorInventory.java index c1c3c27..c50976c 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiAnchorInventory.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiAnchorInventory.java @@ -13,19 +13,16 @@ @SideOnly(Side.CLIENT) public class GuiAnchorInventory extends GuiContainer { - private static final ResourceLocation guiTextures = new ResourceLocation( - "textures/gui/container/dispenser.png"); + private static final ResourceLocation guiTextures = new ResourceLocation("textures/gui/container/dispenser.png"); public TileEntityAnchorInventory tileEntity; - public GuiAnchorInventory(InventoryPlayer inventoryPlayer, - TileEntityAnchorInventory te) { + public GuiAnchorInventory(InventoryPlayer inventoryPlayer, TileEntityAnchorInventory te) { super(new ContainerAnchorInventory(inventoryPlayer, te)); tileEntity = te; } @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { // draw your Gui here, only thing you need to change is the path GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(guiTextures); @@ -38,10 +35,8 @@ protected void drawGuiContainerBackgroundLayer(float par1, int par2, protected void drawGuiContainerForegroundLayer(int param1, int param2) { // draw text and stuff here // the parameters for drawString are: string, x, y, color - fontRendererObj.drawString(I18n.format(tileEntity.getName()), 8, 6, - 0x404040); + fontRendererObj.drawString(I18n.format(tileEntity.getName()), 8, 6, 0x404040); // draws "Inventory" or your regional equivalent - fontRendererObj.drawString(I18n.format("container.inventory"), 8, - ySize - 96 + 2, 0x404040); + fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 0x404040); } } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiLoadSchematic.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiLoadSchematic.java index 6a226ca..bbd19fe 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiLoadSchematic.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiLoadSchematic.java @@ -54,11 +54,9 @@ protected void actionPerformed(GuiButton button) { // better to make sure that it's valid NBT first. try { message.schematicTag = CompressedStreamTools - .readCompressed(new FileInputStream( - slot.files[slot.selected])); + .readCompressed(new FileInputStream(slot.files[slot.selected])); } catch (Exception exc) { - this.mc.displayGuiScreen(new GuiErrorScreen(exc.getClass() - .getName(), exc.getLocalizedMessage())); + this.mc.displayGuiScreen(new GuiErrorScreen(exc.getClass().getName(), exc.getLocalizedMessage())); exc.printStackTrace(); return; } @@ -66,8 +64,7 @@ protected void actionPerformed(GuiButton button) { this.mc.displayGuiScreen(null); } else if (button.id == placementButton.id) { placementOption = placementOption.next; - placementButton.displayString = I18n - .format(placementOption.text); + placementButton.displayString = I18n.format(placementOption.text); } else { slot.actionPerformed(button); } @@ -83,12 +80,12 @@ public void drawScreen(int par1, int par2, float par3) { @Override public void initGui() { - buttonList.add(placementButton = new GuiButton(0, this.width / 2 - 154, - this.height - 52, 150, 20, I18n.format(placementOption.text))); - buttonList.add(doneButton = new GuiButton(1, this.width / 2 + 4, - this.height - 52, 150, 20, I18n.format("gui.done"))); - slot = new GuiSlotFile(this.mc, this, MyWorldGen.globalSchemDir, - this.fontRendererObj, new SchematicFilenameFilter()); + buttonList.add(placementButton = new GuiButton(0, this.width / 2 - 154, this.height - 52, 150, 20, + I18n.format(placementOption.text))); + buttonList.add( + doneButton = new GuiButton(1, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("gui.done"))); + slot = new GuiSlotFile(this.mc, this, MyWorldGen.globalSchemDir, this.fontRendererObj, + new SchematicFilenameFilter()); slot.registerScrollButtons(2, 3); } } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiSaveSchematic.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiSaveSchematic.java index 6f6162f..4673ce7 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiSaveSchematic.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiSaveSchematic.java @@ -22,8 +22,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiSaveSchematic extends GuiScreen implements - GuiSlider.FormatHelper, GuiPageButtonList.GuiResponder { +public class GuiSaveSchematic extends GuiScreen implements GuiSlider.FormatHelper, GuiPageButtonList.GuiResponder { private GuiButton cancelBtn; private GuiTextField fileNameField; private GuiButton saveBtn; @@ -56,8 +55,7 @@ public void initGui() { Keyboard.enableRepeatEvents(true); this.buttonList.clear(); - fileNameField = new GuiTextField(0, this.fontRendererObj, - this.width / 2 - 150, 20, 300, 20); + fileNameField = new GuiTextField(0, this.fontRendererObj, this.width / 2 - 150, 20, 300, 20); fileNameField.setMaxStringLength(32767); fileNameField.setFocused(true); @@ -73,39 +71,33 @@ public void initGui() { fuzzyMatching = schematicToSave.info.fuzzyMatching; terrainSmoothing = schematicToSave.info.terrainSmoothing; } - buttonList.add(lockRotationButton = new GuiButton(2, - this.width / 2 + 2, 60, 150, 20, I18n - .format("gui.lockRotation." + lockRotation))); - buttonList.add(generateSpawnersButton = new GuiButton(3, - this.width / 2 - 152, 60, 150, 20, I18n - .format("gui.generateSpawners." + generateSpawners))); - buttonList.add(fuzzyMatchingButton = new GuiButton(4, - this.width / 2 + 2, 84, 150, 20, I18n - .format("gui.fuzzyMatching." + fuzzyMatching))); - buttonList.add(terrainSmoothingButton = new GuiButton(5, - this.width / 2 - 152, 84, 150, 20, I18n - .format("gui.terrainSmoothing." + terrainSmoothing))); - - buttonList.add(new GuiSlider(this, 11, this.width / 2 - 152, 108, I18n - .format("gui.randomWeight"), 1.0f, 100.0f, 10.0f, this)); - - chestGenSlot = new GuiSlotChestGenTypes(this.mc, this, - this.fontRendererObj, this.width / 2 - 152, 132, 150, + buttonList.add(lockRotationButton = new GuiButton(2, this.width / 2 + 2, 60, 150, 20, + I18n.format("gui.lockRotation." + lockRotation))); + buttonList.add(generateSpawnersButton = new GuiButton(3, this.width / 2 - 152, 60, 150, 20, + I18n.format("gui.generateSpawners." + generateSpawners))); + buttonList.add(fuzzyMatchingButton = new GuiButton(4, this.width / 2 + 2, 84, 150, 20, + I18n.format("gui.fuzzyMatching." + fuzzyMatching))); + buttonList.add(terrainSmoothingButton = new GuiButton(5, this.width / 2 - 152, 84, 150, 20, + I18n.format("gui.terrainSmoothing." + terrainSmoothing))); + + buttonList.add(new GuiSlider(this, 11, this.width / 2 - 152, 108, I18n.format("gui.randomWeight"), 1.0f, 100.0f, + 10.0f, this)); + + chestGenSlot = new GuiSlotChestGenTypes(this.mc, this, this.fontRendererObj, this.width / 2 - 152, 132, 150, this.height - 158); chestGenSlot.registerScrollButtons(6, 7); - buttonList.add(biomeListTypeButton = new GuiButton(8, - this.width / 2 + 2, 108, 150, 20, + buttonList.add(biomeListTypeButton = new GuiButton(8, this.width / 2 + 2, 108, 150, 20, I18n.format("gui.biomeListType." + biomeListType.toString()))); - biomeSlot = new GuiSlotBiomes(this.mc, this, this.fontRendererObj, - this.width / 2 + 2, 128, 150, this.height - 154); + biomeSlot = new GuiSlotBiomes(this.mc, this, this.fontRendererObj, this.width / 2 + 2, 128, 150, + this.height - 154); biomeSlot.registerScrollButtons(9, 10); - buttonList.add(saveBtn = new GuiButton(0, this.width / 2 + 2, - this.height - 22, 150, 20, I18n.format("gui.save"))); - buttonList.add(cancelBtn = new GuiButton(1, this.width / 2 - 152, - this.height - 22, 150, 20, I18n.format("gui.cancel"))); + buttonList.add( + saveBtn = new GuiButton(0, this.width / 2 + 2, this.height - 22, 150, 20, I18n.format("gui.save"))); + buttonList.add(cancelBtn = new GuiButton(1, this.width / 2 - 152, this.height - 22, 150, 20, + I18n.format("gui.cancel"))); updateSaveButton(); } @@ -121,11 +113,9 @@ public void drawScreen(int par1, int par2, float par3) { drawDefaultBackground(); chestGenSlot.drawScreen(par1, par2, par3); biomeSlot.drawScreen(par1, par2, par3); - drawCenteredString(fontRendererObj, I18n.format("gui.filename"), - this.width / 2, 5, 0xFFFFFF); + drawCenteredString(fontRendererObj, I18n.format("gui.filename"), this.width / 2, 5, 0xFFFFFF); drawCenteredString(fontRendererObj, - I18n.format("selectWorld.resultFolder") + " " - + MyWorldGen.globalSchemDir.getAbsolutePath(), + I18n.format("selectWorld.resultFolder") + " " + MyWorldGen.globalSchemDir.getAbsolutePath(), this.width / 2, 45, 0xA0A0A0); fileNameField.drawTextBox(); super.drawScreen(par1, par2, par3); @@ -140,8 +130,7 @@ protected void actionPerformed(GuiButton button) throws IOException { ResourceLocation lootTable = chestGenSlot.tables[chestGenSlot.selected]; schematicToSave.info.chestLootTable = lootTable == null ? "" : lootTable.toString(); - ArrayList biomeNames = new ArrayList( - biomeSlot.selected.size()); + ArrayList biomeNames = new ArrayList(biomeSlot.selected.size()); for (int i : biomeSlot.selected) { biomeNames.add(biomeSlot.biomeNames.get(i)); } @@ -163,13 +152,11 @@ protected void actionPerformed(GuiButton button) throws IOException { } try { CompressedStreamTools.writeCompressed(schematicToSave.getNBT(), - new FileOutputStream(new File( - MyWorldGen.globalSchemDir, name))); + new FileOutputStream(new File(MyWorldGen.globalSchemDir, name))); } catch (Exception exc) { // File does't exist/can't be written // TODO: make this nicer? - mc.displayGuiScreen(new GuiErrorScreen( - exc.getClass().getName(), exc.getLocalizedMessage())); + mc.displayGuiScreen(new GuiErrorScreen(exc.getClass().getName(), exc.getLocalizedMessage())); exc.printStackTrace(); return; } @@ -179,30 +166,25 @@ protected void actionPerformed(GuiButton button) throws IOException { } else if (button.id == lockRotationButton.id) { if (schematicToSave != null) { schematicToSave.info.lockRotation = !schematicToSave.info.lockRotation; - lockRotationButton.displayString = I18n - .format("gui.lockRotation." - + schematicToSave.info.lockRotation); + lockRotationButton.displayString = I18n.format("gui.lockRotation." + schematicToSave.info.lockRotation); } } else if (button.id == generateSpawnersButton.id) { if (schematicToSave != null) { schematicToSave.info.generateSpawners = !schematicToSave.info.generateSpawners; generateSpawnersButton.displayString = I18n - .format("gui.generateSpawners." - + schematicToSave.info.generateSpawners); + .format("gui.generateSpawners." + schematicToSave.info.generateSpawners); } } else if (button.id == fuzzyMatchingButton.id) { if (schematicToSave != null) { schematicToSave.info.fuzzyMatching = !schematicToSave.info.fuzzyMatching; fuzzyMatchingButton.displayString = I18n - .format("gui.fuzzyMatching." - + schematicToSave.info.fuzzyMatching); + .format("gui.fuzzyMatching." + schematicToSave.info.fuzzyMatching); } } else if (button.id == terrainSmoothingButton.id) { if (schematicToSave != null) { schematicToSave.info.terrainSmoothing = !schematicToSave.info.terrainSmoothing; terrainSmoothingButton.displayString = I18n - .format("gui.terrainSmoothing." - + schematicToSave.info.terrainSmoothing); + .format("gui.terrainSmoothing." + schematicToSave.info.terrainSmoothing); } } else if (button.id == biomeListTypeButton.id) { switch (biomeListType) { @@ -215,8 +197,7 @@ protected void actionPerformed(GuiButton button) throws IOException { default: return; } - biomeListTypeButton.displayString = I18n - .format("gui.biomeListType." + biomeListType.toString()); + biomeListTypeButton.displayString = I18n.format("gui.biomeListType." + biomeListType.toString()); } else { chestGenSlot.actionPerformed(button); biomeSlot.actionPerformed(button); @@ -260,9 +241,8 @@ public void handleMouseInput() throws IOException { public void updateSaveButton() { // Call this every so often to make sure we have a valid file name and a // valid schematic - saveBtn.enabled = fileNameField.getText().trim().length() > 0 - && schematicToSave != null && schematicToSave.entities != null - && schematicToSave.tileEntities != null; + saveBtn.enabled = fileNameField.getText().trim().length() > 0 && schematicToSave != null + && schematicToSave.entities != null && schematicToSave.tileEntities != null; } @Override @@ -275,8 +255,7 @@ public void updateScreen() { } @Override - public String getText(int p_175318_1_, String p_175318_2_, - float p_175318_3_) { + public String getText(int p_175318_1_, String p_175318_2_, float p_175318_3_) { return p_175318_2_ + ": " + String.format("%.0f", p_175318_3_); } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotBiomes.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotBiomes.java index dd7f66d..f9b0ffe 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotBiomes.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotBiomes.java @@ -20,8 +20,7 @@ public class GuiSlotBiomes extends GuiSlotResizable { public ArrayList biomeNames; public GuiScreen parent; - public GuiSlotBiomes(Minecraft mc, GuiScreen parent, FontRenderer fr, - int x, int y, int width, int height) { + public GuiSlotBiomes(Minecraft mc, GuiScreen parent, FontRenderer fr, int x, int y, int width, int height) { super(mc, x, y, width, height, 18); selected = new HashSet(2); this.fr = fr; @@ -54,8 +53,7 @@ protected int getSize() { } @Override - protected void elementClicked(int slotIndex, boolean isDoubleClick, - int mouseX, int mouseY) { + protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY) { if (selected.contains(slotIndex)) { selected.remove(slotIndex); } else { diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotChestGenTypes.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotChestGenTypes.java index 1119946..5bdcfed 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotChestGenTypes.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotChestGenTypes.java @@ -20,8 +20,7 @@ public class GuiSlotChestGenTypes extends GuiSlotResizable { public String[] tablesTranslated; public GuiScreen parent; - public GuiSlotChestGenTypes(Minecraft mc, GuiScreen parent, - FontRenderer fr, int x, int y, int width, int height) { + public GuiSlotChestGenTypes(Minecraft mc, GuiScreen parent, FontRenderer fr, int x, int y, int width, int height) { super(mc, x, y, width, height, 18); selected = 0; this.fr = fr; @@ -29,7 +28,7 @@ public GuiSlotChestGenTypes(Minecraft mc, GuiScreen parent, Set allTables = LootTableList.getAll(); tables = ArrayUtils.add(Arrays.copyOf(allTables.toArray(), allTables.size(), ResourceLocation[].class), null); - + Arrays.sort(tables, new Comparator() { @Override public int compare(ResourceLocation x, ResourceLocation y) { @@ -56,8 +55,7 @@ protected int getSize() { } @Override - protected void elementClicked(int slotIndex, boolean isDoubleClick, - int mouseX, int mouseY) { + protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY) { selected = slotIndex; } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotFile.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotFile.java index 3ad2a8f..9c146cf 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotFile.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotFile.java @@ -17,8 +17,7 @@ public class GuiSlotFile extends GuiSlot { public GuiScreen parent; public int selected; - public GuiSlotFile(Minecraft mc, GuiScreen parent, File file, - FontRenderer fr, FilenameFilter filter) { + public GuiSlotFile(Minecraft mc, GuiScreen parent, File file, FontRenderer fr, FilenameFilter filter) { super(mc, parent.width, parent.height, 32, parent.height - 65 + 4, 18); files = file.listFiles(filter); selected = 0; diff --git a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotResizable.java b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotResizable.java index ddb66f7..554e385 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotResizable.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/GuiSlotResizable.java @@ -8,8 +8,7 @@ public abstract class GuiSlotResizable extends GuiSlot { - public GuiSlotResizable(Minecraft mc, int x, int y, int width, int height, - int slotHeight) { + public GuiSlotResizable(Minecraft mc, int x, int y, int width, int height, int slotHeight) { super(mc, width, height, y, y + height, slotHeight); this.left = x; this.right = x + width; @@ -38,8 +37,7 @@ public void drawScreen(int i, int j, float k) { ScaledResolution scaledresolution = new ScaledResolution(this.mc); int f = scaledresolution.getScaleFactor(); GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glScissor(this.left * f, this.mc.displayHeight - this.bottom * f, - this.width * f, this.height * f); + GL11.glScissor(this.left * f, this.mc.displayHeight - this.bottom * f, this.width * f, this.height * f); super.drawScreen(i, j, k); GL11.glScissor(0, 0, this.mc.displayWidth, this.mc.displayHeight); GL11.glDisable(GL11.GL_SCISSOR_TEST); diff --git a/src/main/java/net/boatcake/MyWorldGen/client/NamespacedStateMap.java b/src/main/java/net/boatcake/MyWorldGen/client/NamespacedStateMap.java index 8bf53f6..7755706 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/NamespacedStateMap.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/NamespacedStateMap.java @@ -23,7 +23,6 @@ public NamespacedStateMap(PropertyEnum typeProp, String string) { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState arg0) { String s = ((IStringSerializable) arg0.getValue(prop)).getName(); - return new ModelResourceLocation(new ResourceLocation(MyWorldGen.MODID, - s + postfix), "normal"); + return new ModelResourceLocation(new ResourceLocation(MyWorldGen.MODID, s + postfix), "normal"); } } diff --git a/src/main/java/net/boatcake/MyWorldGen/client/ResourceManagerListener.java b/src/main/java/net/boatcake/MyWorldGen/client/ResourceManagerListener.java index 36179b5..66d2b4e 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/ResourceManagerListener.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/ResourceManagerListener.java @@ -32,8 +32,7 @@ public class ResourceManagerListener implements IResourceManagerReloadListener { private WorldGenerator worldGen; private static final Gson gsonReader = (new GsonBuilder()) - .registerTypeAdapter(JsonObject.class, new StupidDeserializer()) - .create(); + .registerTypeAdapter(JsonObject.class, new StupidDeserializer()).create(); private static final ParameterizedType paramType = new ParameterizedType() { @Override public Type[] getActualTypeArguments() { @@ -56,8 +55,7 @@ public ResourceManagerListener(WorldGenerator worldGen) { } public void register() { - ((SimpleReloadableResourceManager) Minecraft.getMinecraft() - .getResourceManager()).registerReloadListener(this); + ((SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this); } @Override @@ -66,26 +64,21 @@ public void onResourceManagerReload(IResourceManager manager) { Set domains = manager.getResourceDomains(); for (String domain : domains) { try { - List indexes = manager - .getAllResources(new ResourceLocation(domain, - "worldgen.json")); + List indexes = manager.getAllResources(new ResourceLocation(domain, "worldgen.json")); int count = 0; for (IResource jsonResource : indexes) { try { Map indexJson = gsonReader - .fromJson( - new InputStreamReader(jsonResource - .getInputStream()), paramType); - Set> indexEntries = indexJson - .entrySet(); + .fromJson(new InputStreamReader(jsonResource.getInputStream()), paramType); + Set> indexEntries = indexJson.entrySet(); for (Entry entry : indexEntries) { ResourceLocation loc = new ResourceLocation(domain, "worldgen/" + entry.getKey() + ".schematic"); IResource schemResource = manager.getResource(loc); Schematic newSchem = new Schematic( - CompressedStreamTools.readCompressed(schemResource - .getInputStream()), entry.getKey()); + CompressedStreamTools.readCompressed(schemResource.getInputStream()), + entry.getKey()); // Read the JSON *after* the NBT so that it // overrides properly newSchem.info.readFromJson(entry.getValue()); @@ -93,12 +86,9 @@ public void onResourceManagerReload(IResourceManager manager) { count++; } } catch (RuntimeException runtimeexception) { - MyWorldGen.log.warn("Invalid worldgen.json", - runtimeexception); + MyWorldGen.log.warn("Invalid worldgen.json", runtimeexception); } - MyWorldGen.log.log(Level.INFO, - "Loaded {} schematics from {}", count, - jsonResource); + MyWorldGen.log.log(Level.INFO, "Loaded {} schematics from {}", count, jsonResource); } } catch (IOException ioexception) { ; diff --git a/src/main/java/net/boatcake/MyWorldGen/client/StupidDeserializer.java b/src/main/java/net/boatcake/MyWorldGen/client/StupidDeserializer.java index 236cd14..5c33ff3 100644 --- a/src/main/java/net/boatcake/MyWorldGen/client/StupidDeserializer.java +++ b/src/main/java/net/boatcake/MyWorldGen/client/StupidDeserializer.java @@ -10,8 +10,8 @@ public class StupidDeserializer implements JsonDeserializer { @Override - public JsonObject deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { + public JsonObject deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { return json.getAsJsonObject(); } } diff --git a/src/main/java/net/boatcake/MyWorldGen/items/BlockAnchorItem.java b/src/main/java/net/boatcake/MyWorldGen/items/BlockAnchorItem.java index d753064..3411ae3 100644 --- a/src/main/java/net/boatcake/MyWorldGen/items/BlockAnchorItem.java +++ b/src/main/java/net/boatcake/MyWorldGen/items/BlockAnchorItem.java @@ -10,6 +10,7 @@ public class BlockAnchorItem extends ItemMultiTexture { public BlockAnchorItem(Block block) { super(block, block, new Function() { + @Override public String apply(ItemStack stack) { return BlockAnchorMaterial.AnchorType.get(stack.getMetadata()).name; } diff --git a/src/main/java/net/boatcake/MyWorldGen/items/ItemWandLoad.java b/src/main/java/net/boatcake/MyWorldGen/items/ItemWandLoad.java index d1224e0..8b8e0e6 100644 --- a/src/main/java/net/boatcake/MyWorldGen/items/ItemWandLoad.java +++ b/src/main/java/net/boatcake/MyWorldGen/items/ItemWandLoad.java @@ -12,17 +12,15 @@ public class ItemWandLoad extends Item { public ItemWandLoad() { - this.maxStackSize = 1; + this.maxStackSize = 1; } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, - BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, - float hitZ) { + public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, + EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { BlockPos newPos = blockPos.offset(side); - player.openGui(MyWorldGen.instance, 1, world, newPos.getX(), - newPos.getY(), newPos.getZ()); + player.openGui(MyWorldGen.instance, 1, world, newPos.getX(), newPos.getY(), newPos.getZ()); } return EnumActionResult.SUCCESS; } diff --git a/src/main/java/net/boatcake/MyWorldGen/network/MessageGetSchemClient.java b/src/main/java/net/boatcake/MyWorldGen/network/MessageGetSchemClient.java index 8292605..4a6695a 100644 --- a/src/main/java/net/boatcake/MyWorldGen/network/MessageGetSchemClient.java +++ b/src/main/java/net/boatcake/MyWorldGen/network/MessageGetSchemClient.java @@ -19,8 +19,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class MessageGetSchemClient implements IMessage, - IMessageHandler { +public class MessageGetSchemClient implements IMessage, IMessageHandler { public NBTTagList entitiesTag; public NBTTagList tileEntitiesTag; public BlockPos pos1; @@ -36,10 +35,8 @@ public void fromBytes(ByteBuf buf) { e.printStackTrace(); return; } - pos1 = new BlockPos(packetTag.getInteger("x1"), - packetTag.getInteger("y1"), packetTag.getInteger("z1")); - pos2 = new BlockPos(packetTag.getInteger("x2"), - packetTag.getInteger("y2"), packetTag.getInteger("z2")); + pos1 = new BlockPos(packetTag.getInteger("x1"), packetTag.getInteger("y1"), packetTag.getInteger("z1")); + pos2 = new BlockPos(packetTag.getInteger("x2"), packetTag.getInteger("y2"), packetTag.getInteger("z2")); entitiesTag = packetTag.getTagList("entities", 10); tileEntitiesTag = packetTag.getTagList("tileEntities", 10); } @@ -62,8 +59,7 @@ public IMessage onMessage(MessageGetSchemClient message, MessageContext ctx) { if (currentScreen instanceof GuiSaveSchematic) { GuiSaveSchematic guiSchematic = (GuiSaveSchematic) currentScreen; - guiSchematic.schematicToSave = new Schematic(player.worldObj, - message.pos1, message.pos2); + guiSchematic.schematicToSave = new Schematic(player.worldObj, message.pos1, message.pos2); guiSchematic.schematicToSave.entities = message.entitiesTag; guiSchematic.schematicToSave.tileEntities = message.tileEntitiesTag; guiSchematic.updateSaveButton(); diff --git a/src/main/java/net/boatcake/MyWorldGen/network/MessagePlaceSchem.java b/src/main/java/net/boatcake/MyWorldGen/network/MessagePlaceSchem.java index 277599e..474077d 100644 --- a/src/main/java/net/boatcake/MyWorldGen/network/MessagePlaceSchem.java +++ b/src/main/java/net/boatcake/MyWorldGen/network/MessagePlaceSchem.java @@ -17,8 +17,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class MessagePlaceSchem implements IMessage, - IMessageHandler { +public class MessagePlaceSchem implements IMessage, IMessageHandler { public Rotation rotation; public NBTTagCompound schematicTag; public BlockPos pos; @@ -34,12 +33,10 @@ public void fromBytes(ByteBuf buf) { e.printStackTrace(); return; } - pos = new BlockPos(packetTag.getInteger("x"), - packetTag.getInteger("y"), packetTag.getInteger("z")); + pos = new BlockPos(packetTag.getInteger("x"), packetTag.getInteger("y"), packetTag.getInteger("z")); schematicTag = packetTag.getCompoundTag("schematic"); rotation = Rotation.values()[packetTag.getInteger("rotation")]; - placementOption = BlockPlacementOption.get(packetTag - .getInteger("placementOption")); + placementOption = BlockPlacementOption.get(packetTag.getInteger("placementOption")); } @Override @@ -47,10 +44,8 @@ public IMessage onMessage(MessagePlaceSchem message, MessageContext ctx) { EntityPlayerMP playerMP = ctx.getServerHandler().playerEntity; // no cheating! if (playerMP.capabilities.isCreativeMode) { - new Schematic(message.schematicTag, null).placeInWorld( - playerMP.worldObj, message.pos, message.rotation, - message.placementOption.generateChests, - message.placementOption.generateSpawners, + new Schematic(message.schematicTag, null).placeInWorld(playerMP.worldObj, message.pos, message.rotation, + message.placementOption.generateChests, message.placementOption.generateSpawners, message.placementOption.followPlacementRules, new Random()); } return null; diff --git a/src/main/java/net/boatcake/MyWorldGen/utils/DirectionUtils.java b/src/main/java/net/boatcake/MyWorldGen/utils/DirectionUtils.java index 45dca8e..b6f9882 100644 --- a/src/main/java/net/boatcake/MyWorldGen/utils/DirectionUtils.java +++ b/src/main/java/net/boatcake/MyWorldGen/utils/DirectionUtils.java @@ -90,7 +90,7 @@ public static float yawOffsetForRotation(Rotation rotation) { return 0; } } - + public static float yawOffsetForDirection(EnumFacing rotationDirection) { switch (rotationDirection) { case SOUTH: @@ -105,7 +105,7 @@ public static float yawOffsetForDirection(EnumFacing rotationDirection) { return 0; } } - + public static Rotation rotationForFacing(EnumFacing facing) { switch (facing) { case SOUTH: @@ -127,39 +127,35 @@ public static Vec3d rotateCoords(Vec3d coords, Vec3d at, Rotation rot) { double worldZ = coords.zCoord; switch (rot) { case CLOCKWISE_180: - return new Vec3d(-worldX+at.xCoord, worldY+at.yCoord, -worldZ+at.zCoord); + return new Vec3d(-worldX + at.xCoord, worldY + at.yCoord, -worldZ + at.zCoord); case CLOCKWISE_90: - return new Vec3d(-worldZ+at.xCoord, worldY+at.yCoord, worldX+at.zCoord); + return new Vec3d(-worldZ + at.xCoord, worldY + at.yCoord, worldX + at.zCoord); case COUNTERCLOCKWISE_90: - return new Vec3d(worldZ+at.xCoord, worldY+at.yCoord, -worldX+at.zCoord); + return new Vec3d(worldZ + at.xCoord, worldY + at.yCoord, -worldX + at.zCoord); case NONE: default: - return new Vec3d(worldX+at.xCoord, worldY+at.yCoord, worldZ+at.zCoord); + return new Vec3d(worldX + at.xCoord, worldY + at.yCoord, worldZ + at.zCoord); } } public static Vec3d rotateCoords(Vec3i coords, Vec3d at, Rotation rot) { - return rotateCoords(new Vec3d(coords), at,rot); + return rotateCoords(new Vec3d(coords), at, rot); } - public static EnumFacing[] cardinalDirections = new EnumFacing[] { - EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, - EnumFacing.WEST }; + public static EnumFacing[] cardinalDirections = new EnumFacing[] { EnumFacing.NORTH, EnumFacing.EAST, + EnumFacing.SOUTH, EnumFacing.WEST }; public static EnumFacing getDirectionFromYaw(float yaw) { - return cardinalDirections[MathHelper - .floor_double(yaw * 4.0F / 360.0F + 0.5D) & 0x3]; + return cardinalDirections[MathHelper.floor_double(yaw * 4.0F / 360.0F + 0.5D) & 0x3]; } public static Rotation getRotationFromYaw(float yaw) { - return Rotation.values()[MathHelper - .floor_double(yaw * 4.0F / 360.0F + 0.5D) & 0x3]; + return Rotation.values()[MathHelper.floor_double(yaw * 4.0F / 360.0F + 0.5D) & 0x3]; } // This method already exists in EnumFacing, but it's SideOnly(CLIENT) for // some reason >:( - public static EnumFacing rotateAround(EnumFacing facing, - EnumFacing.Axis axis) { + public static EnumFacing rotateAround(EnumFacing facing, EnumFacing.Axis axis) { switch (axis) { case X: switch (facing) { @@ -200,8 +196,7 @@ public static EnumFacing rotateAround(EnumFacing facing, } default: - throw new IllegalStateException("Unable to get CW facing for axis " - + axis); + throw new IllegalStateException("Unable to get CW facing for axis " + axis); } } } diff --git a/src/main/java/net/boatcake/MyWorldGen/utils/FileUtils.java b/src/main/java/net/boatcake/MyWorldGen/utils/FileUtils.java index 5f9712c..cafd191 100644 --- a/src/main/java/net/boatcake/MyWorldGen/utils/FileUtils.java +++ b/src/main/java/net/boatcake/MyWorldGen/utils/FileUtils.java @@ -15,11 +15,9 @@ public class FileUtils { - public static void writeStream(InputStream inStream, String outName) - throws IOException { + public static void writeStream(InputStream inStream, String outName) throws IOException { // Used for self-extracting files - OutputStream outStream = new FileOutputStream(new File( - MyWorldGen.globalSchemDir, new File(outName).getName())); + OutputStream outStream = new FileOutputStream(new File(MyWorldGen.globalSchemDir, new File(outName).getName())); byte[] buffer = new byte[256]; int readLen; while (true) { @@ -42,11 +40,9 @@ public static void extractSchematics(File sourceFile) { ZipFile zf = new ZipFile(sourceFile); ZipEntry worldGenDir = zf.getEntry(MyWorldGen.resourcePath + "/"); if (worldGenDir != null && worldGenDir.isDirectory()) { - for (Enumeration e = zf.entries(); e - .hasMoreElements();) { + for (Enumeration e = zf.entries(); e.hasMoreElements();) { ZipEntry ze = e.nextElement(); - if (!ze.isDirectory() - && ze.getName().startsWith(worldGenDir.getName())) { + if (!ze.isDirectory() && ze.getName().startsWith(worldGenDir.getName())) { writeStream(zf.getInputStream(ze), ze.getName()); } } @@ -54,8 +50,7 @@ public static void extractSchematics(File sourceFile) { zf.close(); } catch (FileNotFoundException e) { // Not in a jar - File f = new File(MyWorldGen.class.getClassLoader() - .getResource(MyWorldGen.resourcePath).getPath()); + File f = new File(MyWorldGen.class.getClassLoader().getResource(MyWorldGen.resourcePath).getPath()); if (f.isDirectory()) { for (String s : f.list()) { try { diff --git a/src/main/java/net/boatcake/MyWorldGen/utils/NetUtils.java b/src/main/java/net/boatcake/MyWorldGen/utils/NetUtils.java index ca25498..e3e2849 100644 --- a/src/main/java/net/boatcake/MyWorldGen/utils/NetUtils.java +++ b/src/main/java/net/boatcake/MyWorldGen/utils/NetUtils.java @@ -24,9 +24,7 @@ public static void sendToServer(IMessage message) { } public static void init() { - INSTANCE.registerMessage(MessageGetSchemClient.class, - MessageGetSchemClient.class, 0, Side.CLIENT); - INSTANCE.registerMessage(MessagePlaceSchem.class, - MessagePlaceSchem.class, 2, Side.SERVER); + INSTANCE.registerMessage(MessageGetSchemClient.class, MessageGetSchemClient.class, 0, Side.CLIENT); + INSTANCE.registerMessage(MessagePlaceSchem.class, MessagePlaceSchem.class, 2, Side.SERVER); } } diff --git a/src/main/java/net/boatcake/MyWorldGen/utils/WorldUtils.java b/src/main/java/net/boatcake/MyWorldGen/utils/WorldUtils.java index f4757b0..f83e0f8 100644 --- a/src/main/java/net/boatcake/MyWorldGen/utils/WorldUtils.java +++ b/src/main/java/net/boatcake/MyWorldGen/utils/WorldUtils.java @@ -11,18 +11,14 @@ public class WorldUtils { - public static NBTTagList getEntities(World world, BlockPos pos1, - BlockPos pos2) { + public static NBTTagList getEntities(World world, BlockPos pos1, BlockPos pos2) { assert !world.isRemote; - BlockPos min = new BlockPos(Math.min(pos1.getX(), pos2.getX()), - Math.min(pos1.getY(), pos2.getY()), Math.min(pos1.getZ(), - pos2.getZ())); - BlockPos max = new BlockPos(Math.max(pos1.getX(), pos2.getX()), - Math.max(pos1.getY(), pos2.getY()), Math.max(pos1.getZ(), - pos2.getZ())); + BlockPos min = new BlockPos(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()), + Math.min(pos1.getZ(), pos2.getZ())); + BlockPos max = new BlockPos(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()), + Math.max(pos1.getZ(), pos2.getZ())); NBTTagList entities = new NBTTagList(); - for (Object o : world.getEntitiesWithinAABB(Entity.class, - new AxisAlignedBB(min, max))) { + for (Object o : world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(min, max))) { NBTTagCompound enbt = new NBTTagCompound(); ((Entity) o).writeToNBTOptional(enbt); if (enbt.hasNoTags()) { @@ -37,15 +33,12 @@ public static NBTTagList getEntities(World world, BlockPos pos1, return entities; } - public static NBTTagList getTileEntities(World world, BlockPos pos1, - BlockPos pos2) { + public static NBTTagList getTileEntities(World world, BlockPos pos1, BlockPos pos2) { assert !world.isRemote; - BlockPos min = new BlockPos(Math.min(pos1.getX(), pos2.getX()), - Math.min(pos1.getY(), pos2.getY()), Math.min(pos1.getZ(), - pos2.getZ())); - BlockPos max = new BlockPos(Math.max(pos1.getX(), pos2.getX()), - Math.max(pos1.getY(), pos2.getY()), Math.max(pos1.getZ(), - pos2.getZ())); + BlockPos min = new BlockPos(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()), + Math.min(pos1.getZ(), pos2.getZ())); + BlockPos max = new BlockPos(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()), + Math.max(pos1.getZ(), pos2.getZ())); NBTTagList tileEntities = new NBTTagList(); for (Object o : BlockPos.getAllInBox(min, max)) { BlockPos pos = (BlockPos) o;