308 lines
7 KiB
Java
Executable file
308 lines
7 KiB
Java
Executable file
package common.item;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import common.attributes.Attribute;
|
|
import common.attributes.UsageSlot;
|
|
import common.block.Block;
|
|
import common.collect.Sets;
|
|
import common.color.TextColor;
|
|
import common.entity.npc.EntityNPC;
|
|
import common.entity.types.EntityLiving;
|
|
import common.model.ItemMeshDefinition;
|
|
import common.model.Model;
|
|
import common.model.ModelProvider;
|
|
import common.model.Transforms;
|
|
import common.util.BlockPos;
|
|
import common.util.ExtMath;
|
|
import common.util.Facing;
|
|
import common.util.HitPosition;
|
|
import common.util.Vec3;
|
|
import common.world.World;
|
|
|
|
public class Item
|
|
{
|
|
private int maxAmount = 64;
|
|
private int maxDamage = 0;
|
|
private Item containerItem;
|
|
private String potionEffect;
|
|
private String display;
|
|
private CheatTab tab;
|
|
private TextColor color = null;
|
|
|
|
public final Item setMaxAmount(int max)
|
|
{
|
|
this.maxAmount = max;
|
|
this.maxDamage = 0;
|
|
return this;
|
|
}
|
|
|
|
public final Item setMaxDamage(int max)
|
|
{
|
|
this.maxAmount = 1;
|
|
this.maxDamage = max;
|
|
return this;
|
|
}
|
|
|
|
public Item setDisplay(String name)
|
|
{
|
|
this.display = name;
|
|
return this;
|
|
}
|
|
|
|
public final Item setContainerItem(Item containerItem)
|
|
{
|
|
this.containerItem = containerItem;
|
|
return this;
|
|
}
|
|
|
|
public final Item setPotionEffect(String potionEffect)
|
|
{
|
|
this.potionEffect = potionEffect;
|
|
return this;
|
|
}
|
|
|
|
public final Item setTab(CheatTab tab)
|
|
{
|
|
this.tab = tab;
|
|
return this;
|
|
}
|
|
|
|
public Item setColor(TextColor color)
|
|
{
|
|
this.color = color;
|
|
return this;
|
|
}
|
|
|
|
|
|
public final int getItemStackLimit()
|
|
{
|
|
return this.maxAmount;
|
|
}
|
|
|
|
public final int getMaxDamage()
|
|
{
|
|
return this.maxDamage;
|
|
}
|
|
|
|
public final boolean isDamageable()
|
|
{
|
|
return this.maxDamage > 0;
|
|
}
|
|
|
|
|
|
public Block getBlock()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, BlockPos block) {
|
|
return false;
|
|
}
|
|
|
|
public float getStrVsBlock(ItemStack stack, Block state)
|
|
{
|
|
return 1.0F;
|
|
}
|
|
|
|
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
|
|
{
|
|
return itemStackIn;
|
|
}
|
|
|
|
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn)
|
|
{
|
|
return stack;
|
|
}
|
|
|
|
public int getMetadata()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLiving playerIn)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public boolean canHarvestBlock(Block blockIn)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public String getDisplay(ItemStack stack)
|
|
{
|
|
return this.display;
|
|
}
|
|
|
|
public Item getContainerItem()
|
|
{
|
|
return this.containerItem;
|
|
}
|
|
|
|
public boolean hasContainerItem()
|
|
{
|
|
return this.containerItem != null;
|
|
}
|
|
|
|
public int getColorFromItemStack(ItemStack stack, int renderPass)
|
|
{
|
|
return 16777215;
|
|
}
|
|
|
|
public ItemAction getItemUseAction(ItemStack stack)
|
|
{
|
|
return ItemAction.NONE;
|
|
}
|
|
|
|
public ItemAction getItemPosition(ItemStack stack)
|
|
{
|
|
return ItemAction.NONE;
|
|
}
|
|
|
|
public int getMaxItemUseDuration(ItemStack stack)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft)
|
|
{
|
|
}
|
|
|
|
public String getPotionEffect(ItemStack stack)
|
|
{
|
|
return this.potionEffect;
|
|
}
|
|
|
|
public boolean isPotionIngredient(ItemStack stack)
|
|
{
|
|
return this.getPotionEffect(stack) != null;
|
|
}
|
|
|
|
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
|
|
{
|
|
}
|
|
|
|
public boolean hasEffect(ItemStack stack)
|
|
{
|
|
return stack.isItemEnchanted();
|
|
}
|
|
|
|
public TextColor getColor(ItemStack stack)
|
|
{
|
|
return this.color != null ? this.color : (stack.isItemEnchanted() ? TextColor.NEON : TextColor.WHITE);
|
|
}
|
|
|
|
public boolean isItemTool(ItemStack stack)
|
|
{
|
|
return this.getItemStackLimit() == 1 && this.isDamageable();
|
|
}
|
|
|
|
protected HitPosition getMovingObjectPositionFromPlayer(World worldIn, EntityNPC playerIn, boolean useLiquids)
|
|
{
|
|
float f = playerIn.rotPitch;
|
|
float f1 = playerIn.rotYaw;
|
|
double d0 = playerIn.posX;
|
|
double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
|
|
double d2 = playerIn.posZ;
|
|
Vec3 vec3 = new Vec3(d0, d1, d2);
|
|
float f2 = ExtMath.cos(-f1 * 0.017453292F - (float)Math.PI);
|
|
float f3 = ExtMath.sin(-f1 * 0.017453292F - (float)Math.PI);
|
|
float f4 = -ExtMath.cos(-f * 0.017453292F);
|
|
float f5 = ExtMath.sin(-f * 0.017453292F);
|
|
float f6 = f3 * f4;
|
|
float f7 = f2 * f4;
|
|
double d3 = 5.0D;
|
|
Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
|
|
return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
|
|
}
|
|
|
|
public int getItemEnchantability()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public void getSubItems(Item itemIn, CheatTab tab, List<ItemStack> subItems)
|
|
{
|
|
subItems.add(new ItemStack(itemIn));
|
|
}
|
|
|
|
public CheatTab getTab()
|
|
{
|
|
return this.tab;
|
|
}
|
|
|
|
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public int getAttackDamageBonus() {
|
|
return 0;
|
|
}
|
|
|
|
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
|
|
{
|
|
}
|
|
|
|
public boolean isFragile() {
|
|
return false;
|
|
}
|
|
|
|
public final Set<String> getValidTags() {
|
|
return Sets.newHashSet();
|
|
}
|
|
|
|
public float getRadiation(ItemStack stack) {
|
|
return 0.0f;
|
|
}
|
|
|
|
public boolean isMagnetic() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isFirstPerson() {
|
|
return true;
|
|
}
|
|
|
|
public boolean canBeWielded() {
|
|
return false;
|
|
}
|
|
|
|
public String getHotbarText(EntityNPC player, ItemStack stack) {
|
|
return stack.getColoredName();
|
|
}
|
|
|
|
public Transforms getTransform() {
|
|
return Transforms.ITEM;
|
|
}
|
|
|
|
public Model getModel(ModelProvider provider, String name) {
|
|
return provider.getModel(this.getTransform(), name);
|
|
}
|
|
|
|
public ItemMeshDefinition getMesher() {
|
|
return null;
|
|
}
|
|
|
|
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
|
|
subItems.add(new ItemStack(itemIn));
|
|
}
|
|
}
|