Jump to content

[1.14.4] Invalid dist DEDICATED_SERVER


EmotionFox

Recommended Posts

Hello everyone, like the title suggest, I've a problem running dedicated server for my mod "emomod, Emotion's Mod", I understand that the problem is caused by my containers because of invalid dist and I understand the concept of side but I really struggle to fix it, for the lore I'm developing this mod since 5 or 6 years from now so it's a huge one, I have like 281 block textures, 167 item textures, biomes, game mechanics, dimensions, entities etc.. I love it but I kept it private for the moment (I may send it public soon) and I use to get back on it sometimes when I want to update the version (I also rewrite everything once because I suck to do so for the version 1.8 to 1.12 / 1.14) or add stuff for example, here is the log of the server :

 

Spoiler

[27sept.2021 11:07:56.786] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmluserdevserver, --fml.mcpVersion, 20190829.143755, --fml.mcVersion, 1.14.4, --fml.forgeGroup, net.minecraftforge, --fml.forgeVersion, 28.2.0]
[27sept.2021 11:07:56.789] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 4.1.0+62+5bfa59b starting: java version 1.8.0_302 by Temurin
[27sept.2021 11:07:57.010] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust
[27sept.2021 11:07:57.670] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmluserdevserver' with arguments [--gameDir, .]
[27sept.2021 11:08:07.396] [main/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, destination] and [teleport, targets] with inputs: [Player, 0123, @e, dd12be42-52a9-4a91-a8a1-11c01849e498]
[27sept.2021 11:08:07.397] [main/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, location] and [teleport, destination] with inputs: [0.1 -0.5 .9, 0 0 0]
[27sept.2021 11:08:07.398] [main/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, location] and [teleport, targets] with inputs: [0.1 -0.5 .9, 0 0 0]
[27sept.2021 11:08:07.398] [main/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, targets] and [teleport, destination] with inputs: [Player, 0123, dd12be42-52a9-4a91-a8a1-11c01849e498]
[27sept.2021 11:08:07.399] [main/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, targets, location] and [teleport, targets, destination] with inputs: [0.1 -0.5 .9, 0 0 0]
[27sept.2021 11:08:08.347] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer/]: Starting minecraft server version 1.14.4
[27sept.2021 11:08:08.590] [Server thread/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/renderer/tileentity/TileEntityRenderer for invalid dist DEDICATED_SERVER
[27sept.2021 11:08:08.590] [Server thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Failed to load class fr.emotion.emomod.MainRegistry
java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/tileentity/TileEntityRenderer for invalid dist DEDICATED_SERVER
    at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClass(RuntimeDistCleaner.java:71) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar:28.2]
    at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClass(ILaunchPluginService.java:102) ~[modlauncher-4.1.0.jar:4.1.0+62+5bfa59b]
    at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:80) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:115) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:241) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:128) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-4.1.0.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_302]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_302]
    at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.<init>(FMLModContainer.java:71) ~[?:28.2]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_302]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_302]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_302]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider$FMLModTarget.loadMod(FMLJavaModLanguageProvider.java:73) ~[?:28.2]
    at net.minecraftforge.fml.ModLoader.buildModContainerFromTOML(ModLoader.java:234) ~[?:?]
    at net.minecraftforge.fml.ModLoader.lambda$buildMods$26(ModLoader.java:214) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_302]
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1699) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_302]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_302]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_302]
    at net.minecraftforge.fml.ModLoader.buildMods(ModLoader.java:216) ~[?:?]
    at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$18(ModLoader.java:173) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_302]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_302]
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) [?:1.8.0_302]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_302]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [?:1.8.0_302]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) [?:1.8.0_302]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_302]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) [?:1.8.0_302]
    at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:175) [?:?]
    at net.minecraftforge.fml.server.ServerModLoader.begin(ServerModLoader.java:45) [?:?]
    at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:124) [?:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_302]
[27sept.2021 11:08:08.602] [Server thread/FATAL] [net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider/LOADING]: Unable to load FMLModContainer, wut?
java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_302]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_302]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_302]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider$FMLModTarget.loadMod(FMLJavaModLanguageProvider.java:73) ~[?:28.2]
    at net.minecraftforge.fml.ModLoader.buildModContainerFromTOML(ModLoader.java:234) ~[?:?]
    at net.minecraftforge.fml.ModLoader.lambda$buildMods$26(ModLoader.java:214) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_302]
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1699) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_302]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_302]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_302]
    at net.minecraftforge.fml.ModLoader.buildMods(ModLoader.java:216) ~[?:?]
    at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$18(ModLoader.java:173) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_302]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_302]
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) [?:1.8.0_302]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_302]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [?:1.8.0_302]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) [?:1.8.0_302]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_302]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) [?:1.8.0_302]
    at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:175) [?:?]
    at net.minecraftforge.fml.server.ServerModLoader.begin(ServerModLoader.java:45) [?:?]
    at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:124) [?:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_302]
Caused by: net.minecraftforge.fml.ModLoadingException: Emotion's Mod has class loading errors
§7Attempted to load class net/minecraft/client/renderer/tileentity/TileEntityRenderer for invalid dist DEDICATED_SERVER
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.<init>(FMLModContainer.java:77) ~[?:28.2]
    ... 29 more
Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/tileentity/TileEntityRenderer for invalid dist DEDICATED_SERVER
    at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClass(RuntimeDistCleaner.java:71) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar:28.2]
    at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClass(ILaunchPluginService.java:102) ~[modlauncher-4.1.0.jar:4.1.0+62+5bfa59b]
    at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:80) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:115) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:241) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:128) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-4.1.0.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_302]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_302]
    at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.<init>(FMLModContainer.java:71) ~[?:28.2]
    ... 29 more
[27sept.2021 11:08:08.604] [Server thread/ERROR] [net.minecraft.server.MinecraftServer/]: Encountered an unexpected exception
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider$FMLModTarget.loadMod(FMLJavaModLanguageProvider.java:78) ~[?:28.2]
    at net.minecraftforge.fml.ModLoader.buildModContainerFromTOML(ModLoader.java:234) ~[?:?]
    at net.minecraftforge.fml.ModLoader.lambda$buildMods$26(ModLoader.java:214) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_302]
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1699) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_302]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_302]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_302]
    at net.minecraftforge.fml.ModLoader.buildMods(ModLoader.java:216) ~[?:?]
    at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$18(ModLoader.java:173) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_302]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_302]
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_302]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_302]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_302]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_302]
    at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:175) ~[?:?]
    at net.minecraftforge.fml.server.ServerModLoader.begin(ServerModLoader.java:45) ~[?:?]
    at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:124) ~[?:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_302]
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_302]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_302]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_302]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider$FMLModTarget.loadMod(FMLJavaModLanguageProvider.java:73) ~[?:28.2]
    ... 24 more
Caused by: net.minecraftforge.fml.ModLoadingException: Emotion's Mod has class loading errors
§7Attempted to load class net/minecraft/client/renderer/tileentity/TileEntityRenderer for invalid dist DEDICATED_SERVER
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.<init>(FMLModContainer.java:77) ~[?:28.2]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_302]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_302]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_302]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider$FMLModTarget.loadMod(FMLJavaModLanguageProvider.java:73) ~[?:28.2]
    ... 24 more
Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/tileentity/TileEntityRenderer for invalid dist DEDICATED_SERVER
    at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClass(RuntimeDistCleaner.java:71) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar:28.2]
    at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClass(ILaunchPluginService.java:102) ~[modlauncher-4.1.0.jar:4.1.0+62+5bfa59b]
    at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:80) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:115) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:241) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:128) ~[modlauncher-4.1.0.jar:?]
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-4.1.0.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_302]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_302]
    at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.<init>(FMLModContainer.java:71) ~[?:28.2]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_302]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_302]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_302]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_302]
    at net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider$FMLModTarget.loadMod(FMLJavaModLanguageProvider.java:73) ~[?:28.2]
    ... 24 more
[27sept.2021 11:08:08.622] [Server thread/ERROR] [net.minecraft.server.MinecraftServer/]: This crash report has been saved to: E:\Users\micka_000\Documents\Programmation\Minecraft\Emotion's Mod\1.14.3\Emomod\run\.\crash-reports\crash-2021-09-27_11.08.08-server.txt
[27sept.2021 11:08:08.641] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Stopping server
[27sept.2021 11:08:08.641] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving worlds
[27sept.2021 11:08:08.644] [Server thread/ERROR] [net.minecraft.server.MinecraftServer/]: Exception stopping the server
java.lang.IllegalArgumentException: Can not hotload overworld. This must be loaded at all times by main Server.
    at org.apache.commons.lang3.Validate.isTrue(Validate.java:158) ~[commons-lang3-3.8.1.jar:3.8.1]
    at net.minecraftforge.common.DimensionManager.initWorld(DimensionManager.java:226) ~[?:?]
    at net.minecraftforge.common.DimensionManager.getWorld(DimensionManager.java:195) ~[?:?]
    at net.minecraft.server.MinecraftServer.getWorld(MinecraftServer.java:1027) ~[?:?]
    at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:536) ~[?:?]
    at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:571) ~[?:?]
    at net.minecraft.server.dedicated.DedicatedServer.stopServer(DedicatedServer.java:596) ~[?:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:685) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_302]

I'm registering Biome, Block, ContainerType, TileEntityType etc.. In differents class that I'm calling in my main one called "MainRegistry" with the method init().
 

Firstly, the classe where I'm registering ContainerType is modestly named "ContainerTypeRegistry" (this is my convention), I've currently three type of container, "CRAFTER" wich is a complex automatic crafting machine, "BAG" is a bag item storing stuff using "ItemStackHandler" and finally "NIGHTSTAND" is a basic chest with less slots (4) using different color GUIs based on the wood used to craft, here is the code :

 

@Mod.EventBusSubscriber(modid = MainRegistry.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ContainerTypeRegistry
{
	private static final List<ContainerType<?>> containerTypeList = new ArrayList<ContainerType<?>>();

	public static final ContainerType<CrafterContainer> CRAFTER = IForgeContainerType.create((windowId, inv, data) ->
	{
		BlockPos pos = data.readBlockPos();
		return new CrafterContainer(windowId, MainRegistry.proxy.getClientWorld(), pos, MainRegistry.proxy.getClientPlayer());
	});

	public static final ContainerType<BagContainer> BAG = IForgeContainerType.create((windowId, inv, data) ->
	{
		return new BagContainer(windowId, inv);
	});

	public static final ContainerType<NightstandContainer> NIGHTSTAND = IForgeContainerType.create((windowId, inv, data) ->
	{
		BlockPos pos = data.readBlockPos();
		return new NightstandContainer(windowId, inv.player.getEntityWorld(), pos, inv);
	});

	public static void init()
	{
		addContainerType(CRAFTER, "crafter");
		addContainerType(BAG, "bag");
		addContainerType(NIGHTSTAND, "nightstand");
	}

	public static void addContainerType(ContainerType<?> tet, String name)
	{
		containerTypeList.add(tet.setRegistryName(name));
	}

	@SubscribeEvent
	public static void registerContainerType(final RegistryEvent.Register<ContainerType<?>> e)
	{
		for (ContainerType<?> tet : containerTypeList)
		{
			e.getRegistry().register(tet);
		}
	}
}

Secondly, I'm using the same technique to register TileEntityType and I'm calling all those init methods but also ScreenManager.registerFactory() like I said in the main class just here :

 

@Mod(MainRegistry.MOD_ID)
public class MainRegistry
{
	public static final String MOD_ID = "emomod";
	public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
	public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
	public static MainRegistry instance;

	public static WorldType PARCEL_TYPE = new ParcelWorldType();
	public static WorldType DREAM_TYPE = new DreamWorldType();

	public MainRegistry()
	{
		ItemRegistry.init();
		BlockRegistry.init();
		TileEntityTypeRegistry.init();
		EntityTypeRegistry.init();
		SurfaceBuilderRegistry.init();
		PlacementRegistry.init();
		FeatureRegistry.init();
		FluidRegistry.init();
		ContainerTypeRegistry.init();

		DispenserBlock.registerDispenseBehavior(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER).getItem(), new IInteractBehavior());

		DispenserBlock.registerDispenseBehavior(Items.WHEAT_SEEDS, new IPlaceBehavior(Blocks.WHEAT, Blocks.FARMLAND));
		DispenserBlock.registerDispenseBehavior(Items.PUMPKIN_SEEDS, new IPlaceBehavior(Blocks.PUMPKIN_STEM, Blocks.FARMLAND));
		DispenserBlock.registerDispenseBehavior(Items.MELON_SEEDS, new IPlaceBehavior(Blocks.MELON_STEM, Blocks.FARMLAND));
		DispenserBlock.registerDispenseBehavior(Items.BEETROOT_SEEDS, new IPlaceBehavior(Blocks.BEETROOTS, Blocks.FARMLAND));
		DispenserBlock.registerDispenseBehavior(Items.CARROT, new IPlaceBehavior(Blocks.CARROTS, Blocks.FARMLAND));
		DispenserBlock.registerDispenseBehavior(Items.POTATO, new IPlaceBehavior(Blocks.POTATOES, Blocks.FARMLAND));

		DispenserBlock.registerDispenseBehavior(Items.OAK_SAPLING, new IPlaceBehavior(Blocks.OAK_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));
		DispenserBlock.registerDispenseBehavior(Items.ACACIA_SAPLING, new IPlaceBehavior(Blocks.ACACIA_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));
		DispenserBlock.registerDispenseBehavior(Items.BIRCH_SAPLING, new IPlaceBehavior(Blocks.BIRCH_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));
		DispenserBlock.registerDispenseBehavior(Items.DARK_OAK_SAPLING, new IPlaceBehavior(Blocks.DARK_OAK_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));
		DispenserBlock.registerDispenseBehavior(Items.JUNGLE_SAPLING, new IPlaceBehavior(Blocks.JUNGLE_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));
		DispenserBlock.registerDispenseBehavior(Items.SPRUCE_SAPLING, new IPlaceBehavior(Blocks.SPRUCE_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));
		DispenserBlock.registerDispenseBehavior(Items.BAMBOO, new IPlaceBehavior(Blocks.BAMBOO_SAPLING, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));

		DispenserBlock.registerDispenseBehavior(Items.NETHER_WART, new IPlaceBehavior(Blocks.NETHER_WART, Blocks.SOUL_SAND, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL));

		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverSetup);

		MinecraftForge.EVENT_BUS.register(new EmotionOverlayEvent());
		MinecraftForge.EVENT_BUS.register(new EmotionLivingEvent());

		ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySign.class, new TileEntitySignRenderer());
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrafter.class, new TileEntityCrafterRenderer());
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPot.class, new TileEntityPotRenderer());

		LootConditionManager.registerCondition(new HarvestLevelCondition.Serializer());

		EmomodPacketHandler.registerMessages();
	}

	private void setup(final FMLCommonSetupEvent e)
	{
		proxy.init();

		RenderingRegistry.registerEntityRenderingHandler(OrbSpellEntity.class, render -> new SpriteRenderer<OrbSpellEntity>(render, Minecraft.getInstance().getItemRenderer()));
		RenderingRegistry.registerEntityRenderingHandler(EntityButterfly.class, render -> new RendererButterfly(render));
		RenderingRegistry.registerEntityRenderingHandler(EntityBeetle.class, render -> new RendererBasic<EntityBeetle, ModelBeetle>(render, new ModelBeetle(), 0.175f, new ResourceLocation(MainRegistry.MOD_ID, "textures/entity/beetle.png")));
		RenderingRegistry.registerEntityRenderingHandler(EntityLightningBug.class,
				render -> new RendererBasic<EntityLightningBug, ModelLightningBug>(render, new ModelLightningBug(), 0.0f, new ResourceLocation(MainRegistry.MOD_ID, "textures/entity/lightning_bug.png")));
		RenderingRegistry.registerEntityRenderingHandler(EntityBoat.class, RendererBoat::new);
		RenderingRegistry.registerEntityRenderingHandler(EntityChubby.class, render -> new RendererBasic<EntityChubby, ModelChubby>(render, new ModelChubby(), .2f, new ResourceLocation(MainRegistry.MOD_ID, "textures/entity/chubby.png")));
		RenderingRegistry.registerEntityRenderingHandler(EntityMouse.class, render -> new RendererMouse(render, new ModelMouse(), 0.1f));
		RenderingRegistry.registerEntityRenderingHandler(EntityOrchardSpider.class, render -> new RendererOrchardSpider<EntityOrchardSpider>(render));

		EmoOreGeneration.setupOreGeneration();

//		RecipeRegistry.init();
	}

	private void clientSetup(final FMLClientSetupEvent e)
	{
		EmoStaff staff = (EmoStaff) ItemRegistry.PURPURA_STAFF;

		Minecraft.getInstance().getItemColors().register((item, tintIndex) ->
		{
			return staff.getColor(new ItemStack(staff), tintIndex);
		}, staff);

		Minecraft.getInstance().getItemColors().register((item, tintIndex) ->
		{
			return GrassColors.get(0.5D, 1.0D);
		}, BlockRegistry.FLOWER_TALLGRASS);

		Minecraft.getInstance().getItemColors().register((item, tintIndex) ->
		{
			BlockState blockstate = ((BlockItem) item.getItem()).getBlock().getDefaultState();
			return Minecraft.getInstance().getBlockColors().getColor(blockstate, (IEnviromentBlockReader) null, (BlockPos) null, tintIndex);
		}, BlockRegistry.LEAVES_CHERRY, BlockRegistry.LEAVES_PEAR, BlockRegistry.LEAVES_ORANGE, BlockRegistry.LEAVES_ATLAS, BlockRegistry.LEAVES_PINE, BlockRegistry.LEAVES_COCO, BlockRegistry.LEAVES_DREAM);

		Minecraft.getInstance().getBlockColors().register((state, reader, pos, color) ->
		{
			return reader != null && pos != null ? BiomeColors.getGrassColor(reader, pos) : GrassColors.get(0.5D, 1.0D);
		}, BlockRegistry.FLOWER_TALLGRASS);

		Minecraft.getInstance().getBlockColors().register((state, reader, pos, color) ->
		{
			return reader != null && pos != null ? BiomeColors.getFoliageColor(reader, pos) : FoliageColors.getDefault();
		}, BlockRegistry.LEAVES_PINE, BlockRegistry.LEAVES_COCO, BlockRegistry.LEAVES_DREAM);

		Minecraft.getInstance().getBlockColors().register((state, reader, pos, color) ->
		{
			return 0xac73af;
		}, BlockRegistry.LEAVES_CHERRY);

		Minecraft.getInstance().getBlockColors().register((state, reader, pos, color) ->
		{
			return 0x487748;
		}, BlockRegistry.LEAVES_PEAR);

		Minecraft.getInstance().getBlockColors().register((state, reader, pos, color) ->
		{
			return 0x45a14a;
		}, BlockRegistry.LEAVES_ORANGE);

		Minecraft.getInstance().getBlockColors().register((state, reader, pos, color) ->
		{
			return 0x4496c4;
		}, BlockRegistry.LEAVES_ATLAS);

		ScreenManager.<CrafterContainer, CrafterScreen>registerFactory(ContainerTypeRegistry.CRAFTER, (container, playerInventory, title) ->
		{
			return new CrafterScreen(container, playerInventory, title);
		});

		ScreenManager.<BagContainer, BagScreen>registerFactory(ContainerTypeRegistry.BAG, (container, playerInventory, title) ->
		{
			return new BagScreen(container, playerInventory, title);
		});

		ScreenManager.<NightstandContainer, NightstandScreen>registerFactory(ContainerTypeRegistry.NIGHTSTAND, (container, playerInventory, title) ->
		{
			return new NightstandScreen(container, playerInventory, title, container.getTileEntity().getColor());
		});
	}

	private void serverSetup(final FMLDedicatedServerSetupEvent e)
	{
	}
}

Finally for the specific class I'm only gonna send the Nightstand one in random way :

 

- Block class :

 

public class EmoNightstand extends Block
{
	private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
	private static final VoxelShape NIGHTSTAND_SHAPE = Block.makeCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 15.0D, 15.0D);
	private float[] color;

	public EmoNightstand(Properties properties, float[] color)
	{
		super(properties);
		this.getDefaultState().with(FACING, Direction.NORTH);
		this.color = color;
	}

	@Override
	public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
	{
		return NIGHTSTAND_SHAPE;
	}

	@Override
	public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
	{
		return NIGHTSTAND_SHAPE;
	}

	@Override
	public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit)
	{
		if (!worldIn.isRemote)
		{
			TileEntity tileEntity = worldIn.getTileEntity(pos);

			if (tileEntity instanceof INamedContainerProvider)
			{
				NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tileEntity, tileEntity.getPos());
			}
		}

		return true;
	}

	public BlockState getStateForPlacement(BlockItemUseContext context)
	{
		return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
	}

	protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
	{
		builder.add(FACING);
	}

	@Override
	public boolean hasTileEntity(BlockState state)
	{
		return true;
	}

	@Override
	public TileEntity createTileEntity(BlockState state, IBlockReader world)
	{
		return new TileEntityNightstand(this.color);
	}
}

- The ContainerScreen class :

 

public class NightstandScreen extends ContainerScreen<NightstandContainer>
{
	private static final ResourceLocation NIGHTSTAND_GUI_SCREEN = new ResourceLocation(MainRegistry.MOD_ID, "textures/gui/container/nightstand.png");
	private float[] color;

	public NightstandScreen(NightstandContainer screenContainer, PlayerInventory playerInventory, ITextComponent titleIn, float[] color)
	{
		super(screenContainer, playerInventory, titleIn);
		this.xSize = 176;
		this.ySize = 127;
		this.color = color;
	}

	protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
	{
		this.font.drawString(this.getTitle().getFormattedText(), 8, 4, 0);
		this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float) (this.ySize - 96 + 2), 0);
	}

	@Override
	protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
	{
		int xPos = (this.width - this.xSize) / 2;
		int yPos = (this.height - this.ySize) / 2;

		GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
		this.minecraft.getTextureManager().bindTexture(NIGHTSTAND_GUI_SCREEN);
		this.blit(xPos, yPos, 0, 0, this.xSize, this.ySize);

		GlStateManager.color4f(color[0] / 255, color[1] / 255, color[2] / 255, 1.0f);
		this.blit(xPos, yPos, 0, 0, this.xSize, this.ySize);

		GlStateManager.disableTexture();
		GlStateManager.enableBlend();
		GlStateManager.disableAlphaTest();
		GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
		GlStateManager.shadeModel(7425);
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder bufferbuilder = tessellator.getBuffer();
		bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
		bufferbuilder.pos((double) xPos + this.xSize, (double) yPos, (double) this.blitOffset).color(0, 0, 0, 0).endVertex();
		bufferbuilder.pos((double) xPos, (double) yPos, (double) this.blitOffset).color(0, 0, 0, 0).endVertex();
		bufferbuilder.pos((double) xPos, (double) yPos + this.ySize, (double) this.blitOffset).color(0, 0, 0, 255 / 2).endVertex();
		bufferbuilder.pos((double) xPos + this.xSize, (double) yPos + this.ySize, (double) this.blitOffset).color(0, 0, 0, 255 / 2).endVertex();
		tessellator.draw();
		GlStateManager.shadeModel(7424);
		GlStateManager.disableBlend();
		GlStateManager.enableAlphaTest();
		GlStateManager.enableTexture();
	}
}

The Container class :

 

public class NightstandContainer extends Container
{
	private TileEntity tileEntity;
	private int containerSlots = 0;

	public NightstandContainer(int id, World world, BlockPos pos, PlayerInventory playerInventory)
	{
		super(ContainerTypeRegistry.NIGHTSTAND, id);
		this.tileEntity = world.getTileEntity(pos);

		tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h ->
		{
			containerSlots = h.getSlots();

			for (int i = 0; i < h.getSlots(); i++)
			{
				addSlot(new SlotItemHandler(h, i, 44 + (i * 18) + (i > 1 ? 18 : 0), 14));
			}
		});

		for (int y = 0; y < 3; ++y)
		{
			for (int x = 0; x < 9; ++x)
			{
				this.addSlot(new Slot(playerInventory, x + y * 9 + 9, 8 + (x * 18), 45 + (y * 18)));
			}
		}

		for (int k = 0; k < 9; ++k)
		{
			this.addSlot(new Slot(playerInventory, k, 8 + k * 18, 103));
		}
	}

	@Override
	public ItemStack transferStackInSlot(PlayerEntity playerIn, int index)
	{
		Slot slot = this.getSlot(index);

		if (!slot.canTakeStack(playerIn))
			return slot.getStack();

		if (!slot.getHasStack())
			return ItemStack.EMPTY;

		ItemStack stack = slot.getStack();
		ItemStack newStack = stack.copy();

		if (index < containerSlots)
		{
			if (!this.mergeItemStack(stack, containerSlots, this.inventorySlots.size(), true))
				return ItemStack.EMPTY;

			slot.onSlotChanged();
		}
		else if (!this.mergeItemStack(stack, 0, containerSlots, false))
			return ItemStack.EMPTY;

		if (stack.isEmpty())
			slot.putStack(ItemStack.EMPTY);
		else
			slot.onSlotChanged();

		return slot.onTake(playerIn, newStack);
	}

	@Override
	public boolean canInteractWith(PlayerEntity playerIn)
	{
		return this.isUsable(playerIn);
	}

	protected boolean isUsable(PlayerEntity playerIn)
	{
		return IWorldPosCallable.of(tileEntity.getWorld(), tileEntity.getPos()).applyOrElse((block, pos) ->
		{
			return !(block.getBlockState(pos).getBlock() instanceof EmoNightstand) ? false
					: playerIn.getDistanceSq((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64.0D;
		}, true);
	}

	@Nullable
	public TileEntityNightstand getTileEntity()
	{
		if (this.tileEntity instanceof TileEntityNightstand)
			return (TileEntityNightstand) this.tileEntity;
		else
			return null;
	}
}

The TileEntity class :

 

public class TileEntityNightstand extends TileEntity implements INamedContainerProvider
{
	private LazyOptional<IItemHandler> handler = LazyOptional.of(this::createHandler);
	private float[] color = new float[]
	{ 0.0f, 255.0f, 0.0f};

	public TileEntityNightstand(float[] color)
	{
		this();
		this.color = color;
	}

	public TileEntityNightstand()
	{
		super(TileEntityTypeRegistry.NIGHTSTAND);
	}

	@SuppressWarnings("unchecked")
	@Override
	public void read(CompoundNBT compound)
	{
		CompoundNBT inventory = compound.getCompound("Inventory");
		handler.ifPresent(h -> ((INBTSerializable<CompoundNBT>) h).deserializeNBT(inventory));
		super.read(compound);
	}

	@SuppressWarnings("unchecked")
	@Override
	public CompoundNBT write(CompoundNBT compound)
	{
		handler.ifPresent(h ->
		{
			CompoundNBT nbt = ((INBTSerializable<CompoundNBT>) h).serializeNBT();
			compound.put("Inventory", nbt);
		});

		return super.write(compound);
	}

	private IItemHandler createHandler()
	{
		return new ItemStackHandler(4)
		{
			@Override
			protected void onContentsChanged(int slot)
			{
				markDirty();
			}
		};
	}

	@Override
	public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
	{
		if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
			return handler.cast();

		return super.getCapability(cap, side);
	}

	@Override
	public ITextComponent getDisplayName()
	{
		return new TranslationTextComponent("container.emomod.nightstand");
	}

	@Override
	public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player)
	{
		return new NightstandContainer(windowId, this.getWorld(), this.getPos(), playerInventory);
	}

	public float[] getColor()
	{
		return this.color;
	}
}

And voilà, I think that everything is here and I will really appreciate some help, this mod is very important for me and I've put so many efforts in it, I've to update it soon to the latest version (I may also want some paid help for that if I can apply some sort of dev recrutment on this forum) and I will stop adding stuff but polish everything up to finally set it public.

Thanks again for giving me some of your time, I can send the WIP version of the mod jar as demo when this will be fixed if some of you want it, and also if I find a way to protect my textures from being copied / reused or modified.

Edited by EmotionFox
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • My modded minecraft world don't go past 100% on the loading screen. My backup still work, but i've made a lot of progress from the point i was that save. i have already checked online and did some suggestions i found, but nothing worked. Here is my latest log + i don´t have crash reports: https://github.com/GmsantosPT/Minecraft-mod-problems/tree/main   Pls Help, Santos
    • Please share a link to your crash report, as explained in the FAQ
    • I have a block already registered in my mod, which I have used in some worlds. The problem arises when in code, I add a property called CURRENT_AGE, when running Minecraft it freezes. In the console it doesn't appear any excpetion except that it stays in this phase: [Render thread/DEBUG] [ne.mi.co.ca.CapabilityManager/CAPABILITIES]: Attempting to automatically register: Lnet/minecraftforge/items/IItemHandler; Does anyone have an idea what it could be? I show the block and its registration public class SoulLichenBlock extends MultifaceBlock implements SimpleWaterloggedBlock, EntityBlock { public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final IntegerProperty SKILL_LEVEL = IntegerProperty.create("soullichen_level", 0, 30); public static final DirectionProperty FACE = DirectionProperty.create("soullichen_face"); public static final DirectionProperty DIRECTION = DirectionProperty.create("soullichen_direction"); public static final IntegerProperty CURRENT_AGE = BlockStateProperties.AGE_25; private final MultifaceSpreader spreader = new MultifaceSpreader(this); private final MultifaceSpreader.DefaultSpreaderConfig config = new MultifaceSpreader.DefaultSpreaderConfig(this); private LivingEntity owner; //private static final Integer MAX_AGE = 25; public SoulLichenBlock(Properties properties) { super(properties); this.registerDefaultState(this .defaultBlockState() .setValue(WATERLOGGED, Boolean.FALSE) .setValue(SKILL_LEVEL, 0) .setValue(FACE, Direction.DOWN) .setValue(DIRECTION, Direction.DOWN) .trySetValue(CURRENT_AGE, 0) ); } public static ToIntFunction<BlockState> emission(int p_181223_) { return (p_181221_) -> MultifaceBlock.hasAnyFace(p_181221_) ? p_181223_ : 0; } public static boolean hasFace(BlockState p_153901_, @NotNull Direction p_153902_) { BooleanProperty booleanproperty = getFaceProperty(p_153902_); return p_153901_.hasProperty(booleanproperty) && p_153901_.getValue(booleanproperty); } protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> stateDefinition) { stateDefinition.add(WATERLOGGED).add(SKILL_LEVEL).add(FACE).add(DIRECTION).add(CURRENT_AGE); super.createBlockStateDefinition(stateDefinition); } public @NotNull BlockState updateShape(BlockState p_153302_, @NotNull Direction p_153303_, @NotNull BlockState p_153304_, @NotNull LevelAccessor p_153305_, @NotNull BlockPos p_153306_, @NotNull BlockPos p_153307_) { if (p_153302_.getValue(WATERLOGGED)) { p_153305_.scheduleTick(p_153306_, Fluids.WATER, Fluids.WATER.getTickDelay(p_153305_)); } return super.updateShape(p_153302_, p_153303_, p_153304_, p_153305_, p_153306_, p_153307_); } @SuppressWarnings("deprecation") public @NotNull FluidState getFluidState(BlockState fluidState) { return fluidState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(fluidState); } public boolean propagatesSkylightDown(BlockState p_181225_, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos) { return p_181225_.getFluidState().isEmpty(); } public @NotNull MultifaceSpreader getSpreader() { return this.spreader; } public Optional<MultifaceSpreader.SpreadPos> spreadFromRandomFaceTowardRandomDirection( BlockState p_221620_, LevelAccessor p_221621_, BlockPos p_221622_, RandomSource p_221623_, int skillPoints, int age) { return Direction.allShuffled(p_221623_).stream().filter((p_221680_) -> { return this.config.canSpreadFrom(p_221620_, p_221680_); }).map((p_221629_) -> { return this.spreadFromFaceTowardRandomDirection(p_221620_, p_221621_, p_221622_, p_221629_, p_221623_, false, skillPoints, age); }).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardRandomDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, RandomSource randomSource, boolean aBoolean, int skillPoints, int age) { return Direction.allShuffled(randomSource).stream().map((direction) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, aBoolean, skillPoints, age)) .filter(Optional::isPresent) .findFirst() .orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, Direction direction, boolean aBoolean, int skillPoints, int age) { //DevilRpg.LOGGER.debug("BEGIN ==================================== spreadFromFaceTowardDirection skillPoints {}", skillPoints); return skillPoints < 0 ? Optional.empty() : getSpreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, this::canSpreadInto) .flatMap((spreadPos) -> { //DevilRpg.LOGGER.debug("END ================================ spreadFromFaceTowardDirection spreadPos {}", spreadPos); return this.spreadToFace(levelAccessor, spreadPos, aBoolean, skillPoints, direction, age); }); } public boolean canSpreadInto(BlockGetter p_221685_, BlockPos p_221686_, MultifaceSpreader.SpreadPos p_221687_) { BlockState blockstate = p_221685_.getBlockState(p_221687_.pos()); return this.stateCanBeReplaced(p_221685_, p_221686_, p_221687_.pos(), p_221687_.face(), blockstate) && isValidStateForPlacement(p_221685_, blockstate, p_221687_.pos(), p_221687_.face()); } protected boolean stateCanBeReplaced(BlockGetter p_221688_, BlockPos p_221689_, BlockPos p_221690_, Direction p_221691_, BlockState p_221692_) { return p_221692_.isAir() || p_221692_.is(this) || p_221692_.is(Blocks.WATER) && p_221692_.getFluidState().isSource(); } public Optional<MultifaceSpreader.SpreadPos> getSpreadFromFaceTowardDirection(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, Direction face, Direction direction, MultifaceSpreader.SpreadPredicate spreadPredicate) { //DevilRpg.LOGGER.debug("--- getSpreadFromFaceTowardDirection direction.getAxis() == face.getAxis(): {}", direction.getAxis() == face.getAxis()); ArrayList<Direction> directions = new ArrayList<>(); directions.add(direction); if (direction.getAxis() == face.getAxis()) { if (direction.getAxis().isHorizontal()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isVertical()).collect(Collectors.toCollection(ArrayList::new)); } if (direction.getAxis().isVertical()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isHorizontal()).collect(Collectors.toCollection(ArrayList::new)); } } for (Direction directionElement : directions) { /*DevilRpg.LOGGER.debug("--->> getSpreadFromFaceTowardDirection config.isOtherBlockValidAsSource(blockState) {} || " + "hasFace(blockState, face) {} && " + "!hasFace(blockState, direction) {}", config.isOtherBlockValidAsSource(blockState), hasFace(blockState, face), !hasFace(blockState, directionElement));*/ if (config.isOtherBlockValidAsSource(blockState) || hasFace(blockState, face) && !hasFace(blockState, directionElement)) { for (MultifaceSpreader.SpreadType multifacespreader$spreadtype : config.getSpreadTypes()) { MultifaceSpreader.SpreadPos multifacespreader$spreadpos = multifacespreader$spreadtype.getSpreadPos(blockPos, directionElement, face); //DevilRpg.LOGGER.debug("--- test SpreadPos: {} direction {} face {} ", multifacespreader$spreadpos, directionElement, face); if (spreadPredicate.test(blockGetter, blockPos, multifacespreader$spreadpos)) { //DevilRpg.LOGGER.debug("--- spreadPredicate success:"); return Optional.of(multifacespreader$spreadpos); } } } } return Optional.empty(); } public boolean isValidStateForPlacement(@NotNull BlockGetter blockGetter, @NotNull BlockState blockState, @NotNull BlockPos blockPos, @NotNull Direction face) { //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 1st condition: {} && ({} || {})", this.isFaceSupported(face), !blockState.is(this), !hasFace(blockState, face)); if (this.isFaceSupported(face) && (!blockState.is(this) || !hasFace(blockState, face))) { BlockPos blockpos = blockPos.relative(face); //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 2nd condition: canAttachTo {} ", secondCondition); return canAttachTo(blockGetter, face, blockpos, blockGetter.getBlockState(blockpos)); } else { return false; } } @Nullable public BlockState getStateForPlacement(@NotNull BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos, @NotNull Direction face, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("--- getStateForPlacement"); boolean isNotValidStateForPlacement = !this.isValidStateForPlacement(blockGetter, blockState, blockPos, face); //DevilRpg.LOGGER.debug("------- isNotValidStateForPlacement: {}", isNotValidStateForPlacement); if (isNotValidStateForPlacement) { return null; } else { BlockState blockstate; if (blockState.is(this)) { blockstate = blockState; } else if (this.isWaterloggable() && blockState.getFluidState().isSourceOfType(Fluids.WATER)) { blockstate = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, Boolean.TRUE); } else { blockstate = this.defaultBlockState(); } //DevilRpg.LOGGER.debug("------- getStateForPlacement -> blockStateResult "); return blockstate .setValue(getFaceProperty(face), Boolean.TRUE) .setValue(SKILL_LEVEL, skillPoints).setValue(FACE, face) .setValue(DIRECTION, direction) .setValue(CURRENT_AGE,age) ; } } public Optional<MultifaceSpreader.SpreadPos> spreadToFace(LevelAccessor levelAccessor, MultifaceSpreader.SpreadPos spreadPos, boolean p_221596_, int skillPoints, Direction direction, int age) { BlockState blockstate = levelAccessor.getBlockState(spreadPos.pos()); //DevilRpg.LOGGER.debug("---> spreadToFace blockstate{} direction: {}", blockstate, direction); return this.placeBlock(levelAccessor, spreadPos, blockstate, p_221596_, skillPoints, direction, age) ? Optional.of(spreadPos) : Optional.empty(); } public boolean placeBlock(LevelAccessor p_221702_, MultifaceSpreader.SpreadPos p_221703_, BlockState p_221704_, boolean p_221705_, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("---> placeBlock {} direction {} ", p_221703_, direction); BlockState blockstate = this.getStateForPlacement(p_221704_, p_221702_, p_221703_.pos(), p_221703_.face(), skillPoints, direction, age); if (blockstate != null) { if (p_221705_) { p_221702_.getChunk(p_221703_.pos()).markPosForPostprocessing(p_221703_.pos()); } //DevilRpg.LOGGER.debug("------> setBlock"); return p_221702_.setBlock(p_221703_.pos(), blockstate, 2); } else { return false; } } public long spreadFromFaceTowardAllDirections( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, boolean aBoolean, int skillPoints, int age) { return Direction.stream().map((p_221656_) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, p_221656_, aBoolean, skillPoints, age)) .filter(Optional::isPresent).count(); } private boolean isWaterloggable() { return this.stateDefinition.getProperties().contains(BlockStateProperties.WATERLOGGED); } @Override public void setPlacedBy(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull BlockState blockState, @Nullable LivingEntity livingEntity, @NotNull ItemStack itemStack) { super.setPlacedBy(level, blockPos, blockState, livingEntity, itemStack); this.setOwner(livingEntity); } public LivingEntity getOwner() { return this.owner; } private void setOwner(LivingEntity livingEntity) { this.owner = livingEntity; } @Deprecated @Override public void entityInside(@NotNull BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull Entity entity) { if (entity instanceof LivingEntity /*&& entity.getType() != EntityType.BEE*/ && entity.getType() != ModEntities.LICHEN_SEEDBALL.get()) { entity.makeStuckInBlock(blockState, new Vec3(0.8D, 0.75D, 0.8D)); if (!level.isClientSide /*&& (entity.xOld != entity.getX() || entity.zOld != entity.getZ())*/) { // double d0 = Math.abs(entity.getX() - entity.xOld); // double d1 = Math.abs(entity.getZ() - entity.zOld); // if (d0 >= (double) 0.003F || d1 >= (double) 0.003F) { entity.hurt(level.damageSources().playerAttack((Player) owner), 1.0F); // Aplicar aceleración al movimiento double speedBoost = -0.4; // Ajusta este valor según lo rápido que quieras que sea el impulso double motionX = entity.getX() - entity.xOld; double motionZ = entity.getZ() - entity.zOld; double speed = Math.sqrt(motionX * motionX + motionZ * motionZ); //if (speed > 0.0) { entity.setDeltaMovement(entity.getDeltaMovement().multiply( (motionX / speed) * speedBoost, 0.0, (motionZ / speed) * speedBoost )); // } //} } } } @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return ModEntityBlocks.SOUL_LICHEN_ENTITY_BLOCK.get().create(pos, state); } @Nullable @Override public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, @NotNull BlockState blockState, @NotNull BlockEntityType<T> type) { return level.isClientSide ? null : (alevel, pos, aBlockstate, blockEntity) -> { if (blockEntity instanceof SoulLichenBlockEntity soulLichenBlockEntity && alevel.getGameTime() % 5 == 0) { soulLichenBlockEntity.tick(blockState, (ServerLevel) alevel, pos, alevel.getRandom()); //DevilRpg.LOGGER.info("-------->tick. this: {}", this.getClass().getSimpleName()); } }; } }   This is the registration:   public final class ModBlocks { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, DevilRpg.MODID); ... public static final RegistryObject<SoulLichenBlock> SOUL_LICHEN_BLOCK = BLOCKS.register("soullichen", () -> new SoulLichenBlock( Block.Properties.copy(Blocks.GLOW_LICHEN).lightLevel(SoulLichenBlock.emission(7)).randomTicks() )); }  
    • If you are using AMD/ATI, check for driver updates on their website - do not update via system
    • Hi, Create a new class that extends "Block" class and you need json for it in resources/assets/modid/blockstates directory and resources/assets/modid/models. You can generate json for it using a tool like misodes model generator. Here, atleast, are blocks explained at forge docs.  Don't forge to look at vanilla code, like Magma Block is a good reference if you're trying a "green fire block".  Modid should be replaced with your actual forge mod namespace!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.