Changed the way Special People Overhead Rendering is handled

This commit is contained in:
Ellpeck 2015-11-02 21:38:49 +01:00
parent 3507961cc0
commit b5e92b10b3
9 changed files with 88 additions and 81 deletions

View file

@ -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.");

View file

@ -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());

View file

@ -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);
}
}
}

View file

@ -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);

View file

@ -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<String, RenderSpecial> specialList = new HashMap<String, RenderSpecial>();
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<String, RenderSpecial> 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));
}
}
}
}

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -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();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB