Energy storages item charging fixes, transformers fixes, electric items fixes.

This commit is contained in:
Dragon2488 2016-07-25 15:10:55 +07:00
parent b42b5274b5
commit be4f10b975
63 changed files with 2154 additions and 2123 deletions

View file

@ -0,0 +1,18 @@
package techreborn.blocks.transformers;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.tiles.transformers.TileEVTransformer;
public class BlockEVTransformer extends BlockTransformer {
public BlockEVTransformer() {
super("evtransformer");
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEVTransformer();
}
}

View file

@ -1,42 +1,21 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileHVTransformer;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Created by modmuss50 on 16/03/2016.
*/
public class BlockHVTransformer extends BlockTransformer
{
public class BlockHVTransformer extends BlockTransformer {
public BlockHVTransformer()
{
super("hvtransformer");
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_)
{
return new TileHVTransformer();
}
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.machineframe, 1 , 7));
return list;
}
public BlockHVTransformer() {
super("hvtransformer");
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileHVTransformer();
}
}

View file

@ -1,40 +1,21 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.tiles.transformers.TileLVTransformer;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Created by modmuss50 on 16/03/2016.
*/
public class BlockLVTransformer extends BlockTransformer
{
public class BlockLVTransformer extends BlockTransformer {
public BlockLVTransformer()
{
super("lvtransformer");
}
public BlockLVTransformer() {
super("lvtransformer");
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_)
{
return new TileLVTransformer();
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileLVTransformer();
}
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(this, 1 , 0));
return list;
}
}

View file

@ -1,41 +1,22 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileMVTransformer;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Created by modmuss50 on 16/03/2016.
*/
public class BlockMVTransformer extends BlockTransformer
{
public class BlockMVTransformer extends BlockTransformer {
public BlockMVTransformer()
{
super("mvtransformer");
}
public BlockMVTransformer() {
super("mvtransformer");
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileMVTransformer();
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_)
{
return new TileMVTransformer();
}
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.machineframe, 1 , 6));
return list;
}
}

View file

@ -32,292 +32,239 @@ import java.util.Random;
/**
* Created by Rushmead
*/
public abstract class BlockTransformer extends BaseTileBlock implements IRotationTexture, ITexturedBlock
{
public static PropertyDirection FACING = PropertyDirection.create("facing", Facings.ALL);
protected final String prefix = "techreborn:blocks/machine/storage/";
public String name;
public abstract class BlockTransformer extends BaseTileBlock implements IRotationTexture, ITexturedBlock {
public static PropertyDirection FACING = PropertyDirection.create("facing", Facings.ALL);
protected final String prefix = "techreborn:blocks/machine/storage/";
public String name;
public BlockTransformer(String name)
{
super(Material.ROCK);
setHardness(2f);
setUnlocalizedName("techreborn." + name.toLowerCase());
setCreativeTab(TechRebornCreativeTab.instance);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
this.name = name;
}
protected BlockStateContainer createBlockState()
{
FACING = PropertyDirection.create("facing", Facings.ALL);
return new BlockStateContainer(this, FACING);
}
public BlockTransformer(String name) {
super(Material.ROCK);
setHardness(2f);
setUnlocalizedName("techreborn." + name.toLowerCase());
setCreativeTab(TechRebornCreativeTab.instance);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
this.name = name;
}
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
super.onBlockAdded(worldIn, pos, state);
this.setDefaultFacing(worldIn, pos, state);
}
protected BlockStateContainer createBlockState() {
FACING = PropertyDirection.create("facing", Facings.ALL);
return new BlockStateContainer(this, FACING);
}
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
if (!worldIn.isRemote)
{
IBlockState sate = worldIn.getBlockState(pos.north());
Block block = sate.getBlock();
IBlockState state1 = worldIn.getBlockState(pos.south());
Block block1 = state1.getBlock();
IBlockState state2 = worldIn.getBlockState(pos.west());
Block block2 = state2.getBlock();
IBlockState state3 = worldIn.getBlockState(pos.east());
Block block3 = state3.getBlock();
EnumFacing enumfacing = state.getValue(FACING);
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
super.onBlockAdded(worldIn, pos, state);
this.setDefaultFacing(worldIn, pos, state);
}
if (enumfacing == EnumFacing.NORTH && block.isFullBlock(state) && !block1.isFullBlock(state1))
{
enumfacing = EnumFacing.SOUTH;
} else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock(state1) && !block.isFullBlock(state))
{
enumfacing = EnumFacing.NORTH;
} else if (enumfacing == EnumFacing.WEST && block2.isFullBlock(state2) && !block3.isFullBlock(state2))
{
enumfacing = EnumFacing.EAST;
} else if (enumfacing == EnumFacing.EAST && block3.isFullBlock(state3) && !block2.isFullBlock(state2))
{
enumfacing = EnumFacing.WEST;
}
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) {
if (!worldIn.isRemote) {
IBlockState sate = worldIn.getBlockState(pos.north());
Block block = sate.getBlock();
IBlockState state1 = worldIn.getBlockState(pos.south());
Block block1 = state1.getBlock();
IBlockState state2 = worldIn.getBlockState(pos.west());
Block block2 = state2.getBlock();
IBlockState state3 = worldIn.getBlockState(pos.east());
Block block3 = state3.getBlock();
EnumFacing enumfacing = state.getValue(FACING);
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
}
if (enumfacing == EnumFacing.NORTH && block.isFullBlock(state) && !block1.isFullBlock(state1)) {
enumfacing = EnumFacing.SOUTH;
} else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock(state1) && !block.isFullBlock(state)) {
enumfacing = EnumFacing.NORTH;
} else if (enumfacing == EnumFacing.WEST && block2.isFullBlock(state2) && !block3.isFullBlock(state2)) {
enumfacing = EnumFacing.EAST;
} else if (enumfacing == EnumFacing.EAST && block3.isFullBlock(state3) && !block2.isFullBlock(state2)) {
enumfacing = EnumFacing.WEST;
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
ItemStack stack)
{
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
EnumFacing facing = placer.getHorizontalFacing().getOpposite();
if (placer.rotationPitch < -50)
{
facing = EnumFacing.DOWN;
} else if (placer.rotationPitch > 50)
{
facing = EnumFacing.UP;
}
setFacing(facing, worldIn, pos);
}
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
ItemStack stack) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
EnumFacing facing = placer.getHorizontalFacing().getOpposite();
if (placer.rotationPitch < -50) {
facing = EnumFacing.DOWN;
} else if (placer.rotationPitch > 50) {
facing = EnumFacing.UP;
}
setFacing(facing, worldIn, pos);
}
protected List<ItemStack> dropInventory(IBlockAccess world, BlockPos pos, ItemStack itemToDrop) {
TileEntity tileEntity = world.getTileEntity(pos);
protected List<ItemStack> dropInventory(IBlockAccess world, BlockPos pos, ItemStack itemToDrop)
{
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity == null) {
System.out.print("Null");
return null;
}
if (!(tileEntity instanceof IInventory)) {
if (tileEntity == null)
{
System.out.print("Null");
return null;
}
if (!(tileEntity instanceof IInventory))
{
System.out.print("Not Instance");
return null;
}
System.out.print("Not INstance");
return null;
}
IInventory inventory = (IInventory) tileEntity;
IInventory inventory = (IInventory) tileEntity;
List<ItemStack> items = new ArrayList<>();
List<ItemStack> items = new ArrayList<>();
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack itemStack = inventory.getStackInSlot(i);
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack == null) {
continue;
}
if (itemStack != null && itemStack.stackSize > 0) {
if (itemStack.getItem() instanceof ItemBlock) {
if (((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid) {
continue;
}
}
}
items.add(itemStack.copy());
}
items.add(itemToDrop.copy());
return items;
if (itemStack == null)
{
continue;
}
if (itemStack != null && itemStack.stackSize > 0)
{
if (itemStack.getItem() instanceof ItemBlock)
{
if (((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid)
{
continue;
}
}
}
items.add(itemStack.copy());
}
items.add(itemToDrop.copy());
return items;
}
}
@Override
public int getMetaFromState(IBlockState state)
{
int facingInt = getSideFromEnum(state.getValue(FACING));
return facingInt;
}
@Override
public int getMetaFromState(IBlockState state) {
int facingInt = getSideFromEnum(state.getValue(FACING));
return facingInt;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
boolean active = false;
EnumFacing facing = getSideFromint(meta);
return this.getDefaultState().withProperty(FACING, facing);
}
@Override
public IBlockState getStateFromMeta(int meta) {
boolean active = false;
EnumFacing facing = getSideFromint(meta);
return this.getDefaultState().withProperty(FACING, facing);
}
public void setFacing(EnumFacing facing, World world, BlockPos pos)
{
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
}
public void setFacing(EnumFacing facing, World world, BlockPos pos) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
}
public EnumFacing getSideFromint(int i)
{
if (i == 0)
{
return EnumFacing.NORTH;
} else if (i == 1)
{
return EnumFacing.SOUTH;
} else if (i == 2)
{
return EnumFacing.EAST;
} else if (i == 3)
{
return EnumFacing.WEST;
} else if (i == 4)
{
return EnumFacing.UP;
} else if (i == 5)
{
return EnumFacing.DOWN;
}
return EnumFacing.NORTH;
}
public EnumFacing getSideFromint(int i) {
if (i == 0) {
return EnumFacing.NORTH;
} else if (i == 1) {
return EnumFacing.SOUTH;
} else if (i == 2) {
return EnumFacing.EAST;
} else if (i == 3) {
return EnumFacing.WEST;
} else if (i == 4) {
return EnumFacing.UP;
} else if (i == 5) {
return EnumFacing.DOWN;
}
return EnumFacing.NORTH;
}
public int getSideFromEnum(EnumFacing facing)
{
if (facing == EnumFacing.NORTH)
{
return 0;
} else if (facing == EnumFacing.SOUTH)
{
return 1;
} else if (facing == EnumFacing.EAST)
{
return 2;
} else if (facing == EnumFacing.WEST)
{
return 3;
} else if (facing == EnumFacing.UP)
{
return 4;
} else if (facing == EnumFacing.DOWN)
{
return 5;
}
return 0;
}
public int getSideFromEnum(EnumFacing facing) {
if (facing == EnumFacing.NORTH) {
return 0;
} else if (facing == EnumFacing.SOUTH) {
return 1;
} else if (facing == EnumFacing.EAST) {
return 2;
} else if (facing == EnumFacing.WEST) {
return 3;
} else if (facing == EnumFacing.UP) {
return 4;
} else if (facing == EnumFacing.DOWN) {
return 5;
}
return 0;
}
@Override
public String getFrontOff()
{
return prefix + name.toLowerCase() + "_front";
}
@Override
public String getFrontOff() {
return prefix + name.toLowerCase() + "_front";
}
@Override
public String getFrontOn()
{
return prefix + name.toLowerCase() + "_front";
}
@Override
public String getFrontOn() {
return prefix + name.toLowerCase() + "_front";
}
@Override
public String getSide()
{
return prefix + name.toLowerCase() + "_side";
}
@Override
public String getSide() {
return prefix + name.toLowerCase() + "_side";
}
@Override
public String getTop()
{
return prefix + name.toLowerCase() + "_side";
}
@Override
public String getTop() {
return prefix + name.toLowerCase() + "_side";
}
@Override
public String getBottom()
{
return prefix + name.toLowerCase() + "_side";
}
@Override
public String getBottom() {
return prefix + name.toLowerCase() + "_side";
}
@Override
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing)
{
if (this instanceof IRotationTexture)
{
IRotationTexture rotationTexture = this;
if (getFacing(blockState) == facing)
{
return rotationTexture.getFrontOff();
}
if (facing == EnumFacing.UP)
{
return rotationTexture.getTop();
}
if (facing == EnumFacing.DOWN)
{
return rotationTexture.getBottom();
}
return rotationTexture.getSide();
}
return "techreborn:blocks/machine/machine_side";
}
@Override
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing) {
if (this instanceof IRotationTexture) {
IRotationTexture rotationTexture = this;
if (getFacing(blockState) == facing) {
return rotationTexture.getFrontOff();
}
if (facing == EnumFacing.UP) {
return rotationTexture.getTop();
}
if (facing == EnumFacing.DOWN) {
return rotationTexture.getBottom();
}
return rotationTexture.getSide();
}
return "techreborn:blocks/machine/machine_side";
}
public EnumFacing getFacing(IBlockState state)
{
return state.getValue(FACING);
}
public EnumFacing getFacing(IBlockState state) {
return state.getValue(FACING);
}
@Override
public int amountOfStates()
{
return 6;
}
@Override
public int amountOfStates() {
return 6;
}
public enum Facings implements Predicate<EnumFacing>, Iterable<EnumFacing> {
ALL;
public enum Facings implements Predicate<EnumFacing>,Iterable<EnumFacing>
{
ALL;
public EnumFacing[] facings() {
return new EnumFacing[]{
EnumFacing.NORTH, EnumFacing.EAST,
EnumFacing.SOUTH, EnumFacing.WEST,
EnumFacing.UP, EnumFacing.DOWN};
}
public EnumFacing[] facings()
{
return new EnumFacing[] { EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST,
EnumFacing.UP, EnumFacing.DOWN };
}
public EnumFacing random(Random rand) {
EnumFacing[] aenumfacing = this.facings();
return aenumfacing[rand.nextInt(aenumfacing.length)];
}
public EnumFacing random(Random rand)
{
EnumFacing[] aenumfacing = this.facings();
return aenumfacing[rand.nextInt(aenumfacing.length)];
}
public boolean apply(EnumFacing facing) {
return facing != null;
}
public boolean apply(EnumFacing p_apply_1_)
{
return p_apply_1_ != null;
}
public Iterator<EnumFacing> iterator() {
return Iterators.forArray(this.facings());
}
public Iterator<EnumFacing> iterator()
{
return Iterators.forArray(this.facings());
}
}
}
}

View file

@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.input.Keyboard;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import reborncore.common.util.Color;
import techreborn.Core;
@ -43,16 +43,16 @@ public class StackToolTipEvent
color = TextFormatting.YELLOW;
}
event.getToolTip().add(color + ""
+ PowerSystem.getLocalizedPower(
+ PowerLocalization.getLocalizedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getEnergy(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " stored");
event.getToolTip().add(Color.GREEN + ""
+ PowerSystem.getLocalizedPower(
+ PowerLocalization.getLocalizedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxPower(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " max");
event.getToolTip()
.add(TextFormatting.GREEN + "" + percentage + "%" + TextFormatting.LIGHT_PURPLE + " charged");
event.getToolTip().add(Color.GREEN + "" + PowerSystem.getLocalizedPower(
event.getToolTip().add(Color.GREEN + "" + PowerLocalization.getLocalizedPower(
(int) ((IEnergyInterfaceItem) event.getItemStack().getItem()).getMaxTransfer(event.getItemStack()))
+ TextFormatting.LIGHT_PURPLE + " /tick in/out");
}

View file

@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.packets.PacketHandler;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerAESU;
import techreborn.packets.PacketAesu;
import techreborn.tiles.TileAesu;
@ -60,11 +60,11 @@ public class GuiAESU extends GuiContainer
{
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.aesu.name"), 40, 10,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.euOut) + " /tick", 10, 20,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerAesu.euOut) + " /tick", 10, 20,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.storedEu) + " ", 10, 30,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerAesu.storedEu) + " ", 10, 30,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerAesu.euChange) + " change", 10, 40,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerAesu.euChange) + " change", 10, 40,
Color.WHITE.getRGB());
}

View file

@ -4,7 +4,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerBatbox;
import techreborn.tiles.storage.TileBatBox;
@ -64,9 +64,9 @@ public class GuiBatbox extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(generator.getMaxPower()), 25, this.ySize - 140,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(generator.getMaxPower()), 25, this.ySize - 140,
4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150,
4210752);
}
}

View file

@ -5,7 +5,7 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerDieselGenerator;
import techreborn.tiles.generator.TileDieselGenerator;
@ -49,7 +49,7 @@ public class GuiDieselGenerator extends GuiContainer
this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10, 30, 16448255);
this.fontRendererObj.drawString("Power Amount", 10, 40, 16448255);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerDieselGenerator.energy) + "", 10, 50,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerDieselGenerator.energy) + "", 10, 50,
16448255);
}
}

View file

@ -8,8 +8,7 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.api.reactor.FusionReactorRecipe;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerFusionReactor;
import techreborn.tiles.fusionReactor.TileEntityFusionController;
@ -30,7 +29,7 @@ public class GuiFusionReactor extends GuiContainer
this.fontRendererObj.drawString(name, 87, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerFusionReactor.energy), 11, 8, 16448255);
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerFusionReactor.energy), 11, 8, 16448255);
this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.hasCoils ? "Yes" : "No"), 11, 16, 16448255);
if(containerFusionReactor.tickTime != -1) {

View file

@ -4,7 +4,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerGenerator;
import techreborn.tiles.generator.TileGenerator;
@ -62,7 +62,7 @@ public class GuiGenerator extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerGenerator.energy), 25, this.ySize - 150,
4210752);
}
}

View file

@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.packets.PacketHandler;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerIDSU;
import techreborn.packets.PacketIdsu;
import techreborn.tiles.idsu.TileIDSU;
@ -85,11 +85,11 @@ public class GuiIDSU extends GuiContainer
{
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.idsu.name"), 75, 10,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.euOut) + "/tick", 10, 22,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerIDSU.euOut) + "/tick", 10, 22,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.storedEu), 10, 32,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerIDSU.storedEu), 10, 32,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerIDSU.euChange) + " change", 10, 42,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerIDSU.euChange) + " change", 10, 42,
Color.WHITE.getRGB());
}

View file

@ -7,7 +7,7 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerLESU;
import techreborn.tiles.lesu.TileLesu;
@ -43,14 +43,14 @@ public class GuiLESU extends GuiContainer
{
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.lesu.name"), 40, 10,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.euOut) + "/t", 10, 20,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerLesu.euOut) + "/t", 10, 20,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.storedEu), 10, 30,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerLesu.storedEu), 10, 30,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.euChange) + " change", 10, 40,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerLesu.euChange) + " change", 10, 40,
Color.WHITE.getRGB());
this.fontRendererObj.drawString(containerLesu.connectedBlocks + " blocks", 10, 50, Color.WHITE.getRGB());
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerLesu.euStorage) + " max", 10, 60,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerLesu.euStorage) + " max", 10, 60,
Color.WHITE.getRGB());
}

View file

@ -4,7 +4,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerMFE;
import techreborn.tiles.storage.TileMFE;
@ -66,9 +66,9 @@ public class GuiMFE extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(generator.getMaxPower()), 110, this.ySize - 150,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(generator.getMaxPower()), 110, this.ySize - 150,
4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160,
4210752);
}
}

View file

@ -4,7 +4,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.container.ContainerMFSU;
import techreborn.tiles.storage.TileMFSU;
@ -66,9 +66,9 @@ public class GuiMFSU extends GuiContainer
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(generator.getMaxPower()), 110, this.ySize - 150,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(generator.getMaxPower()), 110, this.ySize - 150,
4210752);
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160,
this.fontRendererObj.drawString(PowerLocalization.getLocalizedPower(containerGenerator.energy), 110, this.ySize - 160,
4210752);
}
}

View file

@ -17,7 +17,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import reborncore.common.util.Color;
import techreborn.client.keybindings.KeyBindings;
import techreborn.config.ConfigTechReborn;
@ -80,8 +80,8 @@ public class ChargeHud
{
color = Color.DARK_RED;
}
mc.fontRendererObj.drawString(color + PowerSystem.getLocalizedPower(CurrentCharge) + "/"
+ PowerSystem.getLocalizedPower(MaxCharge), 20, y, 0);
mc.fontRendererObj.drawString(color + PowerLocalization.getLocalizedPower(CurrentCharge) + "/"
+ PowerLocalization.getLocalizedPower(MaxCharge), 20, y, 0);
y += 20;
}
@ -108,8 +108,8 @@ public class ChargeHud
{
color = Color.DARK_RED;
}
mc.fontRendererObj.drawString(color + PowerSystem.getLocalizedPower(CurrentCharge) + "/"
+ PowerSystem.getLocalizedPower(MaxCharge), 20, y, 0);
mc.fontRendererObj.drawString(color + PowerLocalization.getLocalizedPower(CurrentCharge) + "/"
+ PowerLocalization.getLocalizedPower(MaxCharge), 20, y, 0);
y += 20;
}
}
@ -133,7 +133,7 @@ public class ChargeHud
{
color = Color.DARK_RED;
}
mc.fontRendererObj.drawString(color + PowerSystem.getLocalizedPower(CurrentCharge) + "/" + PowerSystem.getLocalizedPower(MaxCharge), 20, y, 0);
mc.fontRendererObj.drawString(color + PowerLocalization.getLocalizedPower(CurrentCharge) + "/" + PowerLocalization.getLocalizedPower(MaxCharge), 20, y, 0);
}
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -9,7 +9,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
/**
* Created by Mark on 04/06/2016.

View file

@ -55,6 +55,7 @@ import techreborn.blocks.tier1.BlockElectricFurnace;
import techreborn.blocks.tier1.BlockExtractor;
import techreborn.blocks.tier1.BlockGrinder;
import techreborn.blocks.tier1.BlockRecycler;
import techreborn.blocks.transformers.BlockEVTransformer;
import techreborn.blocks.transformers.BlockHVTransformer;
import techreborn.blocks.transformers.BlockLVTransformer;
import techreborn.blocks.transformers.BlockMVTransformer;
@ -85,6 +86,7 @@ import techreborn.tiles.teir1.TileElectricFurnace;
import techreborn.tiles.teir1.TileExtractor;
import techreborn.tiles.teir1.TileGrinder;
import techreborn.tiles.teir1.TileRecycler;
import techreborn.tiles.transformers.TileEVTransformer;
import techreborn.tiles.transformers.TileHVTransformer;
import techreborn.tiles.transformers.TileLVTransformer;
import techreborn.tiles.transformers.TileMVTransformer;
@ -147,10 +149,12 @@ public class ModBlocks
public static Block mfe;
public static Block mfsu;
public static Block scrapboxinator;
public static Block pump;
public static Block lvt;
public static Block mvt;
public static Block hvt;
public static Block pump;
public static Block evt;
public static BlockOre ore;
public static BlockOre2 ore2;
@ -437,7 +441,11 @@ public class ModBlocks
distributor = new BlockDistributor();
registerBlock(distributor, "distributor");
registerOreDict();
evt = new BlockEVTransformer();
registerBlock(evt, "evt");
GameRegistry.registerTileEntity(TileEVTransformer.class, "TileEVTransformer");
registerOreDict();
Core.logHelper.info("TechReborns Blocks Loaded");
}

View file

@ -1,21 +1,16 @@
package techreborn.init;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.BucketHandler;
import techreborn.Core;
import techreborn.api.Reference;
import techreborn.blocks.BlockMachineFrame;
import techreborn.config.ConfigTechReborn;
import techreborn.events.OreUnifier;
import techreborn.items.*;
import techreborn.items.armor.ItemLapotronPack;
import techreborn.items.armor.ItemLithiumBatpack;
@ -141,51 +136,51 @@ public class ModItems
parts = new ItemParts();
registerItem(parts, "part");
rockCutter = PoweredItem.createItem(ItemRockCutter.class);
rockCutter = new ItemRockCutter();
registerItem(rockCutter, "rockCutter");
lithiumBatpack = PoweredItem.createItem(ItemLithiumBatpack.class);
lithiumBatpack = new ItemLithiumBatpack();
registerItem(lithiumBatpack, "lithiumBatpack");
lapotronpack = PoweredItem.createItem(ItemLapotronPack.class);
lapotronpack = new ItemLapotronPack();
registerItem(lapotronpack, "lapotronPack");
lithiumBattery = PoweredItem.createItem(ItemLithiumBattery.class);
lithiumBattery = new ItemLithiumBattery();
registerItem(lithiumBattery, "lithiumBattery");
lapotronicOrb = PoweredItem.createItem(ItemLapotronicOrb.class);
lapotronicOrb = new ItemLapotronicOrb();
registerItem(lapotronicOrb, "lapotronicOrb");
omniTool = PoweredItem.createItem(ItemOmniTool.class);
omniTool = new ItemOmniTool();
registerItem(omniTool, "omniTool");
energyCrystal = PoweredItem.createItem(ItemEnergyCrystal.class);
energyCrystal = new ItemEnergyCrystal();
registerItem(energyCrystal, "energycrystal");
lapotronCrystal = PoweredItem.createItem(ItemLapotronCrystal.class);
lapotronCrystal = new ItemLapotronCrystal();
registerItem(lapotronCrystal, "lapotroncrystal");
manual = new ItemTechManual();
registerItem(manual, "techmanuel");
uuMatter = new ItemUUmatter();
registerItem(uuMatter, "uumatter");
reBattery = PoweredItem.createItem(ItemReBattery.class);
reBattery = new ItemReBattery();
registerItem(reBattery, "rebattery");
treeTap = new ItemTreeTap();
registerItem(treeTap, "treetap");
ironDrill = PoweredItem.createItem(ItemSteelDrill.class);
ironDrill = new ItemSteelDrill();
registerItem(ironDrill, "irondrill");
diamondDrill = PoweredItem.createItem(ItemDiamondDrill.class);
diamondDrill = new ItemDiamondDrill();
registerItem(diamondDrill, "diamonddrill");
advancedDrill = PoweredItem.createItem(ItemAdvancedDrill.class);
advancedDrill = new ItemAdvancedDrill();
registerItem(advancedDrill, "advanceddrill");
ironChainsaw = PoweredItem.createItem(ItemSteelChainsaw.class);
ironChainsaw = new ItemSteelChainsaw();
registerItem(ironChainsaw, "ironchainsaw");
diamondChainsaw = PoweredItem.createItem(ItemDiamondChainsaw.class);
diamondChainsaw = new ItemDiamondChainsaw();
registerItem(diamondChainsaw, "diamondchainsaw");
advancedChainsaw = PoweredItem.createItem(ItemAdvancedChainsaw.class);
advancedChainsaw = new ItemAdvancedChainsaw();
registerItem(advancedChainsaw, "advancedchainsaw");
steelJackhammer = PoweredItem.createItem(ItemSteelJackhammer.class);
steelJackhammer = new ItemSteelJackhammer();
registerItem(steelJackhammer, "steeljackhammer");
diamondJackhammer = PoweredItem.createItem(ItemDiamondJackhammer.class);
diamondJackhammer = new ItemDiamondJackhammer();
registerItem(diamondJackhammer, "diamondjackhammer");
advancedJackhammer = PoweredItem.createItem(ItemAdvancedJackhammer.class);
advancedJackhammer = new ItemAdvancedJackhammer();
registerItem(advancedJackhammer, "ironjackhammer");
if(ConfigTechReborn.enableGemArmorAndTools){
@ -274,7 +269,7 @@ public class ModItems
wrench = new ItemWrench();
registerItem(wrench, "wrench");
nanosaber = PoweredItem.createItem(ItemNanosaber.class);
nanosaber = new ItemNanosaber();
registerItem(nanosaber, "nanosaber");
scrapBox = new ItemScrapBox();
@ -286,7 +281,7 @@ public class ModItems
upgrades = new ItemUpgrades();
registerItem(upgrades, "upgrades");
cloakingDevice = PoweredItem.createItem(ItemCloakingDevice.class);
cloakingDevice = new ItemCloakingDevice();
registerItem(cloakingDevice, "cloakingdevice");
missingRecipe = new ItemMissingRecipe().setUnlocalizedName("missingRecipe");

View file

@ -15,9 +15,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.init.ModBlocks;
import techreborn.tiles.TileAesu;
public class ItemBlockAesu extends ItemBlock
{
@ -35,7 +34,7 @@ public class ItemBlockAesu extends ItemBlock
if (stack != null && stack.hasTagCompound())
{
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(PowerSystem.getLocalizedPower(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("energy")));
list.add(PowerLocalization.getLocalizedPower(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("energy")));
}
}

View file

@ -5,61 +5,53 @@ import reborncore.api.power.IEnergyItemInfo;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
public class ItemLapotronicOrb extends ItemTextureBase implements IEnergyItemInfo
{
public class ItemLapotronicOrb extends ItemTextureBase implements IEnergyItemInfo {
public static final int maxCharge = ConfigTechReborn.LapotronicOrbMaxCharge;
public static final int tier = ConfigTechReborn.LithiumBatpackTier;
public double transferLimit = 10000;
public static final int maxCharge = ConfigTechReborn.LapotronicOrbMaxCharge;
public static final int tier = ConfigTechReborn.LithiumBatpackTier;
public double transferLimit = 10000;
public ItemLapotronicOrb()
{
super();
setMaxStackSize(1);
setMaxDamage(13);
setUnlocalizedName("techreborn.lapotronicorb");
setCreativeTab(TechRebornCreativeTab.instance);
}
public ItemLapotronicOrb() {
super();
setMaxStackSize(1);
setMaxDamage(13);
setUnlocalizedName("techreborn.lapotronicorb");
setCreativeTab(TechRebornCreativeTab.instance);
}
@Override
public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack)
{
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return true;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return transferLimit;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@Override
public int getStackTier(ItemStack stack)
{
return tier;
}
@Override
public int getStackTier(ItemStack stack) {
return tier;
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/lapotronicEnergyOrb";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/lapotronicEnergyOrb";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta()
{
return 1;
}
}

View file

@ -1,6 +1,9 @@
package techreborn.items.armor;
import cofh.api.energy.IEnergyContainerItem;
import ic2.api.item.IElectricItem;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.darkhax.tesla.capability.TeslaCapabilities;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
@ -13,128 +16,137 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.lib.ModInfo;
import techreborn.power.EnergyItem;
import java.util.List;
public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITexturedItem
{
public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITexturedItem {
public static final int maxCharge = ConfigTechReborn.LapotronPackCharge;
public static final int tier = ConfigTechReborn.LapotronPackTier;
public double transferLimit = 100000;
public static final int MAX_CHARGE = ConfigTechReborn.LapotronPackCharge;
public static final int TIER = ConfigTechReborn.LapotronPackTier;
public static final double TRANSFER_LIMIT = 100000;
public ItemLapotronPack()
{
super(ItemArmor.ArmorMaterial.DIAMOND, 7, EntityEquipmentSlot.CHEST);
setCreativeTab(TechRebornCreativeTab.instance);
setUnlocalizedName("techreborn.lapotronpack");
setMaxStackSize(1);
RebornCore.jsonDestroyer.registerObject(this);
}
public ItemLapotronPack() {
super(ItemArmor.ArmorMaterial.DIAMOND, 7, EntityEquipmentSlot.CHEST);
setCreativeTab(TechRebornCreativeTab.instance);
setUnlocalizedName("techreborn.lapotronpack");
setMaxStackSize(1);
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
@SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
{
return "techreborn:" + "textures/models/lapotronpack.png";
}
@Override
@SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
return "techreborn:" + "textures/models/lapotronpack.png";
}
@Override
public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public double getMaxPower(ItemStack stack) {
return MAX_CHARGE;
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return TRANSFER_LIMIT;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack)
{
return true;
}
@Override
public int getStackTier(ItemStack stack) {
return TIER;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return transferLimit;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public int getStackTier(ItemStack stack)
{
return tier;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack) {
return true;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(player.inventory.getStackInSlot(i) != null){
ItemStack item = player.inventory.getStackInSlot(i);
if(item.getItem() instanceof IEnergyItemInfo){
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();
if(energyItemInfo.getMaxPower(item) != PoweredItem.getEnergy(item)){
if(PoweredItem.canUseEnergy(energyItemInfo.getMaxPower(item), itemStack)){
PoweredItem.useEnergy(energyItemInfo.getMaxTransfer(item), itemStack);
PoweredItem.setEnergy(PoweredItem.getEnergy(item) + energyItemInfo.getMaxTransfer(item), item);
}
}
}
}
}
}
}
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (player.inventory.getStackInSlot(i) != null) {
ItemStack itemStack1 = player.inventory.getStackInSlot(i);
if (itemStack1 != null) {
Item item1 = itemStack1.getItem();
if (item1 instanceof IEnergyInterfaceItem ||
item1 instanceof IEnergyContainerItem ||
item1 instanceof IElectricItem ||
itemStack1.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, null)) {
EnergyItem.charge(itemStack1, new IEnergyInterfaceTile() {
@Override
public double getEnergy() {
return EnergyItem.getEnergy(itemStack);
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/lapotronicPack";
}
@Override
public void setEnergy(double energy) {
EnergyItem.setEnergy(energy, itemStack);
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public double getMaxPower() {
return MAX_CHARGE;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.EXTREME;
}
});
}
}
}
}
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/lapotronicPack";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}

View file

@ -1,6 +1,9 @@
package techreborn.items.armor;
import cofh.api.energy.IEnergyContainerItem;
import ic2.api.item.IElectricItem;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.darkhax.tesla.capability.TeslaCapabilities;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
@ -13,127 +16,135 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.lib.ModInfo;
import techreborn.power.EnergyItem;
import java.util.List;
public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, ITexturedItem
{
public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, ITexturedItem {
public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge;
public static final int tier = ConfigTechReborn.LithiumBatpackTier;
public double transferLimit = 10000;
public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge;
public static final int tier = ConfigTechReborn.LithiumBatpackTier;
public double transferLimit = 10000;
public ItemLithiumBatpack()
{
super(ItemArmor.ArmorMaterial.DIAMOND, 7, EntityEquipmentSlot.CHEST);
setMaxStackSize(1);
setUnlocalizedName("techreborn.lithiumbatpack");
setCreativeTab(TechRebornCreativeTab.instance);
RebornCore.jsonDestroyer.registerObject(this);
}
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(player.inventory.getStackInSlot(i) != null){
ItemStack item = player.inventory.getStackInSlot(i);
if(item.getItem() instanceof IEnergyItemInfo){
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();
if(energyItemInfo.getMaxPower(item) != PoweredItem.getEnergy(item)){
if(PoweredItem.canUseEnergy(energyItemInfo.getMaxPower(item), itemStack)){
PoweredItem.useEnergy(energyItemInfo.getMaxTransfer(item), itemStack);
PoweredItem.setEnergy(PoweredItem.getEnergy(item) + energyItemInfo.getMaxTransfer(item), item);
}
}
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
{
return "techreborn:" + "textures/models/lithiumbatpack.png";
}
public ItemLithiumBatpack() {
super(ItemArmor.ArmorMaterial.DIAMOND, 7, EntityEquipmentSlot.CHEST);
setMaxStackSize(1);
setUnlocalizedName("techreborn.lithiumbatpack");
setCreativeTab(TechRebornCreativeTab.instance);
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (player.inventory.getStackInSlot(i) != null) {
ItemStack itemStack1 = player.inventory.getStackInSlot(i);
Item item1 = itemStack1.getItem();
if (item1 instanceof IEnergyInterfaceItem ||
item1 instanceof IEnergyContainerItem ||
item1 instanceof IElectricItem ||
itemStack1.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, null)) {
EnergyItem.charge(itemStack1, new IEnergyInterfaceTile() {
@Override
public double getEnergy() {
return EnergyItem.getEnergy(itemStack);
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public void setEnergy(double energy) {
EnergyItem.setEnergy(energy, itemStack);
}
@Override
public boolean canProvideEnergy(ItemStack stack)
{
return true;
}
@Override
public double getMaxPower() {
return maxCharge;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return transferLimit;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
});
}
}
}
}
@Override
public int getStackTier(ItemStack stack)
{
return tier;
}
@Override
@SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
return "techreborn:" + "textures/models/lithiumbatpack.png";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override
public boolean canProvideEnergy(ItemStack stack) {
return true;
}
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public int getStackTier(ItemStack stack) {
return tier;
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/lithiumBatpack";
}
@SuppressWarnings({"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override
public int getMaxMeta()
{
return 1;
}
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/lithiumBatpack";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}

View file

@ -16,51 +16,52 @@ import techreborn.lib.ModInfo;
*/
public class ItemTRArmour extends ItemArmor implements ITexturedItem {
private ArmorMaterial material = ArmorMaterial.LEATHER;
private EntityEquipmentSlot slot = EntityEquipmentSlot.HEAD;
private ArmorMaterial material = ArmorMaterial.LEATHER;
private EntityEquipmentSlot slot = EntityEquipmentSlot.HEAD;
public ItemTRArmour(ArmorMaterial material, EntityEquipmentSlot slot) {
super(material, material.getDamageReductionAmount(slot), slot);
if (slot == EntityEquipmentSlot.HEAD)
setUnlocalizedName(material.name().toLowerCase()+"Helmet");
if (slot == EntityEquipmentSlot.CHEST)
setUnlocalizedName(material.name().toLowerCase()+"Chestplate");
if (slot == EntityEquipmentSlot.LEGS)
setUnlocalizedName(material.name().toLowerCase()+"Leggings");
if (slot == EntityEquipmentSlot.FEET)
setUnlocalizedName(material.name().toLowerCase()+"Boots");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
this.slot = slot;
}
public ItemTRArmour(ArmorMaterial material, EntityEquipmentSlot slot) {
super(material, material.getDamageReductionAmount(slot), slot);
if (slot == EntityEquipmentSlot.HEAD)
setUnlocalizedName(material.name().toLowerCase() + "Helmet");
if (slot == EntityEquipmentSlot.CHEST)
setUnlocalizedName(material.name().toLowerCase() + "Chestplate");
if (slot == EntityEquipmentSlot.LEGS)
setUnlocalizedName(material.name().toLowerCase() + "Leggings");
if (slot == EntityEquipmentSlot.FEET)
setUnlocalizedName(material.name().toLowerCase() + "Boots");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
this.slot = slot;
}
@Override
public String getTextureName(int damage) {
if (slot == EntityEquipmentSlot.HEAD)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_helmet";
if (slot == EntityEquipmentSlot.CHEST)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_chestplate";
if (slot == EntityEquipmentSlot.LEGS)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_leggings";
if (slot == EntityEquipmentSlot.FEET)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_boots";
return "techreborn:items/tool/" + material.name().toLowerCase() + "_error";
}
@Override
public String getTextureName(int damage) {
if (slot == EntityEquipmentSlot.HEAD)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_helmet";
if (slot == EntityEquipmentSlot.CHEST)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_chestplate";
if (slot == EntityEquipmentSlot.LEGS)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_leggings";
if (slot == EntityEquipmentSlot.FEET)
return "techreborn:items/tool/" + material.name().toLowerCase() + "_boots";
return "techreborn:items/tool/" + material.name().toLowerCase() + "_error";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
}

View file

@ -2,105 +2,99 @@ package techreborn.items.battery;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.PowerLocalization;
import techreborn.items.ItemTRNoDestroy;
import techreborn.power.EnergyItem;
import javax.annotation.Nullable;
import java.util.List;
public class ItemBattery extends ItemTRNoDestroy implements IEnergyItemInfo
{
public class ItemBattery extends ItemTRNoDestroy implements IEnergyItemInfo {
String name = "null";
int maxEnergy = 0;
int maxTransfer = 0;
int tier = 0;
public ItemBattery(String name, int maxEnergy, int maxTransfer, int tier)
{
super();
setMaxStackSize(1);
setMaxDamage(1);
setUnlocalizedName("techreborn."+name);
this.name=name;
this.maxEnergy=maxEnergy;
this.maxTransfer=maxTransfer;
this.tier=tier;
this.addPropertyOverride(new ResourceLocation("techreborn:empty"), new IItemPropertyGetter()
{
@SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn,
@Nullable EntityLivingBase entityIn)
{
if (stack != null && PoweredItem.getEnergy(stack) == 0.0)
{
return 1.0F;
}
return 0.0F;
}
});
}
int maxEnergy = 0;
int maxTransfer = 0;
int tier = 0;
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
public ItemBattery(String name, int maxEnergy, int maxTransfer, int tier) {
super();
setMaxStackSize(1);
setMaxDamage(1);
setUnlocalizedName("techreborn." + name);
this.maxEnergy = maxEnergy;
this.maxTransfer = maxTransfer;
this.tier = tier;
this.addPropertyOverride(new ResourceLocation("techreborn:empty"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn,
@Nullable EntityLivingBase entityIn) {
if (stack != null && EnergyItem.getEnergy(stack) == 0.0) {
return 1.0F;
}
return 0.0F;
}
});
}
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
String max = PowerLocalization.getLocalizedPower(getMaxPower(stack));
String energy = PowerLocalization.getLocalizedPower(EnergyItem.getEnergy(stack));
tooltip.add(TextFormatting.GRAY + energy + " / " + max);
}
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public double getMaxPower(ItemStack stack)
{
return maxEnergy;
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
return 1 - (EnergyItem.getEnergy(stack) / getMaxPower(stack));
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxEnergy;
}
@Override
public boolean canProvideEnergy(ItemStack stack)
{
return true;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return maxTransfer;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return maxTransfer;
}
@Override
public int getStackTier(ItemStack stack) {
return tier;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return true;
}
@Override
public int getStackTier(ItemStack stack)
{
return tier;
}
}

View file

@ -5,4 +5,5 @@ public class ItemEnergyCrystal extends ItemBattery {
public ItemEnergyCrystal() {
super("energyCrystal", 100000, 512, 1);
}
}

View file

@ -5,4 +5,5 @@ public class ItemLapotronCrystal extends ItemBattery {
public ItemLapotronCrystal() {
super("lapotronCrystal", 1000000, 512, 2);
}
}

View file

@ -5,5 +5,6 @@ public class ItemLithiumBattery extends ItemBattery {
public ItemLithiumBattery() {
super("lithiumBattery", 100000, 512, 1);
}
}

View file

@ -1,10 +1,9 @@
package techreborn.items.battery;
public class ItemReBattery extends ItemBattery
{
public class ItemReBattery extends ItemBattery {
public ItemReBattery()
{
public ItemReBattery() {
super("rebattery", 10000, 64, 1);
}
}

View file

@ -20,12 +20,13 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
import techreborn.power.EnergyItem;
public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, ITexturedItem , IHandHeld
{
@ -137,14 +138,14 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, ITexturedI
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}

View file

@ -12,117 +12,100 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.items.ItemTextureBase;
import techreborn.power.EnergyItem;
public class ItemCloakingDevice extends ItemTextureBase implements IEnergyItemInfo
{
public static int Teir = ConfigTechReborn.CloakingDeviceTier;
public static int MaxCharge = ConfigTechReborn.CloakingDeviceCharge;
public static int Limit = 100;
public static boolean isActive;
private int armorType = 1;
public class ItemCloakingDevice extends ItemTextureBase implements IEnergyItemInfo {
public static int Teir = ConfigTechReborn.CloakingDeviceTier;
public static int MaxCharge = ConfigTechReborn.CloakingDeviceCharge;
public static int Limit = 100;
public static boolean isActive;
private int armorType = 1;
public ItemCloakingDevice()
{
setUnlocalizedName("techreborn.cloakingdevice");
setMaxStackSize(1);
setCreativeTab(TechRebornCreativeTab.instance);
}
public ItemCloakingDevice() {
setUnlocalizedName("techreborn.cloakingdevice");
setMaxStackSize(1);
setCreativeTab(TechRebornCreativeTab.instance);
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{
if (PoweredItem.canUseEnergy(ConfigTechReborn.CloakingDeviceEUTick, itemStack))
{
PoweredItem.useEnergy(ConfigTechReborn.CloakingDeviceEUTick, itemStack);
player.setInvisible(true);
} else
{
if (!player.isPotionActive(MobEffects.INVISIBILITY))
{
player.setInvisible(false);
}
}
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if (EnergyItem.canUseEnergy(ConfigTechReborn.CloakingDeviceEUTick, itemStack)) {
EnergyItem.useEnergy(ConfigTechReborn.CloakingDeviceEUTick, itemStack);
player.setInvisible(true);
} else {
if (!player.isPotionActive(MobEffects.INVISIBILITY)) {
player.setInvisible(false);
}
}
}
@Override
public double getMaxPower(ItemStack stack)
{
return MaxCharge;
}
@Override
public double getMaxPower(ItemStack stack) {
return MaxCharge;
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack)
{
return false;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack) {
return false;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return Limit;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return Limit;
}
@Override
public int getStackTier(ItemStack stack)
{
return Teir;
}
@Override
public int getStackTier(ItemStack stack) {
return Teir;
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
ItemStack itemstack1 = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
ItemStack itemstack1 = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack1 == null)
{
player.setItemStackToSlot(EntityEquipmentSlot.CHEST, itemStack.copy());
itemStack.stackSize = 0;
}
if (itemstack1 == null) {
player.setItemStackToSlot(EntityEquipmentSlot.CHEST, itemStack.copy());
itemStack.stackSize = 0;
}
return itemStack;
}
return itemStack;
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
}
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/cloakingDevice";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/cloakingDevice";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta()
{
return 1;
}
}

View file

@ -12,49 +12,42 @@ import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.items.ItemTextureBase;
/**
* Created by Mark on 20/03/2016.
*/
public class ItemDebugTool extends ItemTextureBase implements ITexturedItem
{
public class ItemDebugTool extends ItemTextureBase implements ITexturedItem {
public ItemDebugTool()
{
setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.debug");
}
public ItemDebugTool() {
setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.debug");
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/misc/debug";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/misc/debug";
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof IEnergyInterfaceTile) {
if (!tile.getWorld().isRemote) {
playerIn.addChatComponentMessage(new TextComponentString(TextFormatting.GREEN + "Power" + TextFormatting.BLUE
+ PowerLocalization.getLocalizedPower(((IEnergyInterfaceTile) tile).getEnergy())));
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof IEnergyInterfaceTile)
{
if (!tile.getWorld().isRemote)
{
playerIn.addChatComponentMessage(
new TextComponentString(TextFormatting.GREEN + "Power" + TextFormatting.BLUE
+ PowerSystem.getLocalizedPower(((IEnergyInterfaceTile) tile).getEnergy())));
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
}

View file

@ -32,4 +32,5 @@ public class ItemDiamondChainsaw extends ItemChainsaw
{
return 1;
}
}

View file

@ -32,4 +32,5 @@ public class ItemDiamondDrill extends ItemDrill
{
return 1;
}
}

View file

@ -23,4 +23,5 @@ public class ItemDiamondJackhammer extends ItemJackhammer
{
return 1;
}
}

View file

@ -22,7 +22,6 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
@ -31,134 +30,130 @@ import java.util.List;
import java.util.Random;
import net.minecraft.item.Item.ToolMaterial;
public class ItemDrill extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem , IHandHeld
{
import techreborn.power.EnergyItem;
public static int tier = 1;
public int maxCharge = 1;
public int cost = 250;
public float unpoweredSpeed = 2.0F;
public double transferLimit = 100;
public class ItemDrill extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem , IHandHeld {
public ItemDrill(ToolMaterial material, String unlocalizedName, int energyCapacity, int tier, float unpoweredSpeed, float efficiencyOnProperMaterial)
{
super(material);
this.efficiencyOnProperMaterial = efficiencyOnProperMaterial;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName(unlocalizedName);
RebornCore.jsonDestroyer.registerObject(this);
this.maxCharge = energyCapacity;
this.tier = tier;
this.unpoweredSpeed = unpoweredSpeed;
}
public static int tier = 1;
public int maxCharge = 1;
public int cost = 250;
public float unpoweredSpeed = 2.0F;
public double transferLimit = 100;
@Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving)
{
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByID(34), stack) + 1) == 0)
{
PoweredItem.useEnergy(cost, stack);
}
return true;
}
public ItemDrill(ToolMaterial material, String unlocalizedName, int energyCapacity, int tier, float unpoweredSpeed, float efficiencyOnProperMaterial) {
super(material);
this.efficiencyOnProperMaterial = efficiencyOnProperMaterial;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName(unlocalizedName);
RebornCore.jsonDestroyer.registerObject(this);
this.maxCharge = energyCapacity;
this.tier = tier;
this.unpoweredSpeed = unpoweredSpeed;
}
@Override public float getStrVsBlock(ItemStack stack, IBlockState state)
{
if (!PoweredItem.canUseEnergy(cost, stack))
{
return unpoweredSpeed;
}
if (Items.WOODEN_PICKAXE.getStrVsBlock(stack, state) > 1.0F
|| Items.WOODEN_SHOVEL.getStrVsBlock(stack, state) > 1.0F)
{
return efficiencyOnProperMaterial;
} else
{
return super.getStrVsBlock(stack, state);
}
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving) {
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByID(34), stack) + 1) == 0) {
EnergyItem.useEnergy(cost, stack);
}
return true;
}
@Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving,
EntityLivingBase entityliving1)
{
return true;
}
@Override
public float getStrVsBlock(ItemStack stack, IBlockState state) {
if (!EnergyItem.canUseEnergy(cost, stack)) {
return unpoweredSpeed;
}
if (Items.WOODEN_PICKAXE.getStrVsBlock(stack, state) > 1.0F
|| Items.WOODEN_SHOVEL.getStrVsBlock(stack, state) > 1.0F) {
return efficiencyOnProperMaterial;
} else {
return super.getStrVsBlock(stack, state);
}
}
@Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos, facing, hitX, hitY, hitZ, hand);
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) {
return true;
}
@Override public boolean isRepairable()
{
return false;
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos, facing, hitX, hitY, hitZ, hand);
}
@Override public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public boolean isRepairable() {
return false;
}
@Override public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override public boolean canProvideEnergy(ItemStack stack)
{
return false;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override public double getMaxTransfer(ItemStack stack)
{
return transferLimit;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override public int getStackTier(ItemStack stack)
{
return tier;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@SuppressWarnings({ "rawtypes", "unchecked" }) @SideOnly(Side.CLIENT) public void getSubItems(Item item,
CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override
public int getStackTier(ItemStack stack) {
return tier;
}
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item item,
CreativeTabs tab, List<ItemStack> itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
}
@Override public String getTextureName(int damage)
{
return "techreborn:items/tool/nullDrill";
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override public int getMaxMeta()
{
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/nullDrill";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player,
int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}

View file

@ -21,160 +21,140 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.power.EnergyItem;
import techreborn.utils.OreDictUtils;
import java.util.List;
import java.util.Random;
import net.minecraft.item.Item.ToolMaterial;
public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem , IHandHeld
{
public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem , IHandHeld {
public static int tier = 1;
public int maxCharge = 1;
public int cost = 250;
public double transferLimit = 100;
public static int tier = 1;
public int maxCharge = 1;
public int cost = 250;
public double transferLimit = 100;
public ItemJackhammer(ToolMaterial material, String unlocalizedName, int energyCapacity, int tier)
{
super(material);
efficiencyOnProperMaterial = 20F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName(unlocalizedName);
RebornCore.jsonDestroyer.registerObject(this);
this.maxCharge = energyCapacity;
this.tier = tier;
}
public ItemJackhammer(ToolMaterial material, String unlocalizedName, int energyCapacity, int tier) {
super(material);
efficiencyOnProperMaterial = 20F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName(unlocalizedName);
RebornCore.jsonDestroyer.registerObject(this);
this.maxCharge = energyCapacity;
ItemJackhammer.tier = tier;
}
@Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving)
{
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByID(34), stack) + 1) == 0)
{
PoweredItem.useEnergy(cost, stack);
}
return true;
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving) {
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByID(34), stack) + 1) == 0) {
EnergyItem.useEnergy(cost, stack);
}
return true;
}
@Override
public boolean canHarvestBlock(IBlockState state)
{
// TODO needs // FIXME: 13/03/2016
return OreDictUtils.isOre(state, "stone") && PoweredItem.canUseEnergy(cost, null);
}
@Override
public boolean canHarvestBlock(IBlockState state) {
return OreDictUtils.isOre(state, "stone");
}
@Override
public float getStrVsBlock(ItemStack stack, IBlockState state) {
if (OreDictUtils.isOre(state, "stone") && PoweredItem.canUseEnergy(cost,
stack)) {
return efficiencyOnProperMaterial;
} else {
return 0.5F;
}
}
@Override
public float getStrVsBlock(ItemStack stack, IBlockState state) {
if (OreDictUtils.isOre(state, "stone") && EnergyItem.canUseEnergy(cost, stack)) {
return efficiencyOnProperMaterial;
} else {
return 0.5F;
}
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1)
{
return true;
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) {
return true;
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos, facing, hitX, hitY, hitZ, hand);
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos, facing, hitX, hitY, hitZ, hand);
}
@Override
public boolean isRepairable()
{
return false;
}
@Override
public boolean isRepairable() {
return false;
}
@Override
public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack)
{
return false;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return transferLimit;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@Override
public int getStackTier(ItemStack stack)
{
return tier;
}
@Override
public int getStackTier(ItemStack stack) {
return tier;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@SuppressWarnings({"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
if (PoweredItem.getEnergy(stack) > getMaxPower(stack))
{
return 0;
}
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override
public double getDurabilityForDisplay(ItemStack stack) {
if (EnergyItem.getEnergy(stack) > getMaxPower(stack)) {
return 0;
}
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
}
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/nullJackhammer";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/nullJackhammer";
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}

View file

@ -24,186 +24,172 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.ChatUtils;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModItems;
import techreborn.lib.MessageIDs;
import techreborn.power.EnergyItem;
import javax.annotation.Nullable;
import java.util.List;
public class ItemNanosaber extends ItemSword implements IEnergyItemInfo
{
public int cost = 250;
public class ItemNanosaber extends ItemSword implements IEnergyItemInfo {
public int cost = 250;
public ItemNanosaber()
{
super(ToolMaterial.DIAMOND);
setNoRepair();
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(1);
setUnlocalizedName("techreborn.nanosaber");
this.addPropertyOverride(new ResourceLocation("techreborn:active"), new IItemPropertyGetter()
{
@SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn,
@Nullable EntityLivingBase entityIn)
{
if (stack != null && stack.getTagCompound().getBoolean("isActive"))
{
return 1.0F;
}
return 0.0F;
}
});
}
public ItemNanosaber() {
super(ToolMaterial.DIAMOND);
setNoRepair();
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(1);
setUnlocalizedName("techreborn.nanosaber");
this.addPropertyOverride(new ResourceLocation("techreborn:active"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn,
@Nullable EntityLivingBase entityIn) {
if (stack != null && stack.getTagCompound().getBoolean("isActive")) {
return 1.0F;
}
return 0.0F;
}
});
}
@Override public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot,
ItemStack stack)
{
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
int modifier = 0;
if (stack.getTagCompound().getBoolean("isActive"))
modifier = 9;
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot,
ItemStack stack) {
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
int modifier = 0;
if (stack.getTagCompound().getBoolean("isActive"))
modifier = 9;
if (slot == EntityEquipmentSlot.MAINHAND)
{
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) modifier, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(),
new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0));
}
return multimap;
}
if (slot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) modifier, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(),
new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0));
}
return multimap;
}
@Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving,
EntityLivingBase entityliving1)
{
if (PoweredItem.canUseEnergy(cost, itemstack))
{
PoweredItem.useEnergy(cost, itemstack);
return true;
} else
{
return false;
}
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving,
EntityLivingBase entityliving1) {
if (EnergyItem.canUseEnergy(cost, itemstack)) {
EnergyItem.useEnergy(cost, itemstack);
return true;
} else {
return false;
}
}
@SuppressWarnings({ "rawtypes", "unchecked" }) @SideOnly(Side.CLIENT) public void getSubItems(Item item,
CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack inactiveUncharged = new ItemStack(ModItems.nanosaber);
inactiveUncharged.setTagCompound(new NBTTagCompound());
inactiveUncharged.getTagCompound().setBoolean("isActive", false);
@SuppressWarnings({"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item,
CreativeTabs par2CreativeTabs, List itemList) {
ItemStack inactiveUncharged = new ItemStack(ModItems.nanosaber);
inactiveUncharged.setTagCompound(new NBTTagCompound());
inactiveUncharged.getTagCompound().setBoolean("isActive", false);
ItemStack inactiveCharged = new ItemStack(ModItems.nanosaber);
inactiveCharged.setTagCompound(new NBTTagCompound());
inactiveCharged.getTagCompound().setBoolean("isActive", false);
PoweredItem.setEnergy(getMaxPower(inactiveCharged), inactiveCharged);
ItemStack inactiveCharged = new ItemStack(ModItems.nanosaber);
inactiveCharged.setTagCompound(new NBTTagCompound());
inactiveCharged.getTagCompound().setBoolean("isActive", false);
EnergyItem.setEnergy(getMaxPower(inactiveCharged), inactiveCharged);
ItemStack activeUncharged = new ItemStack(ModItems.nanosaber);
activeUncharged.setTagCompound(new NBTTagCompound());
activeUncharged.getTagCompound().setBoolean("isActive", true);
ItemStack activeUncharged = new ItemStack(ModItems.nanosaber);
activeUncharged.setTagCompound(new NBTTagCompound());
activeUncharged.getTagCompound().setBoolean("isActive", true);
ItemStack activeCharged = new ItemStack(ModItems.nanosaber);
activeCharged.setTagCompound(new NBTTagCompound());
activeCharged.getTagCompound().setBoolean("isActive", true);
PoweredItem.setEnergy(getMaxPower(activeCharged), activeCharged);
ItemStack activeCharged = new ItemStack(ModItems.nanosaber);
activeCharged.setTagCompound(new NBTTagCompound());
activeCharged.getTagCompound().setBoolean("isActive", true);
EnergyItem.setEnergy(getMaxPower(activeCharged), activeCharged);
itemList.add(inactiveUncharged);
itemList.add(inactiveCharged);
itemList.add(activeUncharged);
itemList.add(activeCharged);
}
itemList.add(inactiveUncharged);
itemList.add(inactiveCharged);
itemList.add(activeUncharged);
itemList.add(activeCharged);
}
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack.getTagCompound() == null || !stack.getTagCompound().getBoolean("isActive"))
{
list.add(TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.nanosaberInactive"));
} else
{
list.add(TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.nanosaberActive"));
}
}
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack.getTagCompound() == null || !stack.getTagCompound().getBoolean("isActive")) {
list.add(TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.nanosaberInactive"));
} else {
list.add(TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.nanosaberActive"));
}
}
@Override public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player,
EnumHand hand)
{
if (player.isSneaking())
{
if (stack.getTagCompound() == null || !stack.getTagCompound().getBoolean("isActive"))
{
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("isActive", true);
if (!world.isRemote && ConfigTechReborn.NanosaberChat)
{
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.setTo") + " "
+ TextFormatting.GOLD + I18n
.translateToLocal("techreborn.message.nanosaberActive")));
}
} else
{
stack.getTagCompound().setBoolean("isActive", false);
if (!world.isRemote && ConfigTechReborn.NanosaberChat)
{
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.setTo") + " "
+ TextFormatting.GOLD + I18n
.translateToLocal("techreborn.message.nanosaberInactive")));
}
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player,
EnumHand hand) {
if (player.isSneaking()) {
if (stack.getTagCompound() == null || !stack.getTagCompound().getBoolean("isActive")) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("isActive", true);
if (!world.isRemote && ConfigTechReborn.NanosaberChat) {
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.setTo") + " "
+ TextFormatting.GOLD + I18n
.translateToLocal("techreborn.message.nanosaberActive")));
}
} else {
stack.getTagCompound().setBoolean("isActive", false);
if (!world.isRemote && ConfigTechReborn.NanosaberChat) {
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.setTo") + " "
+ TextFormatting.GOLD + I18n
.translateToLocal("techreborn.message.nanosaberInactive")));
}
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
@Override public double getDurabilityForDisplay(ItemStack stack)
{
if (PoweredItem.getEnergy(stack) > getMaxPower(stack))
{
return 0;
}
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override
public double getDurabilityForDisplay(ItemStack stack) {
if (EnergyItem.getEnergy(stack) > getMaxPower(stack)) {
return 0;
}
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
}
@Override public boolean isRepairable()
{
return false;
}
@Override
public boolean isRepairable() {
return false;
}
@Override public double getMaxPower(ItemStack stack)
{
return 100000;
}
@Override
public double getMaxPower(ItemStack stack) {
return 100000;
}
@Override public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override public boolean canProvideEnergy(ItemStack stack)
{
return false;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override public double getMaxTransfer(ItemStack stack)
{
return 512;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return 512;
}
@Override
public int getStackTier(ItemStack stack) {
return 2;
}
@Override public int getStackTier(ItemStack stack)
{
return 2;
}
}

View file

@ -23,168 +23,147 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem
{
import techreborn.power.EnergyItem;
public static final int maxCharge = ConfigTechReborn.OmniToolCharge;
public static final int tier = ConfigTechReborn.OmniToolTier;
public int cost = 100;
public int hitCost = 125;
public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem {
public ItemOmniTool()
{
super(ToolMaterial.DIAMOND);
efficiencyOnProperMaterial = 13F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(200);
setUnlocalizedName("techreborn.omniTool");
RebornCore.jsonDestroyer.registerObject(this);
}
public static final int maxCharge = ConfigTechReborn.OmniToolCharge;
public static final int tier = ConfigTechReborn.OmniToolTier;
public int cost = 100;
public int hitCost = 125;
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving)
{
PoweredItem.useEnergy(cost, stack);
return true;
}
public ItemOmniTool() {
super(ToolMaterial.DIAMOND);
efficiencyOnProperMaterial = 13F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(200);
setUnlocalizedName("techreborn.omniTool");
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
public boolean canHarvestBlock(IBlockState state)
{
return Items.DIAMOND_AXE.canHarvestBlock(state) || Items.DIAMOND_SWORD.canHarvestBlock(state)
|| Items.DIAMOND_PICKAXE.canHarvestBlock(state) || Items.DIAMOND_SHOVEL.canHarvestBlock(state)
|| Items.SHEARS.canHarvestBlock(state);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) {
EnergyItem.useEnergy(cost, stack);
return true;
}
// @Override
// public float getDigSpeed(ItemStack stack, IBlockState state) {
// if (PoweredItem.canUseEnergy(cost, stack)) {
// PoweredItem.useEnergy(cost, stack);
// return 5.0F;
// }
//
// if (Items.wooden_axe.getDigSpeed(stack, state) > 1.0F
// || Items.wooden_sword.getDigSpeed(stack, state) > 1.0F
// || Items.wooden_pickaxe.getDigSpeed(stack, state) > 1.0F
// || Items.wooden_shovel.getDigSpeed(stack, state) > 1.0F
// || Items.shears.getDigSpeed(stack, state) > 1.0F) {
// return efficiencyOnProperMaterial;
// } else {
// return super.getDigSpeed(stack, state);
// }
// }
@Override
public boolean canHarvestBlock(IBlockState state) {
return Items.DIAMOND_AXE.canHarvestBlock(state) || Items.DIAMOND_SWORD.canHarvestBlock(state)
|| Items.DIAMOND_PICKAXE.canHarvestBlock(state) || Items.DIAMOND_SHOVEL.canHarvestBlock(state)
|| Items.SHEARS.canHarvestBlock(state);
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker)
{
if (PoweredItem.canUseEnergy(hitCost, itemstack))
{
PoweredItem.useEnergy(hitCost, itemstack);
entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F);
}
return false;
}
// @Override
// public float getDigSpeed(ItemStack stack, IBlockState state) {
// if (PoweredItem.canUseEnergy(cost, stack)) {
// PoweredItem.useEnergy(cost, stack);
// return 5.0F;
// }
//
// if (Items.wooden_axe.getDigSpeed(stack, state) > 1.0F
// || Items.wooden_sword.getDigSpeed(stack, state) > 1.0F
// || Items.wooden_pickaxe.getDigSpeed(stack, state) > 1.0F
// || Items.wooden_shovel.getDigSpeed(stack, state) > 1.0F
// || Items.shears.getDigSpeed(stack, state) > 1.0F) {
// return efficiencyOnProperMaterial;
// } else {
// return super.getDigSpeed(stack, state);
// }
// }
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos, facing, hitX, hitY, hitZ, hand);
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) {
if (EnergyItem.canUseEnergy(hitCost, itemstack)) {
EnergyItem.useEnergy(hitCost, itemstack);
entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F);
}
return false;
}
@Override
public boolean isRepairable()
{
return false;
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos, facing, hitX, hitY, hitZ, hand);
}
@Override
public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public boolean isRepairable() {
return false;
}
@Override
public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack)
{
return false;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public double getMaxTransfer(ItemStack stack)
{
return 200;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack) {
return false;
}
@Override
public int getStackTier(ItemStack stack)
{
return 2;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return 200;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override
public int getStackTier(ItemStack stack) {
return 2;
}
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@SuppressWarnings({"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
ItemStack charged = new ItemStack(this, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/omnitool";
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/omnitool";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
tooltip.add(TextFormatting.RED + "WIP Coming Soon");
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
tooltip.add(TextFormatting.RED + "WIP Coming Soon");
}
}

View file

@ -19,146 +19,139 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.lib.ModInfo;
import techreborn.power.EnergyItem;
import java.util.List;
import java.util.Random;
public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem
{
public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem {
public static final int maxCharge = ConfigTechReborn.RockCutterCharge;
public static final int tier = ConfigTechReborn.RockCutterTier;
public int cost = 500;
public static final int maxCharge = ConfigTechReborn.RockCutterCharge;
public static final int tier = ConfigTechReborn.RockCutterTier;
public int cost = 500;
public ItemRockCutter()
{
super(ToolMaterial.DIAMOND);
setUnlocalizedName("techreborn.rockcutter");
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
efficiencyOnProperMaterial = 16F;
RebornCore.jsonDestroyer.registerObject(this);
}
public ItemRockCutter() {
super(ToolMaterial.DIAMOND);
setUnlocalizedName("techreborn.rockcutter");
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
efficiencyOnProperMaterial = 16F;
RebornCore.jsonDestroyer.registerObject(this);
}
@Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving)
{
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack) + 1) == 0)
{
PoweredItem.useEnergy(cost, stack);
}
return true;
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
EntityLivingBase entityLiving) {
Random rand = new Random();
if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
EnergyItem.useEnergy(cost, stack);
}
return true;
}
@Override public boolean canHarvestBlock(IBlockState state)
{
if (Items.DIAMOND_PICKAXE.canHarvestBlock(state))
{
return true;
}
return false;
}
@Override
public boolean canHarvestBlock(IBlockState state) {
if (Items.DIAMOND_PICKAXE.canHarvestBlock(state)) {
return true;
}
return false;
}
@Override public int getHarvestLevel(ItemStack stack, String toolClass)
{
@Override
public int getHarvestLevel(ItemStack stack, String toolClass) {
if (!stack.isItemEnchanted())
{
stack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
}
if (!stack.isItemEnchanted()) {
stack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
}
return super.getHarvestLevel(stack, toolClass);
}
return super.getHarvestLevel(stack, toolClass);
}
@Override public float getStrVsBlock(ItemStack stack, IBlockState state)
{
if (!PoweredItem.canUseEnergy(cost, stack))
{
return 2F;
}else{
return Items.DIAMOND_PICKAXE.getStrVsBlock(stack, state);
}
}
@Override
public float getStrVsBlock(ItemStack stack, IBlockState state) {
if (!EnergyItem.canUseEnergy(cost, stack)) {
return 2F;
} else {
return Items.DIAMOND_PICKAXE.getStrVsBlock(stack, state);
}
}
@Override public boolean isRepairable()
{
return false;
}
@Override
public boolean isRepairable() {
return false;
}
@Override public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
stack.addEnchantment(Enchantments.SILK_TOUCH, 1);
}
@Override
public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) {
stack.addEnchantment(Enchantments.SILK_TOUCH, 1);
}
@Override public double getMaxPower(ItemStack stack)
{
return maxCharge;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override public boolean canAcceptEnergy(ItemStack stack)
{
return true;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override public boolean canProvideEnergy(ItemStack stack)
{
return false;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override public double getMaxTransfer(ItemStack stack)
{
return 200;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return 200;
}
@Override public int getStackTier(ItemStack stack)
{
return 2;
}
@Override
public int getStackTier(ItemStack stack) {
return 2;
}
@SuppressWarnings({ "rawtypes", "unchecked" }) @SideOnly(Side.CLIENT) public void getSubItems(Item item,
CreativeTabs par2CreativeTabs, List itemList)
{
ItemStack itemStack = new ItemStack(this, 1);
itemStack.addEnchantment(Enchantments.SILK_TOUCH, 1);
itemList.add(itemStack);
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemStack.addEnchantment(Enchantments.SILK_TOUCH, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
charged.addEnchantment(Enchantments.SILK_TOUCH, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
ItemStack charged = new ItemStack(this, 1);
charged.addEnchantment(Enchantments.SILK_TOUCH, 1);
EnergyItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override public double getDurabilityForDisplay(ItemStack stack)
{
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (EnergyItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
}
@Override public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override public String getTextureName(int damage)
{
return "techreborn:items/tool/rockcutter";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/rockcutter";
}
@Override public int getMaxMeta()
{
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player,
int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}

View file

@ -3,31 +3,29 @@ package techreborn.items.tools;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import techreborn.config.ConfigTechReborn;
public class ItemSteelChainsaw extends ItemChainsaw
{
public ItemSteelChainsaw()
{
super(ToolMaterial.IRON, "techreborn.ironChainsaw", ConfigTechReborn.IronChainsawCharge,
ConfigTechReborn.IronChainsawTier, 2.0F);
this.cost = 50;
}
public class ItemSteelChainsaw extends ItemChainsaw {
@Override
public boolean canHarvestBlock(IBlockState state)
{
return Items.IRON_AXE.canHarvestBlock(state);
}
public ItemSteelChainsaw() {
super(ToolMaterial.IRON, "techreborn.ironChainsaw",
ConfigTechReborn.IronChainsawCharge,
ConfigTechReborn.IronChainsawTier, 2.0F);
this.cost = 50;
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/steelChainsaw";
}
@Override
public boolean canHarvestBlock(IBlockState state) {
return Items.IRON_AXE.canHarvestBlock(state);
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/steelChainsaw";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta()
{
return 1;
}
}

View file

@ -3,31 +3,27 @@ package techreborn.items.tools;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import techreborn.config.ConfigTechReborn;
public class ItemSteelDrill extends ItemDrill
{
public class ItemSteelDrill extends ItemDrill {
public ItemSteelDrill()
{
super(ToolMaterial.IRON, "techreborn.ironDrill", ConfigTechReborn.IronDrillCharge,
ConfigTechReborn.IronDrillTier, 0.5F, 10F);
this.cost = 50;
}
public ItemSteelDrill() {
super(ToolMaterial.IRON, "techreborn.ironDrill", ConfigTechReborn.IronDrillCharge,
ConfigTechReborn.IronDrillTier, 0.5F, 10F);
this.cost = 50;
}
@Override
public boolean canHarvestBlock(IBlockState state)
{
return Items.IRON_PICKAXE.canHarvestBlock(state) || Items.IRON_SHOVEL.canHarvestBlock(state);
}
@Override
public boolean canHarvestBlock(IBlockState state) {
return Items.IRON_PICKAXE.canHarvestBlock(state) || Items.IRON_SHOVEL.canHarvestBlock(state);
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/steelDrill";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/steelDrill";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta()
{
return 1;
}
}

View file

@ -1,26 +1,25 @@
package techreborn.items.tools;
import techreborn.config.ConfigTechReborn;
public class ItemSteelJackhammer extends ItemJackhammer
{
public ItemSteelJackhammer()
{
super(ToolMaterial.DIAMOND, "techreborn.steelJackhammer", ConfigTechReborn.SteelJackhammerCharge,
ConfigTechReborn.SteelJackhammerTier);
this.cost = 50;
this.efficiencyOnProperMaterial = 12F;
}
public class ItemSteelJackhammer extends ItemJackhammer {
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/steelJackhammer";
}
public ItemSteelJackhammer() {
super(ToolMaterial.DIAMOND, "techreborn.steelJackhammer",
ConfigTechReborn.SteelJackhammerCharge,
ConfigTechReborn.SteelJackhammerTier);
this.cost = 50;
this.efficiencyOnProperMaterial = 12F;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/steelJackhammer";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta()
{
return 1;
}
}

View file

@ -1,9 +1,6 @@
package techreborn.items.tools;
import java.util.Set;
import com.google.common.collect.Sets;
import me.modmuss50.jsonDestroyer.api.IHandHeld;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.block.Block;
@ -20,48 +17,52 @@ import reborncore.RebornCore;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
import java.util.Set;
public class ItemTRAxe extends ItemTool implements ITexturedItem , IHandHeld {
private ToolMaterial material = ToolMaterial.WOOD;
private ToolMaterial material = ToolMaterial.WOOD;
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.PLANKS, Blocks.BOOKSHELF,
Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK,
Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE });
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF,
Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK,
Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE);
public ItemTRAxe(ToolMaterial material) {
super(material, EFFECTIVE_ON);
this.damageVsEntity = material.getDamageVsEntity() + 5.75F;
this.attackSpeed = (material.getDamageVsEntity() + 6.75F) * -0.344444F;
setUnlocalizedName(material.name().toLowerCase() + "Axe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
}
public ItemTRAxe(ToolMaterial material) {
super(material, EFFECTIVE_ON);
this.damageVsEntity = material.getDamageVsEntity() + 5.75F;
this.attackSpeed = (material.getDamageVsEntity() + 6.75F) * -0.344444F;
setUnlocalizedName(material.name().toLowerCase() + "Axe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
}
public float getStrVsBlock(ItemStack stack, IBlockState state) {
Material material = state.getMaterial();
return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE
? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
}
public float getStrVsBlock(ItemStack stack, IBlockState state) {
Material material = state.getMaterial();
return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE
? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/" + material.name().toLowerCase() + "_axe";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/" + material.name().toLowerCase() + "_axe";
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
}

View file

@ -13,40 +13,37 @@ import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
public class ItemTRHoe extends ItemHoe implements ITexturedItem, IHandHeld
{
private ToolMaterial material = ToolMaterial.WOOD;
public ItemTRHoe(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase()+"Hoe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material=material;
}
public class ItemTRHoe extends ItemHoe implements ITexturedItem, IHandHeld {
private ToolMaterial material = ToolMaterial.WOOD;
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/"+material.name().toLowerCase()+"_hoe";
}
public ItemTRHoe(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase() + "Hoe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/" + material.name().toLowerCase() + "_hoe";
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
@Override
public boolean isFull3D() {
return true;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
}

View file

@ -13,40 +13,36 @@ import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
public class ItemTRPickaxe extends ItemPickaxe implements ITexturedItem , IHandHeld
{
private ToolMaterial material = ToolMaterial.WOOD;
public ItemTRPickaxe(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase()+"Pickaxe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material=material;
}
public class ItemTRPickaxe extends ItemPickaxe implements ITexturedItem , IHandHeld {
private ToolMaterial material = ToolMaterial.WOOD;
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/"+material.name().toLowerCase()+"_pickaxe";
}
public ItemTRPickaxe(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase() + "Pickaxe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/" + material.name().toLowerCase() + "_pickaxe";
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
}

View file

@ -13,40 +13,36 @@ import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
public class ItemTRSpade extends ItemSpade implements ITexturedItem , IHandHeld
{
private ToolMaterial material = ToolMaterial.WOOD;
public ItemTRSpade(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase()+"Spade");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material=material;
}
public class ItemTRSpade extends ItemSpade implements ITexturedItem , IHandHeld {
private ToolMaterial material = ToolMaterial.WOOD;
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/"+material.name().toLowerCase()+"_shovel";
}
public ItemTRSpade(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase() + "Spade");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/" + material.name().toLowerCase() + "_shovel";
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
}

View file

@ -13,40 +13,36 @@ import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.lib.ModInfo;
import net.minecraft.item.Item.ToolMaterial;
public class ItemTRSword extends ItemSword implements ITexturedItem , IHandHeld
{
private ToolMaterial material = ToolMaterial.WOOD;
public ItemTRSword(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase()+"Sword");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material=material;
}
public class ItemTRSword extends ItemSword implements ITexturedItem , IHandHeld {
private ToolMaterial material = ToolMaterial.WOOD;
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/"+material.name().toLowerCase()+"_sword";
}
public ItemTRSword(ToolMaterial material) {
super(material);
setUnlocalizedName(material.name().toLowerCase() + "Sword");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
this.material = material;
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/" + material.name().toLowerCase() + "_sword";
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
}

View file

@ -16,40 +16,29 @@ import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.items.ItemTextureBase;
public class ItemTechManual extends ItemTextureBase implements ITexturedItem
{
public class ItemTechManual extends ItemTextureBase implements ITexturedItem {
public ItemTechManual()
{
setCreativeTab(TechRebornCreativeTab.instance);
setUnlocalizedName("techreborn.manual");
setMaxStackSize(1);
}
public ItemTechManual() {
setCreativeTab(TechRebornCreativeTab.instance);
setUnlocalizedName("techreborn.manual");
setMaxStackSize(1);
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World world, EntityPlayer player,
EnumHand hand)
{
player.openGui(Core.INSTANCE, GuiHandler.manuelID, world, (int) player.posX, (int) player.posY,
(int) player.posY);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World world, EntityPlayer player,
EnumHand hand) {
player.openGui(Core.INSTANCE, GuiHandler.manuelID, world, (int) player.posX, (int) player.posY, (int) player.posY);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/manual";
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/manual";
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
tooltip.add(TextFormatting.RED + I18n.translateToLocal("tooltip.wip"));
}
}

View file

@ -11,40 +11,41 @@ import reborncore.RebornCore;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
public class ItemTreeTap extends Item implements ITexturedItem
{
public class ItemTreeTap extends Item implements ITexturedItem {
public ItemTreeTap()
{
setMaxStackSize(1);
setMaxDamage(20);
setUnlocalizedName("techreborn.treetap");
RebornCore.jsonDestroyer.registerObject(this);
setCreativeTab(TechRebornCreativeTab.instance);
}
public ItemTreeTap() {
setMaxStackSize(1);
setMaxDamage(20);
setUnlocalizedName("techreborn.treetap");
RebornCore.jsonDestroyer.registerObject(this);
setCreativeTab(TechRebornCreativeTab.instance);
}
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return stack.getMetadata() != 0;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return stack.getMetadata() != 0;
}
@Override
public String getTextureName(int damage)
{
return "techreborn:items/tool/treetap";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/treetap";
}
@Override
public int getMaxMeta()
{
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}

View file

@ -37,159 +37,135 @@ import java.util.Random;
/**
* Created by modmuss50 on 26/02/2016.
*/
public class ItemWrench extends ItemTR implements ITexturedItem
{
public class ItemWrench extends ItemTR implements ITexturedItem {
public ItemWrench()
{
setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.wrench");
setMaxStackSize(1);
}
public ItemWrench() {
setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.wrench");
setMaxStackSize(1);
}
@Override public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
{
if (world.isAirBlock(pos))
{
return EnumActionResult.FAIL;
}
TileEntity tile = world.getTileEntity(pos);
if (tile == null)
{
return EnumActionResult.FAIL;
}
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isAirBlock(pos)) {
return EnumActionResult.FAIL;
}
TileEntity tile = world.getTileEntity(pos);
if (tile == null) {
return EnumActionResult.FAIL;
}
if (!player.isSneaking() && !player.worldObj.isRemote)
{
if (tile instanceof TileMachineBase)
{
if (side != EnumFacing.DOWN && side != EnumFacing.UP)
{
((TileMachineBase) tile).setFacing(side);
return EnumActionResult.SUCCESS;
}
}
}
return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ, hand);
}
if (!player.isSneaking() && !player.worldObj.isRemote) {
if (tile instanceof TileMachineBase) {
if (side != EnumFacing.DOWN && side != EnumFacing.UP) {
((TileMachineBase) tile).setFacing(side);
return EnumActionResult.SUCCESS;
}
}
}
return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ, hand);
}
@Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (world.isAirBlock(pos))
{
return EnumActionResult.FAIL;
}
TileEntity tile = world.getTileEntity(pos);
if (tile == null)
{
return EnumActionResult.FAIL;
}
if (!world.isRemote)
{
if (player.isSneaking())
{
List<ItemStack> items = new ArrayList<>();
if (tile instanceof IInventory)
{
IInventory inventory = (IInventory) tile;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack itemStack = inventory.getStackInSlot(i);
if (world.isAirBlock(pos)) {
return EnumActionResult.FAIL;
}
TileEntity tile = world.getTileEntity(pos);
if (tile == null) {
return EnumActionResult.FAIL;
}
if (!world.isRemote) {
if (player.isSneaking()) {
List<ItemStack> items = new ArrayList<>();
if (tile instanceof IInventory) {
IInventory inventory = (IInventory) tile;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack != null)
{
if (itemStack.stackSize > 0)
{
if (itemStack.getItem() instanceof ItemBlock)
if (itemStack != null) {
if (itemStack.stackSize > 0) {
if (itemStack.getItem() instanceof ItemBlock)
if (!(((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase) || !(((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid)
|| !(((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid))
{
items.add(itemStack.copy());
}
}
}
}
if (tile instanceof IWrenchable)
{
if (((IWrenchable) tile).wrenchCanRemove(player))
{
ItemStack itemStack = ((IWrenchable) tile).getWrenchDrop(player);
if (itemStack == null)
{
return EnumActionResult.FAIL;
}
items.add(itemStack);
}
if (!items.isEmpty())
{
for (ItemStack itemStack : items)
{
if (!(((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase) || !(((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid)
|| !(((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid)) {
items.add(itemStack.copy());
}
}
}
}
if (tile instanceof IWrenchable) {
if (((IWrenchable) tile).wrenchCanRemove(player)) {
ItemStack itemStack = ((IWrenchable) tile).getWrenchDrop(player);
if (itemStack == null) {
return EnumActionResult.FAIL;
}
items.add(itemStack);
}
if (!items.isEmpty()) {
for (ItemStack itemStack : items) {
Random rand = new Random();
Random rand = new Random();
float dX = rand.nextFloat() * 0.8F + 0.1F;
float dY = rand.nextFloat() * 0.8F + 0.1F;
float dZ = rand.nextFloat() * 0.8F + 0.1F;
float dX = rand.nextFloat() * 0.8F + 0.1F;
float dY = rand.nextFloat() * 0.8F + 0.1F;
float dZ = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY,
pos.getZ() + dZ, itemStack.copy());
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY,
pos.getZ() + dZ, itemStack.copy());
if (itemStack.hasTagCompound())
{
entityItem.getEntityItem()
.setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem()
.setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
if (!world.isRemote)
{
world.spawnEntityInWorld(entityItem);
}
}
}
world.playSound(null, player.posX, player.posY,
player.posZ, ModSounds.dismantle,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!world.isRemote)
{
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return EnumActionResult.SUCCESS;
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
if (!world.isRemote) {
world.spawnEntityInWorld(entityItem);
}
}
}
world.playSound(null, player.posX, player.posY,
player.posZ, ModSounds.dismantle,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!world.isRemote) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.FAIL;
}else{
return EnumActionResult.FAIL;
}
}
}
}
return EnumActionResult.FAIL;
} else {
return EnumActionResult.FAIL;
}
}
@Override public String getTextureName(int damage)
{
return "techreborn:items/tool/wrench";
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/wrench";
}
@Override public int getMaxMeta()
{
return 1;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player,
int useRemaining)
{
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@SideOnly(Side.CLIENT) public boolean isFull3D()
{
return true;
}
}

View file

@ -0,0 +1,295 @@
package techreborn.power;
import cofh.api.energy.IEnergyContainerItem;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.api.ITeslaProducer;
import net.darkhax.tesla.capability.TeslaCapabilities;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.RebornCoreConfig;
public class EnergyItem {
public static void discharge(ItemStack itemStack, IEnergyInterfaceTile tile) {
Item item = itemStack.getItem();
if(item instanceof IEnergyItemInfo) {
IEnergyItemInfo energyInterfaceItem = (IEnergyItemInfo) item;
if(energyInterfaceItem.canProvideEnergy(itemStack) && getEnergy(itemStack) > 0) {
double extractEnergy = tile.getMaxPower() - tile.getEnergy();
double input = extractEnergy > tile.getMaxInput() ? tile.getMaxInput() : extractEnergy;
double transferLimit = energyInterfaceItem.getMaxTransfer(itemStack);
double remove = input > transferLimit ? transferLimit : input;
System.out.println(remove);
double extracted = useEnergy(remove, itemStack);
if(extracted != 0) {
tile.addEnergy(extracted);
}
}
}
if(item instanceof IEnergyInterfaceItem) {
IEnergyInterfaceItem energyInterfaceItem = (IEnergyInterfaceItem) item;
if(energyInterfaceItem.canProvideEnergy(itemStack) && energyInterfaceItem.getEnergy(itemStack) > 0) {
double extractEnergy = tile.getMaxPower() - tile.getEnergy();
double input = extractEnergy > tile.getMaxInput() ? tile.getMaxInput() : extractEnergy;
double transferLimit = energyInterfaceItem.getMaxTransfer(itemStack);
double remove = input > transferLimit ? transferLimit : input;
double extracted = energyInterfaceItem.useEnergy(remove, itemStack);
if(extracted != 0) {
tile.addEnergy(extracted);
}
}
}
if(RebornCoreConfig.getRebornPower().rf() &&
item instanceof IEnergyContainerItem) {
double extractEnergy = tile.getMaxPower() - tile.getEnergy();
double input = extractEnergy > tile.getMaxInput() ? tile.getMaxInput() : extractEnergy;
int extractRF = (int) (input * RebornCoreConfig.euPerRF);
IEnergyContainerItem energyContainer = (IEnergyContainerItem) item;
if(energyContainer.getEnergyStored(itemStack) > 0) {
int extractedRF = energyContainer.extractEnergy(itemStack, extractRF, false);
if (extractedRF != 0) {
float extractedEU = extractedRF / (RebornCoreConfig.euPerRF * 1F);
tile.addEnergy(extractedEU);
}
}
}
if(Loader.isModLoaded("IC2") &&
RebornCoreConfig.getRebornPower().eu() &&
item instanceof IElectricItem) {
IElectricItem electricItem = (IElectricItem) item;
if(electricItem.canProvideEnergy(itemStack) && ElectricItem.manager.getCharge(itemStack) > 0) {
double extractEnergy = tile.getMaxPower() - tile.getEnergy();
double input = extractEnergy > tile.getMaxInput() ? tile.getMaxInput() : extractEnergy;
double extracted = ElectricItem.manager.discharge(itemStack, input, electricItem.getTier(itemStack), false, true, false);
if(extracted != 0) {
tile.addEnergy(extracted);
}
}
}
if(Loader.isModLoaded("Tesla") &&
RebornCoreConfig.getRebornPower().tesla() &&
itemStack.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, null)) {
ITeslaProducer producer = itemStack.getCapability(TeslaCapabilities.CAPABILITY_PRODUCER, null);
double extractEnergy = tile.getMaxPower() - tile.getEnergy();
double input = extractEnergy > tile.getMaxInput() ? tile.getMaxInput() : extractEnergy;
long extractRF = (long) (input * RebornCoreConfig.euPerRF);
long extractedRF = producer.takePower(extractRF, false);
if(extractedRF != 0) {
float extractedEU = extractedRF / (RebornCoreConfig.euPerRF * 1F);
tile.addEnergy(extractedEU);
}
}
}
public static void charge(ItemStack itemStack, IEnergyInterfaceTile tile) {
Item item = itemStack.getItem();
if(item instanceof IEnergyItemInfo) {
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item;
if(energyItemInfo.canAcceptEnergy(itemStack) &&
getEnergy(itemStack) < energyItemInfo.getMaxPower(itemStack)) {
double storedEnergy = tile.getEnergy();
double output = storedEnergy > tile.getMaxOutput() ? tile.getMaxOutput() : storedEnergy;
double transferLimit = energyItemInfo.getMaxTransfer(itemStack);
double add = output > transferLimit ? transferLimit : output;
double addedEnergy = addEnergy(add, itemStack);
if(addedEnergy != 0) {
tile.useEnergy(addedEnergy);
}
}
}
if(item instanceof IEnergyInterfaceItem) {
IEnergyInterfaceItem energyItem = (IEnergyInterfaceItem) item;
if(energyItem.canAcceptEnergy(itemStack) &&
energyItem.getEnergy(itemStack) < energyItem.getMaxPower(itemStack)) {
double storedEnergy = tile.getEnergy();
double output = storedEnergy > tile.getMaxOutput() ? tile.getMaxOutput() : storedEnergy;
double transferLimit = energyItem.getMaxTransfer(itemStack);
double add = output > transferLimit ? transferLimit : output;
double addedEnergy = energyItem.addEnergy(add, itemStack);
if(addedEnergy != 0) {
tile.useEnergy(addedEnergy);
}
}
}
if(RebornCoreConfig.getRebornPower().rf() &&
item instanceof IEnergyContainerItem) {
double storedEnergy = tile.getEnergy();
double output = storedEnergy > tile.getMaxOutput() ? tile.getMaxOutput() : storedEnergy;
int insertRF = (int) (output * RebornCoreConfig.euPerRF);
IEnergyContainerItem energyContainer = (IEnergyContainerItem) item;
if(energyContainer.getEnergyStored(itemStack) < energyContainer.getMaxEnergyStored(itemStack)) {
int addedRF = energyContainer.receiveEnergy(itemStack, insertRF, false);
if (addedRF != 0) {
float addedEU = addedRF / (RebornCoreConfig.euPerRF * 1F);
tile.useEnergy(addedEU);
}
}
}
if(Loader.isModLoaded("IC2") &&
RebornCoreConfig.getRebornPower().eu() &&
item instanceof IElectricItem) {
IElectricItem electricItem = (IElectricItem) item;
if(ElectricItem.manager.getCharge(itemStack) < electricItem.getMaxCharge(itemStack)) {
double storedEnergy = tile.getEnergy();
double output = storedEnergy > tile.getMaxOutput() ? tile.getMaxOutput() : storedEnergy;
double added = ElectricItem.manager.charge(itemStack, output, electricItem.getTier(itemStack), false, false);
if(added != 0) {
tile.useEnergy(added);
}
}
}
if(Loader.isModLoaded("Tesla") &&
RebornCoreConfig.getRebornPower().tesla() &&
itemStack.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, null)) {
ITeslaConsumer consumer = itemStack.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, null);
double storedEnergy = tile.getEnergy();
double output = storedEnergy > tile.getMaxOutput() ? tile.getMaxOutput() : storedEnergy;
long extractRF = (long) (output * RebornCoreConfig.euPerRF);
long addedRF = consumer.givePower(extractRF, false);
if(addedRF != 0) {
float addedEU = addedRF / (RebornCoreConfig.euPerRF * 1F);
tile.useEnergy(addedEU);
}
}
}
public static void setEnergy(double energy, ItemStack stack) {
NBTTagCompound energyItem = new NBTTagCompound();
energyItem.setDouble("energy", energy);
if(stack.hasTagCompound()) {
stack.getTagCompound().setTag("EnergyItem", energyItem);
} else {
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("EnergyItem", energyItem);
stack.setTagCompound(tag);
}
}
public static double getEnergy(ItemStack stack) {
if(stack.getItem() instanceof IEnergyInterfaceItem) {
return ((IEnergyInterfaceItem) stack.getItem()).getEnergy(stack);
}
if(stack.hasTagCompound()) {
NBTTagCompound energyItem = stack.getTagCompound().getCompoundTag("EnergyItem");
return energyItem.getDouble("energy");
}
return 0.0f;
}
public static double getMaxPower(ItemStack itemStack) {
if(itemStack.getItem() instanceof IEnergyItemInfo)
return ((IEnergyItemInfo) itemStack.getItem()).getMaxPower(itemStack);
return 0F;
}
public static boolean canAddEnergy(double energy, ItemStack stack) {
return getMaxPower(stack) - getEnergy(stack) >= energy;
}
/**
* Will try add add the full amount of energy.
*
* @param energy
* amount to add
* @param stack
* The {@link ItemStack} that contains the power
* @return The amount of energy that was added.
*/
public static double addEnergy(double energy, ItemStack stack) {
return addEnergy(energy, false, stack);
}
/**
* Will try add add the full amount of energy, if simulate is true it wont
* add the energy
*
* @param energy
* amount to add
* @param stack
* The {@link ItemStack} that contains the power
* @return The amount of energy that was added.
*/
public static double addEnergy(double energy, boolean simulate, ItemStack stack) {
double canStore = getMaxPower(stack) - getEnergy(stack);
if(canStore >= energy) {
if(!simulate)
setEnergy(getEnergy(stack) + energy, stack);
return energy;
}
if(!simulate)
setEnergy(getEnergy(stack) + canStore, stack);
return canStore;
}
/**
* Returns true if it can use the full amount of energy
*
* @param energy
* amount of energy to use from the tile.
* @param stack
* The {@link ItemStack} that contains the power
* @return if all the energy can be used.
*/
public static boolean canUseEnergy(double energy, ItemStack stack) {
return getEnergy(stack) >= energy;
}
/**
* Will try and use the full amount of energy
*
* @param energy
* energy to use
* @param stack
* The {@link ItemStack} that contains the power
* @return the amount of energy used
*/
public static double useEnergy(double energy, ItemStack stack) {
return useEnergy(energy, false, stack);
}
/**
* Will try and use the full amount of energy, if simulate is true it wont
* add the energy
*
* @param energy
* energy to use
* @param simulate
* if true it will not use the item, it will only simulate it.
* @param stack
* The {@link ItemStack} that contains the power
* @return the amount of energy used
*/
public static double useEnergy(double energy, boolean simulate, ItemStack stack) {
double energyStored = getEnergy(stack);
if(energyStored >= energy) {
if(!simulate)
setEnergy(energyStored - energy, stack);
return energy;
}
if(!simulate)
setEnergy(0, stack);
return energyStored;
}
}

View file

@ -10,10 +10,9 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.tile.IEnergyReceiverTile;
import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.mcmultipart.block.TileMultipartContainer;
import reborncore.mcmultipart.multipart.ISlottedPart;
import reborncore.mcmultipart.multipart.PartSlot;

View file

@ -12,7 +12,6 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
@ -50,18 +49,6 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable,IIn
super.update();
crafter.updateEntity();
// charge(6); TODO
if (inventory.getStackInSlot(6) != null) {
ItemStack stack = inventory.getStackInSlot(6);
if (stack.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
if (item.canProvideEnergy(stack)) {
if (getEnergy() != getMaxPower()) {
addEnergy(item.getMaxTransfer(stack));
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
}
}
}
}
}
@Override

View file

@ -10,7 +10,7 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.PowerLocalization;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
@ -41,7 +41,7 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
public void addInfo(List<String> info, boolean isRealTile) {
super.addInfo(info, isRealTile);
info.add(TextFormatting.LIGHT_PURPLE + "Eu per extract " + TextFormatting.GREEN
+ PowerSystem.getLocalizedPower(ConfigTechReborn.pumpExtractEU));
+ PowerLocalization.getLocalizedPower(ConfigTechReborn.pumpExtractEU));
info.add(TextFormatting.LIGHT_PURPLE + "Speed: " + TextFormatting.GREEN
+ "1000mb/5 sec");
}

View file

@ -1,18 +1,17 @@
package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.*;
import reborncore.api.fuel.FluidPowerManager;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;

View file

@ -1,6 +1,5 @@
package techreborn.tiles.generator;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@ -8,7 +7,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;

View file

@ -8,15 +8,13 @@ import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.api.power.tile.IEnergyProducerTile;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import techreborn.blocks.storage.BlockEnergyStorage;
import techreborn.power.EnergyItem;
import techreborn.power.EnergyUtils;
import java.util.List;
@ -64,31 +62,12 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IEnergyProdu
@Override
public void update() {
super.update();
if (inventory.getStackInSlot(0) != null) {
ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
return;
}
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) {
if (canUseEnergy(item.getMaxTransfer(stack))) {
useEnergy(item.getMaxTransfer(stack));
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
}
}
EnergyItem.charge(inventory.getStackInSlot(0), this);
}
if (inventory.getStackInSlot(1) != null) {
ItemStack stack = inventory.getStackInSlot(1);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
return;
}
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
if (item.canProvideEnergy(stack)) {
if (getEnergy() != getMaxPower()) {
addEnergy(item.getMaxTransfer(stack));
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
}
}
EnergyItem.discharge(inventory.getStackInSlot(1), this);
}
if (!worldObj.isRemote && getEnergy() > 0) {

View file

@ -0,0 +1,12 @@
package techreborn.tiles.transformers;
import reborncore.api.power.EnumPowerTier;
import techreborn.init.ModBlocks;
public class TileEVTransformer extends TileTransformer {
public TileEVTransformer() {
super("EVTransformer", ModBlocks.evt, EnumPowerTier.EXTREME, 8192, 2048, 8192);
}
}

View file

@ -12,7 +12,7 @@ public class TileHVTransformer extends TileTransformer
public TileHVTransformer()
{
super("HVTransformer", ModBlocks.hvt, EnumPowerTier.EXTREME, ConfigTechReborn.HVTransformerMaxInput, ConfigTechReborn.HVTransformerMaxOutput, ConfigTechReborn.HVTransformerMaxInput*2);
super("HVTransformer", ModBlocks.hvt, EnumPowerTier.HIGH, 2048, 512, 2048);
}
}

View file

@ -10,9 +10,8 @@ import techreborn.init.ModBlocks;
public class TileLVTransformer extends TileTransformer
{
public TileLVTransformer()
{
super("LVTransformer", ModBlocks.lvt, EnumPowerTier.LOW, ConfigTechReborn.LVTransformerMaxInput, ConfigTechReborn.LVTransformerMaxOutput, ConfigTechReborn.LVTransformerMaxInput*2);
public TileLVTransformer() {
super("LVTransformer", ModBlocks.lvt, EnumPowerTier.MEDIUM, 128, 32, 128);
}
}

View file

@ -7,29 +7,10 @@ import techreborn.init.ModBlocks;
/**
* Created by modmuss50 on 16/03/2016.
*/
public class TileMVTransformer extends TileTransformer
{
public class TileMVTransformer extends TileTransformer {
public TileMVTransformer()
{
super("MVTransformer", ModBlocks.mvt, EnumPowerTier.HIGH, ConfigTechReborn.MVTransformerMaxInput, ConfigTechReborn.MVTransformerMaxOutput, ConfigTechReborn.LVTransformerMaxInput*2);
}
public TileMVTransformer() {
super("MVTransformer", ModBlocks.mvt, EnumPowerTier.HIGH, 512, 128, 512);
}
@Override
public double getMaxOutput()
{
return 128;
}
@Override
public double getMaxInput()
{
return 512;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.HIGH;
}
}

View file

@ -7,101 +7,105 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import techreborn.blocks.transformers.BlockTransformer;
/**
* Created by Rushmead
*
* @deprecated ? If wires limited to transfer rate and doesn't burn out, what's use of the transformers?
* TODO: Rewrite, find use or remove
*/
@Deprecated
public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable
{
public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable {
public String name;
public Block wrenchDrop;
public EnumPowerTier tier;
public int maxInput;
public int maxOutput;
public int maxStorage;
public String name;
public Block wrenchDrop;
public EnumPowerTier tier;
public int maxInput;
public int maxOutput;
public int maxStorage;
public TileTransformer(String name, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage)
{
super(1);
this.wrenchDrop = wrenchDrop;
this.tier = tier;
this.name = name;
this.maxInput = maxInput;
this.maxOutput = maxOuput;
this.maxStorage = maxStorage;
}
public TileTransformer(String name, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
this.wrenchDrop = wrenchDrop;
this.tier = tier;
this.name = name;
this.maxInput = maxInput;
this.maxOutput = maxOuput;
this.maxStorage = maxStorage;
}
@Override public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1)
{
return true;
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1) {
return true;
}
@Override public EnumFacing getFacing()
{
return getFacingEnum();
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
}
@Override public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return entityPlayer.isSneaking();
}
@Override
public void setFacing(EnumFacing facing) {
@Override public float getWrenchDropRate()
{
return 1.0F;
}
}
@Override public ItemStack getWrenchDrop(EntityPlayer p0)
{
return new ItemStack(wrenchDrop);
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@Override public double getMaxPower()
{
return maxStorage;
}
@Override
public float getWrenchDropRate() {
return 1.0F;
}
@Override public boolean canAcceptEnergy(EnumFacing direction)
{
@Override
public ItemStack getWrenchDrop(EntityPlayer p0) {
return new ItemStack(wrenchDrop);
}
return getFacingEnum() != direction;
}
@Override
public double getMaxPower() {
return maxStorage;
}
@Override public EnumFacing getFacingEnum()
{
Block block = worldObj.getBlockState(pos).getBlock();
if (block instanceof BlockTransformer)
{
return ((BlockTransformer) block).getFacing(worldObj.getBlockState(pos));
}
return null;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
@Override public boolean canProvideEnergy(EnumFacing direction)
{
return getFacing() == direction;
}
return getFacingEnum() != direction;
}
@Override
public EnumFacing getFacingEnum() {
Block block = worldObj.getBlockState(pos).getBlock();
if (block instanceof BlockTransformer) {
return ((BlockTransformer) block).getFacing(worldObj.getBlockState(pos));
}
return null;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return getFacing() == direction;
}
@Override public double getMaxOutput()
{
return maxOutput;
}
@Override
public double getMaxOutput() {
return maxOutput;
}
@Override public double getMaxInput()
{
return maxInput;
}
@Override
public double getMaxInput() {
return maxInput;
}
@Override
public EnumPowerTier getTier() {
return tier;
}
@Override
public void update() {
}
@Override public EnumPowerTier getTier()
{
return tier;
}
}