Получение тайла при разрушении блока

1,087
2
Я делаю foci (КУЛ КУЛ). Делаю "проверку" (Таум даёт только такую возможность как я понял):
Код:
    public boolean isVisCostPerTick(ItemStack focusstack) {
        return true; //Ну эт значит, что мол мы можем тратить вис.
    }
    
    public AspectList getVisCost(ItemStack focusstack) {
        return new AspectList().add(Aspect.ENTROPY, 50); //Тратит 0,05 вис (Или 0,5...)
    }
    
    public WandFocusAnimation getAnimation(ItemStack focusstack)
    {
        return WandFocusAnimation.WAVE; //Эт какая анимация будет. Я выбрал такую же как та, что исходит от ноды когда мы всасываем вис
    }
    
    public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) //onFocusRightClick, думаю объяснять не надо.
    {
        ItemStack foci = ItemStack.loadItemStackFromNBT(MiscUtils.getStackTag(wandstack).getCompoundTag("focus")); //У меня свой классик MiscUtils, но там толком мало что есть.
        
        if(movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK)
        {
            Block b = world.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); //Проверяем на блок (Кек :D)
            int meta = world.getBlockMetadata(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); //На мету
            int asp = b.??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? /* То-есть, что тут должно быть? */; //Ваще ничего не понимаю. 
        }
    }

MiscUtils -_-:
Код:
package mm.utils;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class MiscUtils {
    public static NBTTagCompound getStackTag(ItemStack stack)
    {
        createNBTTag(stack);
        return stack.getTagCompound();
    }
    
    public static void createNBTTag(ItemStack stack)
    {
        if(stack.hasTagCompound())
        {
            return;
        }
        NBTTagCompound itemTag = new NBTTagCompound();
        stack.setTagCompound(itemTag);
    }
}
Код:
package thaumcraft.api.wands;

import java.text.DecimalFormat;
import java.util.LinkedHashMap;
import java.util.List;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemFocusBasic extends Item {
 
 public ItemFocusBasic ()
    {
        super();
        maxStackSize = 1;
        canRepair=false;
        this.setMaxDamage(0);
    }
 
 public IIcon icon;
 
 @SideOnly(Side.CLIENT)
 @Override
 public IIcon getIconFromDamage(int par1) {
 return icon;
 }
 
 @Override
 public boolean isDamageable() {
 return false;
 }

 @Override
 public void addInformation(ItemStack stack,EntityPlayer player, List list, boolean par4) {
 AspectList al = this.getVisCost(stack);
 if (al!=null && al.size()>0) {
 list.add(StatCollector.translateToLocal(isVisCostPerTick(stack)?"item.Focus.cost2":"item.Focus.cost1"));
 for (Aspect aspect:al.getAspectsSorted()) {
 DecimalFormat myFormatter = new DecimalFormat("#####.##");
 String amount = myFormatter.format(al.getAmount(aspect)/100f);
 list.add(" \u00A7"+aspect.getChatcolor()+aspect.getName()+"\u00A7r x "+ amount); 
 }
 }
 addFocusInformation(stack,player,list,par4);
 }
 
 public void addFocusInformation(ItemStack focusstack,EntityPlayer player, List list, boolean par4) {
 LinkedHashMap<Short, Integer> map = new LinkedHashMap<Short, Integer>();
 for (short id:this.getAppliedUpgrades(focusstack)) {
 if (id>=0) {
 int amt = 1;
 if (map.containsKey(id)) {
 amt = map.get(id) + 1; 
 }
 map.put(id, amt);
 }
 }
 for (Short id:map.keySet()) { 
 list.add(EnumChatFormatting.DARK_PURPLE +FocusUpgradeType.types[id].getLocalizedName()+
 (map.get(id)>1?" "+StatCollector.translateToLocal("enchantment.level." + map.get(id)):""));
 }
 }
 
 /**
  * Purely for display on the focus tooltip (see addInformation method above)
  */
 public boolean isVisCostPerTick(ItemStack focusstack) {
 return false;
 }
 
 @Override
 public EnumRarity getRarity(ItemStack focusstack)
    {
        return EnumRarity.rare;
    } 
 
 /**
  * What color will the focus orb be rendered on the held wand
  */
 public int getFocusColor(ItemStack focusstack) {
 return 0;
 }

 
 /**
  * Does the focus have ornamentation like the focus of the nine hells. Ornamentation is a standard icon rendered in a cross around the focus
  */ 
 public IIcon getOrnament(ItemStack focusstack) {
 // TODO Auto-generated method stub
 return null;
 }
 
 /**
  * An icon to be rendered inside the focus itself
  */
 public IIcon getFocusDepthLayerIcon(ItemStack focusstack) {
 // TODO Auto-generated method stub
 return null;
 }
 
 public enum WandFocusAnimation {
 WAVE, CHARGE;
 }

 public WandFocusAnimation getAnimation(ItemStack focusstack) {
 return WandFocusAnimation.WAVE;
 }
 
 /**
  * Just insert two alphanumeric characters before this string in your focus item class
  */
 public String getSortingHelper(ItemStack focusstack) { 
 String out="";
 for (short id:this.getAppliedUpgrades(focusstack)) {
 out = out + id;
 }
 return out;
 }
 
 
 /**
  * How much vis does this focus consume per activation. 
  */
 public AspectList getVisCost(ItemStack focusstack) {
 return null;
 }
 
 /**
  * This returns how many milliseconds must pass before the focus can be activated again.
  */ 
 public int getActivationCooldown(ItemStack focusstack) {
 return 0;
 } 
 
 /**
  * Used by foci like equal trade to determine their area in artchitect mode 
  */
 public int getMaxAreaSize(ItemStack focusstack) {
 return 1;
 }
 
 /**
  * What upgrades can be applied to this focus for ranks 1 to 5
  */
 public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
 return null;
 }
 
 /**
  * What upgrades does the focus currently have
  */
 public short[] getAppliedUpgrades(ItemStack focusstack) {
 short[] l = new short[] {-1,-1,-1,-1,-1};
 NBTTagList nbttaglist = getFocusUpgradeTagList(focusstack);
        if (nbttaglist == null)
        {
            return l;
        }
        else
        {         
            for (int j = 0; j < nbttaglist.tagCount(); ++j)
            {
             if (j>=5) break;
             l[j] = nbttaglist.getCompoundTagAt(j).getShort("id");
            }

            return l;
        }
 }
 
 public boolean applyUpgrade(ItemStack focusstack, FocusUpgradeType type, int rank) {
 short[] upgrades = getAppliedUpgrades(focusstack);
 if (upgrades[rank-1]!=-1 || rank<1 || rank>5) {
 return false;
 }
 upgrades[rank-1] = type.id;
 setFocusUpgradeTagList(focusstack, upgrades);
 return true;
 }
 
 /**
  * Use this method to define custom logic about which upgrades can be applied. This can be used to set up upgrade "trees" 
  * that make certain upgrades available only when others are unlocked first, when certain research is completed, or similar logic.
  * 
  */
 public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) {
 return true;
 }

 /**
  * Does this focus have the passed upgrade type
  */
 public boolean isUpgradedWith(ItemStack focusstack, FocusUpgradeType focusUpgradetype) {
 return getUpgradeLevel(focusstack,focusUpgradetype)>0;
 }

 /**
  * What level is the passed upgrade type on the focus. If it is not present it returns 0
  */
 public int getUpgradeLevel(ItemStack focusstack, FocusUpgradeType focusUpgradetype) {
 short[] list = getAppliedUpgrades(focusstack);
 int level=0;
 for (short id:list) {
 if (id == focusUpgradetype.id)
            {
                level++;
            }
 }
        return level;
 } 
 
 public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) {
 // TODO Auto-generated method stub
 return null;
 }
 
 public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player,int count) {
 // TODO Auto-generated method stub 
 }
 
 public void onPlayerStoppedUsingFocus(ItemStack wandstack, World world, EntityPlayer player, int count) {
 // TODO Auto-generated method stub
 
 }
 
 public boolean onFocusBlockStartBreak(ItemStack wandstack, int x, int y,int z, EntityPlayer player) {
 // TODO Auto-generated method stub
 return false;
 }
 
 /**
  * Internal helper methods
  */
 private NBTTagList getFocusUpgradeTagList(ItemStack focusstack)
    {
        return focusstack.stackTagCompound == null ? null : focusstack.stackTagCompound.getTagList("upgrade", 10);
    }
 
 private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) {
 if (!focusstack.hasTagCompound()) 
 focusstack.setTagCompound(new NBTTagCompound());
 NBTTagCompound nbttagcompound = focusstack.getTagCompound();
 NBTTagList tlist = new NBTTagList();
 nbttagcompound.setTag("upgrade", tlist);
 for (short id : upgrades) { 
 NBTTagCompound f = new NBTTagCompound();
 f.setShort("id", id);
 tlist.appendTag(f);
 }
 }

 @Override
 public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) {
 if (stack.stackTagCompound !=null && stack.stackTagCompound.hasKey("ench")) {
 stack.stackTagCompound.removeTag("ench");
 }
 super.onUpdate(stack, world, entity, p_77663_4_, p_77663_5_);
 }

 
 
}
//ItemFocusBasic
Код:
package thaumcraft.api.aspects;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.apache.commons.lang3.text.WordUtils;

public class Aspect {
 
 String tag;
 Aspect[] components;
 int color;
 private String chatcolor;
 ResourceLocation image;
 int blend;

 /**
  * Use this constructor to register your own aspects.
  * @param tag the key that will be used to reference this aspect, as well as its latin display name
  * @param color color to display the tag in
  * @param components the aspects this one is formed from
  * @param image ResourceLocation pointing to a 32x32 icon of the aspect
  * @param blend GL11 blendmode (1 or 771). Used for rendering nodes. Default is 1
  */
 public Aspect(String tag, int color, Aspect[] components, ResourceLocation image, int blend) {
 if (aspects.containsKey(tag)) throw new IllegalArgumentException(tag+" already registered!");
 this.tag = tag;
 this.components = components;
 this.color = color;
 this.image = image;
 this.blend = blend;
 aspects.put(tag, this);
 }
 
 /**
  * Shortcut constructor I use for the default aspects - you shouldn't be using this.
  */
 public Aspect(String tag, int color, Aspect[] components) {
 this(tag,color,components,new ResourceLocation("thaumcraft","textures/aspects/"+tag.toLowerCase()+".png"),1);
 }
 
 /**
  * Shortcut constructor I use for the default aspects - you shouldn't be using this.
  */
 public Aspect(String tag, int color, Aspect[] components, int blend) {
 this(tag,color,components,new ResourceLocation("thaumcraft","textures/aspects/"+tag.toLowerCase()+".png"),blend);
 }

 /**
  * Shortcut constructor I use for the primal aspects - 
  * you shouldn't use this as making your own primal aspects will break all the things.
  */
 public Aspect(String tag, int color, String chatcolor, int blend) {
 this(tag,color,(Aspect[])null, blend);
 this.setChatcolor(chatcolor);
 }
 
 public int getColor() {
 return color;
 }
 
 public String getName() {
 return WordUtils.capitalizeFully(tag);
 }
 
 public String getLocalizedDescription() {
 return StatCollector.translateToLocal("tc.aspect."+tag);
 }
 
 public String getTag() {
 return tag;
 }

 public void setTag(String tag) {
 this.tag = tag;
 }

 public Aspect[] getComponents() {
 return components;
 }

 public void setComponents(Aspect[] components) {
 this.components = components;
 }
 
 public ResourceLocation getImage() {
 return image;
 }
 
 public static Aspect getAspect(String tag) {
 return aspects.get(tag);
 }
 
 public int getBlend() {
 return blend;
 }

 public void setBlend(int blend) {
 this.blend = blend;
 }
 
 public boolean isPrimal() {
 return getComponents()==null || getComponents().length!=2;
 }
 
 ///////////////////////////////
 public static ArrayList<Aspect> getPrimalAspects() {
 ArrayList<Aspect> primals = new ArrayList<Aspect>();
 Collection<Aspect> pa = aspects.values();
 for (Aspect aspect:pa) {
 if (aspect.isPrimal())  primals.add(aspect);
 }
 return primals;
 }
 
 public static ArrayList<Aspect> getCompoundAspects() {
 ArrayList<Aspect> compounds = new ArrayList<Aspect>();
 Collection<Aspect> pa = aspects.values();
 for (Aspect aspect:pa) {
 if (!aspect.isPrimal())  compounds.add(aspect);
 }
 return compounds;
 }

 public String getChatcolor() {
 return chatcolor;
 }

 public void setChatcolor(String chatcolor) {
 this.chatcolor = chatcolor;
 }
 

 ///////////////////////////////
 public static LinkedHashMap<String,Aspect> aspects = new LinkedHashMap<String,Aspect>();
 
 //PRIMAL
 public static final Aspect AIR = new Aspect("aer",0xffff7e,"e",1);
 public static final Aspect EARTH = new Aspect("terra",0x56c000,"2",1);
 public static final Aspect FIRE = new Aspect("ignis",0xff5a01,"c",1);
 public static final Aspect WATER = new Aspect("aqua",0x3cd4fc,"3",1);
 public static final Aspect ORDER = new Aspect("ordo",0xd5d4ec,"7",1);
 public static final Aspect ENTROPY = new Aspect("perditio",0x404040,"8",771);
 
 //SECONDARY   
 public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {AIR, ENTROPY},771);
 public static final Aspect LIGHT = new Aspect("lux",0xfff663, new Aspect[] {AIR, FIRE});
 public static final Aspect WEATHER = new Aspect("tempestas",0xFFFFFF, new Aspect[] {AIR, WATER});
 public static final Aspect MOTION = new Aspect("motus",0xcdccf4, new Aspect[] {AIR, ORDER});
 public static final Aspect COLD = new Aspect("gelum",0xe1ffff, new Aspect[] {FIRE, ENTROPY});
 public static final Aspect CRYSTAL = new Aspect("vitreus",0x80ffff, new Aspect[] {EARTH, ORDER});
 public static final Aspect LIFE = new Aspect("victus",0xde0005, new Aspect[] {WATER, EARTH});
 public static final Aspect POISON = new Aspect("venenum",0x89f000,  new Aspect[] {WATER, ENTROPY}); 
 public static final Aspect ENERGY = new Aspect("potentia",0xc0ffff, new Aspect[] {ORDER, FIRE});
 public static final Aspect EXCHANGE = new Aspect("permutatio",0x578357, new Aspect[] {ENTROPY, ORDER});
// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {AIR, EARTH});
// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, EARTH});
// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, WATER});
// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {ORDER, WATER});
// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {EARTH, ENTROPY});
 
 //TERTIARY   
 public static final Aspect METAL = new Aspect("metallum",0xb5b5cd, new Aspect[] {EARTH, CRYSTAL});
 public static final Aspect DEATH = new Aspect("mortuus",0x887788, new Aspect[] {LIFE, ENTROPY});
 public static final Aspect FLIGHT = new Aspect("volatus",0xe7e7d7, new Aspect[] {AIR, MOTION});
 public static final Aspect DARKNESS = new Aspect("tenebrae",0x222222, new Aspect[] {VOID, LIGHT});
 public static final Aspect SOUL = new Aspect("spiritus",0xebebfb, new Aspect[] {LIFE, DEATH});
 public static final Aspect HEAL = new Aspect("sano",0xff2f34, new Aspect[] {LIFE, ORDER});
 public static final Aspect TRAVEL = new Aspect("iter",0xe0585b, new Aspect[] {MOTION, EARTH});
 public static final Aspect ELDRITCH = new Aspect("alienis",0x805080, new Aspect[] {VOID, DARKNESS});
 public static final Aspect MAGIC = new Aspect("praecantatio",0x9700c0, new Aspect[] {VOID, ENERGY});
 public static final Aspect AURA = new Aspect("auram",0xffc0ff, new Aspect[] {MAGIC, AIR});
 public static final Aspect TAINT = new Aspect("vitium",0x800080, new Aspect[] {MAGIC, ENTROPY});
 public static final Aspect SLIME = new Aspect("limus",0x01f800, new Aspect[] {LIFE, WATER});
 public static final Aspect PLANT = new Aspect("herba",0x01ac00, new Aspect[] {LIFE, EARTH});
 public static final Aspect TREE = new Aspect("arbor",0x876531, new Aspect[] {AIR, PLANT}); 
 public static final Aspect BEAST = new Aspect("bestia",0x9f6409, new Aspect[] {MOTION, LIFE});
 public static final Aspect FLESH = new Aspect("corpus",0xee478d, new Aspect[] {DEATH, BEAST});
 public static final Aspect UNDEAD = new Aspect("exanimis",0x3a4000, new Aspect[] {MOTION, DEATH});
 public static final Aspect MIND = new Aspect("cognitio",0xffc2b3, new Aspect[] {FIRE, SOUL});
 public static final Aspect SENSES = new Aspect("sensus",0x0fd9ff, new Aspect[] {AIR, SOUL});
 public static final Aspect MAN = new Aspect("humanus",0xffd7c0, new Aspect[] {BEAST, MIND});
 public static final Aspect CROP = new Aspect("messis",0xe1b371, new Aspect[] {PLANT, MAN}); 
 public static final Aspect MINE = new Aspect("perfodio",0xdcd2d8, new Aspect[] {MAN, EARTH});
 public static final Aspect TOOL = new Aspect("instrumentum",0x4040ee, new Aspect[] {MAN, ORDER});
 public static final Aspect HARVEST = new Aspect("meto",0xeead82, new Aspect[] {CROP, TOOL});
 public static final Aspect WEAPON = new Aspect("telum",0xc05050, new Aspect[] {TOOL, FIRE});
 public static final Aspect ARMOR = new Aspect("tutamen",0x00c0c0, new Aspect[] {TOOL, EARTH});
 public static final Aspect HUNGER = new Aspect("fames",0x9a0305, new Aspect[] {LIFE, VOID});
 public static final Aspect GREED = new Aspect("lucrum",0xe6be44, new Aspect[] {MAN, HUNGER});
 public static final Aspect CRAFT = new Aspect("fabrico",0x809d80, new Aspect[] {MAN, TOOL});
 public static final Aspect CLOTH = new Aspect("pannus",0xeaeac2, new Aspect[] {TOOL, BEAST});
 public static final Aspect MECHANISM = new Aspect("machina",0x8080a0, new Aspect[] {MOTION, TOOL});
 public static final Aspect TRAP = new Aspect("vinculum",0x9a8080, new Aspect[] {MOTION, ENTROPY}); 
 
 
}

Вообщем, мне нужно getPrimalAspect (Хотя конечно может изменю это, но потом). А aspectOrb это тайлы как и ExpDrop...
 
Назад
Сверху