From 2ef892aa3053c8d7969caa7b5eae1bc533b31946 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Tue, 7 Apr 2015 21:27:34 +1000 Subject: [PATCH] Moved the progress stats to a command rather than hover text --- .../common/command/BOPCommand.java | 42 +++++++++++++++++-- .../common/handler/GuiEventHandler.java | 37 ---------------- .../biomesoplenty/common/init/ModBiomes.java | 14 +++---- .../biomesoplenty/common/init/ModBlocks.java | 4 +- .../biomesoplenty/common/init/ModItems.java | 33 ++++++++++----- .../assets/biomesoplenty/lang/en_US.lang | 4 ++ 6 files changed, 74 insertions(+), 60 deletions(-) diff --git a/src/main/java/biomesoplenty/common/command/BOPCommand.java b/src/main/java/biomesoplenty/common/command/BOPCommand.java index adf22e193..f3ddfaa11 100644 --- a/src/main/java/biomesoplenty/common/command/BOPCommand.java +++ b/src/main/java/biomesoplenty/common/command/BOPCommand.java @@ -20,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; @@ -30,6 +31,11 @@ import com.google.common.collect.Lists; public class BOPCommand extends CommandBase { + public static int blockCount = 0; + public static int itemCount = 0; + public static int entityCount = 0; + public static int biomeCount = 0; + @Override public String getCommandName() { @@ -61,15 +67,19 @@ public class BOPCommand extends CommandBase { throw new WrongUsageException("commands.biomesoplenty.usage"); } - else if ("biomename".equals(args[0])) + else if (args[0].equals("biomename")) { getBiomeName(sender, args); } - else if ("tpbiome".equals(args[0])) + else if (args[0].equals("tpbiome")) { teleportFoundBiome(sender, args); } - else if ("stripchunk".equals(args[0])) + else if (args[0].equals("stats")) + { + printStats(sender, args); + } + else if (args[0].equals("stripchunk")) { stripChunk(sender, args); } @@ -116,6 +126,30 @@ public class BOPCommand extends CommandBase } } + private void printStats(ICommandSender sender, String[] args) throws CommandException + { + ChatComponentTranslation text = new ChatComponentTranslation("commands.biomesoplenty.stats.blocks", blockCount); + + text.getChatStyle().setColor(EnumChatFormatting.GREEN); + sender.addChatMessage(text); + + text = new ChatComponentTranslation("commands.biomesoplenty.stats.blocks", blockCount); + text.getChatStyle().setColor(EnumChatFormatting.GREEN); + sender.addChatMessage(text); + + text = new ChatComponentTranslation("commands.biomesoplenty.stats.items", itemCount); + text.getChatStyle().setColor(EnumChatFormatting.GREEN); + sender.addChatMessage(text); + + text = new ChatComponentTranslation("commands.biomesoplenty.stats.entities", entityCount); + text.getChatStyle().setColor(EnumChatFormatting.GREEN); + sender.addChatMessage(text); + + text = new ChatComponentTranslation("commands.biomesoplenty.stats.biomes", biomeCount); + text.getChatStyle().setColor(EnumChatFormatting.GREEN); + sender.addChatMessage(text); + } + private void stripChunk(ICommandSender sender, String[] args) throws CommandException { if (args.length < 5) @@ -191,7 +225,7 @@ public class BOPCommand extends CommandBase { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "biomename", "tpbiome", "stripchunk"); + return getListOfStringsMatchingLastWord(args, "biomename", "tpbiome", "stats", "stripchunk"); } else if (args.length == 3) { diff --git a/src/main/java/biomesoplenty/common/handler/GuiEventHandler.java b/src/main/java/biomesoplenty/common/handler/GuiEventHandler.java index b73706c92..0175ba457 100644 --- a/src/main/java/biomesoplenty/common/handler/GuiEventHandler.java +++ b/src/main/java/biomesoplenty/common/handler/GuiEventHandler.java @@ -8,14 +8,8 @@ package biomesoplenty.common.handler; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiCreateWorld; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.world.WorldType; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @@ -25,10 +19,6 @@ import biomesoplenty.common.init.ModBiomes; public class GuiEventHandler { - public static int blockCount = 0; - public static int itemCount = 0; - public static int biomeCount = 0; - @SideOnly(Side.CLIENT) @SubscribeEvent public void onPreInitCreateWorld(InitGuiEvent.Pre event) @@ -42,31 +32,4 @@ public class GuiEventHandler createWorldGui.selectedIndex = ModBiomes.worldTypeBOP.getWorldTypeID(); } } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onDrawScreen(DrawScreenEvent.Post event) - { - GuiScreen screenGui = event.gui; - - if (screenGui instanceof GuiCreateWorld) - { - GuiCreateWorld createWorldGui = (GuiCreateWorld)screenGui; - GuiButton mapTypeButton = createWorldGui.btnMapType; - int worldTypeIndex = createWorldGui.selectedIndex; - - if (mapTypeButton.isMouseOver() && WorldType.worldTypes[worldTypeIndex] == ModBiomes.worldTypeBOP) - { - List text = new ArrayList(); - - text.add("Progress:"); - text.add("Blocks: " + blockCount); - text.add("Items: " + itemCount); - text.add("Entities: 0"); - text.add("Biomes: " + biomeCount); - - createWorldGui.drawHoveringText(text, event.mouseX, event.mouseY); - } - } - } } diff --git a/src/main/java/biomesoplenty/common/init/ModBiomes.java b/src/main/java/biomesoplenty/common/init/ModBiomes.java index 9dcacfa82..31db67d7f 100644 --- a/src/main/java/biomesoplenty/common/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/common/init/ModBiomes.java @@ -13,19 +13,19 @@ import static biomesoplenty.api.biome.BOPBiomes.alps; import java.io.File; import java.io.IOException; +import net.minecraft.world.biome.BiomeGenBase; + import org.apache.commons.io.FileUtils; -import com.google.common.base.Optional; -import com.google.gson.JsonSyntaxException; - -import net.minecraft.world.biome.BiomeGenBase; -import biomesoplenty.common.biome.ExtendedBiomeRegistry; import biomesoplenty.common.biome.overworld.BiomeGenAlps; -import biomesoplenty.common.handler.GuiEventHandler; +import biomesoplenty.common.command.BOPCommand; import biomesoplenty.common.util.config.JsonBiome; import biomesoplenty.common.world.WorldTypeBOP; import biomesoplenty.core.BiomesOPlenty; +import com.google.common.base.Optional; +import com.google.gson.JsonSyntaxException; + public class ModBiomes { public static WorldTypeBOP worldTypeBOP; @@ -92,7 +92,7 @@ public class ModBiomes private static Optional registerBiome(BiomeGenBase biome, String id) { biome.biomeID = getNextFreeBiomeId(); - GuiEventHandler.biomeCount++; + BOPCommand.biomeCount++; return loadOrCreateConfig(biome, id); } diff --git a/src/main/java/biomesoplenty/common/init/ModBlocks.java b/src/main/java/biomesoplenty/common/init/ModBlocks.java index d8321dd97..df67c334d 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlocks.java +++ b/src/main/java/biomesoplenty/common/init/ModBlocks.java @@ -79,7 +79,7 @@ import biomesoplenty.common.block.BlockHoney; import biomesoplenty.common.block.BlockMud; import biomesoplenty.common.block.BlockStoneFormations; import biomesoplenty.common.block.BlockTurnip; -import biomesoplenty.common.handler.GuiEventHandler; +import biomesoplenty.common.command.BOPCommand; import biomesoplenty.common.util.block.BlockStateUtils; import biomesoplenty.common.util.inventory.CreativeTabBOP; import biomesoplenty.core.BiomesOPlenty; @@ -275,7 +275,7 @@ public class ModBlocks ModelLoader.setCustomModelResourceLocation(item, stateMeta, new ModelResourceLocation(BiomesOPlenty.MOD_ID + ":" + stateName, "inventory")); } - GuiEventHandler.blockCount++; + BOPCommand.blockCount++; } public static Block registerBlock(Block block, String blockName) diff --git a/src/main/java/biomesoplenty/common/init/ModItems.java b/src/main/java/biomesoplenty/common/init/ModItems.java index 0b62f97c9..6df7132fb 100644 --- a/src/main/java/biomesoplenty/common/init/ModItems.java +++ b/src/main/java/biomesoplenty/common/init/ModItems.java @@ -8,19 +8,24 @@ package biomesoplenty.common.init; -import static biomesoplenty.api.item.BOPItems.*; +import static biomesoplenty.api.item.BOPItems.ash; +import static biomesoplenty.api.item.BOPItems.berries; +import static biomesoplenty.api.item.BOPItems.crystal_shard; +import static biomesoplenty.api.item.BOPItems.filled_honeycomb; +import static biomesoplenty.api.item.BOPItems.fleshchunk; +import static biomesoplenty.api.item.BOPItems.gem; +import static biomesoplenty.api.item.BOPItems.honeycomb; +import static biomesoplenty.api.item.BOPItems.mudball; +import static biomesoplenty.api.item.BOPItems.peach; +import static biomesoplenty.api.item.BOPItems.pear; +import static biomesoplenty.api.item.BOPItems.persimmon; +import static biomesoplenty.api.item.BOPItems.turnip; +import static biomesoplenty.api.item.BOPItems.turnip_seeds; +import static biomesoplenty.api.item.BOPItems.wading_boots; import java.util.ArrayList; import java.util.List; -import biomesoplenty.api.block.BOPBlocks; -import biomesoplenty.api.item.BOPItemHelper; -import biomesoplenty.common.handler.GuiEventHandler; -import biomesoplenty.common.item.ItemGem; -import biomesoplenty.common.item.ItemMudball; -import biomesoplenty.common.item.ItemWadingBoots; -import biomesoplenty.common.util.inventory.CreativeTabBOP; -import biomesoplenty.core.BiomesOPlenty; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.init.Blocks; @@ -33,6 +38,14 @@ import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; +import biomesoplenty.api.block.BOPBlocks; +import biomesoplenty.api.item.BOPItemHelper; +import biomesoplenty.common.command.BOPCommand; +import biomesoplenty.common.item.ItemGem; +import biomesoplenty.common.item.ItemMudball; +import biomesoplenty.common.item.ItemWadingBoots; +import biomesoplenty.common.util.inventory.CreativeTabBOP; +import biomesoplenty.core.BiomesOPlenty; public class ModItems { @@ -63,7 +76,7 @@ public class ModItems { item.setUnlocalizedName(name).setCreativeTab(CreativeTabBOP.instance); GameRegistry.registerItem(item,name); - GuiEventHandler.itemCount++; + BOPCommand.itemCount++; // register sub types if there are any if (FMLCommonHandler.instance().getSide() == Side.CLIENT) diff --git a/src/main/resources/assets/biomesoplenty/lang/en_US.lang b/src/main/resources/assets/biomesoplenty/lang/en_US.lang index 416c03341..f12c91a36 100644 --- a/src/main/resources/assets/biomesoplenty/lang/en_US.lang +++ b/src/main/resources/assets/biomesoplenty/lang/en_US.lang @@ -4,6 +4,10 @@ commands.biomesoplenty.biomename.success=Biome ID %s is associated with %s commands.biomesoplenty.tpbiome.usage=/biomesoplenty tpbiome [biomeId] commands.biomesoplenty.tpbiome.success=Teleported %s to biome %s at (%s, %s, %s) commands.biomesoplenty.tpbiome.error=Couldn't find biome %s! +commands.biomesoplenty.stats.blocks=Blocks: %s +commands.biomesoplenty.stats.items=Items: %s +commands.biomesoplenty.stats.entities=Entities: %s +commands.biomesoplenty.stats.biomes=Biomes: %s commands.biomesoplenty.stripchunk.usage=/biomesoplenty stripchunk [radius] [block] [metadata] generator.BIOMESOP=Biomes O' Plenty