Switched to Gradle 1.1 properly (Thanks progwml6|L), fixed a bug with wild carrots, added a one-time warning on startup regarding the BOP worldtype and 1.7

This commit is contained in:
Adubbz 2014-01-14 15:11:49 +11:00
parent ea8942eddc
commit 9a7f95563b
10 changed files with 365 additions and 6 deletions

View file

@ -4,10 +4,14 @@ buildscript {
maven {
name = "ForgeFS"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT'
}
}

View file

@ -10,7 +10,7 @@ import biomesoplenty.common.core.BOPEntities;
import biomesoplenty.common.core.BOPItems;
import biomesoplenty.common.core.BOPPotions;
import biomesoplenty.common.core.BOPVanillaCompat;
import biomesoplenty.common.eventhandler.BOPCommonEventHandlers;
import biomesoplenty.common.eventhandler.BOPEventHandlers;
import biomesoplenty.common.helpers.CreativeTabsBOP;
import biomesoplenty.common.utils.BOPModInfo;
import biomesoplenty.common.world.WorldTypeBOP;
@ -59,7 +59,7 @@ public class BiomesOPlenty
BOPEntities.init();
BOPVanillaCompat.init();
BOPCommonEventHandlers.init();
BOPEventHandlers.init();
proxy.registerRenderers();
}

View file

@ -0,0 +1,172 @@
package biomesoplenty.client.gui;
import static net.minecraft.util.EnumChatFormatting.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.regex.Pattern;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import org.apache.commons.io.FileUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public class StartupWarningGUI extends GuiScreen
{
private GuiScreen parentGuiScreen;
private File nameHashFile;
private String nameHash;
private String link = "http://www.reddit.com/r/biomesoplenty/comments/1v5ly1/logical_bug_reporting/";
private static final ResourceLocation bopLogoTexture = new ResourceLocation("biomesoplenty:textures/gui/logo256.png");
public StartupWarningGUI(GuiScreen parentGuiScreen, File nameHashFile, String nameHash)
{
this.parentGuiScreen = parentGuiScreen;
this.nameHashFile = nameHashFile;
this.nameHash = nameHash;
}
@Override
public void initGui()
{
Keyboard.enableRepeatEvents(true);
//TODO: buttonList
this.field_146292_n.clear();
//TODO: buttonList
this.field_146292_n.add(new GuiButton(0, this.field_146294_l / 2 - 175, this.field_146295_m - 48, 350, 20, I18n.getStringParams("OK")));
//TODO: buttonList
this.field_146292_n.add(new GuiButton(1, this.field_146294_l / 2 - 175, this.field_146295_m - 24, 350, 20, I18n.getStringParams("Cancel")));
}
@Override
public void confirmClicked(boolean par1, int par2)
{
if (par2 == 13)
{
if (par1)
{
try
{
Class oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(this.link)});
}
catch (Throwable throwable)
{
//field_146974_g.error("Couldn\'t open link", throwable);
}
}
//TODO: mc displayGuiScreen
this.field_146297_k.func_147108_a(this);
}
}
@Override
//TODO: onGuiClosed()
public void func_146281_b()
{
Keyboard.enableRepeatEvents(false);
}
@Override
//TODO: actionPerformed()
protected void func_146284_a(GuiButton button)
{
//TODO: enabled
if (button.field_146124_l)
{
//TODO: id
if (button.field_146127_k == 0)
{
try
{
nameHashFile.createNewFile();
FileUtils.write(nameHashFile, nameHash + "StartupWarning".hashCode());
}
catch (IOException e)
{
e.printStackTrace();
}
//TODO: displayGuiScreen()
this.field_146297_k.func_147108_a(this.parentGuiScreen);
}
//TODO: id
if (button.field_146127_k == 1)
{
System.exit(0);
}
}
}
@Override
protected void mouseClicked(int x, int y, int eventButton)
{
super.mouseClicked(x, y, eventButton);
int middleOfScreen = this.field_146294_l / 2;
int middleOfText = this.field_146289_q.getStringWidth(link) / 2;
if (x >= middleOfScreen - middleOfText && x <= middleOfScreen + middleOfText && y >= 108 && y <= 108 + 12)
{
GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, this.link, 13, true);
guiconfirmopenlink.func_146358_g();
//TODO: mc displayGuiScreen()
this.field_146297_k.func_147108_a(guiconfirmopenlink);
}
}
@Override
public void drawScreen(int x, int y, float renderPartialTicks)
{
String linkFormatting = "" + GREEN + UNDERLINE + ITALIC;
//TODO: drawDefaultBackground()
this.func_146276_q_();
//EnumChatFormatting.
//TODO: fontRendererObj width
this.drawCenteredString(this.field_146289_q, "" + YELLOW + BOLD + "WARNING: " + DARK_RED + "Biomes O' Plenty for 1.7 is NOT yet stable. Do not expect everything", this.field_146294_l / 2, 82, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + DARK_RED + "to be perfect.", this.field_146294_l / 2, 94, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, linkFormatting + link, this.field_146294_l / 2, 120, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + GOLD + BOLD + UNDERLINE + "Biomes O' Plenty Worldtype", this.field_146294_l / 2, 156, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + RED + "Biomes O' Plenty uses a custom worldtype for its biomes. When creating a world, it", this.field_146294_l / 2, 180, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + RED + "may be enabled by clicking the 'World Type' button under 'More World Options'", this.field_146294_l / 2, 192, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + RED + "until it displays 'Biomes O' Plenty'.", this.field_146294_l / 2, 204, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + RED + "The worldtype can be used on servers by changing the 'level-type' in", this.field_146294_l / 2, 230, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + RED + "sever.properties to 'BIOMESOP' (without quotes)", this.field_146294_l / 2, 242, 0xFFFFFF);
this.drawCenteredString(this.field_146289_q, "" + DARK_RED + "This message will only display once.", this.field_146294_l / 2, 266, 0xFFFFFF);
this.field_146297_k.getTextureManager().bindTexture(bopLogoTexture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
// width x, y, u, v, width, height
this.drawTexturedModalRect(this.field_146294_l / 2 - 168 / 2, 0, 0, 0, 168, 80);
super.drawScreen(x, y, renderPartialTicks);
}
@Override
public void drawCenteredString(FontRenderer fontRenderer, String string, int x, int y, int colour)
{
fontRenderer.drawStringWithShadow(string, x - fontRenderer.getStringWidth(string.replaceAll("\\P{InBasic_Latin}", "")) / 2, y, colour);
}
}

View file

@ -422,8 +422,10 @@ public class BlockBOPPlant extends BOPBlockWorldDecor implements IShearable
@Override
public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 7 || world.getBlockMetadata(x, y, z) == 8 || world.getBlockMetadata(x, y, z) == 9)
return false;
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 7 || metadata == 8 || metadata == 9 || metadata == 11)
return false;
else
return true;
}

View file

@ -4,19 +4,21 @@ import net.minecraftforge.common.MinecraftForge;
import biomesoplenty.common.eventhandler.entity.DyeEventHandler;
import biomesoplenty.common.eventhandler.entity.FlippersEventHandler;
import biomesoplenty.common.eventhandler.entity.TemptEventHandler;
import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler;
import biomesoplenty.common.eventhandler.misc.CapeEventHandler;
import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler;
import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler;
import biomesoplenty.common.eventhandler.world.DecorateBiomeEventHandler;
import biomesoplenty.common.eventhandler.world.DecorationModificationEventHandler;
public class BOPCommonEventHandlers
public class BOPEventHandlers
{
public static void init()
{
registerWorldEventHandlers();
registerEntityEventHandlers();
registerPotionEventHandlers();
registerGUIEventHandlers();
registerMiscEventHandlers();
}
@ -39,6 +41,11 @@ public class BOPCommonEventHandlers
MinecraftForge.EVENT_BUS.register(new PotionPossessionEventHandler());
}
private static void registerGUIEventHandlers()
{
MinecraftForge.EVENT_BUS.register(StartupWarningEventHandler.instance);
}
private static void registerMiscEventHandlers()
{
MinecraftForge.EVENT_BUS.register(new CapeEventHandler());

View file

@ -0,0 +1,41 @@
package biomesoplenty.common.eventhandler.gui;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
import biomesoplenty.client.gui.StartupWarningGUI;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class StartupWarningEventHandler
{
public static StartupWarningEventHandler instance = new StartupWarningEventHandler();
@SubscribeEvent
public void openMainMenu(GuiOpenEvent event)
{
if (event.gui instanceof GuiMainMenu)
{
File nameHashFile = new File(Minecraft.getMinecraft().mcDataDir.getPath() + File.separator + "BOPChecks".hashCode());
String nameHash = "" + Minecraft.getMinecraft().getSession().func_148256_e().hashCode();
try
{
if (!nameHashFile.exists() || !FileUtils.readFileToString(nameHashFile).contains(nameHash + "StartupWarning".hashCode()))
{
event.gui = new StartupWarningGUI(event.gui, nameHashFile, nameHash);
}
} catch (IOException e)
{
e.printStackTrace();
}
MinecraftForge.EVENT_BUS.unregister(instance);
}
}
}

View file

@ -0,0 +1,35 @@
package biomesoplenty.common.eventhandler.world;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraftforge.event.terraingen.BiomeEvent.CreateDecorator;
import biomesoplenty.common.world.decoration.BOPBiomeDecorator;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class DecoratorHijackEventHandler
{
@SubscribeEvent
public void onDecoratorReplace(CreateDecorator event)
{
//if (BOPBiomeHelper.biomeList.containsValue(event.biome))
//{
BiomeDecorator originalBiomeDecorator = event.originalBiomeDecorator;
BOPBiomeDecorator newBiomeDecorator = new BOPBiomeDecorator();
newBiomeDecorator.bigMushroomsPerChunk = originalBiomeDecorator.bigMushroomsPerChunk;
newBiomeDecorator.cactiPerChunk = originalBiomeDecorator.cactiPerChunk;
newBiomeDecorator.clayPerChunk = originalBiomeDecorator.clayPerChunk;
newBiomeDecorator.deadBushPerChunk = originalBiomeDecorator.deadBushPerChunk;
newBiomeDecorator.flowersPerChunk = originalBiomeDecorator.flowersPerChunk;
newBiomeDecorator.generateLakes = originalBiomeDecorator.generateLakes;
newBiomeDecorator.grassPerChunk = originalBiomeDecorator.grassPerChunk;
newBiomeDecorator.mushroomsPerChunk = originalBiomeDecorator.mushroomsPerChunk;
newBiomeDecorator.reedsPerChunk = originalBiomeDecorator.reedsPerChunk;
newBiomeDecorator.sandPerChunk = originalBiomeDecorator.sandPerChunk;
newBiomeDecorator.sandPerChunk2 = originalBiomeDecorator.sandPerChunk2;
newBiomeDecorator.treesPerChunk = originalBiomeDecorator.treesPerChunk;
newBiomeDecorator.waterlilyPerChunk = originalBiomeDecorator.waterlilyPerChunk;
event.newBiomeDecorator = newBiomeDecorator;
//}
}
}

View file

@ -0,0 +1,98 @@
package biomesoplenty.common.world.decoration;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS;
import java.lang.reflect.Field;
import java.util.Random;
import biomesoplenty.common.world.generation.ForcedBOPWorldGenerators;
import biomesoplenty.common.world.generation.IWorldGeneratorBOP;
import biomesoplenty.common.world.generation.WorldGenFieldAssociation;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.terraingen.TerrainGen;
public class BOPBiomeDecorator extends BiomeDecorator
{
@Override
public void func_150512_a(World world, Random random, BiomeGenBase biome, int chunk_X, int chunk_Z)
{
if (this.currentWorld == null)
{
this.currentWorld = world;
this.randomGenerator = random;
this.chunk_X = chunk_X;
this.chunk_Z = chunk_Z;
this.func_150513_a(biome);
this.currentWorld = null;
this.randomGenerator = null;
}
}
@Override
protected void func_150513_a(BiomeGenBase biome)
{
doBOPDecoration(biome);
super.func_150513_a(biome);
}
public void doBOPDecoration(BiomeGenBase biome)
{
IBOPDecoration bopDecoration = null;
if (biome instanceof IBOPDecoration)
{
bopDecoration = (IBOPDecoration)biome;
}
else if (ForcedDecorators.biomeHasForcedDecorator(biome.biomeID))
{
bopDecoration = ForcedDecorators.getForcedDecorator(biome.biomeID);
}
if (bopDecoration != null)
{
for (Field worldGeneratorField : BOPWorldFeatures.class.getFields())
{
WorldGenerator worldGenerator = null;
if (worldGeneratorField.getName().equals("bopFlowersPerChunk") && TerrainGen.decorate(this.currentWorld, this.randomGenerator, this.chunk_X, this.chunk_Z, FLOWERS))
{
worldGenerator = bopDecoration.getRandomWorldGenForBOPFlowers(this.randomGenerator);
}
else
{
worldGenerator = WorldGenFieldAssociation.getAssociatedWorldGenerator(worldGeneratorField.getName());
}
if (worldGenerator != null)
{
IWorldGeneratorBOP worldGeneratorBOP = null;
if (worldGenerator instanceof IWorldGeneratorBOP)
{
worldGeneratorBOP = (IWorldGeneratorBOP)worldGenerator;
}
else if (ForcedBOPWorldGenerators.hasForcedGenerator(worldGenerator.getClass()))
{
worldGeneratorBOP = ForcedBOPWorldGenerators.getForcedGenerator(worldGenerator.getClass());
}
if (worldGeneratorBOP != null)
{
try
{
worldGeneratorBOP.doGeneration(this.currentWorld, this.randomGenerator, worldGeneratorField, worldGenerator, biome, bopDecoration, this.chunk_X, this.chunk_Z);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
}
}
}

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB