Itemgroup filler moved to init utils.

This commit is contained in:
drcrazy 2019-08-13 17:02:34 +03:00
parent 62f1c521f0
commit f9023d7b0f
21 changed files with 62 additions and 150 deletions

View file

@ -41,6 +41,7 @@ import reborncore.common.util.ItemUtils;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterial;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo {
@ -76,16 +77,11 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.CLOAKING_DEVICE);
ItemStack charged = new ItemStack(TRContent.CLOAKING_DEVICE);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.CLOAKING_DEVICE, itemList);
}
@Override

View file

@ -31,13 +31,13 @@ import net.minecraft.item.*;
import net.minecraft.util.DefaultedList;
import net.minecraft.world.World;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.api.power.ItemPowerManager;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo, ItemDurabilityExtensions {
@ -51,16 +51,11 @@ public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo,
// Item
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.LAPOTRONIC_ORBPACK);
ItemStack charged = new ItemStack(TRContent.LAPOTRONIC_ORBPACK);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.LAPOTRONIC_ORBPACK, itemList);
}
@Override

View file

@ -40,6 +40,7 @@ import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo, ItemDurabilityExtensions {
@ -91,16 +92,11 @@ public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo,
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.LITHIUM_ION_BATPACK);
ItemStack charged = new ItemStack(TRContent.LITHIUM_ION_BATPACK);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.LITHIUM_ION_BATPACK, itemList);
}
// IEnergyItemInfo

View file

@ -29,9 +29,9 @@ import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemEnergyCrystal extends ItemBattery {
@ -42,15 +42,10 @@ public class ItemEnergyCrystal extends ItemBattery {
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.ENERGY_CRYSTAL);
ItemStack charged = new ItemStack(TRContent.ENERGY_CRYSTAL);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.ENERGY_CRYSTAL, itemList);
}
}

View file

@ -29,9 +29,9 @@ import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemLapotronCrystal extends ItemBattery {
@ -42,15 +42,10 @@ public class ItemLapotronCrystal extends ItemBattery {
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
ItemStack charged = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.LAPOTRON_CRYSTAL, itemList);
}
}

View file

@ -29,9 +29,9 @@ import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemLapotronicOrb extends ItemBattery {
@ -42,15 +42,10 @@ public class ItemLapotronicOrb extends ItemBattery {
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.LAPOTRONIC_ORB);
ItemStack charged = new ItemStack(TRContent.LAPOTRONIC_ORB);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.LAPOTRONIC_ORB, itemList);
}
}

View file

@ -29,8 +29,8 @@ import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemLithiumIonBattery extends ItemBattery {
@ -41,16 +41,11 @@ public class ItemLithiumIonBattery extends ItemBattery {
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
ItemStack charged = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.LITHIUM_ION_BATTERY, itemList);
}
}

View file

@ -29,8 +29,8 @@ import net.fabricmc.api.Environment;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
public class ItemRedCellBattery extends ItemBattery {
@ -41,15 +41,10 @@ public class ItemRedCellBattery extends ItemBattery {
@Environment(EnvType.CLIENT)
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> items) {
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> itemList) {
if (!isIn(group)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.RED_CELL_BATTERY);
ItemStack charged = new ItemStack(TRContent.RED_CELL_BATTERY);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
items.add(uncharged);
items.add(charged);
InitUtils.initPoweredItems(TRContent.RED_CELL_BATTERY, itemList);
}
}

View file

@ -32,10 +32,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemChainsaw;
import techreborn.utils.InitUtils;
public class ItemAdvancedChainsaw extends ItemChainsaw {
@ -52,13 +52,7 @@ public class ItemAdvancedChainsaw extends ItemChainsaw {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.ADVANCED_CHAINSAW);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.ADVANCED_CHAINSAW, itemList);
}
@Override

View file

@ -32,10 +32,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemDrill;
import techreborn.utils.InitUtils;
public class ItemAdvancedDrill extends ItemDrill {
@ -52,13 +52,7 @@ public class ItemAdvancedDrill extends ItemDrill {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.ADVANCED_DRILL);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.ADVANCED_DRILL, itemList);
}
@Override

View file

@ -30,10 +30,10 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemJackhammer;
import techreborn.utils.InitUtils;
public class ItemAdvancedJackhammer extends ItemJackhammer {
@ -50,12 +50,6 @@ public class ItemAdvancedJackhammer extends ItemJackhammer {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.ADVANCED_JACKHAMMER);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.ADVANCED_JACKHAMMER, itemList);
}
}

View file

@ -139,7 +139,7 @@ public class ItemRockCutter extends PickaxeItem implements IEnergyItemInfo, Item
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(uncharged);
// itemList.add(charged);
itemList.add(charged);
}
// IEnergyItemInfo

View file

@ -32,10 +32,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemChainsaw;
import techreborn.utils.InitUtils;
public class ItemBasicChainsaw extends ItemChainsaw {
@ -50,13 +50,7 @@ public class ItemBasicChainsaw extends ItemChainsaw {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.BASIC_CHAINSAW);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.BASIC_CHAINSAW, itemList);
}
@Override

View file

@ -32,10 +32,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemDrill;
import techreborn.utils.InitUtils;
public class ItemBasicDrill extends ItemDrill {
@ -50,13 +50,7 @@ public class ItemBasicDrill extends ItemDrill {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.BASIC_DRILL);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.BASIC_DRILL, itemList);
}
@Override

View file

@ -30,10 +30,10 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemJackhammer;
import techreborn.utils.InitUtils;
public class ItemBasicJackhammer extends ItemJackhammer {
@ -48,12 +48,6 @@ public class ItemBasicJackhammer extends ItemJackhammer {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.BASIC_JACKHAMMER);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.BASIC_JACKHAMMER, itemList);
}
}

View file

@ -31,13 +31,13 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.api.power.ItemPowerManager;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
/**
* Created by modmuss50 on 05/11/2016.
@ -72,13 +72,7 @@ public class ItemElectricTreetap extends Item implements IEnergyItemInfo, ItemDu
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.ELECTRIC_TREE_TAP);
ItemStack charged = new ItemStack(TRContent.ELECTRIC_TREE_TAP);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(uncharged);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.ELECTRIC_TREE_TAP, itemList);
}
// IEnergyItemInfo

View file

@ -51,6 +51,7 @@ import reborncore.common.util.ItemUtils;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemChainsaw;
import techreborn.utils.InitUtils;
import techreborn.utils.MessageIDs;
import techreborn.utils.TagUtils;
@ -76,13 +77,7 @@ public class ItemIndustrialChainsaw extends ItemChainsaw {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.INDUSTRIAL_CHAINSAW);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.INDUSTRIAL_CHAINSAW, itemList);
}
@Override

View file

@ -54,6 +54,7 @@ import reborncore.common.util.ItemUtils;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemDrill;
import techreborn.utils.InitUtils;
import techreborn.utils.MessageIDs;
import javax.annotation.Nullable;
@ -71,7 +72,7 @@ public class ItemIndustrialDrill extends ItemDrill {
this.transferLimit = 1000;
}
public Set<BlockPos> getTargetBlocks(World worldIn, BlockPos pos, @Nullable PlayerEntity playerIn) {
private Set<BlockPos> getTargetBlocks(World worldIn, BlockPos pos, @Nullable PlayerEntity playerIn) {
Set<BlockPos> targetBlocks = new HashSet<BlockPos>();
if (playerIn == null) {
return new HashSet<>();
@ -117,7 +118,7 @@ public class ItemIndustrialDrill extends ItemDrill {
return targetBlocks;
}
public void breakBlock(BlockPos pos, World world, PlayerEntity playerIn, ItemStack drill) {
private void breakBlock(BlockPos pos, World world, PlayerEntity playerIn, ItemStack drill) {
BlockState blockState = world.getBlockState(pos);
ItemPowerManager capEnergy = new ItemPowerManager(drill);
@ -243,12 +244,6 @@ public class ItemIndustrialDrill extends ItemDrill {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.INDUSTRIAL_DRILL);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.INDUSTRIAL_DRILL, itemList);
}
}

View file

@ -30,10 +30,10 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.DefaultedList;
import reborncore.api.power.ItemPowerManager;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.items.tool.ItemJackhammer;
import techreborn.utils.InitUtils;
public class ItemIndustrialJackhammer extends ItemJackhammer {
@ -51,12 +51,6 @@ public class ItemIndustrialJackhammer extends ItemJackhammer {
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack stack = new ItemStack(TRContent.INDUSTRIAL_JACKHAMMER);
ItemStack charged = stack.copy();
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(stack);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.INDUSTRIAL_JACKHAMMER, itemList);
}
}

View file

@ -49,6 +49,7 @@ import reborncore.common.util.TorchHelper;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
import techreborn.utils.InitUtils;
import javax.annotation.Nullable;
import java.util.List;
@ -157,13 +158,7 @@ public class ItemOmniTool extends PickaxeItem implements IEnergyItemInfo, ItemDu
if (!isIn(par2ItemGroup)) {
return;
}
ItemStack uncharged = new ItemStack(TRContent.OMNI_TOOL);
ItemStack charged = new ItemStack(TRContent.OMNI_TOOL);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(uncharged);
itemList.add(charged);
InitUtils.initPoweredItems(TRContent.OMNI_TOOL, itemList);
}
// IEnergyItemInfo

View file

@ -26,10 +26,13 @@ package techreborn.utils;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import reborncore.RebornRegistry;
import reborncore.api.power.ItemPowerManager;
import techreborn.TechReborn;
public class InitUtils {
@ -47,4 +50,14 @@ public class InitUtils {
Identifier identifier = new Identifier(TechReborn.MOD_ID, name);
return Registry.register(Registry.SOUND_EVENT, identifier, new SoundEvent(identifier));
}
public static void initPoweredItems(Item item, DefaultedList<ItemStack> itemList) {
ItemStack uncharged = new ItemStack(item);
ItemStack charged = new ItemStack(item);
ItemPowerManager capEnergy = new ItemPowerManager(charged);
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
itemList.add(uncharged);
itemList.add(charged);
}
}