本文整理汇总了Java中net.minecraft.util.ResourceLocation类的典型用法代码示例。如果您正苦于以下问题:Java ResourceLocation类的具体用法?Java ResourceLocation怎么用?Java ResourceLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceLocation类属于net.minecraft.util包,在下文中一共展示了ResourceLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeEntityToNBT
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
if (this.hasDisplayTile())
{
tagCompound.setBoolean("CustomDisplayTile", true);
IBlockState iblockstate = this.getDisplayTile();
ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(iblockstate.getBlock());
tagCompound.setString("DisplayTile", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setInteger("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
tagCompound.setInteger("DisplayOffset", this.getDisplayTileOffset());
}
if (this.entityName != null && this.entityName.length() > 0)
{
tagCompound.setString("CustomName", this.entityName);
}
}
示例2: onRenderPlayer
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event)
{
EntityPlayer player = event.getEntityPlayer();
String uuid = player.getUUID(player.getGameProfile()).toString();
if(player instanceof AbstractClientPlayer && UUIDS.contains(uuid) && !done.contains(player))
{
AbstractClientPlayer clplayer = (AbstractClientPlayer) player;
if(clplayer.hasPlayerInfo())
{
NetworkPlayerInfo info = ReflectionHelper.getPrivateValue(AbstractClientPlayer.class, clplayer, ObfuscatedNames.PLAYER_INFO);
Map<MinecraftProfileTexture.Type, ResourceLocation> textures = ReflectionHelper.getPrivateValue(NetworkPlayerInfo.class, info, ObfuscatedNames.PLAYER_TEXTURES);
ResourceLocation loc = new ResourceLocation("proxyslib", "textures/whoknows/dev_cape.png");
textures.put(MinecraftProfileTexture.Type.CAPE, loc);
textures.put(MinecraftProfileTexture.Type.ELYTRA, loc);
done.add(player);
}
}
}
示例3: handleItemState
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
@Nullable World world, @Nullable EntityLivingBase entity) {
if (stack.getItem() != ModItems.sword) {
return originalModel;
}
BakedSwordModel model = (BakedSwordModel) originalModel;
String key = IBladeTool.getBladeMat(stack).getName() + "|"
+ ICrossguardTool.getCrossguardMat(stack).getName() + "|"
+ IHandleTool.getHandleMat(stack).getName() + "|"
+ IAdornedTool.getAdornmentMat(stack).getName();
if (!model.cache.containsKey(key)) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("blade", IBladeTool.getBladeMat(stack).getName());
builder.put("crossguard", ICrossguardTool.getCrossguardMat(stack).getName());
builder.put("handle", IHandleTool.getHandleMat(stack).getName());
if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
}
IModel parent = model.parent.retexture(builder.build());
Function<ResourceLocation, TextureAtlasSprite> textureGetter;
textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
public TextureAtlasSprite apply(ResourceLocation location) {
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
}
};
IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
textureGetter);
model.cache.put(key, bakedModel);
return bakedModel;
}
return model.cache.get(key);
}
示例4: getTextureHeight
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
private static int getTextureHeight(String p_getTextureHeight_0_, int p_getTextureHeight_1_)
{
try
{
InputStream inputstream = Config.getResourceStream(new ResourceLocation(p_getTextureHeight_0_));
if (inputstream == null)
{
return p_getTextureHeight_1_;
}
else
{
BufferedImage bufferedimage = ImageIO.read(inputstream);
return bufferedimage == null ? p_getTextureHeight_1_ : bufferedimage.getHeight();
}
}
catch (IOException var4)
{
return p_getTextureHeight_1_;
}
}
示例5: makeProperties
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
private static RandomMobsProperties makeProperties(ResourceLocation p_makeProperties_0_)
{
String s = p_makeProperties_0_.getResourcePath();
ResourceLocation resourcelocation = getPropertyLocation(p_makeProperties_0_);
if (resourcelocation != null)
{
RandomMobsProperties randommobsproperties = parseProperties(resourcelocation, p_makeProperties_0_);
if (randommobsproperties != null)
{
return randommobsproperties;
}
}
ResourceLocation[] aresourcelocation = getTextureVariants(p_makeProperties_0_);
return new RandomMobsProperties(s, aresourcelocation);
}
示例6: getChestModel
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
@Override
public ResourceLocation getChestModel(ItemStack stack)
{
NBTTagCompound logNbt = stack.getTagCompound().getCompoundTag("WoodLog");
ItemStack log = new ItemStack(logNbt);
if (log.getItem() == Item.getItemFromBlock(Blocks.LOG))
{
return locationFromName("barrel_" + names[log.getItemDamage()]);
} else if (log.getItem() == Item.getItemFromBlock(Blocks.LOG2))
{
return locationFromName("barrel_" + names[log.getItemDamage() + 4]);
} else if (log.getItem() == Item.getItemFromBlock(Blocks.BEDROCK))
{
return locationFromName("barrel_creative");
}
return locationFromName("barrel_oak");
}
示例7: createRecipesFor
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
@Nonnull
@Override
public Collection<MachineRecipe> createRecipesFor(ResourceLocation owningMachineName) {
Map<ItemStack, ItemStack> inputOutputMap = FurnaceRecipes.instance().getSmeltingList();
List<MachineRecipe> smeltingRecipes = new ArrayList<>(inputOutputMap.size());
int incId = 0;
for (Map.Entry<ItemStack, ItemStack> smelting : inputOutputMap.entrySet()) {
MachineRecipe recipe = createRecipeShell(
new ResourceLocation("minecraft", "smelting_recipe_" + incId),
owningMachineName,
120, 0);
recipe.addRequirement(new ComponentRequirement.RequirementItem(MachineComponent.IOType.INPUT,
ItemUtils.copyStackWithSize(smelting.getKey(), smelting.getKey().getCount())));
recipe.addRequirement(new ComponentRequirement.RequirementItem(MachineComponent.IOType.OUTPUT,
ItemUtils.copyStackWithSize(smelting.getValue(), smelting.getValue().getCount())));
recipe.addRequirement(new ComponentRequirement.RequirementEnergy(MachineComponent.IOType.INPUT,
20));
smeltingRecipes.add(recipe);
incId++;
}
return smeltingRecipes;
}
示例8: getAllResources
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
public List<IResource> getAllResources(ResourceLocation location) throws IOException
{
List<IResource> list = Lists.<IResource>newArrayList();
ResourceLocation resourcelocation = getLocationMcmeta(location);
for (IResourcePack iresourcepack : this.resourcePacks)
{
if (iresourcepack.resourceExists(location))
{
InputStream inputstream = iresourcepack.resourceExists(resourcelocation) ? this.getInputStream(resourcelocation, iresourcepack) : null;
list.add(new SimpleResource(iresourcepack.getPackName(), location, this.getInputStream(location, iresourcepack), inputstream, this.frmMetadataSerializer));
}
}
if (list.isEmpty())
{
throw new FileNotFoundException(location.toString());
}
else
{
return list;
}
}
示例9: getByNameOrId
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
@Nullable
/**
* Tries to get an Item by it's name (e.g. minecraft:apple) or a String representation of a numerical ID. If both
* fail, null is returned.
*/
public static Item getByNameOrId(String id)
{
Item item = (Item)REGISTRY.getObject(new ResourceLocation(id));
if (item == null)
{
try
{
return getItemById(Integer.parseInt(id));
}
catch (NumberFormatException var3)
{
;
}
}
return item;
}
示例10: getResourceLocation
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
public static ResourceLocation getResourceLocation(String basePath, String path, String extension)
{
if (!path.endsWith(extension))
{
path = path + extension;
}
if (!path.contains("/"))
{
path = basePath + "/" + path;
}
else if (path.startsWith("./"))
{
path = basePath + "/" + path.substring(2);
}
else if (path.startsWith("~/"))
{
path = "optifine/" + path.substring(2);
}
return new ResourceLocation(path);
}
示例11: registerFunction
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
public static <T extends LootFunction> void registerFunction(LootFunction.Serializer <? extends T > p_186582_0_)
{
ResourceLocation resourcelocation = p_186582_0_.getFunctionName();
Class<T> oclass = (Class<T>)p_186582_0_.getFunctionClass();
if (NAME_TO_SERIALIZER_MAP.containsKey(resourcelocation))
{
throw new IllegalArgumentException("Can\'t re-register item function name " + resourcelocation);
}
else if (CLASS_TO_SERIALIZER_MAP.containsKey(oclass))
{
throw new IllegalArgumentException("Can\'t re-register item function class " + oclass.getName());
}
else
{
NAME_TO_SERIALIZER_MAP.put(resourcelocation, p_186582_0_);
CLASS_TO_SERIALIZER_MAP.put(oclass, p_186582_0_);
}
}
示例12: Tier
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
public Tier(int tier, int width, int height, int guiGridX, int guiGridY, int guiResultX, int guiResultY, ResourceLocation guiTexture, int guiJeiStartX, int guiJeiStartY, ResourceLocation modelTexture, ResourceLocation obj, ResourceLocation smartModel, boolean areItemsFloating, String unlocalizedName)
{
this.tier = tier;
this.width = width;
this.height = height;
this.guiGridX = guiGridX;
this.guiGridY = guiGridY;
this.guiResultX = guiResultX;
this.guiResultY = guiResultY;
this.guiTexture = guiTexture;
this.guiJeiStartX = guiJeiStartX;
this.guiJeiStartY = guiJeiStartY;
this.modelTexture = modelTexture;
this.obj = obj;
this.smartModel = smartModel;
this.areItemsFloating = areItemsFloating;
this.unlocalizedName = unlocalizedName;
}
示例13: serialize
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
public void serialize(JsonObject object, EnchantRandomly functionClazz, JsonSerializationContext serializationContext)
{
if (!functionClazz.enchantments.isEmpty())
{
JsonArray jsonarray = new JsonArray();
for (Enchantment enchantment : functionClazz.enchantments)
{
ResourceLocation resourcelocation = (ResourceLocation)Enchantment.REGISTRY.getNameForObject(enchantment);
if (resourcelocation == null)
{
throw new IllegalArgumentException("Don\'t know how to serialize enchantment " + enchantment);
}
jsonarray.add(new JsonPrimitive(resourcelocation.toString()));
}
object.add("enchantments", jsonarray);
}
}
示例14: collectFilesFixed
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
private static String[] collectFilesFixed(IResourcePack p_collectFilesFixed_0_, String[] p_collectFilesFixed_1_)
{
if (p_collectFilesFixed_1_ == null)
{
return new String[0];
}
else
{
List list = new ArrayList();
for (int i = 0; i < p_collectFilesFixed_1_.length; ++i)
{
String s = p_collectFilesFixed_1_[i];
ResourceLocation resourcelocation = new ResourceLocation(s);
if (p_collectFilesFixed_0_.resourceExists(resourcelocation))
{
list.add(s);
}
}
String[] astring = (String[])((String[])list.toArray(new String[list.size()]));
return astring;
}
}
示例15: CraftingControl
import net.minecraft.util.ResourceLocation; //导入依赖的package包/类
public <T extends IRecipeWrapper> CraftingControl(IRecipeCategory<T> category, T wrapper, ResourceLocation border, int borderSize)
{
super(border, 2);
this.title = category.getTitle();
off = DrawingTools.getStringHeight(title) + 2;
IRecipeRegistry reg = PMJeiPlugin.RUNTIME.getRecipeRegistry();
IRecipeLayoutDrawable draw = reg.createRecipeLayoutDrawable(category, wrapper, reg.createFocus(IFocus.Mode.OUTPUT, new ItemStack(Items.STICK /*hack*/)));
setWidth(category.getBackground().getWidth() + size * 2);
setHeight(category.getBackground().getHeight() + size * 2);
draw.setPosition(size, size);
this.draw = draw;
}