Jump to content

Overriding a block in the registry. [1.15.2]


RobinCirex

Recommended Posts

Hey, I'm trying to override a block but when booting up the game I get this error 

Registry Block: Override did not have an associated owner object. Name: minecraft:water Value: Block{minecraft:water}

this is my code

	public static final Block WATER = register("water", new CustomFlowingFluidBlock(Fluids.WATER,
			Block.Properties.create(Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops()));

	private static Block register(String key, Block p_222382_1_) {
		return Registry.register(Registry.BLOCK, key, p_222382_1_);
	}

 

Link to comment
Share on other sites

4 minutes ago, RobinCirex said:

public static final Block WATER = register("water", new CustomFlowingFluidBlock(Fluids.WATER, Block.Properties.create(Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops())); private static Block register(String key, Block p_222382_1_) { return Registry.register(Registry.BLOCK, key, p_222382_1_); }

This is not how you register things.

Either use the events or the DeferredRegistry system.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

12 minutes ago, Animefan8888 said:

This is not how you register things.

Either use the events or the DeferredRegistry system.

Okay. 

Is this correct? I get this error for some reason now

java.lang.ClassCastException: me.cirex.erosionmod.CustomFlowingFluidBlock cannot be cast to net.minecraft.item.Item


	@SubscribeEvent
	public void onRegister(RegistryEvent.Register<Block> event) {
		event.getRegistry().register(new CustomFlowingFluidBlock(Fluids.WATER,
				Block.Properties.create(Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops())
						.setRegistryName("minecraft", "water"));
	}

 

Link to comment
Share on other sites

5 minutes ago, RobinCirex said:

java.lang.ClassCastException: me.cirex.erosionmod.CustomFlowingFluidBlock cannot be cast to net.minecraft.item.Item

There's more information to this error that helps like a line number.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 minutes ago, Animefan8888 said:

There's more information to this error that helps like a line number.

14:43:50] [Render thread/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event RegistryEvent.Register<minecraft:item> dispatch for modid erosionmod
java.lang.ClassCastException: me.cirex.erosionmod.CustomFlowingFluidBlock cannot be cast to net.minecraft.item.Item
        at net.minecraftforge.registries.GameData$ItemCallbacks.onAdd(GameData.java:494) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:376) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:308) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:133) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at me.cirex.erosionmod.ErosionMod.onRegister(ErosionMod.java:64) ~[main/:?] {re:classloading}
        at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212) ~[eventbus-2.0.0-milestone.1-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204) ~[eventbus-2.0.0-milestone.1-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-2.0.0-milestone.1-service.jar:?] {}
        at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:31.1] {re:classloading}
        at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_202] {}
        at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_202] {}
        at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$5(ModList.java:125) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_202] {}
        at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:125) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.ModList.lambda$static$1(ModList.java:96) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:71) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:197) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$24(ModLoader.java:189) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:972) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:189) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading}
        at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$2(ClientModLoader.java:97) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
        at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:113) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
        at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:97) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
        at net.minecraft.client.Minecraft.<init>(Minecraft.java:398) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
        at net.minecraft.client.main.Main.main(Main.java:141) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_202] {}
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_202] {}
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202] {}
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202] {}
        at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {}
        at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {}
        at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {}
        at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {}
        at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {}
        at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {}
        at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {}

This is the full error. Line 64 is the line where I register the block. I don't know why it tries to cast it to an item though

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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