mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Fix durability bars for 1.11
This commit is contained in:
4 files changed
+29
-29
No files matched your search
@@ -21,6 +21,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -41,23 +42,21 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
|
||||
public ItemManaTablet() {
|
||||
super(LibItemNames.MANA_TABLET);
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(1000);
|
||||
setNoRepair();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> stacks) {
|
||||
// Empty tablet
|
||||
stacks.add(new ItemStack(item, 1));
|
||||
stacks.add(new ItemStack(item));
|
||||
|
||||
// Full tablet
|
||||
ItemStack fullPower = new ItemStack(item, 1);
|
||||
ItemStack fullPower = new ItemStack(item);
|
||||
setMana(fullPower, MAX_MANA);
|
||||
stacks.add(fullPower);
|
||||
|
||||
// Creative Tablet
|
||||
ItemStack creative = new ItemStack(item, 1);
|
||||
ItemStack creative = new ItemStack(item);
|
||||
setMana(creative, MAX_MANA);
|
||||
setStackCreative(creative);
|
||||
stacks.add(creative);
|
||||
@@ -151,14 +150,16 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
// If the stack is not creative, show the durability bar.
|
||||
return !isStackCreative(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
// I believe Forge has their durability values swapped, hence the (1.0 -).
|
||||
// This will probably be fixed soon.
|
||||
return 1.0 - getManaFractionForDisplay(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
||||
return MathHelper.hsvToRGB(getManaFractionForDisplay(stack) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -36,13 +37,10 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD
|
||||
|
||||
public ItemManaRing() {
|
||||
this(LibItemNames.MANA_RING);
|
||||
setMaxDamage(1000);
|
||||
setNoRepair();
|
||||
}
|
||||
|
||||
public ItemManaRing(String name) {
|
||||
super(name);
|
||||
setMaxDamage(1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +51,11 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> stacks) {
|
||||
stacks.add(new ItemStack(item, 1, 10000));
|
||||
stacks.add(new ItemStack(item));
|
||||
|
||||
ItemStack full = new ItemStack(item);
|
||||
setMana(full, getMaxMana(full));
|
||||
stacks.add(full);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,14 +114,17 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
// For mana rings, always show the durability bar.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
// As in ItemManaTablet, forge seems to have their durability swapped, hence the 1.0 -
|
||||
return 1.0 - getManaFractionForDisplay(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
||||
return MathHelper.hsvToRGB(getManaFractionForDisplay(stack) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,18 +59,15 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
|
||||
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BLAZE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
// Fix up rods from old versions which used meta instead of cooldown tracker
|
||||
if (stack.getItemDamage() > 0)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
// Keep for backward compat
|
||||
if(par1ItemStack.getItemDamage() > 0)
|
||||
par1ItemStack.setItemDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
placePos.setPos(pos.getX() + i, pos.getY(), pos.getZ() + j);
|
||||
if(world.isAirBlock(placePos)
|
||||
|| world.getBlockState(placePos).getBlock() == place) {
|
||||
world.setBlockState(placePos, place.getDefaultState());
|
||||
world.setBlockState(placePos, place.getDefaultState(), 2);
|
||||
TileBifrost tile = (TileBifrost) world.getTileEntity(placePos);
|
||||
if(tile != null) {
|
||||
tile.ticks = time;
|
||||
@@ -119,6 +119,10 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.bifrostRod, SoundCategory.PLAYERS, 0.5F, 0.25F);
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false);
|
||||
player.getCooldownTracker().setCooldown(this, TIME);
|
||||
|
||||
// Fix up rods from old versions which used meta instead of cooldown tracker
|
||||
if (stack.getItemDamage() > 0)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,13 +140,6 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
return !getContainerItem(stack).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
// Kept for backward compat
|
||||
if (par1ItemStack.getItemDamage() > 0)
|
||||
par1ItemStack.setItemDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user