Migrated batteries + TR Itemgroup
This commit is contained in:
parent
0c99a94250
commit
e513e20e5a
16 changed files with 101 additions and 108 deletions
|
@ -39,6 +39,7 @@ import reborncore.common.powerSystem.PowerSystem;
|
|||
import reborncore.common.powerSystem.PoweredItemContainerProvider;
|
||||
import reborncore.common.powerSystem.forge.ForgePowerItemManager;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.TechReborn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -48,15 +49,13 @@ public class ItemBattery extends Item implements IEnergyItemInfo {
|
|||
int maxTransfer = 0;
|
||||
|
||||
public ItemBattery(int maxEnergy, int maxTransfer) {
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(1);
|
||||
super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1).defaultMaxDamage(1));
|
||||
this.maxEnergy = maxEnergy;
|
||||
this.maxTransfer = maxTransfer;
|
||||
this.addPropertyOverride(new ResourceLocation("techreborn:empty"), new IItemPropertyGetter() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
|
||||
public float call(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
|
||||
if (!stack.isEmpty() && new ForgePowerItemManager(stack).getEnergyStored() == 0) {
|
||||
return 1.0F;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.items.battery;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -39,19 +39,18 @@ public class ItemEnergyCrystal extends ItemBattery {
|
|||
public ItemEnergyCrystal() {
|
||||
super(ConfigTechReborn.EnergyCrystalMaxCharge, 1_000);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(TRContent.ENERGY_CRYSTAL);
|
||||
ItemStack charged = stack.copy();
|
||||
ItemStack uncharged = new ItemStack(TRContent.ENERGY_CRYSTAL);
|
||||
ItemStack charged = new ItemStack(TRContent.ENERGY_CRYSTAL);
|
||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
items.add(uncharged);
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.items.battery;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -39,19 +39,18 @@ public class ItemLapotronCrystal extends ItemBattery {
|
|||
public ItemLapotronCrystal() {
|
||||
super(ConfigTechReborn.LapotronCrystalMaxCharge, 10_000);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
|
||||
ItemStack charged = stack.copy();
|
||||
ItemStack uncharged = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
|
||||
ItemStack charged = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
|
||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
items.add(uncharged);
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.items.battery;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -39,19 +39,18 @@ public class ItemLapotronicOrb extends ItemBattery {
|
|||
public ItemLapotronicOrb() {
|
||||
super(ConfigTechReborn.LapotronicOrbMaxCharge, 100_000);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(TRContent.LAPOTRONIC_ORB);
|
||||
ItemStack charged = stack.copy();
|
||||
ItemStack uncharged = new ItemStack(TRContent.LAPOTRONIC_ORB);
|
||||
ItemStack charged = new ItemStack(TRContent.LAPOTRONIC_ORB);
|
||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
items.add(uncharged);
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.items.battery;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -38,20 +38,19 @@ public class ItemLithiumIonBattery extends ItemBattery {
|
|||
public ItemLithiumIonBattery() {
|
||||
super(400_000, 1_000);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
||||
ItemStack charged = stack.copy();
|
||||
ItemStack uncharged = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
||||
ItemStack charged = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
items.add(uncharged);
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.items.battery;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -38,19 +38,18 @@ public class ItemRedCellBattery extends ItemBattery {
|
|||
public ItemRedCellBattery() {
|
||||
super(40_000, 100);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (!isInGroup(group)) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
||||
ItemStack charged = stack.copy();
|
||||
ItemStack uncharged = new ItemStack(TRContent.RED_CELL_BATTERY);
|
||||
ItemStack charged = new ItemStack(TRContent.RED_CELL_BATTERY);
|
||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
items.add(uncharged);
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue