Replace MixinItemRenderer by the new 1.17 vanilla API. Fixes #2602
This commit is contained in:
parent
f500b5ddff
commit
8b24b8439a
16 changed files with 72 additions and 204 deletions
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of RebornCore, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 TeamReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package reborncore.common.util;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public interface ItemDurabilityExtensions {
|
|
||||||
|
|
||||||
default double getDurability(ItemStack stack) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean showDurability(ItemStack stack) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default int getDurabilityColor(ItemStack stack) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -108,12 +108,16 @@ public class ItemUtils {
|
||||||
return ItemStack.fromNbt(data);
|
return ItemStack.fromNbt(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getPowerForDurabilityBar(ItemStack stack) {
|
public static int getPowerForDurabilityBar(ItemStack stack) {
|
||||||
if (!(stack.getItem() instanceof RcEnergyItem energyItem)) {
|
if (!(stack.getItem() instanceof RcEnergyItem energyItem)) {
|
||||||
return 0.0;
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (double) energyItem.getStoredEnergy(stack) / energyItem.getEnergyCapacity();
|
return Math.round((energyItem.getStoredEnergy(stack) * 100f / energyItem.getEnergyCapacity()) * 13) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getColorForDurabilityBar(ItemStack stack) {
|
||||||
|
return 0xff8006;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of RebornCore, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 TeamReborn
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package reborncore.mixin.client;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import net.minecraft.client.font.TextRenderer;
|
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
|
||||||
import net.minecraft.client.render.Tessellator;
|
|
||||||
import net.minecraft.client.render.item.ItemRenderer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
|
|
||||||
//Not too happy with this, need to find and get a better solution into fabric soon
|
|
||||||
@Mixin(ItemRenderer.class)
|
|
||||||
public abstract class MixinItemRenderer {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
protected abstract void renderGuiQuad(BufferBuilder bufferBuilder_1, int int_1, int int_2, int int_3, int int_4, int int_5, int int_6, int int_7, int int_8);
|
|
||||||
|
|
||||||
@Inject(method = "renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At("HEAD"))
|
|
||||||
private void renderGuiItemOverlay(TextRenderer textRenderer, ItemStack stack, int x, int y, @Nullable String string, CallbackInfo info) {
|
|
||||||
if (stack.getItem() instanceof ItemDurabilityExtensions durabilityExtensions) {
|
|
||||||
if (!durabilityExtensions.showDurability(stack)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RenderSystem.disableDepthTest();
|
|
||||||
RenderSystem.disableTexture();
|
|
||||||
//RenderSystem.disableAlphaTest(); FIXME 1.17
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
|
||||||
BufferBuilder bufferBuilder = tessellator.getBuffer();
|
|
||||||
|
|
||||||
int durability = (int) (13 * (1 - Math.max(0.0F, durabilityExtensions.getDurability(stack))));
|
|
||||||
int color = durabilityExtensions.getDurabilityColor(stack);
|
|
||||||
|
|
||||||
this.renderGuiQuad(bufferBuilder, x + 2, y + 13, 13, 2, 0, 0, 0, 255);
|
|
||||||
this.renderGuiQuad(bufferBuilder, x + 2, y + 13, durability, 1, color >> 16 & 255, color >> 8 & 255, color & 255, 255);
|
|
||||||
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
//RenderSystem.enableAlphaTest();
|
|
||||||
RenderSystem.enableTexture();
|
|
||||||
RenderSystem.enableDepthTest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"client": [
|
"client": [
|
||||||
"MixinGameRenderer",
|
"MixinGameRenderer",
|
||||||
"MixinItemRenderer",
|
|
||||||
"MixinDebugRenderer",
|
"MixinDebugRenderer",
|
||||||
"AccessorModelPredicateProviderRegistry",
|
"AccessorModelPredicateProviderRegistry",
|
||||||
"AccessorChatHud",
|
"AccessorChatHud",
|
||||||
|
|
|
@ -42,7 +42,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
@ -50,7 +49,7 @@ import techreborn.utils.MessageIDs;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BatteryItem extends Item implements RcEnergyItem, ItemDurabilityExtensions {
|
public class BatteryItem extends Item implements RcEnergyItem {
|
||||||
|
|
||||||
private final int maxEnergy;
|
private final int maxEnergy;
|
||||||
private final RcEnergyTier tier;
|
private final RcEnergyTier tier;
|
||||||
|
@ -113,17 +112,17 @@ public class BatteryItem extends Item implements RcEnergyItem, ItemDurabilityExt
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
// ItemDurabilityExtensions
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,11 @@ import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
public class BatpackItem extends ArmorItem implements RcEnergyItem, ItemDurabilityExtensions {
|
public class BatpackItem extends ArmorItem implements RcEnergyItem {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final RcEnergyTier tier;
|
public final RcEnergyTier tier;
|
||||||
|
@ -95,19 +94,18 @@ public class BatpackItem extends ArmorItem implements RcEnergyItem, ItemDurabili
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,12 +61,12 @@ public class CloakingDeviceItem extends TRArmourItem implements RcEnergyItem, Ar
|
||||||
|
|
||||||
// ItemTRArmour
|
// ItemTRArmour
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ public class CloakingDeviceItem extends TRArmourItem implements RcEnergyItem, Ar
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item
|
// Item
|
||||||
|
|
|
@ -143,12 +143,12 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,8 +158,8 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.item.ArmorItem;
|
import net.minecraft.item.ArmorItem;
|
||||||
import net.minecraft.item.ArmorMaterial;
|
import net.minecraft.item.ArmorMaterial;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -36,7 +35,7 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 26/02/2016.
|
* Created by modmuss50 on 26/02/2016.
|
||||||
*/
|
*/
|
||||||
public class TRArmourItem extends ArmorItem implements ItemDurabilityExtensions {
|
public class TRArmourItem extends ArmorItem {
|
||||||
|
|
||||||
//Thanks for being private
|
//Thanks for being private
|
||||||
public static final UUID[] MODIFIERS = new UUID[]{
|
public static final UUID[] MODIFIERS = new UUID[]{
|
||||||
|
|
|
@ -36,14 +36,13 @@ import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ChainsawItem extends AxeItem implements RcEnergyItem, ItemDurabilityExtensions {
|
public class ChainsawItem extends AxeItem implements RcEnergyItem {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final int cost;
|
public final int cost;
|
||||||
|
@ -118,20 +117,19 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem, ItemDurabilit
|
||||||
return referenceTool.isSuitableFor(state);
|
return referenceTool.isSuitableFor(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
|
|
|
@ -38,12 +38,11 @@ import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
public class DrillItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions, DynamicAttributeTool {
|
public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final int cost;
|
public final int cost;
|
||||||
|
@ -133,20 +132,19 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, ItemDurabili
|
||||||
InitUtils.initPoweredItems(this, stacks);
|
InitUtils.initPoweredItems(this, stacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
|
|
|
@ -39,7 +39,6 @@ import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
@ -47,7 +46,7 @@ import techreborn.utils.ToolsUtil;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class JackhammerItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions, DynamicAttributeTool {
|
public class JackhammerItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
|
||||||
|
|
||||||
public final int maxCharge;
|
public final int maxCharge;
|
||||||
public final RcEnergyTier tier;
|
public final RcEnergyTier tier;
|
||||||
|
@ -144,20 +143,19 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem, ItemDur
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DynamicAttributeTool
|
// DynamicAttributeTool
|
||||||
|
|
|
@ -33,7 +33,6 @@ import net.minecraft.util.collection.DefaultedList;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -42,7 +41,7 @@ import techreborn.utils.InitUtils;
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 05/11/2016.
|
* Created by modmuss50 on 05/11/2016.
|
||||||
*/
|
*/
|
||||||
public class ElectricTreetapItem extends Item implements RcEnergyItem, ItemDurabilityExtensions {
|
public class ElectricTreetapItem extends Item implements RcEnergyItem {
|
||||||
|
|
||||||
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
|
public final int maxCharge = TechRebornConfig.electricTreetapCharge;
|
||||||
public int cost = TechRebornConfig.electricTreetapCost;
|
public int cost = TechRebornConfig.electricTreetapCost;
|
||||||
|
@ -67,20 +66,19 @@ public class ElectricTreetapItem extends Item implements RcEnergyItem, ItemDurab
|
||||||
InitUtils.initPoweredItems(this, stacks);
|
InitUtils.initPoweredItems(this, stacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
|
|
|
@ -37,7 +37,6 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
@ -46,7 +45,7 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class RockCutterItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions {
|
public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
|
||||||
|
|
||||||
public static final int maxCharge = TechRebornConfig.rockCutterCharge;
|
public static final int maxCharge = TechRebornConfig.rockCutterCharge;
|
||||||
public int cost = TechRebornConfig.rockCutterCost;
|
public int cost = TechRebornConfig.rockCutterCost;
|
||||||
|
@ -129,18 +128,18 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem, ItemDur
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
// ItemDurabilityExtensions
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.items.ItemStackModifiers;
|
import reborncore.api.items.ItemStackModifiers;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
|
@ -57,7 +56,7 @@ import techreborn.utils.MessageIDs;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemDurabilityExtensions, ItemStackModifiers {
|
public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemStackModifiers {
|
||||||
public static final int maxCharge = TechRebornConfig.nanosaberCharge;
|
public static final int maxCharge = TechRebornConfig.nanosaberCharge;
|
||||||
public int cost = TechRebornConfig.nanosaberCost;
|
public int cost = TechRebornConfig.nanosaberCost;
|
||||||
|
|
||||||
|
@ -152,20 +151,19 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemDurabi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemStackModifiers
|
// ItemStackModifiers
|
||||||
|
|
|
@ -46,7 +46,6 @@ import net.minecraft.world.World;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.RcEnergyItem;
|
import reborncore.common.powerSystem.RcEnergyItem;
|
||||||
import reborncore.common.util.ItemDurabilityExtensions;
|
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.TorchHelper;
|
import reborncore.common.util.TorchHelper;
|
||||||
import reborncore.common.powerSystem.RcEnergyTier;
|
import reborncore.common.powerSystem.RcEnergyTier;
|
||||||
|
@ -58,7 +57,7 @@ import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class OmniToolItem extends PickaxeItem implements RcEnergyItem, ItemDurabilityExtensions, DynamicAttributeTool {
|
public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
|
||||||
|
|
||||||
public final int maxCharge = TechRebornConfig.omniToolCharge;
|
public final int maxCharge = TechRebornConfig.omniToolCharge;
|
||||||
public int cost = TechRebornConfig.omniToolCost;
|
public int cost = TechRebornConfig.omniToolCost;
|
||||||
|
@ -139,20 +138,19 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, ItemDurab
|
||||||
tooltip.add(new LiteralText(Formatting.YELLOW + I18n.translate("techreborn.tooltip.omnitool_motto")));
|
tooltip.add(new LiteralText(Formatting.YELLOW + I18n.translate("techreborn.tooltip.omnitool_motto")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemDurabilityExtensions
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurability(ItemStack stack) {
|
public int getItemBarStep(ItemStack stack) {
|
||||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
return ItemUtils.getPowerForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showDurability(ItemStack stack) {
|
public boolean isItemBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurabilityColor(ItemStack stack) {
|
public int getItemBarColor(ItemStack stack) {
|
||||||
return PowerSystem.getDisplayPower().colour;
|
return ItemUtils.getColorForDurabilityBar(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnergyHolder
|
// EnergyHolder
|
||||||
|
|
Loading…
Reference in a new issue