Migrated batteries + TR Itemgroup
This commit is contained in:
parent
0c99a94250
commit
e513e20e5a
16 changed files with 101 additions and 108 deletions
|
@ -26,10 +26,13 @@ package techreborn;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockDispenser;
|
import net.minecraft.block.BlockDispenser;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
@ -84,12 +87,13 @@ public class TechReborn {
|
||||||
public static TechRebornWorldGen worldGen;
|
public static TechRebornWorldGen worldGen;
|
||||||
public static File configDir;
|
public static File configDir;
|
||||||
|
|
||||||
// public static final CreativeTabs TAB = new CreativeTabs(MOD_ID) {
|
public static final ItemGroup ITEMGROUP = new ItemGroup(-1, MOD_ID) {
|
||||||
// @Override
|
@OnlyIn(Dist.CLIENT)
|
||||||
// public ItemStack createIcon() {
|
public ItemStack createIcon() {
|
||||||
// return TRContent.Parts.MACHINE_PARTS.getStack();
|
return TRContent.Parts.MACHINE_PARTS.getStack();
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
|
||||||
|
|
||||||
public TechReborn() {
|
public TechReborn() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.world.RubberTreeGenerator;
|
import techreborn.world.RubberTreeGenerator;
|
||||||
|
|
||||||
|
@ -47,8 +48,8 @@ public class BlockRubberSapling extends BlockSapling {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) {
|
public void grow(IWorld worldIn, BlockPos pos, IBlockState state, Random rand) {
|
||||||
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) {
|
if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(worldIn, rand, pos)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
|
|
|
@ -38,8 +38,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.api.ToolManager;
|
import reborncore.api.ToolManager;
|
||||||
|
@ -55,7 +55,7 @@ public class BlockLamp extends BaseTileBlock {
|
||||||
|
|
||||||
public static DirectionProperty FACING;
|
public static DirectionProperty FACING;
|
||||||
public static BooleanProperty ACTIVE;
|
public static BooleanProperty ACTIVE;
|
||||||
private AxisAlignedBB[] bbs;
|
protected final VoxelShape[] shape;
|
||||||
|
|
||||||
private int cost;
|
private int cost;
|
||||||
private int brightness;
|
private int brightness;
|
||||||
|
@ -63,23 +63,23 @@ public class BlockLamp extends BaseTileBlock {
|
||||||
public BlockLamp(int brightness, int cost, double depth, double width) {
|
public BlockLamp(int brightness, int cost, double depth, double width) {
|
||||||
super(Block.Properties.create(Material.REDSTONE_LIGHT));
|
super(Block.Properties.create(Material.REDSTONE_LIGHT));
|
||||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, EnumFacing.NORTH).with(ACTIVE, false));
|
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, EnumFacing.NORTH).with(ACTIVE, false));
|
||||||
this.bbs = GenBoundingBoxes(depth, width);
|
this.shape = GenCuboidShapes(depth, width);
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
this.brightness = brightness;
|
this.brightness = brightness;
|
||||||
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/lighting"));
|
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/lighting"));
|
||||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AxisAlignedBB[] GenBoundingBoxes(double depth, double width) {
|
private VoxelShape[] GenCuboidShapes(double depth, double width) {
|
||||||
AxisAlignedBB[] bb = {
|
VoxelShape[] shapes = {
|
||||||
new AxisAlignedBB(width, 1.0 - depth, width, 1.0 - width, 1.0D, 1.0 - width),
|
Block.makeCuboidShape(width, 1.0 - depth, width, 1.0 - width, 1.0D, 1.0 - width),
|
||||||
new AxisAlignedBB(width, 0.0D, width, 1.0 - width, depth, 1.0 - width),
|
Block.makeCuboidShape(width, 0.0D, width, 1.0 - width, depth, 1.0 - width),
|
||||||
new AxisAlignedBB(width, width, 1.0 - depth, 1.0 - width, 1.0 - width, 1.0D),
|
Block.makeCuboidShape(width, width, 1.0 - depth, 1.0 - width, 1.0 - width, 1.0D),
|
||||||
new AxisAlignedBB(width, width, 0.0D, 1.0 - width, 1.0 - width, depth),
|
Block.makeCuboidShape(width, width, 0.0D, 1.0 - width, 1.0 - width, depth),
|
||||||
new AxisAlignedBB(1.0 - depth, width, width, 1.0D, 1.0 - width, 1.0 - width),
|
Block.makeCuboidShape(1.0 - depth, width, width, 1.0D, 1.0 - width, 1.0 - width),
|
||||||
new AxisAlignedBB(0.0D, width, width, depth, 1.0 - width, 1.0 - width),
|
Block.makeCuboidShape(0.0D, width, width, depth, 1.0 - width, 1.0 - width),
|
||||||
};
|
};
|
||||||
return bb;
|
return shapes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActive(IBlockState state) {
|
public static boolean isActive(IBlockState state) {
|
||||||
|
@ -149,8 +149,8 @@ public class BlockLamp extends BaseTileBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockReader worldIn, BlockPos pos) {
|
public VoxelShape getShape(IBlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||||
return this.bbs[getFacing(state).getIndex()];
|
return shape[getFacing(state).getIndex()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|
|
@ -97,24 +97,24 @@ public class RegistryEventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||||
Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block));
|
Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties()));
|
||||||
Arrays.stream(StorageBlocks.values()).forEach(value -> RebornRegistry.registerBlock(value.block));
|
Arrays.stream(StorageBlocks.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties()));
|
||||||
Arrays.stream(MachineBlocks.values()).forEach(value -> {
|
Arrays.stream(MachineBlocks.values()).forEach(value -> {
|
||||||
RebornRegistry.registerBlock(value.frame);
|
RebornRegistry.registerBlock(value.frame, new Item.Properties());
|
||||||
RebornRegistry.registerBlock(value.casing);
|
RebornRegistry.registerBlock(value.casing, new Item.Properties());
|
||||||
});
|
});
|
||||||
Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block));
|
Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties()));
|
||||||
Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block));
|
Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties()));
|
||||||
Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block));
|
Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties()));
|
||||||
|
|
||||||
// Misc. blocks
|
// Misc. blocks
|
||||||
RebornRegistry.registerBlock(TRContent.COMPUTER_CUBE = InitUtils.setup(new BlockComputerCube(), "computer_cube"));
|
RebornRegistry.registerBlock(TRContent.COMPUTER_CUBE = InitUtils.setup(new BlockComputerCube(), "computer_cube"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.NUKE = InitUtils.setup(new BlockNuke(), "nuke"));
|
RebornRegistry.registerBlock(TRContent.NUKE = InitUtils.setup(new BlockNuke(), "nuke"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.REFINED_IRON_FENCE = InitUtils.setup(new BlockRefinedIronFence(), "refined_iron_fence"));
|
RebornRegistry.registerBlock(TRContent.REFINED_IRON_FENCE = InitUtils.setup(new BlockRefinedIronFence(), "refined_iron_fence"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"));
|
RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"));
|
RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"));
|
RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"));
|
RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), new Item.Properties());
|
||||||
RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"),
|
RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"),
|
||||||
ItemBlockRubberSapling.class,
|
ItemBlockRubberSapling.class,
|
||||||
"rubber_sapling");
|
"rubber_sapling");
|
||||||
|
@ -123,7 +123,7 @@ public class RegistryEventHandler {
|
||||||
new ItemSlab(TRContent.RUBBER_LOG_SLAB_HALF, (BlockSlab) TRContent.RUBBER_LOG_SLAB_HALF, (BlockSlab) TRContent.RUBBER_LOG_SLAB_DOUBLE),
|
new ItemSlab(TRContent.RUBBER_LOG_SLAB_HALF, (BlockSlab) TRContent.RUBBER_LOG_SLAB_HALF, (BlockSlab) TRContent.RUBBER_LOG_SLAB_DOUBLE),
|
||||||
"rubber_plank_double_slab");
|
"rubber_plank_double_slab");
|
||||||
RebornRegistry.registerBlock(TRContent.RUBBER_LOG_STAIR = InitUtils.setup(new BlockRubberPlankStair(TRContent.RUBBER_LOG.getDefaultState(), "rubber_plank"),
|
RebornRegistry.registerBlock(TRContent.RUBBER_LOG_STAIR = InitUtils.setup(new BlockRubberPlankStair(TRContent.RUBBER_LOG.getDefaultState(), "rubber_plank"),
|
||||||
"rubber_plank_stair"));
|
"rubber_plank_stair"), new Item.Properties());
|
||||||
|
|
||||||
TechReborn.LOGGER.debug("TechReborns Blocks Loaded");
|
TechReborn.LOGGER.debug("TechReborns Blocks Loaded");
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ public class TRContent {
|
||||||
|
|
||||||
private Dusts() {
|
private Dusts() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name + "_dust");
|
InitUtils.setup(item, name + "_dust");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ public class TRContent {
|
||||||
|
|
||||||
private SmallDusts() {
|
private SmallDusts() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name + "_small_dust");
|
InitUtils.setup(item, name + "_small_dust");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ public class TRContent {
|
||||||
|
|
||||||
private Gems() {
|
private Gems() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name + "_gem");
|
InitUtils.setup(item, name + "_gem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ public class TRContent {
|
||||||
|
|
||||||
private Ingots() {
|
private Ingots() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name + "_ingot");
|
InitUtils.setup(item, name + "_ingot");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ public class TRContent {
|
||||||
|
|
||||||
private Nuggets() {
|
private Nuggets() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name + "_nugget");
|
InitUtils.setup(item, name + "_nugget");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ public class TRContent {
|
||||||
|
|
||||||
private Parts() {
|
private Parts() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name);
|
InitUtils.setup(item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ public class TRContent {
|
||||||
|
|
||||||
private Plates() {
|
private Plates() {
|
||||||
name = this.toString().toLowerCase();
|
name = this.toString().toLowerCase();
|
||||||
item = new Item();
|
item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP));
|
||||||
InitUtils.setup(item, name + "_plate");
|
InitUtils.setup(item, name + "_plate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import reborncore.api.tile.IUpgrade;
|
import reborncore.api.tile.IUpgrade;
|
||||||
import reborncore.common.recipes.IUpgradeHandler;
|
import reborncore.common.recipes.IUpgradeHandler;
|
||||||
import reborncore.common.tile.TileMachineBase;
|
import reborncore.common.tile.TileMachineBase;
|
||||||
|
import techreborn.TechReborn;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -39,9 +40,9 @@ public class ItemUpgrade extends Item implements IUpgrade {
|
||||||
public final IUpgrade behavior;
|
public final IUpgrade behavior;
|
||||||
|
|
||||||
public ItemUpgrade(String name, IUpgrade process) {
|
public ItemUpgrade(String name, IUpgrade process) {
|
||||||
|
super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(16));
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.behavior = process;
|
this.behavior = process;
|
||||||
setMaxStackSize(16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,9 +52,7 @@ public class ItemLapotronicOrbpack extends ItemArmor implements IEnergyItemInfo
|
||||||
public int transferLimit = 100_000;
|
public int transferLimit = 100_000;
|
||||||
|
|
||||||
public ItemLapotronicOrbpack() {
|
public ItemLapotronicOrbpack() {
|
||||||
super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST, (new Item.Builder()).group(ItemGroup.COMBAT));
|
super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST, new Item.Properties().maxStackSize(1));
|
||||||
//TODO: move to builder
|
|
||||||
//setMaxStackSize(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item
|
// Item
|
||||||
|
|
|
@ -56,9 +56,7 @@ public class ItemLithiumIonBatpack extends ItemArmor implements IEnergyItemInfo
|
||||||
public int transferLimit = 2_000;
|
public int transferLimit = 2_000;
|
||||||
|
|
||||||
public ItemLithiumIonBatpack() {
|
public ItemLithiumIonBatpack() {
|
||||||
super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST, (new Item.Builder()).group(ItemGroup.COMBAT));
|
super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST, new Item.Properties().maxStackSize(1));
|
||||||
//TODO: move to builder
|
|
||||||
//setMaxStackSize(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void distributePowerToInventory(World world, EntityPlayer player, ItemStack itemStack, int maxSend) {
|
public static void distributePowerToInventory(World world, EntityPlayer player, ItemStack itemStack, int maxSend) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.items.armor;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
|
import techreborn.TechReborn;
|
||||||
import techreborn.events.TRRecipeHandler;
|
import techreborn.events.TRRecipeHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +42,7 @@ public class ItemTRArmour extends ItemArmor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemTRArmour(IArmorMaterial material, EntityEquipmentSlot slot, String repairOreDict) {
|
public ItemTRArmour(IArmorMaterial material, EntityEquipmentSlot slot, String repairOreDict) {
|
||||||
super(material, slot, (new Item.Properties()).group(ItemGroup.COMBAT));
|
super(material, slot, (new Item.Properties()).group(TechReborn.ITEMGROUP).maxStackSize(1));
|
||||||
this.repairOreDict = repairOreDict;
|
this.repairOreDict = repairOreDict;
|
||||||
if (slot == EntityEquipmentSlot.HEAD)
|
if (slot == EntityEquipmentSlot.HEAD)
|
||||||
//setTranslationKey(material.name().toLowerCase() + "Helmet");
|
//setTranslationKey(material.name().toLowerCase() + "Helmet");
|
||||||
|
|
|
@ -39,6 +39,7 @@ import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.powerSystem.PoweredItemContainerProvider;
|
import reborncore.common.powerSystem.PoweredItemContainerProvider;
|
||||||
import reborncore.common.powerSystem.forge.ForgePowerItemManager;
|
import reborncore.common.powerSystem.forge.ForgePowerItemManager;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
|
import techreborn.TechReborn;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -48,15 +49,13 @@ public class ItemBattery extends Item implements IEnergyItemInfo {
|
||||||
int maxTransfer = 0;
|
int maxTransfer = 0;
|
||||||
|
|
||||||
public ItemBattery(int maxEnergy, int maxTransfer) {
|
public ItemBattery(int maxEnergy, int maxTransfer) {
|
||||||
super();
|
super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1).defaultMaxDamage(1));
|
||||||
setMaxStackSize(1);
|
|
||||||
setMaxDamage(1);
|
|
||||||
this.maxEnergy = maxEnergy;
|
this.maxEnergy = maxEnergy;
|
||||||
this.maxTransfer = maxTransfer;
|
this.maxTransfer = maxTransfer;
|
||||||
this.addPropertyOverride(new ResourceLocation("techreborn:empty"), new IItemPropertyGetter() {
|
this.addPropertyOverride(new ResourceLocation("techreborn:empty"), new IItemPropertyGetter() {
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@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) {
|
if (!stack.isEmpty() && new ForgePowerItemManager(stack).getEnergyStored() == 0) {
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
package techreborn.items.battery;
|
package techreborn.items.battery;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -42,16 +42,15 @@ public class ItemEnergyCrystal extends ItemBattery {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
if (!isInGroup(group)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = new ItemStack(TRContent.ENERGY_CRYSTAL);
|
ItemStack uncharged = new ItemStack(TRContent.ENERGY_CRYSTAL);
|
||||||
ItemStack charged = stack.copy();
|
ItemStack charged = new ItemStack(TRContent.ENERGY_CRYSTAL);
|
||||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||||
|
items.add(uncharged);
|
||||||
itemList.add(stack);
|
items.add(charged);
|
||||||
itemList.add(charged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
package techreborn.items.battery;
|
package techreborn.items.battery;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -42,16 +42,15 @@ public class ItemLapotronCrystal extends ItemBattery {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
if (!isInGroup(group)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
|
ItemStack uncharged = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
|
||||||
ItemStack charged = stack.copy();
|
ItemStack charged = new ItemStack(TRContent.LAPOTRON_CRYSTAL);
|
||||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||||
|
items.add(uncharged);
|
||||||
itemList.add(stack);
|
items.add(charged);
|
||||||
itemList.add(charged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
package techreborn.items.battery;
|
package techreborn.items.battery;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -42,16 +42,15 @@ public class ItemLapotronicOrb extends ItemBattery {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
if (!isInGroup(group)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = new ItemStack(TRContent.LAPOTRONIC_ORB);
|
ItemStack uncharged = new ItemStack(TRContent.LAPOTRONIC_ORB);
|
||||||
ItemStack charged = stack.copy();
|
ItemStack charged = new ItemStack(TRContent.LAPOTRONIC_ORB);
|
||||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||||
|
items.add(uncharged);
|
||||||
itemList.add(stack);
|
items.add(charged);
|
||||||
itemList.add(charged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
package techreborn.items.battery;
|
package techreborn.items.battery;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -41,17 +41,16 @@ public class ItemLithiumIonBattery extends ItemBattery {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
if (!isInGroup(group)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
ItemStack uncharged = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
||||||
ItemStack charged = stack.copy();
|
ItemStack charged = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
||||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||||
|
items.add(uncharged);
|
||||||
itemList.add(stack);
|
items.add(charged);
|
||||||
itemList.add(charged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
package techreborn.items.battery;
|
package techreborn.items.battery;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -41,16 +41,15 @@ public class ItemRedCellBattery extends ItemBattery {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
if (!isInGroup(group)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = new ItemStack(TRContent.LITHIUM_ION_BATTERY);
|
ItemStack uncharged = new ItemStack(TRContent.RED_CELL_BATTERY);
|
||||||
ItemStack charged = stack.copy();
|
ItemStack charged = new ItemStack(TRContent.RED_CELL_BATTERY);
|
||||||
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
ForgePowerItemManager capEnergy = new ForgePowerItemManager(charged);
|
||||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||||
|
items.add(uncharged);
|
||||||
itemList.add(stack);
|
items.add(charged);
|
||||||
itemList.add(charged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,11 @@ import techreborn.TechReborn;
|
||||||
public class InitUtils {
|
public class InitUtils {
|
||||||
public static <I extends Item> I setup(I item, String name) {
|
public static <I extends Item> I setup(I item, String name) {
|
||||||
item.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, name));
|
item.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, name));
|
||||||
item.setTranslationKey(TechReborn.MOD_ID + "." + name);
|
|
||||||
item.setCreativeTab(TechReborn.TAB);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <B extends Block> B setup(B block, String name) {
|
public static <B extends Block> B setup(B block, String name) {
|
||||||
block.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, name));
|
block.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, name));
|
||||||
block.setTranslationKey(TechReborn.MOD_ID + "." + name);
|
|
||||||
block.setCreativeTab(TechReborn.TAB);
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue