diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/render/CapeHandler.java | 120 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/item/ModItems.java | 2 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/item/base/CoreItem.java | 12 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/proxy/ClientProxy.java | 13 |
4 files changed, 144 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/render/CapeHandler.java b/src/Java/gtPlusPlus/core/handler/render/CapeHandler.java new file mode 100644 index 0000000000..9f449e3044 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/render/CapeHandler.java @@ -0,0 +1,120 @@ +package gtPlusPlus.core.handler.render; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; + +import java.util.Collection; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.lwjgl.opengl.GL11; + +public class CapeHandler extends RenderPlayer { + private final ResourceLocation[] mCapes = { + new ResourceLocation(CORE.MODID+":textures/TesterCape.png"), + new ResourceLocation(CORE.MODID+":textures/Draknyte1.png"), + new ResourceLocation("gregtech:textures/GregoriusCape.png") }; + private final Collection<String> mCapeList; + + public CapeHandler(Collection<String> aCapeList) { + this.mCapeList = aCapeList; + setRenderManager(RenderManager.instance); + } + + public void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + if (GT_Utility.getFullInvisibility(aPlayer)) { + aEvent.setCanceled(true); + return; + } + float aPartialTicks = aEvent.partialRenderTick; + if (aPlayer.isInvisible()) { + return; + } + if (GT_Utility.getPotion(aPlayer, + Integer.valueOf(Potion.invisibility.id).intValue())) { + return; + } + try { + ResourceLocation tResource = null; + if (aPlayer.getDisplayName().equalsIgnoreCase("XW3B")) { + tResource = this.mCapes[0]; + } + if (this.mCapeList.contains(aPlayer.getDisplayName().toLowerCase())) { + tResource = this.mCapes[0]; + } + if (aPlayer.getDisplayName().equalsIgnoreCase("Draknyte1")) { + tResource = this.mCapes[1]; + } + if (aPlayer.getDisplayName().equalsIgnoreCase("GregoriusT")) { + tResource = this.mCapes[2]; + } + if ((tResource != null) && (!(aPlayer.getHideCape()))) { + bindTexture(tResource); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d0 = aPlayer.field_71091_bM + + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) + * aPartialTicks + - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) + * aPartialTicks); + double d1 = aPlayer.field_71096_bN + + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) + * aPartialTicks + - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) + * aPartialTicks); + double d2 = aPlayer.field_71097_bO + + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) + * aPartialTicks + - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) + * aPartialTicks); + float f6 = aPlayer.prevRenderYawOffset + + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) + * aPartialTicks; + double d3 = MathHelper.sin(f6 * 3.141593F / 180.0F); + double d4 = -MathHelper.cos(f6 * 3.141593F / 180.0F); + float f7 = (float) d1 * 10.0F; + float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; + float f9 = (float) (d0 * d4 - (d2 * d3)) * 100.0F; + if (f7 < -6.0F) { + f7 = -6.0F; + } + if (f7 > 32.0F) { + f7 = 32.0F; + } + if (f8 < 0.0F) { + f8 = 0.0F; + } + float f10 = aPlayer.prevCameraYaw + + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) + * aPartialTicks; + f7 += MathHelper + .sin((aPlayer.prevDistanceWalkedModified + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) + * aPartialTicks) * 6.0F) + * 32.0F * f10; + if (aPlayer.isSneaking()) { + f7 += 25.0F; + } + GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + ((ModelBiped) this.mainModel).renderCloak(0.0625F); + GL11.glPopMatrix(); + } + } catch (Throwable e) { + if (GT_Values.D1) + e.printStackTrace(GT_Log.err); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 0060841291..a344b11ecc 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -198,7 +198,7 @@ public final class ModItems { //Register Hydrogen Blobs first, so we can replace old helium blobs. - itemHydrogenBlob = new CoreItem("itemHydrogenBlob", tabMisc).setTextureName(CORE.MODID + ":itemHydrogenBlob"); + itemHydrogenBlob = new CoreItem("itemHydrogenBlob", "Blob of Helium", tabMisc).setTextureName(CORE.MODID + ":itemHydrogenBlob"); //GT_OreDictUnificator.registerOre("dustHydrogen", new ItemStack(ModItems.itemHydrogenBlob)); //Register Old Helium Blob, this will be replaced when held by a player. itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc, ItemUtils.getSimpleStack(itemHydrogenBlob)).setTextureName(CORE.MODID + ":itemHeliumBlob"); diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java index 5638dac475..6c3fb531dd 100644 --- a/src/Java/gtPlusPlus/core/item/base/CoreItem.java +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -47,13 +47,21 @@ public class CoreItem extends Item } //0.1 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, ItemStack OverrideItem) + { + this(unlocalizedName, creativeTab, 64, 0, "This item will be replaced by another when helf by a player, it is old and should not be used in recipes.", EnumRarity.uncommon, EnumChatFormatting.UNDERLINE, false, OverrideItem); //Calls 5 + } + //0.1 /* * Name, Tab - 64 Stack, 0 Dmg */ - public CoreItem(String unlocalizedName, CreativeTabs creativeTab, ItemStack OverrideItem) + public CoreItem(String unlocalizedName, String displayName, CreativeTabs creativeTab, ItemStack OverrideItem) { this(unlocalizedName, creativeTab, 64, 0, "This item will be replaced by another when helf by a player, it is old and should not be used in recipes.", EnumRarity.uncommon, EnumChatFormatting.UNDERLINE, false, OverrideItem); //Calls 5 - + itemName = displayName; } //1 diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 26a2aa500a..276af700f0 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -14,6 +14,14 @@ import cpw.mods.fml.common.event.*; public class ClientProxy extends CommonProxy{ + /*private final HashSet<String> mCapeList = new HashSet<String>(); + private final CapeHandler mCapeRenderer; + + ClientProxy(){ + mCapeRenderer = new CapeHandler(mCapeList); + } + */ + @Override public void preInit(FMLPreInitializationEvent e) { // TODO Auto-generated method stub @@ -86,6 +94,11 @@ public class ClientProxy extends CommonProxy{ { } + + /*@SubscribeEvent + public void receiveRenderSpecialsEvent(net.minecraftforge.client.event.RenderPlayerEvent.Specials.Pre aEvent) { + mCapeRenderer.receiveRenderSpecialsEvent(aEvent); + }*/ |