2014-06-06 19:46:05 -08:00
package tconstruct.armor ;
2013-07-26 21:18:53 -07:00
2014-09-09 18:30:15 +10:00
import com.google.common.collect.Lists ;
import cpw.mods.fml.common.* ;
import cpw.mods.fml.common.eventhandler.SubscribeEvent ;
import java.util.* ;
2014-07-03 16:11:54 -08:00
import mantle.lib.client.MantleClientRegistry ;
2013-07-26 21:18:53 -07:00
import net.minecraft.client.Minecraft ;
import net.minecraft.client.gui.ScaledResolution ;
2014-06-06 19:46:05 -08:00
import net.minecraft.client.gui.inventory.GuiInventory ;
2014-06-30 22:26:00 -08:00
import net.minecraft.client.model.ModelBiped ;
2013-07-26 21:18:53 -07:00
import net.minecraft.client.renderer.Tessellator ;
2014-09-09 18:30:15 +10:00
import net.minecraft.client.settings.* ;
import net.minecraft.entity.* ;
2014-01-01 08:54:06 -05:00
import net.minecraft.entity.ai.attributes.IAttributeInstance ;
2014-06-06 19:46:05 -08:00
import net.minecraft.entity.player.EntityPlayer ;
2014-09-09 18:30:15 +10:00
import net.minecraft.init.* ;
import net.minecraft.item.* ;
import net.minecraft.potion.* ;
import net.minecraft.util.* ;
2014-06-06 19:46:05 -08:00
import net.minecraft.world.World ;
2013-08-01 20:54:56 -07:00
import net.minecraftforge.client.GuiIngameForge ;
2014-09-09 18:30:15 +10:00
import net.minecraftforge.client.event.* ;
2013-08-01 20:54:56 -07:00
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType ;
2014-06-06 19:46:05 -08:00
import net.minecraftforge.common.MinecraftForge ;
2014-09-09 18:30:15 +10:00
import tconstruct.armor.gui.* ;
2014-07-21 12:52:39 -08:00
import tconstruct.armor.items.TravelGear ;
2014-09-09 18:30:15 +10:00
import tconstruct.armor.model.* ;
import tconstruct.armor.player.* ;
import tconstruct.client.* ;
import tconstruct.client.tabs.* ;
2014-06-30 14:57:06 -08:00
import tconstruct.common.TProxyCommon ;
2014-06-30 22:26:00 -08:00
import tconstruct.library.accessory.IAccessoryModel ;
2014-07-03 16:11:54 -08:00
import tconstruct.library.client.TConstructClientRegistry ;
2014-09-09 22:26:42 +02:00
import tconstruct.library.crafting.ModifyBuilder ;
2014-07-03 16:11:54 -08:00
import tconstruct.world.TinkerWorld ;
2014-06-30 22:26:00 -08:00
2014-06-06 19:46:05 -08:00
public class ArmorProxyClient extends ArmorProxyCommon
2013-07-26 21:18:53 -07:00
{
2014-06-30 22:26:00 -08:00
public static WingModel wings = new WingModel ();
public static BootBump bootbump = new BootBump ();
public static HiddenPlayerModel glove = new HiddenPlayerModel ( 0 . 25F , 4 );
public static HiddenPlayerModel vest = new HiddenPlayerModel ( 0 . 25f , 1 );
public static BeltModel belt = new BeltModel ();
2014-07-02 23:37:28 -08:00
2014-07-06 22:59:44 -08:00
public static KnapsackInventory knapsack = new KnapsackInventory ();
public static ArmorExtended armorExtended = new ArmorExtended ();
2014-07-02 20:27:32 -08:00
@Override
2014-07-02 23:37:28 -08:00
public void initialize ()
2013-07-26 21:18:53 -07:00
{
2014-06-30 14:57:06 -08:00
registerGuiHandler ();
2014-07-03 16:11:54 -08:00
registerKeys ();
2014-09-09 22:26:42 +02:00
registerManualIcons ();
2014-07-03 16:11:54 -08:00
registerManualRecipes ();
2014-06-06 19:46:05 -08:00
MinecraftForge . EVENT_BUS . register ( this );
2014-07-03 16:11:54 -08:00
FMLCommonHandler . instance (). bus (). register ( new ArmorAbilitiesClient ( mc , controlInstance ));
}
2014-09-09 18:30:15 +10:00
2014-09-09 22:26:42 +02:00
private void registerManualIcons ()
{
MantleClientRegistry . registerManualIcon ( "travelgoggles" , TinkerArmor . travelGoggles . getDefaultItem ());
MantleClientRegistry . registerManualIcon ( "travelvest" , TinkerArmor . travelVest . getDefaultItem ());
MantleClientRegistry . registerManualIcon ( "travelwings" , TinkerArmor . travelWings . getDefaultItem ());
MantleClientRegistry . registerManualIcon ( "travelboots" , TinkerArmor . travelBoots . getDefaultItem ());
MantleClientRegistry . registerManualIcon ( "travelbelt" , TinkerArmor . travelBelt . getDefaultItem ());
MantleClientRegistry . registerManualIcon ( "travelglove" , TinkerArmor . travelGlove . getDefaultItem ());
}
2014-07-03 16:11:54 -08:00
private void registerManualRecipes ()
{
ItemStack feather = new ItemStack ( Items . feather );
ItemStack redstone = new ItemStack ( Items . redstone );
2014-07-21 12:52:39 -08:00
ItemStack goggles = TinkerArmor . travelGoggles . getDefaultItem ();
2014-09-09 22:26:42 +02:00
//MantleClientRegistry.registerManualSmallRecipe("nightvision", goggles.copy(), new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.golden_carrot), null);
ItemStack g2 = goggles . copy ();
g2 = ModifyBuilder . instance . modifyItem ( g2 , new ItemStack [] { new ItemStack ( Items . flint_and_steel ), new ItemStack ( Items . potionitem , 1 , 0 ), new ItemStack ( Items . golden_carrot )});
MantleClientRegistry . registerManualSmallRecipe ( "nightvision" , g2 , new ItemStack ( Items . flint_and_steel ), new ItemStack ( Items . potionitem , 1 , 8198 ), new ItemStack ( Items . golden_carrot ), null );
2014-07-03 16:11:54 -08:00
2014-07-21 12:52:39 -08:00
ItemStack vest = TinkerArmor . travelVest . getDefaultItem ();
2014-07-03 16:11:54 -08:00
MantleClientRegistry . registerManualSmallRecipe ( "dodge" , vest . copy (), new ItemStack ( Items . ender_eye ), new ItemStack ( Items . ender_pearl ), new ItemStack ( Items . sugar ), null );
2014-09-09 18:30:15 +10:00
MantleClientRegistry . registerManualSmallRecipe ( "stealth" , vest . copy (), new ItemStack ( Items . fermented_spider_eye ), new ItemStack ( Items . ender_eye ), new ItemStack ( Items . potionitem , 1 , 0 ), new ItemStack ( Items . golden_carrot ));
2014-07-03 16:11:54 -08:00
ItemStack wings = new ItemStack ( TinkerArmor . travelWings );
MantleClientRegistry . registerManualSmallRecipe ( "doublejump" , wings . copy (), new ItemStack ( Items . ghast_tear ), new ItemStack ( TinkerWorld . slimeGel , 1 , 0 ), new ItemStack ( Blocks . piston ), null );
2014-09-09 18:30:15 +10:00
MantleClientRegistry . registerManualLargeRecipe ( "featherfall" , wings . copy (), new ItemStack ( TinkerWorld . slimeGel , 1 , 0 ), feather , feather , feather , wings . copy (), feather , feather , new ItemStack ( Items . ender_pearl ), feather );
2014-07-03 16:11:54 -08:00
2014-07-21 12:52:39 -08:00
ItemStack boots = TinkerArmor . travelBoots . getDefaultItem ();
MantleClientRegistry . registerManualSmallRecipe ( "doublejumpboots" , boots . copy (), new ItemStack ( Items . ghast_tear ), new ItemStack ( TinkerWorld . slimeGel , 1 , 1 ), new ItemStack ( Blocks . piston ), null );
2014-07-03 16:11:54 -08:00
TConstructClientRegistry . registerManualModifier ( "waterwalk" , boots . copy (), new ItemStack ( Blocks . waterlily ), new ItemStack ( Blocks . waterlily ));
TConstructClientRegistry . registerManualModifier ( "leadboots" , boots . copy (), new ItemStack ( Blocks . iron_block ));
TConstructClientRegistry . registerManualModifier ( "slimysoles" , boots . copy (), new ItemStack ( TinkerWorld . slimePad , 1 , 0 ), new ItemStack ( TinkerWorld . slimePad , 1 , 0 ));
2014-07-21 12:52:39 -08:00
ItemStack gloves = TinkerArmor . travelGlove . getDefaultItem ();
2014-07-03 16:11:54 -08:00
TConstructClientRegistry . registerManualModifier ( "glovehaste" , gloves . copy (), redstone , new ItemStack ( Blocks . redstone_block ));
2014-07-21 12:52:39 -08:00
//MantleClientRegistry.registerManualSmallRecipe("gloveclimb", gloves.copy(), new ItemStack(Items.slime_ball), new ItemStack(Blocks.web), new ItemStack(TinkerTools.materials, 1, 25), null);
2014-07-03 16:11:54 -08:00
TConstructClientRegistry . registerManualModifier ( "gloveknuckles" , gloves . copy (), new ItemStack ( Items . quartz ), new ItemStack ( Blocks . quartz_block , 1 , Short . MAX_VALUE ));
2014-06-06 19:46:05 -08:00
}
2014-07-02 23:37:28 -08:00
2014-06-30 14:57:06 -08:00
@Override
2014-07-02 23:37:28 -08:00
protected void registerGuiHandler ()
2014-06-30 14:57:06 -08:00
{
super . registerGuiHandler ();
TProxyCommon . registerClientGuiHandler ( inventoryGui , this );
TProxyCommon . registerClientGuiHandler ( armorGuiID , this );
TProxyCommon . registerClientGuiHandler ( knapsackGuiID , this );
}
2014-07-02 23:37:28 -08:00
2014-06-06 19:46:05 -08:00
@Override
public Object getClientGuiElement ( int ID , EntityPlayer player , World world , int x , int y , int z )
{
if ( ID == ArmorProxyCommon . inventoryGui )
2013-07-26 21:18:53 -07:00
{
2014-06-06 19:46:05 -08:00
GuiInventory inventory = new GuiInventory ( player );
return inventory ;
2013-07-26 21:18:53 -07:00
}
2014-06-06 19:46:05 -08:00
if ( ID == ArmorProxyCommon . armorGuiID )
{
2014-07-06 22:59:44 -08:00
ArmorProxyClient . armorExtended . init ( Minecraft . getMinecraft (). thePlayer );
return new ArmorExtendedGui ( player . inventory , ArmorProxyClient . armorExtended );
2014-06-06 19:46:05 -08:00
}
if ( ID == ArmorProxyCommon . knapsackGuiID )
{
2014-07-06 22:59:44 -08:00
ArmorProxyClient . knapsack . init ( Minecraft . getMinecraft (). thePlayer );
return new KnapsackGui ( player . inventory , ArmorProxyClient . knapsack );
2014-06-06 19:46:05 -08:00
}
return null ;
2013-08-11 12:23:49 -07:00
}
2013-07-26 21:18:53 -07:00
2014-06-06 19:46:05 -08:00
@Override
public void registerTickHandler ()
{
FMLCommonHandler . instance (). bus (). register ( new ArmorTickHandler ());
}
2014-07-02 23:37:28 -08:00
2014-06-06 19:46:05 -08:00
/* Keybindings */
2014-09-05 21:31:20 +02:00
public static ArmorControls controlInstance ;
2013-11-19 20:57:52 -08:00
2014-06-06 19:46:05 -08:00
@Override
public void registerKeys ()
2013-11-19 20:57:52 -08:00
{
2014-09-05 21:31:20 +02:00
controlInstance = new ArmorControls ();
2014-06-06 19:46:05 -08:00
uploadKeyBindingsToGame ( Minecraft . getMinecraft (). gameSettings , controlInstance );
TabRegistry . registerTab ( new InventoryTabVanilla ());
TabRegistry . registerTab ( new InventoryTabArmorExtended ());
TabRegistry . registerTab ( new InventoryTabKnapsack ());
2013-11-19 20:57:52 -08:00
}
2014-06-06 19:46:05 -08:00
public void uploadKeyBindingsToGame ( GameSettings settings , TKeyHandler keyhandler )
2013-07-26 21:18:53 -07:00
{
2014-06-06 19:46:05 -08:00
ArrayList < KeyBinding > harvestedBindings = Lists . newArrayList ();
for ( KeyBinding kb : keyhandler . keyBindings )
2013-07-26 21:18:53 -07:00
{
2014-06-06 19:46:05 -08:00
harvestedBindings . add ( kb );
2013-07-26 21:18:53 -07:00
}
2014-06-06 19:46:05 -08:00
KeyBinding [] modKeyBindings = harvestedBindings . toArray ( new KeyBinding [ harvestedBindings . size () ] );
KeyBinding [] allKeys = new KeyBinding [ settings . keyBindings . length + modKeyBindings . length ] ;
System . arraycopy ( settings . keyBindings , 0 , allKeys , 0 , settings . keyBindings . length );
System . arraycopy ( modKeyBindings , 0 , allKeys , settings . keyBindings . length , modKeyBindings . length );
settings . keyBindings = allKeys ;
settings . loadOptions ();
2013-07-26 21:18:53 -07:00
}
2014-06-06 19:46:05 -08:00
Minecraft mc = Minecraft . getMinecraft ();
2013-07-28 19:56:01 -07:00
private static final ResourceLocation hearts = new ResourceLocation ( "tinker" , "textures/gui/newhearts.png" );
private static final ResourceLocation icons = new ResourceLocation ( "textures/gui/icons.png" );
2014-02-16 14:23:50 -05:00
// public static int left_height = 39;
// public static int right_height = 39;
2013-08-01 20:54:56 -07:00
Random rand = new Random ();
int updateCounter = 0 ;
2014-02-11 21:35:05 -05:00
2014-02-08 13:30:19 -05:00
GameSettings gs = Minecraft . getMinecraft (). gameSettings ;
2014-09-09 18:30:15 +10:00
2014-07-21 12:52:39 -08:00
@SubscribeEvent
public void goggleZoom ( FOVUpdateEvent event )
{
2014-09-05 21:31:20 +02:00
if ( ArmorControls . zoom )
2014-07-21 12:52:39 -08:00
{
ItemStack helmet = event . entity . getCurrentArmor ( 3 );
if ( helmet != null && helmet . getItem () instanceof TravelGear )
{
event . newfov = 0 . 3f ;
}
}
//ItemStack feet = player.getCurrentArmor(0);
//event.newfov = 1.0f;
}
2013-07-26 21:18:53 -07:00
/* HUD */
2014-01-01 08:54:06 -05:00
@SubscribeEvent
2013-08-01 20:54:56 -07:00
public void renderHealthbar ( RenderGameOverlayEvent . Pre event )
2013-07-26 21:18:53 -07:00
{
2014-04-19 22:10:51 -08:00
if ( ! Loader . isModLoaded ( "tukmc_Vz" ) || Loader . isModLoaded ( "borderlands" )) // Loader check to avoid conflicting
2014-09-09 18:30:15 +10:00
// with a GUI mod (thanks Vazkii!)
2013-07-26 21:18:53 -07:00
{
2013-11-23 09:31:19 -05:00
if ( event . type == ElementType . HEALTH )
2013-08-01 20:54:56 -07:00
{
2013-11-23 09:31:19 -05:00
updateCounter ++ ;
2013-08-01 20:54:56 -07:00
2014-06-25 21:01:20 -04:00
ScaledResolution scaledresolution = new ScaledResolution ( this . mc , this . mc . displayWidth , this . mc . displayHeight );
2013-11-23 09:31:19 -05:00
int scaledWidth = scaledresolution . getScaledWidth ();
int scaledHeight = scaledresolution . getScaledHeight ();
int xBasePos = scaledWidth / 2 - 91 ;
int yBasePos = scaledHeight - 39 ;
2013-08-01 20:54:56 -07:00
2013-11-23 09:31:19 -05:00
boolean highlight = mc . thePlayer . hurtResistantTime / 3 % 2 == 1 ;
2013-08-01 20:54:56 -07:00
2013-11-23 09:31:19 -05:00
if ( mc . thePlayer . hurtResistantTime < 10 )
{
highlight = false ;
}
2013-08-01 20:54:56 -07:00
2014-01-01 08:54:06 -05:00
IAttributeInstance attrMaxHealth = this . mc . thePlayer . getEntityAttribute ( SharedMonsterAttributes . maxHealth );
2013-11-23 09:31:19 -05:00
int health = MathHelper . ceiling_float_int ( mc . thePlayer . getHealth ());
int healthLast = MathHelper . ceiling_float_int ( mc . thePlayer . prevHealth );
float healthMax = ( float ) attrMaxHealth . getAttributeValue ();
if ( healthMax > 20 )
healthMax = 20 ;
float absorb = this . mc . thePlayer . getAbsorptionAmount ();
2013-08-01 20:54:56 -07:00
2013-11-23 09:31:19 -05:00
int healthRows = MathHelper . ceiling_float_int (( healthMax + absorb ) / 2 . 0F / 10 . 0F );
int rowHeight = Math . max ( 10 - ( healthRows - 2 ), 3 );
2013-08-01 20:54:56 -07:00
2013-11-23 09:31:19 -05:00
this . rand . setSeed (( long ) ( updateCounter * 312871 ));
2013-08-01 20:54:56 -07:00
2013-11-23 09:31:19 -05:00
int left = scaledWidth / 2 - 91 ;
2014-02-04 21:21:50 -05:00
int top = scaledHeight - GuiIngameForge . left_height ;
2013-08-01 20:54:56 -07:00
2014-08-28 11:25:27 +02:00
if ( ! GuiIngameForge . renderExperiance )
{
top += 7 ;
yBasePos += 7 ;
}
2013-11-23 09:31:19 -05:00
int regen = - 1 ;
if ( mc . thePlayer . isPotionActive ( Potion . regeneration ))
2013-08-01 20:54:56 -07:00
{
2013-11-23 09:31:19 -05:00
regen = updateCounter % 25 ;
2013-08-01 20:54:56 -07:00
}
2013-11-23 09:31:19 -05:00
final int TOP = 9 * ( mc . theWorld . getWorldInfo (). isHardcoreModeEnabled () ? 5 : 0 );
final int BACKGROUND = ( highlight ? 25 : 16 );
int MARGIN = 16 ;
if ( mc . thePlayer . isPotionActive ( Potion . poison ))
MARGIN += 36 ;
else if ( mc . thePlayer . isPotionActive ( Potion . wither ))
MARGIN += 72 ;
float absorbRemaining = absorb ;
for ( int i = MathHelper . ceiling_float_int (( healthMax + absorb ) / 2 . 0F ) - 1 ; i >= 0 ; -- i )
2013-08-01 20:54:56 -07:00
{
2013-11-23 09:31:19 -05:00
int b0 = ( highlight ? 1 : 0 );
int row = MathHelper . ceiling_float_int (( float ) ( i + 1 ) / 10 . 0F ) - 1 ;
int x = left + i % 10 * 8 ;
int y = top - row * rowHeight ;
if ( health <= 4 )
y += rand . nextInt ( 2 );
if ( i == regen )
y -= 2 ;
drawTexturedModalRect ( x , y , BACKGROUND , TOP , 9 , 9 );
if ( highlight )
{
if ( i * 2 + 1 < healthLast )
2014-02-16 14:23:50 -05:00
drawTexturedModalRect ( x , y , MARGIN + 54 , TOP , 9 , 9 ); // 6
2013-11-23 09:31:19 -05:00
else if ( i * 2 + 1 == healthLast )
2014-02-16 14:23:50 -05:00
drawTexturedModalRect ( x , y , MARGIN + 63 , TOP , 9 , 9 ); // 7
2013-11-23 09:31:19 -05:00
}
if ( absorbRemaining > 0 . 0F )
{
if ( absorbRemaining == absorb && absorb % 2 . 0F == 1 . 0F )
2014-02-16 14:23:50 -05:00
drawTexturedModalRect ( x , y , MARGIN + 153 , TOP , 9 , 9 ); // 17
2013-11-23 09:31:19 -05:00
else
2014-02-16 14:23:50 -05:00
drawTexturedModalRect ( x , y , MARGIN + 144 , TOP , 9 , 9 ); // 16
2013-11-23 09:31:19 -05:00
absorbRemaining -= 2 . 0F ;
}
2013-08-01 20:54:56 -07:00
else
2013-11-23 09:31:19 -05:00
{
if ( i * 2 + 1 < health )
2014-02-16 14:23:50 -05:00
drawTexturedModalRect ( x , y , MARGIN + 36 , TOP , 9 , 9 ); // 4
2013-11-23 09:31:19 -05:00
else if ( i * 2 + 1 == health )
2014-02-16 14:23:50 -05:00
drawTexturedModalRect ( x , y , MARGIN + 45 , TOP , 9 , 9 ); // 5
2013-11-23 09:31:19 -05:00
}
2013-08-01 20:54:56 -07:00
}
2014-04-19 22:10:51 -08:00
int potionOffset = 0 ;
2013-11-23 09:31:19 -05:00
PotionEffect potion = mc . thePlayer . getActivePotionEffect ( Potion . wither );
if ( potion != null )
2014-04-19 22:10:51 -08:00
potionOffset = 18 ;
2013-11-23 09:31:19 -05:00
potion = mc . thePlayer . getActivePotionEffect ( Potion . poison );
if ( potion != null )
2014-04-19 22:10:51 -08:00
potionOffset = 9 ;
2013-08-01 20:54:56 -07:00
2014-02-16 14:23:50 -05:00
// Extra hearts
2013-11-23 09:31:19 -05:00
this . mc . getTextureManager (). bindTexture ( hearts );
2013-07-26 21:18:53 -07:00
2013-11-23 09:31:19 -05:00
int hp = MathHelper . ceiling_float_int ( this . mc . thePlayer . getHealth ());
for ( int iter = 0 ; iter < hp / 20 ; iter ++ )
2013-07-26 21:18:53 -07:00
{
2013-11-23 09:31:19 -05:00
int renderHearts = ( hp - 20 * ( iter + 1 )) / 2 ;
if ( renderHearts > 10 )
renderHearts = 10 ;
for ( int i = 0 ; i < renderHearts ; i ++ )
{
2014-04-19 22:10:51 -08:00
int y = 0 ;
if ( i == regen )
y -= 2 ;
this . drawTexturedModalRect ( xBasePos + 8 * i , yBasePos + y , 0 + 18 * iter , potionOffset , 9 , 9 );
2013-11-23 09:31:19 -05:00
}
if ( hp % 2 == 1 && renderHearts < 10 )
{
2014-04-19 22:10:51 -08:00
this . drawTexturedModalRect ( xBasePos + 8 * renderHearts , yBasePos , 9 + 18 * iter , potionOffset , 9 , 9 );
2013-11-23 09:31:19 -05:00
}
2013-07-26 21:18:53 -07:00
}
2013-11-23 09:31:19 -05:00
this . mc . getTextureManager (). bindTexture ( icons );
2013-08-01 20:54:56 -07:00
GuiIngameForge . left_height += 10 ;
2013-11-23 09:31:19 -05:00
if ( absorb > 0 )
GuiIngameForge . left_height += 10 ;
2013-11-29 23:16:32 -05:00
2013-11-23 09:31:19 -05:00
event . setCanceled ( true );
2014-02-08 13:30:19 -05:00
if ( event . type == ElementType . CROSSHAIRS && gs . thirdPersonView != 0 )
{
event . setCanceled ( true );
}
2013-11-23 09:31:19 -05:00
}
2013-07-31 13:08:18 -07:00
}
2013-07-26 21:18:53 -07:00
}
public void drawTexturedModalRect ( int par1 , int par2 , int par3 , int par4 , int par5 , int par6 )
{
float f = 0 . 00390625F ;
float f1 = 0 . 00390625F ;
Tessellator tessellator = Tessellator . instance ;
tessellator . startDrawingQuads ();
tessellator . addVertexWithUV (( double ) ( par1 + 0 ), ( double ) ( par2 + par6 ), ( double ) this . zLevel , ( double ) (( float ) ( par3 + 0 ) * f ), ( double ) (( float ) ( par4 + par6 ) * f1 ));
tessellator . addVertexWithUV (( double ) ( par1 + par5 ), ( double ) ( par2 + par6 ), ( double ) this . zLevel , ( double ) (( float ) ( par3 + par5 ) * f ), ( double ) (( float ) ( par4 + par6 ) * f1 ));
tessellator . addVertexWithUV (( double ) ( par1 + par5 ), ( double ) ( par2 + 0 ), ( double ) this . zLevel , ( double ) (( float ) ( par3 + par5 ) * f ), ( double ) (( float ) ( par4 + 0 ) * f1 ));
tessellator . addVertexWithUV (( double ) ( par1 + 0 ), ( double ) ( par2 + 0 ), ( double ) this . zLevel , ( double ) (( float ) ( par3 + 0 ) * f ), ( double ) (( float ) ( par4 + 0 ) * f1 ));
tessellator . draw ();
}
double zLevel = 0 ;
2014-07-02 23:37:28 -08:00
/* Armor rendering */
2014-06-30 22:26:00 -08:00
@SubscribeEvent
public void adjustArmor ( RenderPlayerEvent . SetArmorModel event )
{
switch ( event . slot )
{
case 1 :
ArmorProxyClient . vest . onGround = event . renderer . modelBipedMain . onGround ;
ArmorProxyClient . vest . isRiding = event . renderer . modelBipedMain . isRiding ;
ArmorProxyClient . vest . isChild = event . renderer . modelBipedMain . isChild ;
ArmorProxyClient . vest . isSneak = event . renderer . modelBipedMain . isSneak ;
case 2 :
ArmorProxyClient . wings . onGround = event . renderer . modelBipedMain . onGround ;
ArmorProxyClient . wings . isRiding = event . renderer . modelBipedMain . isRiding ;
ArmorProxyClient . wings . isChild = event . renderer . modelBipedMain . isChild ;
ArmorProxyClient . wings . isSneak = event . renderer . modelBipedMain . isSneak ;
ArmorProxyClient . glove . onGround = event . renderer . modelBipedMain . onGround ;
ArmorProxyClient . glove . isRiding = event . renderer . modelBipedMain . isRiding ;
ArmorProxyClient . glove . isChild = event . renderer . modelBipedMain . isChild ;
ArmorProxyClient . glove . isSneak = event . renderer . modelBipedMain . isSneak ;
ArmorProxyClient . glove . heldItemLeft = event . renderer . modelBipedMain . heldItemLeft ;
ArmorProxyClient . glove . heldItemRight = event . renderer . modelBipedMain . heldItemRight ;
2014-07-02 23:37:28 -08:00
2014-06-30 22:26:00 -08:00
ArmorProxyClient . belt . onGround = event . renderer . modelBipedMain . onGround ;
ArmorProxyClient . belt . isRiding = event . renderer . modelBipedMain . isRiding ;
ArmorProxyClient . belt . isChild = event . renderer . modelBipedMain . isChild ;
ArmorProxyClient . belt . isSneak = event . renderer . modelBipedMain . isSneak ;
2014-07-02 23:37:28 -08:00
2014-06-30 22:26:00 -08:00
renderArmorExtras ( event );
2014-07-02 23:37:28 -08:00
2014-06-30 22:26:00 -08:00
break ;
case 3 :
ArmorProxyClient . bootbump . onGround = event . renderer . modelBipedMain . onGround ;
ArmorProxyClient . bootbump . isRiding = event . renderer . modelBipedMain . isRiding ;
ArmorProxyClient . bootbump . isChild = event . renderer . modelBipedMain . isChild ;
ArmorProxyClient . bootbump . isSneak = event . renderer . modelBipedMain . isSneak ;
break ;
}
}
2014-07-02 23:37:28 -08:00
void renderArmorExtras ( RenderPlayerEvent . SetArmorModel event )
2014-06-30 22:26:00 -08:00
{
float partialTick = event . partialRenderTick ;
EntityPlayer player = event . entityPlayer ;
float posX = ( float ) ( player . lastTickPosX + ( player . posX - player . lastTickPosX ) * partialTick );
float posY = ( float ) ( player . lastTickPosY + ( player . posY - player . lastTickPosY ) * partialTick );
float posZ = ( float ) ( player . lastTickPosZ + ( player . posZ - player . lastTickPosZ ) * partialTick );
float yawOffset = this . interpolateRotation ( player . prevRenderYawOffset , player . renderYawOffset , partialTick );
float yawRotation = this . interpolateRotation ( player . prevRotationYawHead , player . rotationYawHead , partialTick );
float pitch ;
final float zeropointsixtwofive = 0 . 0625F ;
if ( player . isRiding () && player . ridingEntity instanceof EntityLivingBase )
{
EntityLivingBase entitylivingbase1 = ( EntityLivingBase ) player . ridingEntity ;
yawOffset = this . interpolateRotation ( entitylivingbase1 . prevRenderYawOffset , entitylivingbase1 . renderYawOffset , partialTick );
pitch = MathHelper . wrapAngleTo180_float ( yawRotation - yawOffset );
if ( pitch < - 85 . 0F )
{
pitch = - 85 . 0F ;
}
if ( pitch >= 85 . 0F )
{
pitch = 85 . 0F ;
}
yawOffset = yawRotation - pitch ;
if ( pitch * pitch > 2500 . 0F )
{
yawOffset += pitch * 0 . 2F ;
}
}
pitch = this . handleRotationFloat ( player , partialTick );
float bodyRotation = player . prevRotationPitch + ( player . rotationPitch - player . prevRotationPitch ) * partialTick ;
float limbSwing = player . prevLimbSwingAmount + ( player . limbSwingAmount - player . prevLimbSwingAmount ) * partialTick ;
float limbSwingMod = player . limbSwing - player . limbSwingAmount * ( 1 . 0F - partialTick );
2014-07-06 22:59:44 -08:00
//TPlayerStats stats = TPlayerStats.get(player);
ArmorExtended armor = ArmorProxyClient . armorExtended ; //TODO: Do this for every player, not just the client
if ( armor . inventory [ 1 ] != null )
2014-06-30 22:26:00 -08:00
{
2014-07-06 22:59:44 -08:00
Item item = armor . inventory [ 1 ] . getItem ();
ModelBiped model = item . getArmorModel ( player , armor . inventory [ 1 ] , 4 );
2014-06-30 22:26:00 -08:00
if ( item instanceof IAccessoryModel )
{
2014-07-06 22:59:44 -08:00
this . mc . getTextureManager (). bindTexture ((( IAccessoryModel ) item ). getWearbleTexture ( player , armor . inventory [ 1 ] , 1 ));
2014-06-30 22:26:00 -08:00
model . setLivingAnimations ( player , limbSwingMod , limbSwing , partialTick );
model . render ( player , limbSwingMod , limbSwing , pitch , yawRotation - yawOffset , bodyRotation , zeropointsixtwofive );
}
}
2014-07-06 22:59:44 -08:00
if ( armor . inventory [ 3 ] != null )
2014-06-30 22:26:00 -08:00
{
2014-07-06 22:59:44 -08:00
Item item = armor . inventory [ 3 ] . getItem ();
ModelBiped model = item . getArmorModel ( player , armor . inventory [ 3 ] , 5 );
2014-06-30 22:26:00 -08:00
if ( item instanceof IAccessoryModel )
{
2014-07-06 22:59:44 -08:00
this . mc . getTextureManager (). bindTexture ((( IAccessoryModel ) item ). getWearbleTexture ( player , armor . inventory [ 1 ] , 1 ));
2014-06-30 22:26:00 -08:00
model . setLivingAnimations ( player , limbSwingMod , limbSwing , partialTick );
model . render ( player , limbSwingMod , limbSwing , pitch , yawRotation - yawOffset , bodyRotation , zeropointsixtwofive );
}
}
}
2014-07-02 23:37:28 -08:00
2014-06-30 22:26:00 -08:00
private float interpolateRotation ( float par1 , float par2 , float par3 )
{
float f3 ;
for ( f3 = par2 - par1 ; f3 < - 180 . 0F ; f3 += 360 . 0F )
{
;
}
while ( f3 >= 180 . 0F )
{
f3 -= 360 . 0F ;
}
return par1 + par3 * f3 ;
}
2014-07-02 23:37:28 -08:00
2014-06-30 22:26:00 -08:00
protected float handleRotationFloat ( EntityLivingBase par1EntityLivingBase , float par2 )
{
return ( float ) par1EntityLivingBase . ticksExisted + par2 ;
}
2014-07-02 23:37:28 -08:00
2013-07-26 21:18:53 -07:00
}