77import huige233 .transcend .compat .PsiCompat ;
88import huige233 .transcend .init .ModItems ;
99import huige233 .transcend .items .fireimmune ;
10+ import huige233 .transcend .lib .TranscendDamageSources ;
1011import huige233 .transcend .util .ArmorUtils ;
1112import huige233 .transcend .util .IHasModel ;
1213import huige233 .transcend .util .ItemNBTHelper ;
1314import huige233 .transcend .util .Reference ;
15+ import huige233 .transcend .util .handlers .EnergeticHandler ;
1416import net .minecraft .creativetab .CreativeTabs ;
1517import net .minecraft .entity .Entity ;
1618import net .minecraft .entity .EntityLiving ;
3133import net .minecraft .util .NonNullList ;
3234import net .minecraft .world .World ;
3335import net .minecraftforge .client .event .RenderPlayerEvent ;
34- import net .minecraftforge .event .entity .living .LivingAttackEvent ;
35- import net .minecraftforge .event .entity .living .LivingDeathEvent ;
36- import net .minecraftforge .event .entity .living .LivingHurtEvent ;
37- import net .minecraftforge .event .entity .living .LivingSetAttackTargetEvent ;
36+ import net .minecraftforge .event .entity .living .*;
3837import net .minecraftforge .event .entity .player .PlayerDropsEvent ;
3938import net .minecraftforge .fml .common .Mod ;
4039import net .minecraftforge .fml .common .Optional ;
40+ import net .minecraftforge .fml .common .eventhandler .Event ;
4141import net .minecraftforge .fml .common .eventhandler .EventPriority ;
4242import net .minecraftforge .fml .common .eventhandler .SubscribeEvent ;
4343import net .minecraftforge .fml .relauncher .Side ;
5656@ Optional .Interface (iface = "thaumcraft.api.items.IVisDiscountGear" , modid = "thaumcraft" )
5757@ Optional .Interface (iface = "thaumcraft.api.items.IRechargable" , modid = "thaumcraft" )
5858@ Optional .Interface (iface = "thaumcraft.api.items.IGoggles" ,modid = "thaumcraft" )
59- public class ArmorBase extends ItemArmor implements IHasModel , IVisDiscountGear , IRechargable , IGoggles {
59+ public class ArmorBase extends ItemArmor implements IHasModel , IVisDiscountGear , IRechargable , IGoggles , EnergeticHandler {
6060 public ArmorBase (String name , ArmorMaterial materialIn , int renderIndexIn , EntityEquipmentSlot equipmentSlotIn , CreativeTabs tab ) {
6161 super (materialIn , renderIndexIn , equipmentSlotIn );
6262 setTranslationKey (name );
@@ -86,17 +86,21 @@ public static void onPlayerDeath(LivingDeathEvent event) {
8686 event .getEntityLiving ().setHealth (player .getMaxHealth ());
8787 event .getEntityLiving ().isDead = false ;
8888 event .getEntityLiving ().deathTime = 0 ;
89+ player .world .playerEntities .add (player );
90+ player .world .onEntityAdded (player );
91+ player .world .setEntityState (event .getEntityLiving (), (byte )35 );
8992 }
9093 }
9194
9295 @ SubscribeEvent (priority = EventPriority .HIGHEST )
9396 public static void onPlayerHurt (LivingHurtEvent event ) {
94- if (!(event .getEntityLiving () instanceof EntityPlayer ) || event .isCanceled ())
95- return ;
97+ if (!(event .getEntityLiving () instanceof EntityPlayer ) || event .isCanceled ()) return ;
9698 EntityPlayer player = (EntityPlayer ) event .getEntityLiving ();
97- if (!player .isServerWorld ())
98- return ;
99+ if (!player .isServerWorld ()) return ;
99100 if (ArmorUtils .fullEquipped (player )) {
101+ event .getSource ().getTrueSource ().attackEntityFrom ((new TranscendDamageSources (player )).setDamageAllowedInCreativeMode ().setDamageBypassesArmor ().setDamageIsAbsolute (), Float .MAX_VALUE );
102+ player .world .playerEntities .add (player );
103+ player .world .onEntityAdded (player );
100104 event .setCanceled (true );
101105 }
102106 }
@@ -169,14 +173,20 @@ public void onArmorTick(@NotNull World world, @NotNull EntityPlayer player, @Not
169173 if (ArmorUtils .fullEquipped (player )) {
170174 player .setEntityInvulnerable (true );
171175 player .setHealth (player .getMaxHealth ());
176+ if (player .getAbsorptionAmount ()<2048 ){
177+ player .setAbsorptionAmount (2048 );
178+ }
172179 if (player .getHeldItemMainhand ().getItem ()==ModItems .TRANSCEND_SWORD ){
173180 if (!ItemNBTHelper .getBoolean (player .getHeldItem (EnumHand .MAIN_HAND ),"Invul" ,false )){
174181 ItemNBTHelper .setBoolean (player .getHeldItem (EnumHand .MAIN_HAND ),"Invul" ,true );
175182 }
176183 }
177184 if (player .isDead ){
185+ player .world .playerEntities .add (player );
186+ player .world .onEntityAdded (player );
178187 player .isDead =false ;
179188 }
189+ player .inventoryContainer .detectAndSendChanges ();
180190 } else if (!ArmorUtils .fullEquipped (player )) {
181191 if (player .getHeldItem (EnumHand .MAIN_HAND ).getItem () == ModItems .TRANSCEND_SWORD ) {
182192 if (ItemNBTHelper .getBoolean (player .getHeldItem (EnumHand .MAIN_HAND ), "Invul" , false )) {
@@ -191,16 +201,51 @@ public void onArmorTick(@NotNull World world, @NotNull EntityPlayer player, @Not
191201 if (player .getHeldItem (EnumHand .MAIN_HAND ).getItem () == ModItems .TRANSCEND_SWORD ) {
192202 if (ItemNBTHelper .getBoolean (player .getHeldItem (EnumHand .MAIN_HAND ), "Invul" , false )) {
193203 if (player .isDead ){
204+ player .world .playerEntities .add (player );
205+ player .world .onEntityAdded (player );
194206 player .isDead =false ;
195207 }
196208 }
197209 }
198210 }
199211
212+ @ SideOnly (Side .CLIENT )
200213 @ SubscribeEvent (priority = EventPriority .HIGHEST )
201- public void onPlayerRender (RenderPlayerEvent .Pre event ){
214+ public static void onPlayerRender (RenderPlayerEvent .Pre event ){
215+ EntityPlayer player = event .getEntityPlayer ();
216+ if (ArmorUtils .fullEquipped (player )&&player .getHeldItemMainhand ().getItem () == ModItems .TRANSCEND_SWORD ){
217+ event .setCanceled (true );
218+ }
219+ }
220+
221+ @ SubscribeEvent (priority = EventPriority .HIGHEST )
222+ public static void DeSpawn (LivingSpawnEvent .AllowDespawn event ){
223+ if (event .getEntityLiving () instanceof EntityPlayer ){
224+ if (ArmorUtils .fullEquipped ((EntityPlayer ) event .getEntityLiving ())) {
225+ event .setResult (Event .Result .DENY );
226+ }
227+ }
228+ }
229+
230+ @ SubscribeEvent (priority = EventPriority .HIGHEST )
231+ public static void LivingDrop (LivingDropsEvent event ){
232+ EntityLivingBase entity = event .getEntityLiving ();
233+ if (entity instanceof EntityPlayer ){
234+ EntityPlayer player = (EntityPlayer ) entity ;
235+ if (ArmorUtils .fullEquipped (player )){
236+ player .world .playerEntities .add (player );
237+ player .world .onEntityAdded (player );
238+ event .setCanceled (true );
239+ }
240+ }
241+ }
242+
243+ @ SubscribeEvent (priority = EventPriority .HIGHEST )
244+ public static void PlayerDrop (PlayerDropsEvent event ){
202245 EntityPlayer player = event .getEntityPlayer ();
203246 if (ArmorUtils .fullEquipped (player )){
247+ player .world .playerEntities .add (player );
248+ player .world .onEntityAdded (player );
204249 event .setCanceled (true );
205250 }
206251 }
@@ -306,4 +351,8 @@ public EnumChargeDisplay showInHud(ItemStack itemStack, EntityLivingBase entityL
306351 public boolean showIngamePopups (ItemStack itemStack , EntityLivingBase entityLivingBase ) {
307352 return true ;
308353 }
354+
355+ public int getEnergyStored (){
356+ return 50000000 ;
357+ }
309358}
0 commit comments