本文整理汇总了Java中cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java UniqueIdentifier类的具体用法?Java UniqueIdentifier怎么用?Java UniqueIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UniqueIdentifier类属于cpw.mods.fml.common.registry.GameRegistry包,在下文中一共展示了UniqueIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseModItems
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
private static void parseModItems() {
HashMap<String, ItemStackSet> modSubsets = new HashMap<String, ItemStackSet>();
for (Item item : (Iterable<Item>) Item.itemRegistry) {
UniqueIdentifier ident = GameRegistry.findUniqueIdentifierFor(item);
if(ident == null) {
NEIClientConfig.logger.error("Failed to find identifier for: "+item);
continue;
}
String modId = GameRegistry.findUniqueIdentifierFor(item).modId;
itemOwners.put(item, modId);
ItemStackSet itemset = modSubsets.get(modId);
if(itemset == null)
modSubsets.put(modId, itemset = new ItemStackSet());
itemset.with(item);
}
API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
for(Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
if(mc == null)
NEIClientConfig.logger.error("Missing container for "+entry.getKey());
else
API.addSubset("Mod."+mc.getName(), entry.getValue());
}
}
示例2: onBlockPlaced
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
@SubscribeEvent
public void onBlockPlaced(BlockEvent.PlaceEvent event) {
if (event.player.capabilities.isCreativeMode)
return;
int playerDimension = event.player.dimension;
if (dimensionWhitelist.keySet().contains(playerDimension)) {
Set<UniqueIdentifier> uniqueIdentifierWhitelist = dimensionWhitelist.get(playerDimension);
UniqueIdentifier placedBlockUniqueIdentifier = GameRegistry.findUniqueIdentifierFor(event.placedBlock);
if (!uniqueIdentifierWhitelist.contains(placedBlockUniqueIdentifier)) {
event.setCanceled(true);
}
}
}
示例3: parseBlockWhitelist
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
private Map<Integer, Set<UniqueIdentifier>> parseBlockWhitelist(String[] rawBlockWhitelist) {
HashMap<Integer, Set<UniqueIdentifier>> map = new HashMap<Integer, Set<UniqueIdentifier>>();
for (String s : rawBlockWhitelist) {
int i = s.indexOf(':');
int dim = Integer.parseInt(s.substring(0, i));
Set<UniqueIdentifier> whitelist;
if (!map.containsKey(dim)) {
whitelist = new HashSet<UniqueIdentifier>();
map.put(dim, whitelist);
} else {
whitelist = map.get(dim);
}
String blockID = s.substring(i + 1);
whitelist.add(new UniqueIdentifier(blockID));
}
return map;
}
示例4: StructureBlock
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
public StructureBlock(Block b, int meta, TileEntity te) {
if(b == null) {
Log.warn("StructureBlock.StructureBlock: Null block");
b = Blocks.air;
}
UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(b);
if(uid == null) {
modId = "minecraft";
blockName = "air";
Log.warn("StructureBlock.StructureBlock: Null UID for " + b);
} else {
modId = uid.modId;
blockName = uid.name;
}
blockMeta = (short) meta;
if(te != null) {
tileEntity = new NBTTagCompound();
te.writeToNBT(tileEntity);
} else {
tileEntity = null;
}
}
示例5: getItemStack
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
public static ItemStack getItemStack(JsonObject json, String element) {
JsonObject obj = getObjectField(json, element);
if(obj == null) {
return null;
}
String uid = getStringField(obj, "uid", null);
if(uid == null) {
return null;
}
UniqueIdentifier u = new UniqueIdentifier(uid);
ItemStack res = GameRegistry.findItemStack(u.modId, u.name, 1);
if(res == null) {
return res;
}
res.setItemDamage(getIntField(obj, "meta", res.getItemDamage()));
String nbtStr = getStringField(obj, "nbt", null);
if(nbtStr != null) {
NBTTagCompound nbt = parseNBT(nbtStr);
if(nbt != null) {
res.setTagCompound(nbt);
}
}
return res;
}
示例6: serialize
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
@Override
public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
if(src == null) {
return JsonNull.INSTANCE;
}
JsonObject res = new JsonObject();
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(src.getItem());
res.addProperty("item", id.modId + ":" + id.name);
res.addProperty("number", src.stackSize);
res.addProperty("meta", src.getItemDamage());
String nbt = serializeNBT(src.stackTagCompound);
if(nbt != null && nbt.trim().length() > 0) {
res.addProperty("nbt", nbt);
}
return res;
}
示例7: replaceRecipeResults
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
public static void replaceRecipeResults() {
// replace smelting results
OresPlus.log.info("Replacing smelting results");
Collection smeltingResultsList = FurnaceRecipes.smelting().getSmeltingList().values();
for (Object result : smeltingResultsList.toArray()) {
if (result instanceof ItemStack) {
Item item = ((ItemStack)result).getItem();
UniqueIdentifier itemUid = GameRegistry.findUniqueIdentifierFor(item);
if (itemUid.modId != "minecraft" && itemUid.modId != References.MOD_ID) {
OresPlus.log.info("Recipe Result " + itemUid.modId + ":" + itemUid.name);
ItemStack newItem = new ItemStack(Ores.manager.getOreItem(itemUid.name), ((ItemStack)result).stackSize);
if (newItem != null) {
((ItemStack)result).func_150996_a(newItem.getItem());
net.minecraft.init.Items.apple.setDamage(newItem, net.minecraft.init.Items.apple.getDamage(((ItemStack)result)));
}
}
}
}
}
示例8: loadAttributeFromNBT
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
public static Attribute loadAttributeFromNBT(NBTTagCompound nbt)
{
ItemStack itemStack = ItemStack.loadItemStackFromNBT(nbt);
if (itemStack == null) {
String uuid = nbt.getString(TAG_UNIQUE_ID);
if (uuid.contains(":")) {
UniqueIdentifier uniqueId = new UniqueIdentifier(uuid);
itemStack = GameRegistry.findItemStack(uniqueId.modId, uniqueId.name, 1);
if (itemStack != null) {
int dmg = nbt.getShort("Damage");
itemStack.setItemDamage(dmg);
ModLogger.log(Level.WARN, "Invalid Id for attribute '" + uniqueId.toString() + "' corrected.");
} else {
ModLogger.log(Level.WARN, "Block attribute '" + uniqueId.toString() + "' was unable to be recovered. Was a mod removed?");
}
} else {
ModLogger.log(Level.WARN, "Unable to resolve attribute '" + uuid + "'");
}
}
return new Attribute(itemStack);
}
示例9: EnderID
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
public EnderID(ItemStack stack) throws BlockConversionException {
if(!(stack instanceof ItemStack)) throw new BlockConversionException("", "unknown", "Custom item stacks unsupported!");
UniqueIdentifier itemID = GameRegistry.findUniqueIdentifierFor(stack.getItem());
if(itemID == null) {
this.modId = "Minecraft";
this.name = stack.getItem().getUnlocalizedName();
} else {
this.modId = itemID.modId;
this.name = itemID.name;
}
this.metadata = stack.getItemDamage();
this.stackSize = stack.stackSize;
if(blacklistedItems.contains(getItemIdentifier())) throw new BlockConversionException(modId, name, "Blacklisted!");
if(stack.hasTagCompound()) {
NBTTagCompound compound = stack.getTagCompound();
try {
this.compound = CompressedStreamTools.compress(compound);
} catch(Exception e) { e.printStackTrace(); throw new BlockConversionException(modId, name, "Could not compress NBT tag compound!"); }
if(!isAllowedTagCompound(compound)) throw new BlockConversionException(modId, name, "NBT tag compound cannot be sent!");
}
}
示例10: areStacksEqual
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
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);
}
示例11: createBasicProperties
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
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;
}
示例12: findModOwner
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
/**
* @deprecated no replacement planned
*/
@Deprecated
public static ModContainer findModOwner(String string)
{
UniqueIdentifier ui = new UniqueIdentifier(string);
if (customOwners.containsKey(ui))
{
return customOwners.get(ui);
}
return Loader.instance().getIndexedModList().get(ui.modId);
}
示例13: getUniqueName
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
static UniqueIdentifier getUniqueName(Block block)
{
if (block == null) return null;
String name = getMain().iBlockRegistry.func_148750_c(block);
UniqueIdentifier ui = new UniqueIdentifier(name);
if (customItemStacks.contains(ui.modId, ui.name))
{
return null;
}
return ui;
}
示例14: BlockSnapshot
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
/**
* Raw constructor designed for serialization usages.
*/
public BlockSnapshot(int dimension, int x, int y, int z, String modid, String blockName, int meta, int flag, NBTTagCompound nbt)
{
this.dimId = dimension;
this.x = x;
this.y = y;
this.z = z;
this.meta = meta;
this.flag = flag;
this.blockIdentifier = new UniqueIdentifier(modid + ":" + blockName);
this.nbt = nbt;
}
示例15: CheckPlayerTouchesBlock
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; //导入依赖的package包/类
/**
* 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();
}
}