2018-10-15 14:45:56 -05:00
|
|
|
package net.yseven.findyourway.item;
|
|
|
|
|
2018-10-15 22:29:48 -05:00
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
2018-10-15 14:45:56 -05:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
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;
|
2018-10-15 22:29:48 -05:00
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2018-10-15 14:45:56 -05:00
|
|
|
import net.yseven.findyourway.Client.ClientProxy;
|
|
|
|
import net.yseven.findyourway.CommonProxy;
|
|
|
|
import net.yseven.findyourway.FindYourWay;
|
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
|
|
|
public class ItemCompassBase extends Item {
|
|
|
|
private final String structureType;
|
|
|
|
private BlockPos structurePos;
|
|
|
|
private World structureWorld;
|
|
|
|
public final String assetTag;
|
|
|
|
|
2018-10-15 22:29:48 -05:00
|
|
|
public ItemCompassBase(String name, String structureName) {
|
|
|
|
setUnlocalizedName(FindYourWay.modId + "." + name);
|
|
|
|
setRegistryName(name);
|
|
|
|
structureType = structureName;
|
|
|
|
setCreativeTab(CreativeTabs.TOOLS);
|
|
|
|
setMaxStackSize(1);
|
|
|
|
assetTag = name + "_angle";
|
2018-10-15 14:45:56 -05:00
|
|
|
CommonProxy.compassList.add(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getStructureType() {
|
|
|
|
return structureType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStructurePos(BlockPos pos) {
|
|
|
|
structurePos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
public BlockPos getStructurePos() {
|
|
|
|
return structurePos;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStructureWorld(World world) {
|
|
|
|
structureWorld = world;
|
|
|
|
}
|
|
|
|
|
|
|
|
public World getStructureWorld() {
|
|
|
|
return structureWorld;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void registerItemModel() {
|
2018-10-15 22:29:48 -05:00
|
|
|
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
|
2018-10-15 14:45:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
|
|
|
|
if (world.isRemote) {
|
|
|
|
ClientProxy.resetStructurePos(this);
|
|
|
|
}
|
|
|
|
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
|
|
|
}
|
|
|
|
}
|