diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index f2057b331..c2e5f35fa 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -70,7 +70,7 @@ public class ActuallyAdditions{ InitItems.init(); InitVillager.init(); FuelHandler.init(); - new UpdateChecker().init(); + UpdateChecker.init(); proxy.preInit(event); ModUtil.LOGGER.info("PreInitialization Finished."); diff --git a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java index 82d9b0c42..02f6e8426 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java +++ b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java @@ -12,7 +12,6 @@ package ellpeck.actuallyadditions.event; import cpw.mods.fml.common.Loader; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; -import ellpeck.actuallyadditions.misc.special.RenderPlayerEventAA; import ellpeck.actuallyadditions.nei.NeiScreenEvents; import ellpeck.actuallyadditions.update.UpdateCheckerClientNotifier; import ellpeck.actuallyadditions.util.ModUtil; @@ -38,7 +37,6 @@ public class InitEvents{ public static void initClient(){ Util.registerEvent(new TooltipEvent()); - Util.registerEvent(new RenderPlayerEventAA()); if(Loader.isModLoaded("NotEnoughItems")){ Util.registerEvent(new NeiScreenEvents()); diff --git a/src/main/java/ellpeck/actuallyadditions/misc/special/RenderPlayerEventAA.java b/src/main/java/ellpeck/actuallyadditions/misc/special/RenderPlayerEventAA.java deleted file mode 100644 index bf58b476a..000000000 --- a/src/main/java/ellpeck/actuallyadditions/misc/special/RenderPlayerEventAA.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file ("RenderPlayerEventAA.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015 Ellpeck - */ - -package ellpeck.actuallyadditions.misc.special; - -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import ellpeck.actuallyadditions.blocks.InitBlocks; -import ellpeck.actuallyadditions.items.InitItems; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.RenderPlayerEvent; - -import java.util.UUID; - -public class RenderPlayerEventAA{ - - public static RenderSpecial lariRender = new RenderSpecial(new ItemStack(Items.dye)); - private static RenderSpecial ellpeckRender = new RenderSpecial(new ItemStack(InitItems.itemPhantomConnector)); - private static RenderSpecial hoseRender = new RenderSpecial(new ItemStack(Blocks.torch)); - private static RenderSpecial paktoRender = new RenderSpecial(new ItemStack(Blocks.wool, 1, 6)); - private static RenderSpecial glenRender = new RenderSpecial(new ItemStack(InitBlocks.blockHeatCollector)); - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void RenderPlayerEvent(RenderPlayerEvent.Specials.Pre event){ - //Ellpeck - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("3f9f4a94-95e3-40fe-8895-e8e3e84d1468"))){ - ellpeckRender.render(event.entityPlayer, 0.4F, 0.2F); - } - //Paktosan - else if(event.entityPlayer.getUniqueID().equals(UUID.fromString("0bac71ad-9156-487e-9ade-9c5b57274b23"))){ - paktoRender.render(event.entityPlayer, 0.3F, 0); - } - //TwoOfEight - else if(event.entityPlayer.getUniqueID().equals(UUID.fromString("a57d2829-9711-4552-a7de-ee800802f643"))){ - glenRender.render(event.entityPlayer, 0.3F, 0); - } - //dqmhose - else if(event.entityPlayer.getUniqueID().equals(UUID.fromString("cb7b293a-5031-484e-b5be-b4f2f4e92726"))){ - hoseRender.render(event.entityPlayer, 0.5F, -0.075F); - } - //Lari - else if(event.entityPlayer.getUniqueID().equals(UUID.fromString("ac275e30-c468-42af-b5d4-b26c1c705b70"))){ - lariRender.render(event.entityPlayer, 0.15F, -0.125F); - } - } -} diff --git a/src/main/java/ellpeck/actuallyadditions/misc/special/RenderSpecial.java b/src/main/java/ellpeck/actuallyadditions/misc/special/RenderSpecial.java index ec31103b9..5a23913a5 100644 --- a/src/main/java/ellpeck/actuallyadditions/misc/special/RenderSpecial.java +++ b/src/main/java/ellpeck/actuallyadditions/misc/special/RenderSpecial.java @@ -12,23 +12,18 @@ package ellpeck.actuallyadditions.misc.special; import ellpeck.actuallyadditions.proxy.ClientProxy; import ellpeck.actuallyadditions.util.AssetUtil; -import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelSquid; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import java.util.Calendar; public class RenderSpecial{ - private static final ResourceLocation squidTextures = new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/specialSquid.png"); private double lastTimeForBobbing; private ItemStack theThingToRender; @@ -36,11 +31,15 @@ public class RenderSpecial{ this.theThingToRender = stack; } - public void render(EntityPlayer player, float size, float offsetUp){ + public void render(EntityPlayer player){ if(player.isInvisible() || player.getHideCape()){ return; } + boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock; + float size = isBlock ? 0.3F : 0.4F; + float offsetUp = isBlock ? 0F : 0.2F; + if(ClientProxy.pumpkinBlurPumpkinBlur){ this.theThingToRender = new ItemStack(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)%2 == 0 ? Blocks.lit_pumpkin : Blocks.pumpkin); size = 0.3F; @@ -71,19 +70,12 @@ public class RenderSpecial{ GL11.glDisable(GL11.GL_LIGHTING); if(this.theThingToRender != null){ - if(this.theThingToRender.getItem() == Items.dye && this.theThingToRender.getItemDamage() == 0){ - Minecraft.getMinecraft().renderEngine.bindTexture(squidTextures); - GL11.glRotatef(180F, 1F, 0F, 0F); - new ModelSquid().render(null, 0F, 0F, 0.25F, 0F, 0F, 0.0625F); + if(isBlock){ + AssetUtil.renderBlock(Block.getBlockFromItem(this.theThingToRender.getItem()), this.theThingToRender.getItemDamage()); } else{ - if(this.theThingToRender.getItem() instanceof ItemBlock){ - AssetUtil.renderBlock(Block.getBlockFromItem(this.theThingToRender.getItem()), this.theThingToRender.getItemDamage()); - } - else{ - GL11.glTranslatef(-0.5F, 0F, 0F); - AssetUtil.renderItem(this.theThingToRender, 0); - } + GL11.glTranslatef(-0.5F, 0F, 0F); + AssetUtil.renderItem(this.theThingToRender, 0); } } GL11.glEnable(GL11.GL_LIGHTING); diff --git a/src/main/java/ellpeck/actuallyadditions/misc/special/SpecialRenderInit.java b/src/main/java/ellpeck/actuallyadditions/misc/special/SpecialRenderInit.java new file mode 100644 index 000000000..c511b7456 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/misc/special/SpecialRenderInit.java @@ -0,0 +1,70 @@ +/* + * This file ("Special.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.misc.special; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.util.Util; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +public class SpecialRenderInit{ + + public static HashMap specialList = new HashMap(); + + public static void init(){ + new ThreadSpecialFetcher(); + Util.registerEvent(new SpecialRenderInit()); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerRender(RenderPlayerEvent.Specials.Pre event){ + if(!specialList.isEmpty()){ + for(Map.Entry entry : specialList.entrySet()){ + //Does the player have one of the names from the list? + if(entry.getKey().toLowerCase().equals(event.entityPlayer.getDisplayName().toLowerCase())){ + //Render the special Item/Block + entry.getValue().render(event.entityPlayer); + break; + } + } + } + } + + public static void parse(Properties properties){ + for(String key : properties.stringPropertyNames()){ + String value = properties.getProperty(key); + + ItemStack stack = null; + //Get the Item from the String + if(Item.itemRegistry.containsKey(value)){ + stack = new ItemStack((Item)Item.itemRegistry.getObject(value)); + } + else{ + if(Block.blockRegistry.containsKey(value)){ + stack = new ItemStack((Block)Block.blockRegistry.getObject(value)); + } + } + + //Add a new Special Renderer to the list + if(stack != null){ + specialList.put(key, new RenderSpecial(stack)); + } + } + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/misc/special/ThreadSpecialFetcher.java b/src/main/java/ellpeck/actuallyadditions/misc/special/ThreadSpecialFetcher.java index 20285b52b..0e66a3d92 100644 --- a/src/main/java/ellpeck/actuallyadditions/misc/special/ThreadSpecialFetcher.java +++ b/src/main/java/ellpeck/actuallyadditions/misc/special/ThreadSpecialFetcher.java @@ -18,8 +18,6 @@ import java.util.Properties; public class ThreadSpecialFetcher extends Thread{ - private static Properties specialProperties; - public ThreadSpecialFetcher(){ this.setName(ModUtil.MOD_ID+" Special Fetcher"); this.setDaemon(true); @@ -28,16 +26,17 @@ public class ThreadSpecialFetcher extends Thread{ @Override public void run(){ - ModUtil.LOGGER.info("Fetching Special People Stuff"); + ModUtil.LOGGER.info("Fetching Special People Stuff..."); try{ URL url = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/specialPeopleStuff.properties"); - specialProperties = new Properties(); + Properties specialProperties = new Properties(); specialProperties.load(new InputStreamReader(url.openStream())); + SpecialRenderInit.parse(specialProperties); ModUtil.LOGGER.info("Fetching Special People Stuff done!"); } catch(Exception e){ - ModUtil.LOGGER.error("Fetching Special People Stuff failed!", e); + ModUtil.LOGGER.error("Fetching Special People Stuff failed! (You can ignore this error technically.)", e); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java index 9ca165670..b1d2f8596 100644 --- a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java +++ b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java @@ -22,6 +22,7 @@ import ellpeck.actuallyadditions.blocks.render.*; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.event.InitEvents; +import ellpeck.actuallyadditions.misc.special.SpecialRenderInit; import ellpeck.actuallyadditions.tile.*; import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.ModUtil; @@ -56,6 +57,8 @@ public class ClientProxy implements IProxy{ } PersistentClientData.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"Data.dat")); + + SpecialRenderInit.init(); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java b/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java index 4892b0477..c0cd87553 100644 --- a/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java +++ b/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java @@ -21,7 +21,7 @@ public class UpdateChecker{ public static boolean needsUpdateNotify; public static String updateVersion; - public void init(){ + public static void init(){ if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){ ModUtil.LOGGER.info("Initializing Update Checker..."); new ThreadUpdateChecker(); diff --git a/src/main/resources/assets/actuallyadditions/textures/specialSquid.png b/src/main/resources/assets/actuallyadditions/textures/specialSquid.png deleted file mode 100644 index 6ffc37eca..000000000 Binary files a/src/main/resources/assets/actuallyadditions/textures/specialSquid.png and /dev/null differ