Jump to content

Recommended Posts

Posted

This thing bothers my server for a long time. I still don't know what could possibly cause this issue. Hope any of you here smarter than me can help my find the culprit.
I'll post the crash report under, if there's anything else you need, I'll post upon request.
 

---- Minecraft Crash Report ----
// You should try our sister game, Minceraft!

Time: 19-12-11 下午6:16
Description: Exception getting block type in world

java.lang.NullPointerException: Exception getting block type in world
    at net.minecraft.world.gen.ChunkProviderServer.func_73154_d(ChunkProviderServer.java:314)
    at net.minecraft.world.World.func_72964_e(World.java:751)
    at net.minecraft.world.World.func_147439_a(World.java:677)
    at net.minecraft.block.BlockGrass.func_149674_a(BlockGrass.java:77)
    at net.minecraft.world.WorldServer.func_147456_g(WorldServer.java:569)
    at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:288)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:931)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:431)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:809)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:669)
    at java.lang.Thread.run(Unknown Source)


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

-- Head --
Stacktrace:
    at net.minecraft.world.gen.ChunkProviderServer.func_73154_d(ChunkProviderServer.java:314)
    at net.minecraft.world.World.func_72964_e(World.java:751)

-- Requested block coordinates --
Details:
    Found chunk: true
    Location: World: (-183,54,160), Chunk: (at 9,3,0 in -12,10; contains blocks -192,0,160 to -177,255,175), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Stacktrace:
    at net.minecraft.world.World.func_147439_a(World.java:677)
    at net.minecraft.block.BlockGrass.func_149674_a(BlockGrass.java:77)
    at net.minecraft.world.WorldServer.func_147456_g(WorldServer.java:569)
    at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:288)

-- Affected level --
Details:
    Level name: world
    All players: 2 total; [EntityPlayerMP['xi_la_nai'/468191, l='world', x=909.74, y=41.50, z=231.77](xi_la_nai at 909.7406993221408,41.5,231.77345211942998), EntityPlayerMP['benzhu'/753351, l='world', x=-654.09, y=50.00, z=121.05](benzhu at -654.0857398205269,50.0,121.05339298195648)]
    Chunk stats: ServerChunkCache: 1071 Drop: 0
    Level seed: 16
    Level generator: ID 01 - flat, ver 0. Features enabled: true
    Level generator options: 
    Level spawn location: World: (882,38,436), Chunk: (at 2,2,4 in 55,27; contains blocks 880,0,432 to 895,255,447), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511)
    Level time: 4338789580 game time, 658092836 day time
    Level dimension: 0
    Level storage version: 0x04ABD - Anvil
    Level weather: Rain time: 129106 (now: false), thunder time: 1824 (now: true)
    Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
Stacktrace:
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:931)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:431)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:809)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:669)
    at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
    Minecraft Version: 1.7.10
    KCauldron Version: pw.prok:KCauldron:1.7.10-1614.200 Official
    Plugins: CleanroomGenerator, EnderCrystalSpawnerTool, GroupManager, PlaceholderAPI, PluginManager, TuxTwoLib, FireworkBuilder, ConsoleCommands, Lockette, ConsoleSpamFix, PowerNBT, SkinsRestorer, NoBookBug, RedstoneJukeboxTrig, VoxelSniper, DeathMessages, GiftCode, FishLimitPlugin, LagMonitor, FireworkShowManager, ItemRestrict, CoreProtect, dynmap, Itemizer, Essentials, ClearLag, TimingsPatcher, AutoMessage, ManaPlugin, WorldBorder, ProtocolLib, MCCore, AutoSaveWorld, FastAsyncWorldEdit, EssentialsChat, Vault, bugfix, Lores, ScriptBlock, VariableTriggers, QuickShop, TagAPI, SkillAPI, EssentialsProtect, EssentialsGeoIP, EssentialsAntiBuild, RemoteController, RandomLocation, BossShop, EssentialsSpawn, DeathControl, WorldEdit, PlotMe, CrazyCore, ColorMOTD, Multiverse-Core, CrazyLogin, VanishNoPacket, VTTimerPlus, Plan, SimplePrefix, AncientGates, WorldGuard, ItemLoreStats, Multiverse-Inventories, WeatherMan, Transporter, CrazyLogin_Encryptor_xAuth, AreaShop, RPG_Items, Dynmap-WorldGuard
    Disabled Plugins: 
    Operating System: Windows Server 2016 (amd64) version 10.0
    Java Version: 1.8.0_202, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 1945270816 bytes (1855 MB) / 4410896384 bytes (4206 MB) up to 34246361088 bytes (32659 MB)
    JVM Flags: 2 total; -Xincgc -Xmx32767M
    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    IntCache: cache: 7, tcache: 0, allocated: 13, tallocated: 95
    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 79 mods loaded, 79 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAAAA    FML{7.10.99.99} [Forge Mod Loader] (KCauldron-1.7.10-1614.200.jar) 
    UCHIJAAAA    Forge{10.13.4.1614} [Minecraft Forge] (KCauldron-1.7.10-1614.200.jar) 
    UCHIJAAAA    kimagine{0.2} [KImagine] (minecraft.jar) 
    UCHIJAAAA    CodeChickenCore{1.0.7.47} [CodeChicken Core] (minecraft.jar) 
    UCHIJAAAA    ImmibisMicroblocks{59.1.2} [Immibis's Microblocks] ([Build]immibis-microblocks-59.1.2.jar) 
    UCHIJAAAA    cuchaz.ships.core{1.7.10-1.0.3} [Ships Mod Core] (minecraft.jar) 
    UCHIJAAAA    GollumCoreLib{2.0.0} [Gollum Core Lib] ([API]GollumCoreLib-2.0.0-1.7.10.jar) 
    UCHIJAAAA    SlimevoidLib{2.0.4.7} [Slimevoid Library] ([API]SlimevoidLibrary-2.0.4.7.jar) 
    UCHIJAAAA    ateliercanvas{0.2.0} [Atelier Canvas] ([Build]AtelierCanvas[1.7.10]-0.2.0.jar) 
    UCHIJAAAA    Backpack{2.0.1} [Backpack] ([Build]backpack-2.0.1-1.7.x.jar) 
    UCHIJAAAA    BambooMod{Minecraft@MC_VERSION@ var@VERSION@} [BambooMod] ([Build]Bamboo-2.6.8.5.jar) 
    UCHIJAAAA    BiblioCraft{1.11.7} [BiblioCraft] ([Build]BiblioCraft[v1.11.7][MC1.7.10].jar) 
    UCHIJAAAA    Railcraft{9.12.2.0} [Railcraft] ([Build]Railcraft_1.7.10-9.12.2.0.jar) 
    UCHIJAAAA    ForgeMultipart{1.2.0.347} [Forge Multipart] (ForgeMultipart-1.7.10-1.2.0.347-universal.jar) 
    UCHIJAAAA    chisel{2.9.5.11} [Chisel] ([Build]Chisel-2.9.5.11.jar) 
    UCHIJAAAA    CarpentersBlocks{3.3.8.1} [Carpenter's Blocks] ([Build]Carpenter's Blocks v3.3.8.1 - MC 1.7.10.jar) 
    UCHIJAAAA    ChestTransporter{2.0.6} [Chest Transporter] ([Build]ChestTransporter-1.7.10-2.0.6.jar) 
    UCHIJAAAA    chinacraft{0.4.206} [ChinaCraft] ([Build]ChinaCraft-1.7.10-0.4.206.jar) 
    UCHIJAAAA    creativecore{1.3.14} [CreativeCore] ([Build]CreativeCore v1.3.24 mc1.7.10.jar) 
    UCHIJAAAA    customnpcs{1.7.10d} [CustomNpcs] ([Build]CustomNPCs_1.7.10d.jar) 
    UCHIJAAAA    CustomStuff2{0.11.29} [Custom Stuff 2] ([Build]CustomStuff2-0.11.29-MC1.7.10.jar) 
    UCHIJAAAA    CustomStuff3{0.7.10} [Custom Stuff 3] ([Build]CustomStuff3-0.7.10-MC1.7.10.jar) 
    UCHIJAAAA    DynamicTransport{0.1.2.0} [Dynamic Transport] ([Build]DynamicTransport-0.1.2.0-hammer354-a1.jar) 
    UCHIJAAAA    mod_301{0.1} [mod_301] ([Build]ElectricRailway(MC幻想乡、喵玉技术专供) 0.2 for 1.7.10.jar) 
    UCHIJAAAA    flansmod{4.10.0} [Flan's Mod] ([Build]Flans Mod Plus-1.7.10-4.10.0-1.0.3 (1).jar) 
    UCHIJAAAA    MapWriter{2.1.1} [MapWriter] ([Build]Flans Mod Plus-1.7.10-4.10.0-1.0.3 (1).jar) 
    UCHIJAAAA    ForgottenNature{1.7.19} [Forgotten Nature] ([Build]ForgottenNature_1.7.19.jar) 
    UCHIJAAAA    GardenContainers{1.7.10-1.7.0} [Garden Containers] ([Build]GardenStuff-1.7.10-1.7.0.jar) 
    UCHIJAAAA    GardenCore{1.7.10-1.7.0} [Garden Core] ([Build]GardenStuff-1.7.10-1.7.0.jar) 
    UCHIJAAAA    GardenStuff{1.7.10-1.7.0} [Garden Stuff] ([Build]GardenStuff-1.7.10-1.7.0.jar) 
    UCHIJAAAA    GardenTrees{1.7.10-1.7.0} [Garden Trees] ([Build]GardenStuff-1.7.10-1.7.0.jar) 
    UCHIJAAAA    GregsLighting{1.11.2} [Greg's Lighting] ([Build]GregsLighting-1.11.2-mc1.7.10.jar) 
    UCHIJAAAA    mimgMoreBlocks{0.0.1} [mimg's More blocks] ([Build]hxxMoreBlocks.jar) 
    UCHIJAAAA    ImmibisCore{59.1.4} [Immibis Core] ([Build]immibis-core-59.1.4.jar) 
    UCHIJAAAA    mod_Invasion{1.1.5} [Invasion] ([Build]Invasion_1.1.5_1.7.10.jar) 
    UCHIJAAAA    JammyFurniture{5.0.0 [Build Smeagol]} [Jammy Furniture Mod] ([Build]JammyFurniture-5.0.0-1.7.10.jar) 
    UCHIJAAAA    minepainter{0.3.4f2} [MinePainter] ([Build]minepainter-0.3.4f2.jar) 
    UCHIJAAAA    MoarSigns{1.2.4} [MoarSigns] ([Build]MoarSigns-1.7.10-1.2.4.jar) 
    UCHIJAAAA    MorePistons{2.0.0} [More Pistons] ([Build]MorePistons-2.0.0-1.7.10.jar) 
    UCHIJAAAA    cfm{3.4.8} [?9MrCrayfish's Furniture Mod] ([Build]MrCrayfishFurnitureModv3.4.8(1.7.10).jar) 
    UCHIJAAAA    opframe{0.1} [OnlinePictureFrame] ([Build]OnlinePicFrame v1.0 mc1.7.10.jar) 
    UCHIJAAAA    RedLogic{59.1.13} [RedLogic] ([Build]redlogic-59.1.13.jar) 
    UCHIJAAAA    cuchaz.cuchazinteractive{1.7.10-1.0} [Cuchaz Interactive] ([Build]shipsMod-v1.7.10-1.0.4.jar) 
    UCHIJAAAA    cuchaz.ships{1.7.10-1.0.3} [Ships Mod] ([Build]shipsMod-v1.7.10-1.0.4.jar) 
    UCHIJAAAA    signpic{2.8.0} [SignPicture] ([Build]SignPicture-1.7.10-2.8.0-universal.jar) 
    UCHIJAAAA    touhou_alice_core{1.7.10-kog3} [Alice's Core MOD] ([Build]TouhouAliceDoll_kog3.zip) 
    UCHIJAAAA    touhou_alice_dolls{1.7.10-kog3} [Alice's Dolls MOD] ([Build]TouhouAliceDoll_kog3.zip) 
    UCHIJAAAA    touhou_alice_extras{1.7.10-kog3} [Alice's Dolls Ex] ([Build]TouhouAliceDoll_kog3.zip) 
    UCHIJAAAA    tc{4.3.3_011} [Traincraft] ([Build]Traincraft-4.3.3_011.jar) 
    UCHIJAAAA    Tubestuff{59.0.4} [Tubestuff] ([Build]tubestuff-59.0.4.jar) 
    UCHIJAAAA    vending{1.2.3} [vending] ([Build]vending-1.7.10-1.2.3.jar) 
    UCHIJAAAA    mw{1.11.7.7} [Modern Warfare] ([Build]Vic's Modern Warfare-1.7.10-1.11.7.jar) 
    UCHIJAAAA    weaponmod{v1.14.3} [Balkon's WeaponMod] ([Build]weaponmod-1.14.3.jar) 
    UCHIJAAAA    WR-CBE|Core{1.4.1.11} [WR-CBE Core] ([Build]WR-CBE-1.7.10-1.4.1.11-universal.jar) 
    UCHIJAAAA    WR-CBE|Addons{1.4.1.11} [WR-CBE Addons] ([Build]WR-CBE-1.7.10-1.4.1.11-universal.jar) 
    UCHIJAAAA    WR-CBE|Logic{1.4.1.11} [WR-CBE Logic] ([Build]WR-CBE-1.7.10-1.4.1.11-universal.jar) 
    UCHIJAAAA    Dynmap{2.2-143} [Dynmap] ([Func]Dynmap-2.2-forge-1.7.10.jar) 
    UCHIJAAAA    NBTEdit{1.7.2.2} [In-game NBTEdit] ([Func]NBTEdit_1.7.10.jar) 
    UCHIJAAAA    worldedit{6.1.1} [WorldEdit] ([Func]worldedit-forge-mc1.7.10-6.1.1-dist.jar) 
    UCHIJAAAA    armourersWorkshop{1.7.10-0.48.3} [Armourer's Workshop] (Armourers-Workshop-1.7.10-0.48.3.jar) 
    UCHIJAAAA    Gift{1.0.0} [Gift] (CS2_Gift) 
    UCHIJAAAA    MakaiProject{1.0.0} [MakaiProject] (CS2_MakaiProject) 
    UCHIJAAAA    MidAut{1.0.0} [MidAut] (CS2_MidAut) 
    UCHIJAAAA    TouhouBarrage{1.0.0} [TouhouBarrage] (CS2_TouhouBarrage) 
    UCHIJAAAA    TouhouBattle{1.0.0} [TouhouBattle] (CS2_TouhouBattle) 
    UCHIJAAAA    TouhouCraft{1.0.0} [TouhouCraft] (CS2_TouhouCraft) 
    UCHIJAAAA    TouhouFarm{1.0.0} [TouhouFarm] (CS2_TouhouFarm) 
    UCHIJAAAA    TouhouFood{1.0.0} [TouhouFood] (CS2_TouhouFood) 
    UCHIJAAAA    TouhouFZA{1.0.0} [TouhouFZA] (CS2_TouhouFZA) 
    UCHIJAAAA    TouhouFZGift{1.0.0} [TouhouFZGift] (CS2_TouhouFZGift) 
    UCHIJAAAA    TouhouFZN{1.0.0} [TouhouFZN] (CS2_TouhouFZN) 
    UCHIJAAAA    WoolCraft{1.0.0} [WoolCraft] (CS2_WoolCraft) 
    UCHIJAAAA    NyaSamaElectricity{0.6} [NyaSama Electricity] (NyaSamaCompletePack-MCG-181117.jar) 
    UCHIJAAAA    NyaSamaOptics{0.2} [NyaSama Optics] (NyaSamaCompletePack-MCG-181117.jar) 
    UCHIJAAAA    NyaSamaRailway{1.0} [NyaSama Railway] (NyaSamaCompletePack-MCG-181117.jar) 
    UCHIJAAAA    NyaSamaTelecom{0.2} [NyaSama Telecom] (NyaSamaCompletePack-MCG-181117.jar) 
    UCHIJAAAA    ForgeMicroblock{1.2.0.347} [Forge Microblocks] (ForgeMultipart-1.7.10-1.2.0.347-universal.jar) 
    UCHIJAAAA    McMultipart{1.2.0.347} [Minecraft Multipart Plugin] (ForgeMultipart-1.7.10-1.2.0.347-universal.jar) 
    Chisel: Errors like "[FML]: Unable to lookup ..." are NOT the cause of this crash. You can safely ignore these errors. And update forge while you're at it.
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    Player Count: 2 / 45; [EntityPlayerMP['xi_la_nai'/468191, l='world', x=909.74, y=41.50, z=231.77](xi_la_nai at 909.7406993221408,41.5,231.77345211942998), EntityPlayerMP['benzhu'/753351, l='world', x=-654.09, y=50.00, z=121.05](benzhu at -654.0857398205269,50.0,121.05339298195648)]
    Is Modded: Definitely; Server brand changed to 'kcauldron,cauldron,craftbukkit,mcpc,fml,forge'
    Type: Dedicated Server (map_server.txt)

Posted

1.7.10 is no longer supported on these forums due to how old it is. You will need to update to a more modern version (1.12.2+) to receive support here.

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
    • Okay, but does the modpack works with 1.12 or just with 1.12.2, because I need the Forge client specifically for Minecraft 1.12, not 1.12.2
    • 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() ); } }  
  • Topics

×
×
  • Create New...

Important Information

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