();
326 |
327 | /**
328 | * Checks to see if the passed item/block already has aspects associated with it.
329 | * @param id
330 | * @param meta
331 | * @return
332 | */
333 | public static boolean exists(Item item, int meta) {
334 | AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,meta));
335 | if (tmp==null) {
336 | tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,OreDictionary.WILDCARD_VALUE));
337 | if (meta==OreDictionary.WILDCARD_VALUE && tmp==null) {
338 | int index=0;
339 | do {
340 | tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,index));
341 | index++;
342 | } while (index<16 && tmp==null);
343 | }
344 | if (tmp==null) return false;
345 | }
346 |
347 | return true;
348 | }
349 |
350 | /**
351 | * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:
352 | * ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));
353 | * @param item the item passed. Pass OreDictionary.WILDCARD_VALUE if all damage values of this item/block should have the same aspects
354 | * @param aspects A ObjectTags object of the associated aspects
355 | */
356 | public static void registerObjectTag(ItemStack item, AspectList aspects) {
357 | if (aspects==null) aspects=new AspectList();
358 | try {
359 | objectTags.put(Arrays.asList(item.getItem(),item.getItemDamage()), aspects);
360 | } catch (Exception e) {}
361 | }
362 |
363 |
364 | /**
365 | * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:
366 | * ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), new int[]{0,1}, (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));
367 | * @param item
368 | * @param meta A range of meta values if you wish to lump several item meta's together as being the "same" item (i.e. stair orientations)
369 | * @param aspects A ObjectTags object of the associated aspects
370 | */
371 | public static void registerObjectTag(ItemStack item, int[] meta, AspectList aspects) {
372 | if (aspects==null) aspects=new AspectList();
373 | try {
374 | objectTags.put(Arrays.asList(item.getItem(),meta), aspects);
375 | } catch (Exception e) {}
376 | }
377 |
378 | /**
379 | * Used to assign apsects to the given ore dictionary item.
380 | * @param oreDict the ore dictionary name
381 | * @param aspects A ObjectTags object of the associated aspects
382 | */
383 | public static void registerObjectTag(String oreDict, AspectList aspects) {
384 | if (aspects==null) aspects=new AspectList();
385 | ArrayList ores = OreDictionary.getOres(oreDict);
386 | if (ores!=null && ores.size()>0) {
387 | for (ItemStack ore:ores) {
388 | try {
389 | objectTags.put(Arrays.asList(ore.getItem(), ore.getItemDamage()), aspects);
390 | } catch (Exception e) {}
391 | }
392 | }
393 | }
394 |
395 | /**
396 | * Used to assign aspects to the given item/block.
397 | * Attempts to automatically generate aspect tags by checking registered recipes.
398 | * Here is an example of the declaration for pistons:
399 | * ThaumcraftApi.registerComplexObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.MECHANISM, 2).add(Aspect.MOTION, 4));
400 | * IMPORTANT - this should only be used if you are not happy with the default aspects the object would be assigned.
401 | * @param item, pass OreDictionary.WILDCARD_VALUE to meta if all damage values of this item/block should have the same aspects
402 | * @param aspects A ObjectTags object of the associated aspects
403 | */
404 | public static void registerComplexObjectTag(ItemStack item, AspectList aspects ) {
405 | if (!exists(item.getItem(),item.getItemDamage())) {
406 | AspectList tmp = ThaumcraftApiHelper.generateTags(item.getItem(), item.getItemDamage());
407 | if (tmp != null && tmp.size()>0) {
408 | for(Aspect tag:tmp.getAspects()) {
409 | aspects.add(tag, tmp.getAmount(tag));
410 | }
411 | }
412 | registerObjectTag(item,aspects);
413 | } else {
414 | AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item);
415 | for(Aspect tag:aspects.getAspects()) {
416 | tmp.merge(tag, tmp.getAmount(tag));
417 | }
418 | registerObjectTag(item,tmp);
419 | }
420 | }
421 |
422 | //WARP ///////////////////////////////////////////////////////////////////////////////////////
423 | private static HashMap