Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.16.5 Is there a possibility to get string i.e "FARMLAND" from string? from Block object?


LemonekPL
 Share

Recommended Posts

As in topic, is there any way to get String  like FARMLAND or COBBLESTONE from BLOCK object? 

Here is a class, with static fields. I would appreciate if there would be possibility to get such String like those static fields are named. Currently Im using getDescriptionId() which returns strings like "block.minecraft.farmland" its ok, but if I want to implement support for other types I would need to know those descriptiosn and those are not hmm Human friendly. If I would get string like FARMLAND I could easly nearly copy/paste list from link below and implement it.

https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.16.5/net/minecraft/block/Blocks.html

 

Link to comment
Share on other sites

1 hour ago, LemonekPL said:

As in topic, is there any way to get String  like FARMLAND or COBBLESTONE from BLOCK object? 

Here is a class, with static fields. I would appreciate if there would be possibility to get such String like those static fields are named. Currently Im using getDescriptionId() which returns strings like "block.minecraft.farmland" its ok, but if I want to implement support for other types I would need to know those descriptiosn and those are not hmm Human friendly. If I would get string like FARMLAND I could easly nearly copy/paste list from link below and implement it.

you can get a block form a ResourceLocation, take a look at NBTUtil#readBlockState, do somthing like that

Link to comment
Share on other sites

I made some ugly solution quickly with a help of excel...

 

...
if(inBlock.equals(Blocks.SLIME_BLOCK)) return "SLIME_BLOCK";
if(inBlock.equals(Blocks.SMITHING_TABLE)) return "SMITHING_TABLE";
if(inBlock.equals(Blocks.SMOKER)) return "SMOKER";
if(inBlock.equals(Blocks.SMOOTH_QUARTZ)) return "SMOOTH_QUARTZ";
...


 

Link to comment
Share on other sites

42 minutes ago, LemonekPL said:

I made some ugly solution quickly with a help of excel...

there is a simple solution to this:

public static String getBlockName(Block blockIn) {
	List<Block> registryBlocks = Registry.BLOCK.stream().collect(Collectors.toList());
	for (Block block : registryBlocks) {
		if (block == blockIn) {
			return block.getRegistryName().getPath().toUpperCase();
		}
	}
	return Blocks.AIR.getRegistryName().getPath().toUpperCase();
}

Input: Blocks.ANDESITE_SLAB
Output: ANDESITE_SLAB

 

Link to comment
Share on other sites

3 hours ago, Luis_ST said:

if (block == blockIn) {
  return block.getRegistryName().getPath().toUpperCase();
}

really!?

fuck man, replace that entire function with blockIn.getRegistryName().getPath().toUpperCase();

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I tried to make an entity, but when I summon my entity, Minecraft crashes: https://gist.github.com/ArianKG/27288da1b8d670817711372a9e715d96 Source code: https://github.com/ArianKG/KGForge
    • en un servidor que he intentado crear me da este error es de la 1.12.2       ---- Minecraft Crash Report ---- WARNING: coremods are present:   Do not report to Forge! (If you haven't disabled the FoamFix coremod, try disabling it in the config! Note that this bit of text will still appear.) (foamfix-0.10.7-1.12.2.jar)   llibrary (llibrary-core-1.0.11-1.12.2.jar)   iceandfire (iceandfire-1.8.3.jar)   AppleCore (AppleCore-mc1.12.2-3.2.0.jar)   CreativePatchingLoader (CreativeCore_v1.9.68_mc1.12.2.jar)   MalisisCorePlugin (malisiscore-1.12.2-6.5.1.jar)   McLib core mod (mclib-1.0.3-1.12.2.jar)   LoadingPlugin (Bloodmoon-MC1.12.2-1.5.3.jar) Contact their authors BEFORE contacting forge // Uh... Did I do that? Time: 20/10/21 14:03 Description: Exception in server tick loop net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Decocraft (props) Caused by: java.lang.OutOfMemoryError: Java heap space     at java.awt.image.DataBufferByte.<init>(Unknown Source)     at java.awt.image.ComponentSampleModel.createDataBuffer(Unknown Source)     at java.awt.image.Raster.createWritableRaster(Unknown Source)     at javax.imageio.ImageTypeSpecifier.createBufferedImage(Unknown Source)     at javax.imageio.ImageReader.getDestination(Unknown Source)     at com.sun.imageio.plugins.png.PNGImageReader.readImage(Unknown Source)     at com.sun.imageio.plugins.png.PNGImageReader.read(Unknown Source)     at com.mia.craftstudio.utils.ImageIOCS.read(ImageIOCS.java:26)     at com.mia.craftstudio.CSModel.<init>(CSModel.java:379)     at com.mia.craftstudio.CSPack.readPackFile(CSPack.java:197)     at com.mia.craftstudio.CSProject.loadPacks(CSProject.java:252)     at com.mia.craftstudio.minecraft.forge.CSLibMod.getCSProjectAndLoad(CSLibMod.java:91)     at com.mia.props.Props.loadModels(Props.java:209)     at com.mia.props.Props.preInit(Props.java:166)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)     at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)     at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)     at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)     at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)     at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)     at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)     at com.google.common.eventbus.EventBus.post(EventBus.java:217)     at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)     at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Windows 10 (x86) version 10.0     Java Version: 1.8.0_251, Oracle Corporation     Java VM Version: Java HotSpot(TM) Client VM (mixed mode, sharing), Oracle Corporation     Memory: 3977648 bytes (3 MB) / 259522560 bytes (247 MB) up to 259522560 bytes (247 MB)     JVM Flags: 0 total;      IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0     FML: MCP 9.42 Powered by Forge 14.23.5.2855 43 mods loaded, 42 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     | State | ID                  | Version               | Source                                  | Signature                                |     |:----- |:------------------- |:--------------------- |:--------------------------------------- |:---------------------------------------- |     | LCH   | minecraft           | 1.12.2                | minecraft.jar                           | None                                     |     | LCH   | mcp                 | 9.42                  | minecraft.jar                           | None                                     |     | LCH   | FML                 | 8.0.99.99             | forge-1.12.2-14.23.5.2855.jar           | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCH   | forge               | 14.23.5.2855          | forge-1.12.2-14.23.5.2855.jar           | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCH   | creativecoredummy   | 1.0.0                 | minecraft.jar                           | None                                     |     | LCH   | foamfixcore         | 7.7.4                 | minecraft.jar                           | None                                     |     | LCH   | securitycraft       | v1.8.12.1             | [1.12.2]+SecurityCraft+v1.8.12.1.jar    | None                                     |     | LCH   | damageindicatorsmod | 1.0                   | [1.12.2]DamageIndicatorsMod-3.5.1.jar   | None                                     |     | LCH   | applecore           | 3.2.0                 | AppleCore-mc1.12.2-3.2.0.jar            | None                                     |     | LCH   | jei                 | 4.15.0.268            | jei_1.12.2-4.15.0.268.jar               | None                                     |     | LCH   | appleskin           | 1.0.9                 | AppleSkin-mc1.12-1.0.9.jar              | None                                     |     | LCH   | astralsorcery       | 1.6.1                 | astralsorcery-1.12-1.6.1.jar            | None                                     |     | LCH   | baubles             | 1.5.2                 | Baubles-1.12-1.5.2.jar                  | None                                     |     | LCH   | bloodmoon           | 1.5.3                 | Bloodmoon-MC1.12.2-1.5.3.jar            | d72e0dd57935b3e9476212aea0c0df352dd76291 |     | LCH   | chesttransporter    | 2.8.8                 | Chest-Transporter-Mod-1.12.2.jar        | None                                     |     | LCH   | playerrevive        | 1.0                   | PlayerRevive_v1.2.28_mc1.12.2.jar       | None                                     |     | LCH   | creativecore        | 1.9.9                 | CreativeCore_v1.9.68_mc1.12.2.jar       | None                                     |     | LCE   | props               | 2.6.3                 | Decocraft-2.6.3_1.12.2.jar              | None                                     |     | LC    | dynamictrees        | 1.12.2-0.9.5          | DynamicTrees-1.12.2-0.9.5.jar           | None                                     |     | LC    | harvestcraft        | 1.12.2zb              | Pam's+HarvestCraft+1.12.2zf.jar         | None                                     |     | LC    | dynamictreesphc     | 1.12.2-1.4.2          | DynamicTreesPHC-1.12.2-1.4.2.jar        | None                                     |     | LC    | mclib               | 1.0.3                 | mclib-1.0.3-1.12.2.jar                  | None                                     |     | LC    | emoticons           | 0.3                   | emoticons-0.3-1.12.2-dist.jar           | None                                     |     | LC    | fencejumper         | 1.0.5                 | fencejumper-1.12-1.0.5.jar              | None                                     |     | LC    | ferdinandsflowers   | 1.10.4.1              | Ferdinand's+Flowers-1.12.x-1.10.4.1.jar | None                                     |     | LC    | foamfix             | 0.10.7-1.12.2         | foamfix-0.10.7-1.12.2.jar               | None                                     |     | LC    | waila               | 1.8.26                | Hwyla-1.8.26-B41_1.12.2.jar             | None                                     |     | LC    | llibrary            | 1.7.19                | llibrary-1.7.19-1.12.2.jar              | b9f30a813bee3b9dd5652c460310cfcd54f6b7ec |     | LC    | iceandfire          | 1.8.3                 | iceandfire-1.8.3.jar                    | None                                     |     | LC    | ichunutil           | 7.2.2                 | iChunUtil-1.12.2-7.2.2.jar              | 4db5c2bd1b556f252a5b8b54b256d381b2a0a6b8 |     | LC    | infernalmobs        | 1.7.6                 | InfernalMobs-1.12.2.jar                 | None                                     |     | LC    | journeymap          | 1.12.2-5.5.4          | journeymap-1.12.2-5.5.4.jar             | None                                     |     | LC    | laggoggles          | FAT-1.12.2-4.8        | LagGoggles-FAT-1.12.2-4.8.jar           | None                                     |     | LC    | libraryex           | 1.0.12                | LibraryEx-1.12.2-1.0.12.jar             | None                                     |     | LC    | magma_monsters      | 0.3.0                 | MagmaMonsters-0.3.0.jar                 | None                                     |     | LC    | malisiscore         | 1.12.2-6.5.1-SNAPSHOT | malisiscore-1.12.2-6.5.1.jar            | None                                     |     | LC    | malisisdoors        | 1.12.2-7.3.0          | malisisdoors-1.12.2-7.3.0.jar           | None                                     |     | LC    | netherex            | 2.0.15                | NetherEx-1.12.2-2.0.15.jar              | None                                     |     | LC    | playerskins         | 1.0.4                 | playerskin-1.12.2-1.0.5.jar             | None                                     |     | LC    | radixcore           | 1.12.x-2.2.1          | RadixCore-1.12.x-2.2.1-universal.jar    | None                                     |     | LC    | cactusmod           | 1.2.1                 | The-Cactus-Mod-1.12.2.jar               | None                                     |     | LC    | tombstone           | 3.5.9                 | tombstone-3.5.9-1.12.2.jar              | None                                     |     | UD    | mclib_core          | 1.0.3                 | minecraft.jar                           | None                                     |     Loaded coremods (and transformers):  Do not report to Forge! (If you haven't disabled the FoamFix coremod, try disabling it in the config! Note that this bit of text will still appear.) (foamfix-0.10.7-1.12.2.jar)   pl.asie.foamfix.coremod.FoamFixTransformer llibrary (llibrary-core-1.0.11-1.12.2.jar)   net.ilexiconn.llibrary.server.core.plugin.LLibraryTransformer   net.ilexiconn.llibrary.server.core.patcher.LLibraryRuntimePatcher iceandfire (iceandfire-1.8.3.jar)   com.github.alexthe666.iceandfire.patcher.IceAndFireRuntimePatcher AppleCore (AppleCore-mc1.12.2-3.2.0.jar)   squeek.applecore.asm.TransformerModuleHandler CreativePatchingLoader (CreativeCore_v1.9.68_mc1.12.2.jar)    MalisisCorePlugin (malisiscore-1.12.2-6.5.1.jar)    McLib core mod (mclib-1.0.3-1.12.2.jar)   mchorse.mclib.core.McLibCMClassTransformer LoadingPlugin (Bloodmoon-MC1.12.2-1.5.3.jar)   lumien.bloodmoon.asm.ClassTransformer     Profiler Position: N/A (disabled)     Is Modded: Definitely; Server brand changed to 'fml,forge'     Type: Dedicated Server (map_server.txt)
    • https://gist.github.com/twixsbar/62ebb07f0c4877c7c62023fda1b8961f tell me if this works
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.