From e3be87d51786c69bb4ead6b30323b41d3421937e Mon Sep 17 00:00:00 2001 From: drcrazy Date: Fri, 22 Feb 2019 01:13:30 +0300 Subject: [PATCH] MOre fixes for items. Down to 860 --- .../java/techreborn/items/DynamicCell.java | 4 +-- .../techreborn/items/ItemDestructopack.java | 8 ++++- .../items/ItemFrequencyTransmitter.java | 12 +++---- .../java/techreborn/items/ItemManual.java | 2 +- .../java/techreborn/items/ItemScrapBox.java | 2 ++ .../techreborn/items/tool/ItemDebugTool.java | 36 +++++++++---------- .../techreborn/items/tool/ItemTreeTap.java | 10 ++---- .../techreborn/items/tool/ItemWrench.java | 3 +- 8 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/main/java/techreborn/items/DynamicCell.java b/src/main/java/techreborn/items/DynamicCell.java index 8f12742a6..d5e9b5205 100644 --- a/src/main/java/techreborn/items/DynamicCell.java +++ b/src/main/java/techreborn/items/DynamicCell.java @@ -47,6 +47,7 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; import org.apache.commons.lang3.Validate; import reborncore.common.util.StringUtils; +import techreborn.TechReborn; import techreborn.events.TRRecipeHandler; import techreborn.init.TRContent; @@ -58,8 +59,7 @@ public class DynamicCell extends Item { public static final int CAPACITY = Fluid.BUCKET_VOLUME; public DynamicCell() { - super(); - setMaxStackSize(64); + super(new Item.Properties().group(TechReborn.ITEMGROUP)); TRRecipeHandler.hideEntry(this); } diff --git a/src/main/java/techreborn/items/ItemDestructopack.java b/src/main/java/techreborn/items/ItemDestructopack.java index a5d2672f1..7668356f4 100644 --- a/src/main/java/techreborn/items/ItemDestructopack.java +++ b/src/main/java/techreborn/items/ItemDestructopack.java @@ -30,6 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import techreborn.TechReborn; import techreborn.client.EGui; @@ -37,11 +38,16 @@ import techreborn.client.EGui; public class ItemDestructopack extends Item { public ItemDestructopack() { + super(new Item.Properties().group(TechReborn.ITEMGROUP)); } @Override public ActionResult onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) { - player.openGui(TechReborn.INSTANCE, EGui.DESTRUCTOPACK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posY); + if (world.isRemote) { + BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ); + EGui.DESTRUCTOPACK.open(player, pos, world); + } + //TODO: Add server part return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } } diff --git a/src/main/java/techreborn/items/ItemFrequencyTransmitter.java b/src/main/java/techreborn/items/ItemFrequencyTransmitter.java index 201c3abad..5c8675606 100644 --- a/src/main/java/techreborn/items/ItemFrequencyTransmitter.java +++ b/src/main/java/techreborn/items/ItemFrequencyTransmitter.java @@ -43,6 +43,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.DimensionManager; import reborncore.client.hud.StackInfoElement; import reborncore.common.util.ChatUtils; +import techreborn.TechReborn; import techreborn.init.TRContent; import techreborn.utils.MessageIDs; @@ -52,16 +53,13 @@ import java.util.List; public class ItemFrequencyTransmitter extends Item { public ItemFrequencyTransmitter() { - setMaxStackSize(1); + super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); this.addPropertyOverride(new ResourceLocation("techreborn", "coords"), new IItemPropertyGetter() { @Override @OnlyIn(Dist.CLIENT) - public float apply(ItemStack stack, - @Nullable - World worldIn, - @Nullable - EntityLivingBase entityIn) { - if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().hasKey("x") && stack.getTag().hasKey("y") && stack.getTag().hasKey("z") && stack.getTag().hasKey("dim")) { + public float call(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { + if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().hasKey("x") + && stack.getTag().hasKey("y") && stack.getTag().hasKey("z") && stack.getTag().hasKey("dim")) { return 1.0F; } return 0.0F; diff --git a/src/main/java/techreborn/items/ItemManual.java b/src/main/java/techreborn/items/ItemManual.java index 3ee2a6cb3..b5ec5f570 100644 --- a/src/main/java/techreborn/items/ItemManual.java +++ b/src/main/java/techreborn/items/ItemManual.java @@ -37,7 +37,7 @@ import techreborn.client.EGui; public class ItemManual extends Item { public ItemManual() { - this.setMaxStackSize(1); + super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); } @Override diff --git a/src/main/java/techreborn/items/ItemScrapBox.java b/src/main/java/techreborn/items/ItemScrapBox.java index 80e5774df..9a74ef47a 100644 --- a/src/main/java/techreborn/items/ItemScrapBox.java +++ b/src/main/java/techreborn/items/ItemScrapBox.java @@ -34,12 +34,14 @@ import net.minecraft.world.World; import reborncore.api.recipe.IBaseRecipeType; import reborncore.api.recipe.RecipeHandler; import reborncore.common.util.WorldUtils; +import techreborn.TechReborn; import techreborn.api.Reference; import java.util.List; public class ItemScrapBox extends Item { public ItemScrapBox() { + super(new Item.Properties().group(TechReborn.ITEMGROUP)); } @Override diff --git a/src/main/java/techreborn/items/tool/ItemDebugTool.java b/src/main/java/techreborn/items/tool/ItemDebugTool.java index e0e1aba7f..7272b0cff 100644 --- a/src/main/java/techreborn/items/tool/ItemDebugTool.java +++ b/src/main/java/techreborn/items/tool/ItemDebugTool.java @@ -25,19 +25,17 @@ package techreborn.items.tool; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; import net.minecraftforge.energy.CapabilityEnergy; +import net.minecraftforge.energy.IEnergyStorage; import reborncore.api.power.IEnergyInterfaceTile; import reborncore.common.powerSystem.PowerSystem; +import techreborn.TechReborn; /** * Created by Mark on 20/03/2016. @@ -45,37 +43,37 @@ import reborncore.common.powerSystem.PowerSystem; public class ItemDebugTool extends Item { public ItemDebugTool() { + super(new Item.Properties().group(TechReborn.ITEMGROUP)); } @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, - EnumFacing facing, float hitX, float hitY, float hitZ) { - Block block = worldIn.getBlockState(pos).getBlock(); + public EnumActionResult onItemUse(ItemUseContext context) { + Block block = context.getWorld().getBlockState(context.getPos()).getBlock(); if (block != null) { - sendMessage(playerIn, worldIn, new TextComponentString(TextFormatting.GREEN + "Block Registry Name: " + sendMessage(context, new TextComponentString(TextFormatting.GREEN + "Block Registry Name: " + TextFormatting.BLUE + block.getRegistryName().toString())); } else { return EnumActionResult.FAIL; } - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = context.getWorld().getTileEntity(context.getPos()); if (tile != null) { - sendMessage(playerIn, worldIn, new TextComponentString( - TextFormatting.GREEN + "Tile Entity: " + TextFormatting.BLUE + tile.getDisplayName().toString())); + sendMessage(context, new TextComponentString( + TextFormatting.GREEN + "Tile Entity: " + TextFormatting.BLUE + tile.getType().toString())); } if (tile instanceof IEnergyInterfaceTile) { - sendMessage(playerIn, worldIn, new TextComponentString(TextFormatting.GREEN + "Power: " + sendMessage(context, new TextComponentString(TextFormatting.GREEN + "Power: " + TextFormatting.BLUE + PowerSystem.getLocaliszedPower(((IEnergyInterfaceTile) tile).getEnergy()))); - } else if (tile.hasCapability(CapabilityEnergy.ENERGY, facing)) { - sendMessage(playerIn, worldIn, new TextComponentString(TextFormatting.GREEN + "Power " + TextFormatting.RED - + tile.getCapability(CapabilityEnergy.ENERGY, facing).getEnergyStored() + "FU")); + } else if (tile.getCapability(CapabilityEnergy.ENERGY, context.getPlacementHorizontalFacing()) != null) { + sendMessage(context, new TextComponentString(TextFormatting.GREEN + "Power " + TextFormatting.RED + + ((IEnergyStorage) tile.getCapability(CapabilityEnergy.ENERGY, context.getPlacementHorizontalFacing())).getEnergyStored() + "FU")); } return EnumActionResult.SUCCESS; } - private void sendMessage(EntityPlayer playerIn, World worldIn, TextComponentString string) { - if (!worldIn.isRemote) { - playerIn.sendMessage(string); + private void sendMessage(ItemUseContext context, TextComponentString string) { + if (!context.getWorld().isRemote) { + context.getPlayer().sendMessage(string); } } } diff --git a/src/main/java/techreborn/items/tool/ItemTreeTap.java b/src/main/java/techreborn/items/tool/ItemTreeTap.java index 23b9af554..70c23a18b 100644 --- a/src/main/java/techreborn/items/tool/ItemTreeTap.java +++ b/src/main/java/techreborn/items/tool/ItemTreeTap.java @@ -25,17 +25,11 @@ package techreborn.items.tool; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import techreborn.TechReborn; public class ItemTreeTap extends Item { public ItemTreeTap() { - setMaxStackSize(1); - setMaxDamage(20); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return stack.getMetadata() != 0; + super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1).defaultMaxDamage(20)); } } diff --git a/src/main/java/techreborn/items/tool/ItemWrench.java b/src/main/java/techreborn/items/tool/ItemWrench.java index 5cca0a4ef..78809d507 100644 --- a/src/main/java/techreborn/items/tool/ItemWrench.java +++ b/src/main/java/techreborn/items/tool/ItemWrench.java @@ -33,6 +33,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import reborncore.api.IToolHandler; +import techreborn.TechReborn; /** * Created by modmuss50 on 26/02/2016. @@ -40,7 +41,7 @@ import reborncore.api.IToolHandler; public class ItemWrench extends Item implements IToolHandler { public ItemWrench() { - setMaxStackSize(1); + super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); } @Override