Initial 1.11.2 update

This commit is contained in:
Electroblob
2018-02-07 21:15:50 +00:00
parent 67f6be0671
commit 3df5597dcc
368 changed files with 17234 additions and 15082 deletions
@@ -1,7 +1,5 @@
package electroblob.wizardry.item;
import java.util.List;
import javax.annotation.Nullable;
import electroblob.wizardry.Wizardry;
@@ -24,6 +22,7 @@ import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
@@ -37,65 +36,64 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem {
this.setMaxDamage(getBaseDuration());
this.setNoRepair();
this.setCreativeTab(null);
this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter()
{
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
{
if (entityIn == null)
{
return 0.0F;
}
else
{
ItemStack itemstack = entityIn.getActiveItemStack();
// Mojang, observe - hardcoding item references into their own classes is NOT good Java.
return itemstack != null && itemstack.getItem() == ItemSpectralBow.this ? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
}
}
});
this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter()
{
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
{
return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
}
});
this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter(){
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn){
if(entityIn == null){
return 0.0F;
}else{
ItemStack itemstack = entityIn.getActiveItemStack();
// Mojang, observe - hardcoding item references into their own classes is NOT good Java.
return itemstack.getItem() == ItemSpectralBow.this
? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F
: 0.0F;
}
}
});
this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter(){
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn){
return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F
: 0.0F;
}
});
}
@Override
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT)
// Why does this still exist? Item models deal with this now, right?
public boolean isFull3D(){
return true;
}
@Override
public int getBaseDuration(){
return 600;
}
@Override
public int getMaxDamage(ItemStack stack){
return this.getMaxDamageFromNBT(stack);
}
return this.getMaxDamageFromNBT(stack);
}
@Override
// This method allows the code for the item's timer to be greatly simplified by damaging it directly from
// onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff.
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){
if(oldStack != null && newStack != null){
// TODO: For some reason there used to be an && here instead of an ||, which makes me wonder if there's a weird
// fix I did that needs removing.
if(!oldStack.isEmpty() || !newStack.isEmpty()){
// We only care about the situation where we specifically want the animation NOT to play.
if(oldStack.getItem() == newStack.getItem() && !slotChanged
// This code should only run on the client side, so using Minecraft is ok.
&& !Minecraft.getMinecraft().thePlayer.isHandActive()) return false;
// This code should only run on the client side, so using Minecraft is ok.
&& !Minecraft.getMinecraft().player.isHandActive())
return false;
}
return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged);
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected){
int damage = stack.getItemDamage();
@@ -105,23 +103,26 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem {
stack.setItemDamage(damage + 1);
}
}
// The following two methods re-route the displayed durability through the proxies in order to override the pausing
// of the item timer when the bow is being pulled.
@Override
public double getDurabilityForDisplay(ItemStack stack){
return Wizardry.proxy.getConjuredBowDurability(stack);
}
public double getDefaultDurabilityForDisplay(ItemStack stack){
return super.getDurabilityForDisplay(stack);
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand){
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(stack, world, player, hand, true);
ItemStack stack = player.getHeldItem(hand);
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(stack, world, player, hand,
true);
if(ret != null) return ret;
@@ -132,7 +133,7 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem {
}
@Override
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack stack){
return true;
}
@@ -152,7 +153,7 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem {
public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){
return false;
}
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count){
// player.getItemInUseMaxCount() is named incorrectly; you only have to look at the method to see what it really
@@ -165,55 +166,54 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem {
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int timeLeft){
// Decreases the timer by the amount it should have been decreased while the bow was in use.
if(!world.isRemote) stack.setItemDamage(stack.getItemDamage() + (this.getMaxItemUseDuration(stack) - timeLeft));
if (entity instanceof EntityPlayer){
if(entity instanceof EntityPlayer){
EntityPlayer entityplayer = (EntityPlayer)entity;
int i = this.getMaxItemUseDuration(stack) - timeLeft;
i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, world, (EntityPlayer)entity, i, true);
if (i < 0) return;
if(i < 0) return;
float f = getArrowVelocity(i);
if ((double)f >= 0.1D){
if((double)f >= 0.1D){
if(!world.isRemote){
if (!world.isRemote){
ItemArrow itemarrow = (ItemArrow)Items.ARROW;
EntityArrow entityarrow = itemarrow.createArrow(world, new ItemStack(itemarrow), entityplayer);
entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.0F, 1.0F);
entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F,
f * 3.0F, 1.0F);
if (f == 1.0F)
{
if(f == 1.0F){
entityarrow.setIsCritical(true);
}
int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
if (j > 0)
{
if(j > 0){
entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
if (k > 0)
{
if(k > 0){
entityarrow.setKnockbackStrength(k);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
{
if(EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0){
entityarrow.setFire(100);
}
entityarrow.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
world.spawnEntityInWorld(entityarrow);
world.spawnEntity(entityarrow);
}
world.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);
world.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);
entityplayer.addStat(StatList.getObjectUseStats(this));
}
@@ -222,8 +222,8 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> subItems){
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems){
subItems.add(new ItemStack(this, 1));
}
}