2014-06-06 19:46:05 -08:00
|
|
|
package tconstruct.armor;
|
|
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-11-02 17:57:28 +01:00
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.entity.boss.*;
|
2014-06-06 19:46:05 -08:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
|
import net.minecraft.entity.monster.IMob;
|
2014-11-16 23:39:49 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-06-06 19:46:05 -08:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraftforge.event.entity.living.*;
|
2014-07-02 23:37:28 -08:00
|
|
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
|
2014-06-06 19:46:05 -08:00
|
|
|
import tconstruct.TConstruct;
|
2014-07-02 23:37:28 -08:00
|
|
|
import tconstruct.armor.items.TravelWings;
|
2014-11-02 17:57:28 +01:00
|
|
|
import tconstruct.armor.player.ArmorExtended;
|
2014-07-06 22:59:44 -08:00
|
|
|
import tconstruct.armor.player.TPlayerStats;
|
2014-07-02 23:37:28 -08:00
|
|
|
import tconstruct.library.modifier.IModifyable;
|
2014-06-06 19:46:05 -08:00
|
|
|
import tconstruct.world.entity.BlueSlime;
|
|
|
|
|
|
|
|
|
|
public class TinkerArmorEvents
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onLivingDrop (LivingDropsEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.entityLiving == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-12 10:22:01 +01:00
|
|
|
if(!event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-06-06 19:46:05 -08:00
|
|
|
if (TConstruct.random.nextInt(200) == 0 && event.entityLiving instanceof IMob && event.source.damageType.equals("player"))
|
2014-08-09 01:49:18 +03:00
|
|
|
{
|
|
|
|
|
ItemStack dropStack = new ItemStack(TinkerArmor.heartCanister, 1, 1);
|
|
|
|
|
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
|
|
|
|
entityitem.delayBeforeCanPickup = 10;
|
|
|
|
|
event.drops.add(entityitem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event.entityLiving instanceof IBossDisplayData)
|
2014-06-06 19:46:05 -08:00
|
|
|
{
|
2014-08-09 01:49:18 +03:00
|
|
|
String entityName = event.entityLiving.getClass().getSimpleName().toLowerCase();
|
2014-10-12 12:26:39 +02:00
|
|
|
if (entityName.contains("entitynpc") || entityName.contains("entitycustomnpc"))
|
2014-08-09 01:49:18 +03:00
|
|
|
return;
|
|
|
|
|
|
2014-06-06 19:46:05 -08:00
|
|
|
int count = event.entityLiving instanceof EntityDragon ? 5 : 1;
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
2014-08-09 01:49:18 +03:00
|
|
|
ItemStack dropStack = new ItemStack(TinkerArmor.heartCanister, 1, 3);
|
2014-06-06 19:46:05 -08:00
|
|
|
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
|
|
|
|
entityitem.delayBeforeCanPickup = 10;
|
|
|
|
|
event.drops.add(entityitem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-02 23:37:28 -08:00
|
|
|
|
|
|
|
|
/* Abilities */
|
2014-07-03 16:11:54 -08:00
|
|
|
@SubscribeEvent
|
2014-07-02 23:37:28 -08:00
|
|
|
public void armorMineSpeed (net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed event)
|
|
|
|
|
{
|
2014-10-10 12:39:14 +02:00
|
|
|
if(event.entityPlayer == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ItemStack glove = TPlayerStats.get(event.entityPlayer).armor.getStackInSlot(1);
|
|
|
|
|
if(event.entityPlayer.worldObj.isRemote) // todo: sync extended inventory with clients so this stuff and rendering is done properly...
|
|
|
|
|
glove = ArmorProxyClient.armorExtended.getStackInSlot(1);
|
|
|
|
|
if(glove == null || !glove.hasTagCompound())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// ok, we got a glove. bonus mining speeeeed
|
|
|
|
|
NBTTagCompound tags = glove.getTagCompound().getCompoundTag(TinkerArmor.travelGlove.getBaseTagName());
|
|
|
|
|
float mineSpeed = tags.getInteger("MiningSpeed");
|
|
|
|
|
|
|
|
|
|
float modifier = 1f + mineSpeed / 1000f;
|
|
|
|
|
float base = mineSpeed / 250f;
|
|
|
|
|
event.newSpeed = (event.originalSpeed + base) * modifier;
|
2014-07-02 23:37:28 -08:00
|
|
|
}
|
|
|
|
|
|
2014-07-03 16:11:54 -08:00
|
|
|
@SubscribeEvent
|
2014-07-02 23:37:28 -08:00
|
|
|
public void jumpHeight (LivingJumpEvent event)
|
|
|
|
|
{
|
|
|
|
|
ItemStack stack = event.entityLiving.getEquipmentInSlot(2);
|
|
|
|
|
if (stack != null && stack.getItem() instanceof TravelWings)
|
|
|
|
|
{
|
|
|
|
|
event.entityLiving.motionY += 0.2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 16:11:54 -08:00
|
|
|
@SubscribeEvent
|
2014-07-02 23:37:28 -08:00
|
|
|
public void slimefall (LivingFallEvent event)
|
|
|
|
|
{
|
|
|
|
|
ItemStack boots = event.entityLiving.getEquipmentInSlot(1);
|
|
|
|
|
if (boots != null && boots.getItem() instanceof IModifyable)
|
|
|
|
|
{
|
|
|
|
|
NBTTagCompound tag = boots.getTagCompound().getCompoundTag(((IModifyable) boots.getItem()).getBaseTagName());
|
|
|
|
|
int sole = tag.getInteger("Slimy Soles");
|
|
|
|
|
if (sole > 0)
|
|
|
|
|
{
|
|
|
|
|
event.distance /= (1 + sole);
|
|
|
|
|
event.entityLiving.fallDistance /= (1 + sole);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-16 23:39:49 +01:00
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void perfectDodge(LivingAttackEvent event)
|
|
|
|
|
{
|
|
|
|
|
if(!event.source.isProjectile())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// perfect dodge?
|
|
|
|
|
if(!(event.entityLiving instanceof EntityPlayer))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
|
|
|
|
ItemStack chest = player.getCurrentArmor(2);
|
|
|
|
|
if(chest == null || !(chest.getItem() instanceof IModifyable) || !chest.hasTagCompound())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
NBTTagCompound tags = chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName());
|
|
|
|
|
int dodge = tags.getInteger("Perfect Dodge");
|
|
|
|
|
if(dodge > TConstruct.random.nextInt(10))
|
|
|
|
|
event.setCanceled(true);
|
|
|
|
|
}
|
2014-06-06 19:46:05 -08:00
|
|
|
}
|