Jump to content

Recommended Posts

Posted

Hey sorry for my bad english, i am german. So i am coding a mod where I craft a custom block but when i put the last item in the crafting gui minecraft crashes with a null pointer exception (when you need the crash report just post it)

 

here is  my main class:

 

 

//Variablen

public static final String MODID = "kohlewerk";

   

 

 

 

public static final int GUIMASCHC = 0;

 

List<String> authors = Arrays.asList("Jan");

 

Block blockmaschc = new BlockMaschC();

ItemStack maschc = new ItemStack(blockmaschc);

 

@Instance

public static KohleWerk instance;

 

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

 

 

ModMetadata ModData = event.getModMetadata();

modinfo(ModData);

        GameRegistry.addShapedRecipe(maschc, "XXX",

                                    "XYX",

                                            "ZZZ", 'X', new ItemStack(Blocks.cobblestone), 'Y', new ItemStack(Items.diamond), 'Z', new ItemStack(Items.coal));

 

 

 

}

 

@EventHandler

public void Init(FMLInitializationEvent event){

 

 

GameRegistry.registerBlock(blockmaschc, "maschc");

Item itemfromblock = Item.getItemFromBlock(blockmaschc);

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemfromblock, 3, new ModelResourceLocation("kohlewerk:maschc", "inventory"));

 

 

//GuiHandler

 

NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

 

//TileEntitys

 

GameRegistry.registerTileEntity(TileEntityMaschC.class, "TileEntityMaschC");

 

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

public void modinfo(ModMetadata data){

//Modinfos setzten

 

data.autogenerated = false;

data.name = EnumChatFormatting.BLUE +  "" + EnumChatFormatting.BOLD  + "Kohle Werk";

data.authorList = authors;

data.description = "Dieser Mod fügt ein Kohlewerk hinzu mit dem man Erze vervielvältigen kann.";

data.credits = "HyCraftHD";

data.logoFile = "assets/kohlewerk/textures/logo/logo.png";

data.version= "0.1";

}

 

 

public void CraftingOfen(){

 

 

}

 

}

 

I hope you can help me

thanks in advance <3

Jan

 

 

 

Posted

So my code is now this:

 

@Mod(modid = KohleWerk.MODID)

public class KohleWerk {

   

//Variablen

public static final String MODID = "kohlewerk";

   

public static Item koks = new ItemKoks();

 

 

public static final int GUIMASCHC = 0;

 

List<String> authors = Arrays.asList("Jan");

 

Block blockmaschc = new BlockMaschC();

ItemStack maschc = new ItemStack(blockmaschc);

 

@Instance

public static KohleWerk instance;

 

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

 

GameRegistry.registerBlock(blockmaschc, "maschc");

Item itemfromblock = Item.getItemFromBlock(blockmaschc);

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemfromblock, 3, new ModelResourceLocation("kohlewerk:maschc", "inventory"));

 

 

 

GameRegistry.registerItem(koks, "koks");

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(koks, 0, new ModelResourceLocation("kohlewerk:koks", "inventory"));

 

 

//GuiHandler

 

NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

 

//TileEntitys

 

GameRegistry.registerTileEntity(TileEntityMaschC.class, "TileEntityMaschC");

 

 

ModMetadata ModData =  event.getModMetadata();

modinfo(ModData);

 

 

 

}

 

@EventHandler

public void Init(FMLInitializationEvent event){

 

        GameRegistry.addShapedRecipe(maschc, "XXX",

                                    "XYX",

                                            "ZZZ", 'X', Blocks.cobblestone, 'Y',Items.diamond, 'Z', Items.coal);

 

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

public void modinfo(ModMetadata data){

//Modinfos setzten

 

data.autogenerated = false;

data.name = EnumChatFormatting.BLUE +  "" + EnumChatFormatting.BOLD  + "Kohle Werk";

data.authorList = authors;

data.description = "Dieser Mod fügt ein Kohlewerk hinzu mit dem man Erze vervielvältigen kann.";

data.credits = "HyCraftHD";

data.logoFile = "assets/kohlewerk/textures/logo/logo.png";

data.version= "0.1";

}

 

 

public void CraftingOfen(){

 

 

}

 

}

 

 

but it still crashes when i craft

 

Posted

After reading what you have done, there is a lot of clean up to do.

 

ItemStack maschc = new ItemStack(blockmaschc);

No.

 

Block blockmaschc = new BlockMaschC();

Should be public static

 

   public void CraftingOfen(){
      
      
   }

?

 

public void modinfo(ModMetadata data){
      //Modinfos setzten
      
      data.autogenerated = false;
      data.name = EnumChatFormatting.BLUE +  "" + EnumChatFormatting.BOLD  + "Kohle Werk";
      data.authorList = authors;
      data.description = "Dieser Mod fügt ein Kohlewerk hinzu mit dem man Erze vervielvältigen kann.";
      data.credits = "HyCraftHD";
      data.logoFile = "assets/kohlewerk/textures/logo/logo.png";
      data.version= "0.1";
   }

Not sure why you do this in a method if you can fill the mcmod.info (I think that was its name)

 

To come to your problem. Replace the reference to the maschc with a new ItemStack(blockmaschc). If that doenst helps post your log and if u changed the code post it also. and please us tags

 

 

Posted

First of all thank you but is still doesnt work so now here`s my main class

@Mod(modid = KohleWerk.MODID)
public class KohleWerk {
    
//Variablen
public static final String MODID = "kohlewerk";
    
public static Item koks = new ItemKoks();


public static final int GUIMASCHC = 0;

List<String> authors = Arrays.asList("Jan");

public static Block blockmaschc = new BlockMaschC();


@Instance
public static KohleWerk instance;

  

@EventHandler
public void preInit(FMLPreInitializationEvent event){


	GameRegistry.addShapedRecipe(new ItemStack(KohleWerk.blockmaschc), "XXX",
                                                                           "XYX",
                                                                           "ZZZ", 'X', Blocks.cobblestone, 'Y',Items.diamond, 'Z', Items.coal);





	//GuiHandler

	NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

	//TileEntitys

	GameRegistry.registerTileEntity(TileEntityMaschC.class, "TileEntityMaschC");


	ModMetadata ModData =  event.getModMetadata();
	modinfo(ModData);



}

@EventHandler
public void Init(FMLInitializationEvent event){
	GameRegistry.registerBlock(blockmaschc, "maschc");
	Item itemfromblock = Item.getItemFromBlock(blockmaschc);

	GameRegistry.registerItem(koks, "koks");
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(koks, 0, new ModelResourceLocation("kohlewerk:koks", "inventory"));



	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemfromblock, 3, new ModelResourceLocation("kohlewerk:maschc", "inventory"));
        

}

@EventHandler
public void postInit(FMLPostInitializationEvent event){

}
   
public void modinfo(ModMetadata data){
	//Modinfos setzten

	data.autogenerated = false;
	data.name = EnumChatFormatting.BLUE +  "" + EnumChatFormatting.BOLD  + "Kohle Werk";
	data.authorList = authors;
	data.description = "Dieser Mod fügt ein Kohlewerk hinzu mit dem man Erze vervielvältigen kann.";
	data.credits = "HyCraftHD";
	data.logoFile = "assets/kohlewerk/textures/logo/logo.png";
	data.version= "0.1";
}



}

i set the mod data in methods becuase i don`t like the mcmod.info file

 

so here`s my crashreport

 

 

java.lang.NullPointerException

at net.minecraft.client.resources.model.ModelBakery.loadModel(ModelBakery.java:270) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.access$900(ModelLoader.java:71) ~[ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:534) ~[ModelLoader$VanillaLoader.class:?]

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:92) [ModelLoaderRegistry.class:?]

at net.minecraftforge.client.model.ModelLoader.loadAnyModel(ModelLoader.java:201) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.getModel(ModelLoader.java:184) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.loadItems(ModelLoader.java:171) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:96) [ModelLoader.class:?]

at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:143) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:121) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:774) [Minecraft.class:?]

at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:331) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:528) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_75]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

[17:05:16] [Client thread/INFO]: Created: 512x512 textures-atlas

[17:05:16] [Client thread/ERROR] [FML]: Model definition for location kohlewerk:maschc#inventory not found

[17:05:19] [server thread/INFO]: Starting integrated minecraft server version 1.8

[17:05:19] [server thread/INFO]: Generating keypair

[17:05:19] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance

[17:05:19] [server thread/INFO] [FML]: Applying holder lookups

[17:05:19] [server thread/INFO] [FML]: Holder lookups applied

[17:05:19] [server thread/INFO] [FML]: Loading dimension 0 (debu) (net.minecraft.server.integrated.IntegratedServer@5dbab9df)

[17:05:19] [server thread/INFO] [FML]: Loading dimension 1 (debu) (net.minecraft.server.integrated.IntegratedServer@5dbab9df)

[17:05:19] [server thread/INFO] [FML]: Loading dimension -1 (debu) (net.minecraft.server.integrated.IntegratedServer@5dbab9df)

[17:05:19] [server thread/INFO]: Preparing start region for level 0

[17:05:20] [server thread/INFO]: Changing view distance to 12, from 10

[17:05:21] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2

[17:05:21] [Netty Server IO #1/INFO] [FML]: Client protocol version 2

[17:05:21] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected]

[17:05:21] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established

[17:05:21] [server thread/INFO] [FML]: [server thread] Server side modded connection established

[17:05:21] [server thread/INFO]: Player880[local:E:cf26d101] logged in with entity id 287 at (-188.67640487113474, 71.0, 387.89668531842136)

[17:05:21] [server thread/INFO]: Player880 hat das Spiel betreten

[17:05:23] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@2909f424[id=1344ba46-6b08-3a2e-813a-3106d9215e61,name=Player880,properties={},legacy=false]

com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time

at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:158) [YggdrasilMinecraftSessionService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:53) [YggdrasilMinecraftSessionService$1.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:50) [YggdrasilMinecraftSessionService$1.class:?]

at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:148) [YggdrasilMinecraftSessionService.class:?]

at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [skinManager$3.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_75]

at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.7.0_75]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.7.0_75]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.7.0_75]

at java.lang.Thread.run(Unknown Source) [?:1.7.0_75]

[17:05:34] [server thread/INFO]: Stopping server

[17:05:34] [server thread/INFO]: Saving players

[17:05:34] [server thread/INFO]: Saving worlds

[17:05:34] [server thread/INFO]: Saving chunks for level 'debu'/Overworld

[17:05:34] [server thread/INFO]: Saving chunks for level 'debu'/Nether

[17:05:34] [server thread/INFO]: Saving chunks for level 'debu'/The End

[17:05:34] [server thread/INFO] [FML]: Unloading dimension 0

[17:05:34] [server thread/INFO] [FML]: Unloading dimension -1

[17:05:34] [server thread/INFO] [FML]: Unloading dimension 1

[17:05:34] [server thread/INFO] [FML]: Applying holder lookups

[17:05:34] [server thread/INFO] [FML]: Holder lookups applied

[17:05:35] [Client thread/FATAL]: Reported exception thrown!

net.minecraft.util.ReportedException: Rendering item

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1164) ~[EntityRenderer.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_75]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: java.lang.NullPointerException

at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:280) ~[itemStack.class:?]

at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70) ~[itemModelMesher.class:?]

at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43) ~[itemModelMesher.class:?]

at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:363) ~[RenderItem.class:?]

at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:414) ~[RenderItem.class:?]

at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:293) ~[GuiContainer.class:?]

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:116) ~[GuiContainer.class:?]

at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462) ~[ForgeHooksClient.class:?]

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1134) ~[EntityRenderer.class:?]

... 11 more

[17:05:35] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----

// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]

 

Time: 20.08.15 17:05

Description: Rendering item

 

java.lang.NullPointerException: Rendering item

at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:280)

at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70)

at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43)

at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:363)

at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:414)

at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:293)

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:116)

at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1134)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114)

at net.minecraft.client.Minecraft.run(Minecraft.java:376)

at net.minecraft.client.main.Main.main(Main.java:117)

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.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:280)

at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70)

at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43)

at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:363)

 

-- Item being rendered --

Details:

Item Type: null

Item Aux: ~~ERROR~~ NullPointerException: null

Item NBT: null

Item Foil: ~~ERROR~~ NullPointerException: null

Stacktrace:

at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:414)

at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:293)

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:116)

at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462)

 

-- Screen render details --

Details:

Screen name: net.minecraft.client.gui.inventory.GuiCrafting

Mouse location: Scaled: (183, 76). Absolute: (367, 327)

Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityPlayerSP['Player880'/287, l='MpServer', x=-188,85, y=71,00, z=388,73]]

Chunk stats: MultiplayerChunkCache: 621, 621

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: -108,00,64,00,252,00 - World: (-108,64,252), Chunk: (at 4,4,12 in -7,15; contains blocks -112,0,240 to -97,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 27335 game time, 1329 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 45 total; [EntityCow['Kuh'/68, l='MpServer', x=-252,59, y=84,00, z=443,69], EntityCow['Kuh'/69, l='MpServer', x=-256,00, y=84,00, z=440,13], EntityCow['Kuh'/64, l='MpServer', x=-245,44, y=105,00, z=313,13], EntityCow['Kuh'/65, l='MpServer', x=-252,03, y=104,00, z=323,13], EntityCow['Kuh'/66, l='MpServer', x=-249,75, y=85,00, z=349,31], EntityCreeper['Creeper'/67, l='MpServer', x=-254,50, y=71,00, z=406,50], EntityCreeper['Creeper'/76, l='MpServer', x=-225,94, y=74,00, z=322,41], EntityCreeper['Creeper'/77, l='MpServer', x=-231,50, y=75,00, z=327,50], EntityCow['Kuh'/78, l='MpServer', x=-237,00, y=105,00, z=333,13], EntityEnderman['Enderman'/79, l='MpServer', x=-230,50, y=78,00, z=346,50], EntityBat['Fledermaus'/134, l='MpServer', x=-167,05, y=20,86, z=317,78], EntityCreeper['Creeper'/75, l='MpServer', x=-233,50, y=75,00, z=328,50], EntityBat['Fledermaus'/155, l='MpServer', x=-152,74, y=37,34, z=309,52], EntityBat['Fledermaus'/156, l='MpServer', x=-134,28, y=26,10, z=406,13], EntityCow['Kuh'/81, l='MpServer', x=-232,28, y=82,00, z=445,22], EntityZombie['Zombie'/157, l='MpServer', x=-128,81, y=41,00, z=415,50], EntityCow['Kuh'/80, l='MpServer', x=-239,44, y=81,00, z=382,63], EntityCow['Kuh'/82, l='MpServer', x=-243,16, y=80,00, z=440,13], EntityCreeper['Creeper'/144, l='MpServer', x=-159,91, y=32,00, z=363,56], EntityZombie['Zombie'/145, l='MpServer', x=-154,50, y=34,00, z=390,50], EntityBat['Fledermaus'/146, l='MpServer', x=-160,54, y=35,98, z=377,79], EntityCreeper['Creeper'/168, l='MpServer', x=-120,50, y=65,00, z=438,50], EntityZombie['Zombie'/110, l='MpServer', x=-194,31, y=28,00, z=325,69], EntitySpider['Spinne'/111, l='MpServer', x=-204,50, y=69,00, z=323,50], EntityZombie['Zombie'/109, l='MpServer', x=-203,50, y=69,00, z=318,50], EntityZombie['Zombie'/167, l='MpServer', x=-109,63, y=64,00, z=443,97], EntitySkeleton['Skelett'/166, l='MpServer', x=-116,22, y=37,00, z=414,44], EntityBat['Fledermaus'/165, l='MpServer', x=-115,97, y=60,10, z=371,31], EntityZombie['Zombie'/164, l='MpServer', x=-117,16, y=17,00, z=354,34], EntityCow['Kuh'/51, l='MpServer', x=-268,47, y=94,00, z=327,16], EntitySkeleton['Skelett'/119, l='MpServer', x=-185,19, y=20,00, z=320,50], EntityCow['Kuh'/50, l='MpServer', x=-268,25, y=89,00, z=315,44], EntitySkeleton['Skelett'/118, l='MpServer', x=-191,56, y=24,00, z=320,84], EntitySkeleton['Skelett'/117, l='MpServer', x=-186,91, y=22,00, z=321,47], EntityPlayerSP['Player880'/287, l='MpServer', x=-188,85, y=71,00, z=388,73], EntityCow['Kuh'/54, l='MpServer', x=-266,81, y=80,00, z=355,28], EntitySkeleton['Skelett'/293, l='MpServer', x=-215,50, y=39,00, z=466,50], EntityCow['Kuh'/53, l='MpServer', x=-268,81, y=80,00, z=356,75], EntityZombie['Zombie'/294, l='MpServer', x=-239,88, y=55,00, z=454,44], EntityZombie['Zombie'/112, l='MpServer', x=-206,50, y=69,00, z=322,50], EntityZombie['Zombie'/59, l='MpServer', x=-259,50, y=28,00, z=444,50], EntityZombie['Zombie'/58, l='MpServer', x=-259,50, y=28,00, z=442,50], EntityEnderman['Enderman'/56, l='MpServer', x=-257,50, y=20,00, z=390,50], EntityZombie['Zombie'/299, l='MpServer', x=-261,50, y=17,00, z=459,50], EntitySkeleton['Skelett'/300, l='MpServer', x=-257,50, y=35,00, z=449,50]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2614)

at net.minecraft.client.Minecraft.run(Minecraft.java:398)

at net.minecraft.client.main.Main.main(Main.java:117)

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.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

 

 

Posted

Seems like there is a problem with ur json's, but that sohuldnt create a crash.. The problem isnt because u are crafting the item it seems like there is something wrong with rendering it..

I am not good at that, if u are lucky TheGreyGhost will take a look and find ur error :b

 

For now. Show ur json's , since minecraft seems to miss them.

 

Also DONT DO THIS

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemfromblock, 3, new ModelResourceLocation("kohlewerk:maschc", "inventory"));

U need to do that inside ur proxy, because if u compile the mod and run it on a server it will throw you a ClassNotFound exception.

Rendering stuff is Client ONLY so u need to register the renderer inside ur proxy.

 

Posted

 

Here are my json files

blockstates

{
    "variants": {
        "normal": { "model": "kohlewerk:maschc" }
    }
}

models.item

{
    "parent": "kohlewerk:block/maschc",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

models.block

{
    "parent": "block/cube",
    "textures": {
    
    
        "particle": "kohlewerk:blocks/maschc_top",
        "up": "kohlewerk:blocks/maschc_top",
        "down": "kohlewerk:blocks/maschc_side",
        "north": "kohlewerk:blocks/maschc_front",
        "south": "kohlewerk:blocks/maschc_side",
        "west": "kohlewerk:blocks/maschc_side",
        "east": "kohlewerk:blocks/maschc_side"
    
    }
}

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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