cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier Java Examples

The following examples show how to use cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PneumaticCraftUtils.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public static boolean areStacksEqual(ItemStack stack1, ItemStack stack2, boolean checkMeta, boolean checkNBT, boolean checkOreDict, boolean checkModSimilarity){
    if(stack1 == null && stack2 == null) return true;
    if(stack1 == null && stack2 != null || stack1 != null && stack2 == null) return false;

    if(checkModSimilarity) {
        UniqueIdentifier id1 = GameRegistry.findUniqueIdentifierFor(stack1.getItem());
        if(id1 == null || id1.modId == null) return false;
        String modId1 = id1.modId;
        UniqueIdentifier id2 = GameRegistry.findUniqueIdentifierFor(stack2.getItem());
        if(id2 == null || id2.modId == null) return false;
        String modId2 = id2.modId;
        return modId1.equals(modId2);
    }
    if(checkOreDict) {
        return isSameOreDictStack(stack1, stack2);
    }

    if(stack1.getItem() != stack2.getItem()) return false;

    boolean metaSame = stack1.getItemDamage() == stack2.getItemDamage();
    boolean nbtSame = stack1.hasTagCompound() ? stack1.getTagCompound().equals(stack2.getTagCompound()) : !stack2.hasTagCompound();

    return (!checkMeta || metaSame) && (!checkNBT || nbtSame);
}
 
Example #2
Source File: ItemStackMetadataBuilder.java    From OpenPeripheral with MIT License 6 votes vote down vote up
private static Map<String, Object> createBasicProperties(Item item, ItemStack itemstack) {
	Map<String, Object> map = Maps.newHashMap();
	UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item);

	map.put("id", id != null? id.toString() : "?");
	map.put("name", id != null? id.name : "?");
	map.put("mod_id", id != null? id.modId : "?");

	map.put("display_name", getNameForItemStack(itemstack));
	map.put("raw_name", getRawNameForStack(itemstack));
	map.put("qty", itemstack.stackSize);
	map.put("dmg", itemstack.getItemDamage());

	if (item.showDurabilityBar(itemstack)) map.put("health_bar", item.getDurabilityForDisplay(itemstack));
	map.put("max_dmg", itemstack.getMaxDamage());
	map.put("max_size", itemstack.getMaxStackSize());

	return map;
}
 
Example #3
Source File: HazardousItemsHandler.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if player actually swims in a fluid
 *
 * @param pPlayer
 */
private void CheckPlayerTouchesBlock( EntityPlayer pPlayer )
{
  if( _mRnd.nextInt( _mExecuteChance ) != 0 ) {
      return;
  }

  try
  {
    int blockX = MathHelper.floor_double( pPlayer.posX );
    int blockY = MathHelper.floor_double( pPlayer.boundingBox.minY );
    int blockZ = MathHelper.floor_double( pPlayer.posZ );
    Block pBlockContact = pPlayer.worldObj.getBlock( blockX, blockY, blockZ );
    Block pBlockUnderFeet = pPlayer.worldObj.getBlock( blockX, blockY - 1, blockZ );
    UniqueIdentifier tUidContact = GameRegistry.findUniqueIdentifierFor( pBlockContact );
    UniqueIdentifier tUidFeet = GameRegistry.findUniqueIdentifierFor( pBlockUnderFeet );

    // Skip air block and null results
    if( tUidContact != null && tUidContact.toString() != "minecraft:air" )
    {
      HazardousItems.HazardousFluid hf = _mHazardItemsCollection.FindHazardousFluidExact( tUidContact.toString() );
      if( hf != null && hf.getCheckContact() ) {
          DoHIEffects(hf, pPlayer);
      }
    }

    if( tUidFeet != null && tUidFeet.toString() != "minecraft:air" )
    {
      HazardousItems.HazardousItem hi = _mHazardItemsCollection.FindHazardousItemExact( tUidFeet.toString() );
      if( hi != null && hi.getCheckContact() ) {
          DoHIEffects(hi, pPlayer);
      }
    }
  }
  catch( Exception e )
  {
    _mLogger.error( "HazardousItemsHandler.CheckPlayerTouchesBlock.error", "Something bad happend while processing the onPlayerTick event" );
    e.printStackTrace();
  }
}
 
Example #4
Source File: ItemFingerprint.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
public ItemFingerprint(ItemStack stack) {
	String itemId = GameData.getItemRegistry().getNameForObject(stack.getItem());
	this.id = new UniqueIdentifier(itemId);
	this.damage = stack.getItemDamage();

	NBTTagCompound tag = stack.getTagCompound();
	this.nbtHash = tag != null? ItemUtils.getNBTHash(tag) : null;
}
 
Example #5
Source File: ItemFingerprint.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
public ItemFingerprint(String id, int damage, String nbtHash) {
	this.id = new UniqueIdentifier(id);
	this.damage = damage;
	this.nbtHash = nbtHash;
}
 
Example #6
Source File: ItemFingerprint.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
public ItemFingerprint(Item item, int damage, NBTTagCompound tag) {
	String itemId = GameData.getItemRegistry().getNameForObject(item);
	this.id = new UniqueIdentifier(itemId);
	this.damage = damage;
	this.nbtHash = tag != null? ItemUtils.getNBTHash(tag) : null;
}
 
Example #7
Source File: WikiHooks.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
public static IWikiProvider getWikiFor(Block block) {
	UniqueIdentifier mod = GameRegistry.findUniqueIdentifierFor(block);
	return getWikiFor(mod == null ? "" : mod.modId.toLowerCase());
}