More error fixes (down to 381)

This commit is contained in:
WayofTime 2016-03-18 14:54:31 -04:00
parent 7706d0667a
commit 09168fa386
11 changed files with 206 additions and 134 deletions

View file

@ -1,17 +1,20 @@
package WayofTime.bloodmagic.item.soul;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemSentientArmourGem extends Item
{
@ -35,7 +38,7 @@ public class ItemSentientArmourGem extends Item
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
boolean hasSentientArmour = false;
ItemStack[] armourInventory = player.inventory.armorInventory;
@ -63,7 +66,7 @@ public class ItemSentientArmourGem extends Item
}
}
return stack;
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
public int getWillBracket(double will)

View file

@ -1,21 +1,24 @@
package WayofTime.bloodmagic.item.soul;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Enchantments;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemArrow;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
public class ItemSentientBow extends ItemBow
{
@ -28,72 +31,87 @@ public class ItemSentientBow extends ItemBow
}
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft)
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
{
boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (flag || playerIn.inventory.hasItem(Items.arrow))
if (entityLiving instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer) entityLiving;
boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.infinity, stack) > 0;
ItemStack itemstack = this.getFiredArrow(entityplayer);
int i = this.getMaxItemUseDuration(stack) - timeLeft;
net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, i);
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, (EntityPlayer) entityLiving, i, itemstack != null || flag);
if (i < 0)
return;
i = event.charge;
float f = (float) i / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double) f < 0.1D)
if (itemstack != null || flag)
{
return;
}
if (itemstack == null)
{
itemstack = new ItemStack(Items.arrow);
}
if (f > 1.0F)
{
f = 1.0F;
}
float f = func_185059_b(i);
EntityArrow entityarrow = new EntitySentientArrow(worldIn, playerIn, f * 2.0F, 0);
if ((double) f >= 0.1D)
{
boolean flag1 = flag && itemstack.getItem() instanceof ItemArrow; //Forge: Fix consuming custom arrows.
if (f == 1.0F)
{
entityarrow.setIsCritical(true);
}
if (!worldIn.isRemote)
{
//Need to do some stuffs
ItemArrow itemarrow = (ItemArrow) ((ItemArrow) (itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.arrow));
EntityArrow entityarrow = itemarrow.makeTippedArrow(worldIn, itemstack, entityplayer);
entityarrow.func_184547_a(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.0F, 1.0F);
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (f == 1.0F)
{
entityarrow.setIsCritical(true);
}
if (j > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double) j * 0.5D + 0.5D);
}
int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.power, stack);
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (j > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double) j * 0.5D + 0.5D);
}
if (k > 0)
{
entityarrow.setKnockbackStrength(k);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.punch, stack);
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
{
entityarrow.setFire(100);
}
if (k > 0)
{
entityarrow.setKnockbackStrength(k);
}
stack.damageItem(1, playerIn);
worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.flame, stack) > 0)
{
entityarrow.setFire(100);
}
if (flag)
{
entityarrow.canBePickedUp = 2;
} else
{
playerIn.inventory.consumeInventoryItem(Items.arrow);
}
stack.damageItem(1, entityplayer);
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
if (flag1)
{
entityarrow.canBePickedUp = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(entityarrow);
worldIn.spawnEntityInWorld(entityarrow);
}
worldIn.playSound((EntityPlayer) null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.entity_arrow_shoot, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (!flag1)
{
--itemstack.stackSize;
if (itemstack.stackSize == 0)
{
entityplayer.inventory.deleteStack(itemstack);
}
}
entityplayer.addStat(StatList.func_188057_b(this));
}
}
}
}
@ -101,11 +119,6 @@ public class ItemSentientBow extends ItemBow
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
if (player.getItemInUse() == null)
{
return null;
}
int i = stack.getMaxItemUseDuration() - player.getItemInUseCount();
if (i >= 18)
@ -121,4 +134,28 @@ public class ItemSentientBow extends ItemBow
return null;
}
protected ItemStack getFiredArrow(EntityPlayer player)
{
if (this.func_185058_h_(player.getHeldItem(EnumHand.OFF_HAND)))
{
return player.getHeldItem(EnumHand.OFF_HAND);
} else if (this.func_185058_h_(player.getHeldItem(EnumHand.MAIN_HAND)))
{
return player.getHeldItem(EnumHand.MAIN_HAND);
} else
{
for (int i = 0; i < player.inventory.getSizeInventory(); ++i)
{
ItemStack itemstack = player.inventory.getStackInSlot(i);
if (this.func_185058_h_(itemstack))
{
return itemstack;
}
}
return null;
}
}
}

View file

@ -12,18 +12,24 @@ import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -55,7 +61,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (player.isSneaking())
setActivatedState(stack, !getActivated(stack));
@ -74,8 +80,8 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
setDropOfActivatedSword(stack, level >= 0 ? soulDrop[level] : 0);
}
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
return stack;
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
@Override
@ -198,11 +204,13 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
return soulList;
}
//TODO: Change attack speed.
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack)
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", getActivated(stack) ? getDamageOfActivatedSword(stack) : 2, 0));
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? getDamageOfActivatedSword(stack) : 2, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4, 0));
return multimap;
}

View file

@ -14,9 +14,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@ -45,7 +49,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IVariantProvider
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
EnumDemonWillType type = this.getCurrentType(stack);
double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
@ -53,7 +57,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IVariantProvider
double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack);
this.drainWill(type, stack, filled);
return stack;
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
@Override

View file

@ -7,11 +7,17 @@ import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@ -35,21 +41,21 @@ public class ItemSoulSnare extends Item implements IVariantProvider
}
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.entity_snowball_throw, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(new EntitySoulSnare(worldIn, playerIn));
}
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
}
@Override