2014-06-06 19:46:05 -08:00
|
|
|
package tconstruct.tools;
|
2013-11-19 20:57:52 -08:00
|
|
|
|
2014-02-05 10:28:54 -05:00
|
|
|
import mantle.blocks.BlockUtils;
|
2013-08-01 20:54:56 -07:00
|
|
|
import net.minecraft.block.Block;
|
2013-11-19 20:57:52 -08:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2014-02-25 19:48:18 -05:00
|
|
|
import net.minecraft.entity.boss.EntityDragon;
|
|
|
|
|
import net.minecraft.entity.boss.IBossDisplayData;
|
2013-11-19 20:57:52 -08:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
|
import net.minecraft.entity.monster.EntityCreeper;
|
|
|
|
|
import net.minecraft.entity.monster.EntityGhast;
|
|
|
|
|
import net.minecraft.entity.monster.EntitySkeleton;
|
|
|
|
|
import net.minecraft.entity.monster.EntityZombie;
|
|
|
|
|
import net.minecraft.entity.monster.IMob;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-04-02 20:38:48 -04:00
|
|
|
import net.minecraft.entity.projectile.EntityArrow;
|
2013-12-31 20:24:06 -05:00
|
|
|
import net.minecraft.init.Blocks;
|
2013-12-31 16:37:46 -05:00
|
|
|
import net.minecraft.init.Items;
|
2014-04-02 20:38:48 -04:00
|
|
|
import net.minecraft.item.Item;
|
2013-11-19 20:57:52 -08:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-04-02 20:38:48 -04:00
|
|
|
import net.minecraft.util.DamageSource;
|
|
|
|
|
import net.minecraft.util.EntityDamageSourceIndirect;
|
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
2013-11-19 20:57:52 -08:00
|
|
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
|
2013-07-31 13:08:18 -07:00
|
|
|
import tconstruct.TConstruct;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.armor.TinkerArmor;
|
2014-07-06 22:59:44 -08:00
|
|
|
import tconstruct.armor.player.TPlayerStats;
|
2013-07-31 13:08:18 -07:00
|
|
|
import tconstruct.library.TConstructRegistry;
|
2013-11-19 20:57:52 -08:00
|
|
|
import tconstruct.library.event.PartBuilderEvent;
|
|
|
|
|
import tconstruct.library.event.ToolCraftEvent;
|
2014-06-06 19:46:05 -08:00
|
|
|
import tconstruct.library.tools.AbilityHelper;
|
2013-11-19 20:57:52 -08:00
|
|
|
import tconstruct.library.tools.ArrowMaterial;
|
|
|
|
|
import tconstruct.library.tools.BowMaterial;
|
|
|
|
|
import tconstruct.library.tools.BowstringMaterial;
|
|
|
|
|
import tconstruct.library.tools.FletchingMaterial;
|
|
|
|
|
import tconstruct.library.tools.ToolCore;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.smeltery.TinkerSmeltery;
|
2014-06-06 19:46:05 -08:00
|
|
|
import tconstruct.util.ItemHelper;
|
2013-10-01 19:44:04 -07:00
|
|
|
import tconstruct.util.config.PHConstruct;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.world.entity.BlueSlime;
|
2014-02-05 10:28:54 -05:00
|
|
|
import cpw.mods.fml.common.eventhandler.Event.Result;
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-06-06 19:46:05 -08:00
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-06-06 19:46:05 -08:00
|
|
|
public class TinkerToolEvents
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onCrafting (ItemCraftedEvent event)
|
|
|
|
|
{
|
|
|
|
|
Item item = event.crafting.getItem();
|
|
|
|
|
if (!event.player.worldObj.isRemote)
|
|
|
|
|
{
|
|
|
|
|
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood))
|
|
|
|
|
{
|
|
|
|
|
TPlayerStats stats = TPlayerStats.get(event.player);
|
|
|
|
|
if (!stats.materialManual)
|
|
|
|
|
{
|
|
|
|
|
stats.materialManual = true;
|
|
|
|
|
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-31 20:24:06 -05:00
|
|
|
@SubscribeEvent
|
2013-11-04 00:33:39 +01:00
|
|
|
public void craftTool (ToolCraftEvent.NormalTool event)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool");
|
2014-06-04 21:44:48 -08:00
|
|
|
if (PHConstruct.denyMattock && event.tool == TinkerTools.mattock)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
int head = toolTag.getInteger("Head");
|
|
|
|
|
int handle = toolTag.getInteger("Handle");
|
|
|
|
|
int accessory = toolTag.getInteger("Accessory");
|
|
|
|
|
|
|
|
|
|
if (!allowCrafting(head, handle, accessory))
|
|
|
|
|
{
|
|
|
|
|
event.setResult(Result.DENY);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int thaum = 0;
|
|
|
|
|
if (toolTag.getInteger("Head") == 31)
|
|
|
|
|
thaum++;
|
|
|
|
|
if (toolTag.getInteger("Handle") == 31)
|
|
|
|
|
thaum++;
|
|
|
|
|
if (toolTag.getInteger("Accessory") == 31)
|
|
|
|
|
thaum++;
|
|
|
|
|
if (toolTag.getInteger("Extra") == 31)
|
|
|
|
|
thaum++;
|
|
|
|
|
|
|
|
|
|
if ((thaum >= 3) || (!toolTag.hasKey("Accessory") && thaum >= 2))
|
|
|
|
|
{
|
|
|
|
|
int modifiers = toolTag.getInteger("Modifiers");
|
|
|
|
|
modifiers += 2;
|
|
|
|
|
toolTag.setInteger("Modifiers", modifiers);
|
|
|
|
|
}
|
|
|
|
|
else if (thaum >= 1)
|
|
|
|
|
{
|
|
|
|
|
int modifiers = toolTag.getInteger("Modifiers");
|
|
|
|
|
modifiers += 1;
|
|
|
|
|
toolTag.setInteger("Modifiers", modifiers);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 21:44:48 -08:00
|
|
|
if (event.tool == TinkerTools.shortbow)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
BowMaterial top = TConstructRegistry.getBowMaterial(toolTag.getInteger("Head"));
|
|
|
|
|
BowMaterial bottom = TConstructRegistry.getBowMaterial(toolTag.getInteger("Accessory"));
|
|
|
|
|
BowstringMaterial string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(toolTag.getInteger("Handle"), BowstringMaterial.class);
|
|
|
|
|
|
|
|
|
|
if (top != null && bottom != null && string != null)
|
|
|
|
|
{
|
|
|
|
|
if (toolTag.getInteger("Handle") == 1)
|
|
|
|
|
{
|
|
|
|
|
int modifiers = toolTag.getInteger("Modifiers");
|
|
|
|
|
modifiers += 1;
|
|
|
|
|
toolTag.setInteger("Modifiers", modifiers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int durability = (int) ((top.durability + bottom.durability) / 2 * string.durabilityModifier);
|
|
|
|
|
toolTag.setInteger("TotalDurability", durability);
|
|
|
|
|
toolTag.setInteger("BaseDurability", durability);
|
|
|
|
|
|
|
|
|
|
int drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2 * string.drawspeedModifier);
|
|
|
|
|
toolTag.setInteger("DrawSpeed", drawSpeed);
|
|
|
|
|
toolTag.setInteger("BaseDrawSpeed", drawSpeed);
|
|
|
|
|
|
|
|
|
|
float flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax) / 2f * string.flightSpeedModifier;
|
|
|
|
|
toolTag.setFloat("FlightSpeed", flightSpeed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 21:44:48 -08:00
|
|
|
if (event.tool == TinkerTools.arrow)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
ArrowMaterial head = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Head"));
|
|
|
|
|
ArrowMaterial shaft = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Handle"));
|
|
|
|
|
FletchingMaterial fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(toolTag.getInteger("Accessory"), FletchingMaterial.class);
|
|
|
|
|
|
|
|
|
|
if (head != null && shaft != null && fletching != null)
|
|
|
|
|
{
|
|
|
|
|
float mass = head.mass / 5f + shaft.mass + fletching.mass;
|
|
|
|
|
float shatter = (head.breakChance + shaft.breakChance + fletching.breakChance) / 4f;
|
|
|
|
|
float accuracy = (head.accuracy + shaft.accuracy + fletching.accuracy) / 3;
|
|
|
|
|
|
|
|
|
|
ItemStack arrow = new ItemStack(event.tool, 4);
|
|
|
|
|
toolTag.setInteger("TotalDurability", 0);
|
|
|
|
|
toolTag.setFloat("Mass", mass);
|
|
|
|
|
toolTag.setFloat("BreakChance", shatter);
|
|
|
|
|
toolTag.setFloat("Accuracy", accuracy);
|
|
|
|
|
toolTag.setInteger("Unbreaking", 10);
|
|
|
|
|
arrow.setTagCompound(event.toolTag);
|
|
|
|
|
event.overrideResult(arrow);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-03 22:28:37 -04:00
|
|
|
|
2014-06-04 21:44:48 -08:00
|
|
|
if (event.tool == TinkerTools.battlesign)
|
2014-04-02 20:38:48 -04:00
|
|
|
{
|
|
|
|
|
int modifiers = toolTag.getInteger("Modifiers");
|
|
|
|
|
modifiers += 1;
|
|
|
|
|
toolTag.setInteger("Modifiers", modifiers);
|
|
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2013-11-04 00:33:39 +01:00
|
|
|
private boolean allowCrafting (int head, int handle, int accessory)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 };
|
|
|
|
|
for (int i = 0; i < nonMetals.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (head == nonMetals[i] || handle == nonMetals[i] || accessory == nonMetals[i])
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-31 20:24:06 -05:00
|
|
|
@SubscribeEvent
|
2013-11-04 00:33:39 +01:00
|
|
|
public void craftPart (PartBuilderEvent.NormalPart event)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-04 21:44:48 -08:00
|
|
|
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 23)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
ItemStack result = craftBowString(event.material);
|
|
|
|
|
if (result != null)
|
|
|
|
|
{
|
|
|
|
|
event.overrideResult(new ItemStack[] { result, null });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 21:44:48 -08:00
|
|
|
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 24)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
ItemStack result = craftFletching(event.material);
|
|
|
|
|
if (result != null)
|
|
|
|
|
{
|
|
|
|
|
event.overrideResult(new ItemStack[] { result, null });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 00:33:39 +01:00
|
|
|
public static ItemStack craftBowString (ItemStack stack)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
if (stack.stackSize < 3)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
BowstringMaterial mat = (BowstringMaterial) TConstructRegistry.getCustomMaterial(stack, BowstringMaterial.class);
|
|
|
|
|
if (mat != null)
|
|
|
|
|
return mat.craftingItem.copy();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 00:33:39 +01:00
|
|
|
public static ItemStack craftFletching (ItemStack stack)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-08-01 20:54:56 -07:00
|
|
|
if (matchesLeaves(stack))
|
|
|
|
|
{
|
2013-12-31 20:24:06 -05:00
|
|
|
FletchingMaterial leaves = (FletchingMaterial) TConstructRegistry.getCustomMaterial(new ItemStack(Blocks.leaves), FletchingMaterial.class);
|
2013-08-01 20:54:56 -07:00
|
|
|
return leaves.craftingItem.copy();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
FletchingMaterial mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchingMaterial.class);
|
|
|
|
|
if (mat != null)
|
|
|
|
|
return mat.craftingItem.copy();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 00:33:39 +01:00
|
|
|
public static boolean matchesLeaves (ItemStack stack)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-03-01 21:44:33 -05:00
|
|
|
if (stack != null)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-04-02 22:49:37 -04:00
|
|
|
Block block = BlockUtils.getBlockFromItemStack(stack);
|
2014-03-01 21:44:33 -05:00
|
|
|
if (block != null)
|
|
|
|
|
{
|
|
|
|
|
if (block.isLeaves(null, 0, 0, 0))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2013-08-01 20:54:56 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-06-06 19:46:05 -08:00
|
|
|
|
2013-08-01 18:45:05 -07:00
|
|
|
|
2014-04-03 22:28:37 -04:00
|
|
|
|
2014-04-02 20:38:48 -04:00
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onAttack (LivingAttackEvent event)
|
|
|
|
|
{
|
|
|
|
|
//System.out.println("Damage: "+event.ammount);
|
|
|
|
|
if (event.entityLiving instanceof EntityPlayer)
|
|
|
|
|
{
|
|
|
|
|
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
|
|
|
|
//Cutlass
|
|
|
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
2014-06-04 21:44:48 -08:00
|
|
|
if (stack != null && stack.getItem() == TinkerTools.battlesign && player.isUsingItem())
|
2013-08-16 13:51:33 -07:00
|
|
|
{
|
2014-04-02 20:38:48 -04:00
|
|
|
DamageSource source = event.source;
|
|
|
|
|
if (!source.isUnblockable() && !source.isMagicDamage() && !source.isExplosion())
|
|
|
|
|
{
|
|
|
|
|
if (source instanceof EntityDamageSourceIndirect)
|
|
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
if (TConstruct.random.nextInt(3) == 0)
|
2014-04-02 20:38:48 -04:00
|
|
|
{
|
|
|
|
|
Entity attacker = source.getEntity();
|
|
|
|
|
Entity projectile = ((EntityDamageSourceIndirect) source).getSourceOfDamage();
|
|
|
|
|
projectile.motionX *= -1;
|
|
|
|
|
projectile.motionZ *= -1;
|
|
|
|
|
projectile.setDead();
|
|
|
|
|
event.setCanceled(true);
|
|
|
|
|
|
|
|
|
|
if (projectile.getClass() == EntityArrow.class && !player.worldObj.isRemote)
|
|
|
|
|
{
|
|
|
|
|
EntityArrow reflection = null;
|
|
|
|
|
if (attacker instanceof EntityLivingBase)
|
|
|
|
|
reflection = new EntityArrow(player.worldObj, (EntityLivingBase) attacker, 0);
|
|
|
|
|
else
|
|
|
|
|
reflection = new EntityArrow(player.worldObj, player, 0);
|
|
|
|
|
|
|
|
|
|
Vec3 look = player.getLookVec();
|
|
|
|
|
reflection.posX = projectile.posX;
|
|
|
|
|
reflection.posY = projectile.posY;
|
|
|
|
|
reflection.posZ = projectile.posZ;
|
|
|
|
|
reflection.motionX = (projectile.motionX + (look.xCoord * 8)) / 6;
|
|
|
|
|
reflection.motionY = (projectile.motionY + (look.yCoord * 8)) / 6;
|
|
|
|
|
reflection.motionZ = (projectile.motionZ + (look.zCoord * 8)) / 6;
|
|
|
|
|
reflection.damage = ((EntityArrow) projectile).damage;
|
|
|
|
|
player.worldObj.spawnEntityInWorld(reflection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Entity attacker = source.getEntity();
|
2014-05-27 22:57:30 -04:00
|
|
|
if(attacker != null)
|
|
|
|
|
{
|
|
|
|
|
attacker.attackEntityFrom(DamageSource.causeThornsDamage(player), event.ammount);
|
|
|
|
|
}
|
2014-04-02 20:38:48 -04:00
|
|
|
}
|
|
|
|
|
}
|
2013-08-16 13:51:33 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-06 19:46:05 -08:00
|
|
|
|
2013-12-31 20:24:06 -05:00
|
|
|
@SubscribeEvent
|
2013-11-04 00:33:39 +01:00
|
|
|
public void onLivingDrop (LivingDropsEvent event)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-11-19 20:57:52 -08:00
|
|
|
if (event.entityLiving == null)
|
|
|
|
|
return;
|
2013-12-11 23:47:07 -05:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
if (event.recentlyHit)
|
|
|
|
|
{
|
|
|
|
|
if (event.entityLiving.getClass() == EntitySkeleton.class)
|
|
|
|
|
{
|
|
|
|
|
EntitySkeleton enemy = (EntitySkeleton) event.entityLiving;
|
|
|
|
|
|
|
|
|
|
if (event.source.damageType.equals("player"))
|
|
|
|
|
{
|
|
|
|
|
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
|
|
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
|
|
|
|
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
|
|
|
|
{
|
|
|
|
|
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
2014-06-04 21:44:48 -08:00
|
|
|
if (stack.getItem() == TinkerTools.cleaver)
|
2013-07-26 21:18:53 -07:00
|
|
|
beheading += 2;
|
2014-06-06 19:46:05 -08:00
|
|
|
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 10)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, enemy.getSkeletonType()));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-06 19:46:05 -08:00
|
|
|
if (enemy.getSkeletonType() == 1 && TConstruct.random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, new ItemStack(TinkerTools.materials, 1, 8));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event.entityLiving.getClass() == EntityZombie.class)
|
|
|
|
|
{
|
|
|
|
|
EntityZombie enemy = (EntityZombie) event.entityLiving;
|
|
|
|
|
|
|
|
|
|
if (event.source.damageType.equals("player"))
|
|
|
|
|
{
|
|
|
|
|
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
|
|
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
|
|
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
|
|
|
|
{
|
|
|
|
|
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
2014-06-04 21:44:48 -08:00
|
|
|
if (stack != null && stack.hasTagCompound() && stack.getItem() == TinkerTools.cleaver)
|
2013-07-26 21:18:53 -07:00
|
|
|
beheading += 2;
|
2014-06-06 19:46:05 -08:00
|
|
|
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 10)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, 2));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
2014-02-25 19:48:18 -05:00
|
|
|
|
2014-06-06 19:46:05 -08:00
|
|
|
if (stack != null && stack.hasTagCompound() && stack.getItem() == TinkerTools.cleaver && TConstruct.random.nextInt(100) < 10)
|
2014-02-25 19:48:18 -05:00
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, 2));
|
2014-02-25 19:48:18 -05:00
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event.entityLiving.getClass() == EntityCreeper.class)
|
|
|
|
|
{
|
|
|
|
|
EntityCreeper enemy = (EntityCreeper) event.entityLiving;
|
|
|
|
|
|
|
|
|
|
if (event.source.damageType.equals("player"))
|
|
|
|
|
{
|
|
|
|
|
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
|
|
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
|
|
|
|
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
|
|
|
|
{
|
|
|
|
|
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
2014-06-04 21:44:48 -08:00
|
|
|
if (stack.getItem() == TinkerTools.cleaver)
|
2013-07-26 21:18:53 -07:00
|
|
|
beheading += 2;
|
2014-06-06 19:46:05 -08:00
|
|
|
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 5)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, 4));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event.entityLiving instanceof EntityPlayer)
|
|
|
|
|
{
|
|
|
|
|
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
|
|
|
|
|
|
|
|
|
if (PHConstruct.dropPlayerHeads)
|
|
|
|
|
{
|
2013-12-31 20:24:06 -05:00
|
|
|
ItemStack dropStack = new ItemStack(Items.skull, 1, 3);
|
2013-07-26 21:18:53 -07:00
|
|
|
NBTTagCompound nametag = new NBTTagCompound();
|
2014-01-07 15:07:07 -05:00
|
|
|
nametag.setString("SkullOwner", player.getDisplayName());
|
2014-02-04 21:21:50 -05:00
|
|
|
dropStack.setTagCompound(nametag);
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, dropStack);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (event.source.damageType.equals("player"))
|
|
|
|
|
{
|
|
|
|
|
EntityPlayer source = (EntityPlayer) event.source.getEntity();
|
|
|
|
|
ItemStack stack = source.getCurrentEquippedItem();
|
|
|
|
|
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
|
|
|
|
{
|
|
|
|
|
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
2014-06-04 21:44:48 -08:00
|
|
|
if (stack.getItem() == TinkerTools.cleaver)
|
2013-07-26 21:18:53 -07:00
|
|
|
beheading += 2;
|
2014-06-06 19:46:05 -08:00
|
|
|
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 50)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-31 20:24:06 -05:00
|
|
|
ItemStack dropStack = new ItemStack(Items.skull, 1, 3);
|
2013-07-26 21:18:53 -07:00
|
|
|
NBTTagCompound nametag = new NBTTagCompound();
|
2014-01-07 15:07:07 -05:00
|
|
|
nametag.setString("SkullOwner", player.getDisplayName());
|
2014-02-04 21:21:50 -05:00
|
|
|
dropStack.setTagCompound(nametag);
|
2014-06-06 19:46:05 -08:00
|
|
|
ItemHelper.addDrops(event, dropStack);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-06 19:46:05 -08:00
|
|
|
|
2013-12-31 20:24:06 -05:00
|
|
|
@SubscribeEvent
|
2013-11-04 00:33:39 +01:00
|
|
|
public void registerOre (OreRegisterEvent evt)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-11 23:47:07 -05:00
|
|
|
|
2013-11-25 15:36:32 -05:00
|
|
|
if (evt.Name == "crystalQuartz")
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-06-04 21:44:48 -08:00
|
|
|
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 2);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (evt.Name == "crystalCerusQuartz")
|
|
|
|
|
{
|
2014-06-04 21:44:48 -08:00
|
|
|
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 24);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|