添加电池满能量物品方法
This commit is contained in:
parent
2b1d464a97
commit
ce371f2e30
2 changed files with 12 additions and 0 deletions
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.init;
|
|||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.item.ArmorPlate;
|
||||
import com.atsuishio.superbwarfare.item.BatteryItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem;
|
||||
|
@ -127,6 +128,9 @@ public class ModTabs {
|
|||
if (registryObject.get() == ModItems.ARMOR_PLATE.get()) {
|
||||
output.accept(ArmorPlate.getInfiniteInstance());
|
||||
}
|
||||
if (registryObject.get() instanceof BatteryItem batteryItem) {
|
||||
output.accept(batteryItem.makeFullEnergyStack());
|
||||
}
|
||||
}
|
||||
}))
|
||||
.build());
|
||||
|
|
|
@ -62,4 +62,12 @@ public class BatteryItem extends Item {
|
|||
public @NotNull Optional<TooltipComponent> getTooltipImage(@NotNull ItemStack pStack) {
|
||||
return Optional.of(new CellImageComponent(pStack));
|
||||
}
|
||||
|
||||
public ItemStack makeFullEnergyStack() {
|
||||
ItemStack stack = new ItemStack(this);
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||
e -> e.receiveEnergy(maxEnergy, false)
|
||||
);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue