MOre fixes for items. Down to 860

This commit is contained in:
drcrazy 2019-02-22 01:13:30 +03:00
parent e513e20e5a
commit e3be87d517
8 changed files with 38 additions and 39 deletions

View file

@ -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);
}

View file

@ -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<ItemStack> 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));
}
}

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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);
}
}
}

View file

@ -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));
}
}

View file

@ -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