Java Code Examples for net.minecraft.util.ResourceLocation#toString()
The following examples show how to use
net.minecraft.util.ResourceLocation#toString() .
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: BlockInfo.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public BlockInfo(IBlockState state, String titleKey) { String pre = GuiBase.TXT_WHITE + GuiBase.TXT_BOLD; this.title = pre + StringUtils.translate(titleKey) + GuiBase.TXT_RST; this.state = state; this.stack = ItemUtils.getItemForState(this.state); ResourceLocation rl = Block.REGISTRY.getNameForObject(this.state.getBlock()); this.blockRegistryname = rl != null ? rl.toString() : "<null>"; this.stackName = this.stack.getDisplayName(); int w = StringUtils.getStringWidth(this.stackName) + 20; w = Math.max(w, StringUtils.getStringWidth(this.blockRegistryname)); w = Math.max(w, StringUtils.getStringWidth(this.title)); this.columnWidth = w; this.props = BlockUtils.getFormattedBlockStateProperties(this.state, " = "); this.totalWidth = this.columnWidth + 40; this.totalHeight = this.props.size() * (StringUtils.getFontHeight() + 2) + 50; }
Example 2
Source File: ToolHud.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
protected String getBlockStateString(IBlockState state) { ResourceLocation id = Block.REGISTRY.getNameForObject(state.getBlock()); String regName = id != null ? id.toString() : "<null>"; String green = GuiBase.TXT_GREEN; String rst = GuiBase.TXT_RST; String strBlock = String.format("%s%s (%s)%s", green, regName, state.getBlock().getLocalizedName(), rst); EnumFacing facing = BlockUtils.getFirstPropertyFacingValue(state); if (facing != null) { String gold = GuiBase.TXT_GOLD; String strFacing = gold + facing.getName().toLowerCase() + rst; strBlock += " - " + StringUtils.translate("litematica.tool_hud.facing", strFacing); } return strBlock; }
Example 3
Source File: TaskPasteSchematicPerChunkCommand.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
private void sendSetBlockCommand(int x, int y, int z, IBlockState state, EntityPlayerSP player) { Block block = state.getBlock(); ResourceLocation rl = Block.REGISTRY.getNameForObject(block); if (rl == null) { return; } String blockName = rl.toString(); String cmdName = Configs.Generic.PASTE_COMMAND_SETBLOCK.getStringValue(); String strCommand = String.format("/%s %d %d %d %s %d", cmdName, x, y, z, blockName, block.getMetaFromState(state)); player.sendChatMessage(strCommand); ++this.sentCommandsTotal; }
Example 4
Source File: BuiltinLoader.java From VanillaFix with MIT License | 6 votes |
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { String path = modelLocation.getPath(); if ("builtin/generated".equals(path) || "block/builtin/generated".equals(path) || "item/builtin/generated".equals(path)) { // TODO: why is this necessary? return ItemLayerModel.INSTANCE; //new VanillaModelWrapper(modelLocation, MODEL_GENERATED); } if ("builtin/entity".equals(path)) { return new VanillaModelWrapper(modelLocation, MODEL_ENTITY); } if ("builtin/missing".equals(path)) { return WRAPPED_MODEL_MISSING; } throw new FileNotFoundException(modelLocation.toString()); }
Example 5
Source File: VanillaLoader.java From VanillaFix with MIT License | 6 votes |
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { // Load vanilla model ModelBlock vanillaModel; ResourceLocation vanillaModelLocation = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath() + ".json"); try (IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(vanillaModelLocation); Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) { vanillaModel = ModelBlock.deserialize(reader); vanillaModel.name = modelLocation.toString(); } // Load armature animation (currently disabled for efficiency, see MixinModelBlockAnimation) String modelPath = modelLocation.getPath(); if (modelPath.startsWith("models/")) { modelPath = modelPath.substring("models/".length()); } ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json"); ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(Minecraft.getMinecraft().getResourceManager(), armatureLocation); // Return the vanilla model weapped in a VanillaModelWrapper return new VanillaModelWrapper(modelLocation, vanillaModel , false, animation); }
Example 6
Source File: WavefrontObject.java From AdvancedRocketry with MIT License | 6 votes |
public WavefrontObject(ResourceLocation resource) throws ModelFormatException { this.fileName = resource.toString(); try { IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); loadObjModel(res.getInputStream()); } catch (IOException e) { throw new ModelFormatException("IO Exception reading model format", e); } }
Example 7
Source File: GuiCustomizeWorld.java From YUNoMakeGoodMap with Apache License 2.0 | 6 votes |
private StructInfo getInfo(ResourceLocation res) { StructInfo ret = structInfo.get(res); if (ret != null) return ret; try { IResource ir = this.mc.getResourceManager().getResource(new ResourceLocation(res.getResourceDomain(), "structures/" + res.getResourcePath() + ".json")); ret = GSON.fromJson(new InputStreamReader(ir.getInputStream()), StructInfo.class); if (ret.logo != null) { ir = this.mc.getResourceManager().getResource(new ResourceLocation(res.getResourceDomain(), "structures/" + ret.logo)); if (ir != null) { BufferedImage l = ImageIO.read(ir.getInputStream()); ret.logoPath = this.mc.getTextureManager().getDynamicTextureLocation("platformlogo", new DynamicTexture(l)); ret.logoSize = new Dimension(l.getWidth(), l.getHeight()); } } } catch (IOException e) { //Ugh wish it had a 'hasResource' } if (ret == null) ret = new StructInfo(); if (ret.name == null) ret.name = res.toString(); structInfo.put(res, ret); return ret; }
Example 8
Source File: ResourcePackHook.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public InputStream getInputStream(ResourceLocation location) throws IOException { for (IResourcePackFileHook hook : hooks) { if (hook.resourceExists(location)) return hook.getInputStream(location); } throw new FileNotFoundException(location.toString()); }
Example 9
Source File: AbstractBlockModelFactory.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public InputStream getInputStream(ResourceLocation location) throws IOException { String resourcePath = location.getResourcePath(); // blockstates/compressed_1.json resourcePath = resourcePath.substring(0, resourcePath.length() - 5); //remove .json resourcePath = resourcePath.substring(12); //remove blockstates/ if (resourcePath.startsWith(blockNamePrefix)) { Block block = Block.REGISTRY.getObject(new ResourceLocation(location.getResourceDomain(), resourcePath)); if (block != null && block != Blocks.AIR) { return FileUtility.writeInputStream(fillSample(block, blockStateSample)); } throw new IllegalArgumentException("Block not found: " + resourcePath); } throw new FileNotFoundException(location.toString()); }
Example 10
Source File: TaskPasteSchematicPerChunkCommand.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
private void summonEntities(IntBoundingBox box, WorldSchematic worldSchematic, EntityPlayerSP player) { AxisAlignedBB bb = new AxisAlignedBB(box.minX, box.minY, box.minZ, box.maxX + 1, box.maxY + 1, box.maxZ + 1); List<Entity> entities = worldSchematic.getEntitiesWithinAABBExcludingEntity(null, bb); for (Entity entity : entities) { ResourceLocation rl = EntityList.getKey(entity); if (rl != null) { String entityName = rl.toString(); /* NBTTagCompound nbt = new NBTTagCompound(); entity.writeToNBTOptional(nbt); String nbtString = nbt.toString(); */ String strCommand = String.format(Locale.ROOT, "/summon %s %f %f %f", entityName, entity.posX, entity.posY, entity.posZ); /* String strCommand = String.format("/summon %s %f %f %f %s", entityName, entity.posX, entity.posY, entity.posZ, nbtString); System.out.printf("entity: %s\n", entity); System.out.printf("%s\n", strCommand); System.out.printf("nbt: %s\n", nbtString); */ player.sendChatMessage(strCommand); } } }
Example 11
Source File: WidgetSchematicVerificationResult.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public BlockMismatchInfo(IBlockState stateExpected, IBlockState stateFound) { this.stateExpected = stateExpected; this.stateFound = stateFound; this.stackExpected = ItemUtils.getItemForState(this.stateExpected); this.stackFound = ItemUtils.getItemForState(this.stateFound); Block blockExpected = this.stateExpected.getBlock(); Block blockFound = this.stateFound.getBlock(); ResourceLocation rl1 = Block.REGISTRY.getNameForObject(blockExpected); ResourceLocation rl2 = Block.REGISTRY.getNameForObject(blockFound); this.blockRegistrynameExpected = rl1 != null ? rl1.toString() : "<null>"; this.blockRegistrynameFound = rl2 != null ? rl2.toString() : "<null>"; this.nameExpected = getDisplayName(stateExpected, this.stackExpected); this.nameFound = getDisplayName(stateFound, this.stackFound); List<String> propsExpected = BlockUtils.getFormattedBlockStateProperties(this.stateExpected, " = "); List<String> propsFound = BlockUtils.getFormattedBlockStateProperties(this.stateFound, " = "); int w1 = Math.max(StringUtils.getStringWidth(this.nameExpected) + 20, StringUtils.getStringWidth(this.blockRegistrynameExpected)); int w2 = Math.max(StringUtils.getStringWidth(this.nameFound) + 20, StringUtils.getStringWidth(this.blockRegistrynameFound)); w1 = Math.max(w1, fi.dy.masa.litematica.render.RenderUtils.getMaxStringRenderLength(propsExpected)); w2 = Math.max(w2, fi.dy.masa.litematica.render.RenderUtils.getMaxStringRenderLength(propsFound)); this.columnWidthExpected = w1; this.totalWidth = this.columnWidthExpected + w2 + 40; this.totalHeight = Math.max(propsExpected.size(), propsFound.size()) * (StringUtils.getFontHeight() + 2) + 50; }
Example 12
Source File: CustomGradient.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public CustomGradient(ResourceLocation textureFile) { BufferedImage img = TextureUtils.loadBufferedImage(textureFile); if (img == null) { throw new RuntimeException("File not found: " + textureFile.toString()); } int[] data = new int[img.getWidth()]; img.getRGB(0, 0, img.getWidth(), 1, data, 0, img.getWidth()); gradient = new int[img.getWidth()]; for (int i = 0; i < data.length; i++) { gradient[i] = (data[i] << 8) | (((data[i]) >> 24) & 0xFF); } }
Example 13
Source File: CustomGradient.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public CustomGradient(ResourceLocation textureFile) { BufferedImage img = TextureUtils.loadBufferedImage(textureFile); if(img == null) throw new RuntimeException("File not found: "+textureFile.toString()); int[] data = new int[img.getWidth()]; img.getRGB(0, 0, img.getWidth(), 1, data, 0, img.getWidth()); gradient = new int[img.getWidth()]; for(int i = 0; i < data.length; i++) gradient[i] = (data[i]<<8)|(((data[i])>>24)&0xFF); }
Example 14
Source File: TaskFillArea.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
protected TaskFillArea(List<SelectionBox> boxes, IBlockState fillState, @Nullable IBlockState replaceState, boolean removeEntities, String nameOnHud) { super(nameOnHud); this.fillState = fillState; this.replaceState = replaceState; this.removeEntities = removeEntities; ResourceLocation rl = Block.REGISTRY.getNameForObject(fillState.getBlock()); String strName = null; if (rl != null) { String blockName = rl.toString(); strName = blockName + " " + String.valueOf(fillState.getBlock().getMetaFromState(fillState)); if (replaceState != null) { rl = Block.REGISTRY.getNameForObject(replaceState.getBlock()); if (rl != null) { strName += " replace " + rl.toString(); } else { InfoUtils.showGuiOrInGameMessage(MessageType.ERROR, "litematica-message.error.invalid_block", replaceState.toString()); strName = null; } } } else { InfoUtils.showGuiOrInGameMessage(MessageType.ERROR, "litematica-message.error.invalid_block", fillState.toString()); } this.blockString = strName; this.addBoxesPerChunks(boxes); this.updateInfoHudLinesMissingChunks(this.requiredChunks); }
Example 15
Source File: CustomRecipeBase.java From OpenModsLib with MIT License | 4 votes |
public CustomRecipeBase(ResourceLocation group) { this.group = group.toString(); }