Jump to content

[1.10.2] Strange crash, I cant figured where the problem is.


Recommended Posts

Posted

Hello again.

 

Well, i've decided to add more block to my mod.

 

But then, this happends :

 

---- Minecraft Crash Report ----
// I feel sad now :(

Time: 14/08/17 15:01
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Steamhouse's Mod (stm)
Caused by: java.lang.NullPointerException
	at fr.steamhouse.mod.init.ModBlocks.registerBlock(ModBlocks.java:257)
	at fr.steamhouse.mod.init.ModBlocks.register(ModBlocks.java:193)
	at fr.steamhouse.mod.MainClass.preInit(MainClass.java:48)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:618)
	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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221)
	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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:624)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:259)
	at net.minecraft.client.Minecraft.startGame(Minecraft.java:477)
	at net.minecraft.client.Minecraft.run(Minecraft.java:386)
	at net.minecraft.client.main.Main.main(Main.java:118)
	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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:26)


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

-- System Details --
Details:
	Minecraft Version: 1.10.2
	Operating System: Windows 7 (amd64) version 6.1
	Java Version: 1.8.0_131, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 802307184 bytes (765 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.32 Powered by Forge 12.18.3.2281 5 mods loaded, 5 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UCH	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
	UCH	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.3.2281.jar) 
	UCH	Forge{12.18.3.2281} [Minecraft Forge] (forgeSrc-1.10.2-12.18.3.2281.jar) 
	UCE	stm{Stable Alpha} [Steamhouse's Mod] (bin) 
	UCH	JEI{3.14.6.409} [Just Enough Items] (jei_1.10.2-3.14.6.409.jar) 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 384.76' Renderer: 'GeForce GTX 770/PCIe/SSE2'

 

And here's my code for all the blocks :

 

package fr.steamhouse.mod.init;

import com.ibm.icu.impl.Norm2AllModes.Normalizer2WithImpl;

import fr.steamhouse.mod.MainClass;
import fr.steamhouse.mod.References;
import fr.steamhouse.mod.blocks.BlockSystemShock;
import fr.steamhouse.mod.blocks.BlockColor;
import fr.steamhouse.mod.blocks.BlockRPGM;
import fr.steamhouse.mod.utilities.Utools;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.NextTickListEntry;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;

public class ModBlocks {
	
		public static Block matrix;
		public static Block fondVert;
		public static Block Rouge;
		public static Block Bleu;
		public static Block Vert;
		public static Block Noir;
		public static Block Jaune;
		public static Block Blanc;
		public static Block Gris;
		public static Block Rose;
		public static Block Marron;
		public static Block Orange;
		public static Block Violet;
		public static Block carrelage;
		
		public static Block bridgeblack1176;
		public static Block bridgeblack1178;
		public static Block bridgeblack1180;
		public static Block bridgeblack1181;
		public static Block bridgeblack1184;
		public static Block bridgeblack1187;
		public static Block bridgegray1179;
		public static Block bridgegray1231;
		public static Block bridgegray1231_1;
		public static Block bridgetan1228;
		public static Block citmatblue2183;
		public static Block citmatbluegreen2180;
		public static Block citmatgray2186;
		public static Block citmatgray2187;
		public static Block citmatgray2188;
		public static Block citmatgray2189;
		public static Block citmatgray2192;
		public static Block citmatgraynocontain;
		public static Block citmatorange2184;
		public static Block citmatorange2185;
		public static Block citmatorange2190;
		public static Block citmatorange2194;
		public static Block citmatred2182;
		public static Block citmatyellow2181;
		public static Block sharedtan1118;
		
		public static Block brickpath;
		public static Block brickwall;
		public static Block brickwall2;
		public static Block brickwall3;
		public static Block dalle1;
		public static Block dalle2;
		public static Block desertpath;
		public static Block desertpath2;
		public static Block frozenwall;
		public static Block frozenpath;
		public static Block kitchencal;
		public static Block rockpath;
		public static Block rockpath2;
		public static Block rockwall;
		public static Block woodpath;
		
		public static void init() {
			matrix  = new BlockSystemShock("matrix", "matrix").setLightLevel(0.6F);
			fondVert = new BlockColor("fondvert", "fondvert");
			Rouge = new BlockColor("red", "red");
			Bleu = new BlockColor("blue", "blue");
			Vert = new BlockColor("green", "green");
			Noir = new BlockColor("black", "black");
			Jaune = new BlockColor("yellow", "yellow");
			Blanc = new BlockColor("white", "white");
			Violet = new BlockColor("purple", "purple");
			Rose = new BlockColor(("pink"), "pink");
			Gris = new BlockColor("gray", "gray");
			Orange = new BlockColor("orange", "orange");
			Marron = new BlockColor("brown", "brown");
			carrelage = new BlockSystemShock("carrelage", "carrelage");
			
			bridgeblack1176  = new BlockSystemShock("bridgeblack1176", "bridgeblack1176");
			bridgeblack1178 = new BlockSystemShock("bridgeblack1178", "bridgeblack1178");
			bridgeblack1180 = new BlockSystemShock("bridgeblack1180", "bridgeblack1180");
			bridgeblack1181 = new BlockSystemShock("bridgeblack1181", "bridgeblack1181");
			bridgeblack1184 = new BlockSystemShock("bridgeblack1184", "bridgeblack1184");
			bridgeblack1187 = new BlockSystemShock("bridgeblack1187", "bridgeblack1187");
			bridgegray1179 = new BlockSystemShock("bridgegray1179", "bridgegray1179");
			bridgegray1231 = new BlockSystemShock("bridgegray1231", "bridgegray1231");
			bridgegray1231_1 = new BlockSystemShock("bridgegray1231_1", "bridgegray1231_1");
			bridgetan1228 = new BlockSystemShock("bridgetan1228", "bridgetan1228");
			citmatblue2183 = new BlockSystemShock("citmatblue2183", "citmatblue2183");
			citmatbluegreen2180 = new BlockSystemShock("citmatbluegreen2180", "citmatbluegreen2180");
			citmatgray2186 = new BlockSystemShock("citmatgray2186", "citmatgray2186");
			citmatgray2187 = new BlockSystemShock("citmatgray2187", "citmatgray2187");
			citmatgray2188 = new BlockSystemShock("citmatgray2188", "citmatgray2188");
			citmatgray2189 = new BlockSystemShock("citmatgray2189", "citmatgray2189");
			citmatgray2192 = new BlockSystemShock("citmatgray2192", "citmatgray2192");
			citmatgraynocontain = new BlockSystemShock("citmatgraynocontain", "citmatgraynocontain");
			citmatorange2184 = new BlockSystemShock("citmatorange2184", "citmatorange2184");
			citmatorange2185 = new BlockSystemShock("citmatorange2185", "citmatorange2185");
			citmatorange2190 = new BlockSystemShock("citmatorange2190", "citmatorange2190");
			citmatorange2194 = new BlockSystemShock("citmatorange2194", "citmatorange2194");
			citmatred2182 = new BlockSystemShock("citmatred2182", "citmatred2182");
			citmatyellow2181 = new BlockSystemShock("citmatyellow2181", "citmatyellow2181");
			sharedtan1118 = new BlockSystemShock("sharedtan1118", "sharedtan1118");
			
			brickpath = new BlockRPGM("brickpath", "brickpath");
			brickwall = new BlockRPGM("brickwall", "brickwall");
			brickwall2 = new BlockRPGM("brickwall2", "brickwall2");
			brickwall3 = new BlockRPGM("brickwall3", "brickwall3");
			dalle1 = new BlockRPGM("dalle1", "dalle1");
			dalle2 = new BlockRPGM("dalle2", "dalle2");
			desertpath = new BlockRPGM("desertpath", "desertpath");
			desertpath2 = new BlockRPGM("desertpath2", "desertpath2");
			frozenpath = new BlockRPGM("frozenpath", "frozenpath");
			frozenwall = new BlockRPGM("frozenwall", "frozenwall");
			kitchencal = new BlockRPGM("kitchencal", "kitchencal");
			rockpath = new BlockRPGM("rockpath", "rockpath");
			rockpath2 = new BlockRPGM("rockpath2", "rockpath2");
			woodpath = new BlockRPGM("woodpath", "woodpath");
		}
		
		public static void register() {
			registerBlock(matrix);
			registerBlock(Bleu);
			registerBlock(Noir);
			registerBlock(Rouge);
			registerBlock(Vert);
			registerBlock(Jaune);
			registerBlock(Blanc);
			registerBlock(Gris);
			registerBlock(Violet);
			registerBlock(Marron);
			registerBlock(Rose);
			registerBlock(Orange);
			registerBlock(fondVert);
			registerBlock(carrelage);
			
			registerBlock(bridgeblack1176);
			registerBlock(bridgeblack1178);
			registerBlock(bridgeblack1180);
			registerBlock(bridgeblack1181);
			registerBlock(bridgeblack1184);
			registerBlock(bridgeblack1187);
			registerBlock(bridgegray1179);
			registerBlock(bridgegray1231);
			registerBlock(bridgegray1231_1);
			registerBlock(bridgetan1228);
			registerBlock(citmatblue2183);
			registerBlock(citmatbluegreen2180);
			registerBlock(citmatgray2186);
			registerBlock(citmatgray2187);
			registerBlock(citmatgray2188);
			registerBlock(citmatgray2189);
			registerBlock(citmatgray2192);
			registerBlock(citmatgraynocontain);
			registerBlock(citmatorange2184);
			registerBlock(citmatorange2185);
			registerBlock(citmatorange2190);
			registerBlock(citmatorange2194);
			registerBlock(citmatred2182);
			registerBlock(citmatyellow2181);
			registerBlock(sharedtan1118);
			
			registerBlock(brickpath);
			registerBlock(brickwall);
			registerBlock(brickwall2);
			registerBlock(brickwall3);
			registerBlock(dalle1);
			registerBlock(dalle2);
			registerBlock(desertpath);
			registerBlock(desertpath2);
			registerBlock(frozenpath);
			registerBlock(frozenwall);
			registerBlock(kitchencal);
			registerBlock(rockpath);
			registerBlock(rockpath2);
			registerBlock(rockwall);
			registerBlock(woodpath);
		}
		
		public static void registerRenders() {
			registerRender(matrix);
			registerRender(Bleu);
			registerRender(Noir);
			registerRender(Rouge);
			registerRender(Vert);
			registerRender(Jaune);
			registerRender(Blanc);
			registerRender(Gris);
			registerRender(Violet);
			registerRender(Marron);
			registerRender(Rose);
			registerRender(Orange);
			registerRender(fondVert);
			registerRender(carrelage);
			
			registerRender(bridgeblack1176);
			registerRender(bridgeblack1178);
			registerRender(bridgeblack1180);
			registerRender(bridgeblack1181);
			registerRender(bridgeblack1184);
			registerRender(bridgeblack1187);
			registerRender(bridgegray1179);
			registerRender(bridgegray1231);
			registerRender(bridgegray1231_1);
			registerRender(bridgetan1228);
			registerRender(citmatblue2183);
			registerRender(citmatbluegreen2180);
			registerRender(citmatgray2186);
			registerRender(citmatgray2187);
			registerRender(citmatgray2188);
			registerRender(citmatgray2189);
			registerRender(citmatgray2192);
			registerRender(citmatgraynocontain);
			registerRender(citmatorange2184);
			registerRender(citmatorange2185);
			registerRender(citmatorange2190);
			registerRender(citmatorange2194);
			registerRender(citmatred2182);
			registerRender(citmatyellow2181);
			registerRender(sharedtan1118);
			
			registerRender(brickpath);
			registerRender(brickwall);
			registerRender(brickwall2);
			registerRender(brickwall3);
			registerRender(dalle1);
			registerRender(dalle2);
			registerRender(desertpath);
			registerRender(desertpath2);
			registerRender(frozenpath);
			registerRender(frozenwall);
			registerRender(kitchencal);
			registerRender(rockpath);
			registerRender(rockpath2);
			registerRender(rockwall);
			registerRender(woodpath);
		}
		
		public static void registerBlock(Block block) {
			block.setCreativeTab(MainClass.TabB);
			GameRegistry.register(block);
			GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
			Utools.getLogger().info("Register block for" + block.getUnlocalizedName().substring(5));
		}
		
		public static void registerRender(Block block) {
			ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(new ResourceLocation(References.MODID, block.getUnlocalizedName().substring(5)), "inventory"));
			Utools.getLogger().info("Register render for" + block.getUnlocalizedName().substring(5));;
		}
	}

 

I just make this the exact same way than before, so, why this time, it dosent work ? Did I make something wrong ?

 

Thanks for the help !

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

×
×
  • Create New...

Important Information

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