Jump to content

Recommended Posts

Posted (edited)

Edit Solved Issues 1 and 2:
CMD Code:
https://gist.github.com/jredfox/6108a45efc52e6e214d8161a0ed693a3

 

Goal teleport player to x dimension specified including other players.

 

Issues With CMD:
after teleportation a couple times @p no longer works
after teleporting from the end to nether then dying the ender dragon bar doesn't go away.

 

Steps to reproduce Issue 1:

/tpdim @p ~ ~ ~ -1
/tpdim @p ~ ~ ~ 1
/tpdim @p ~ ~ ~ -1
/tpdim @p ~ ~ ~ 1 > errors here cannot find @p
/tp @p ~ ~ ~+1 > errors here cannot find @p vanilla test

Steps to reproduce Issue 2:
go to end dimension

go to nether dimension observe ender dragon bar

/kill and observe both fog and the ender dragon bar
 

Code:

https://gist.github.com/jredfox/9b81f4f26ebb81a9398618e330a7abae

Edited by jredfox
Posted (edited)

I guess I was being specific enough I need help fixing those issues and have no clue how to undo the boss bar and no clue as to why @p cannot find me

Edited by jredfox
Posted (edited)

I think I figured out the dragon/wither it's setup hard coded and stupid at least via server side. The entity contains the boss info server necessary to send a packet to the client to add/remove boss bar.but, the thing is you need that instance to begin with. I don't see why the server is handling client only code. It should be only packets and then handled via client side and clients then have an array of bars. I will test my hypothesis by caching all boss mobs then on world change remove boss bars and then clear the cache.

I still need help with not being able to find @p bug? please help. Why can't the vanilla command not be able to find the nearest player?

Edit: the objects for the dragon/wither boss data doesn't get updated and no longer exist after traveling to another dimension so I am thinking of a tick handler client only where if the data doesn't update in so many ticks to remove the bar. How could I do this?

Edited by jredfox
Posted (edited)
15 hours ago, diesieben07 said:

Once again you insist on doing things completely ass-backwards.

Vanilla manages cross-dimension teleports just fine: Via portals. No hacks or tick handlers or whatever the fuck needed.

You need to do the same thing and it will work.

I didn't do anything backwards and no it doesn't work. Take a look at mist craft which did the same thing the ender dragon bug still occurs when doing as I said above just with their command. So how do I fix this?

Why can't the command find @p is what I need to know

And if you took a look at my code I call a vanilla handler for changing dimensions so....

Edited by jredfox
Posted (edited)

I got the dragon manager to update as the player leaves the world. It appears this bug is only 1.9+ I never heard of it occurring in 1.7 especially since it use to be client only and we had mods to transfer to other dimensions lots of them some only calling vanilla methods. It appears this issue doesn't exist for withers and it also appears that dragon bars do not appear and dragons do not work unless they are in their specified dimension unlike < 1.9 versions

Now I need to know why the @p cannot find nearest player. Something isn't syncing when the player goes from the end dimension to the nether dimension. I need to know what hashmap isn't populated

Edited by jredfox
Posted
    /**
     * Must be only called if player is at end dim this is because vanilla is hard coded and no longer displays bars outside of end dim
     */
    public void removeDragonBars(EntityPlayerMP p,World end) 
    {
    	try
    	{
    		DragonFightManager fightManager = ((WorldProviderEnd)end.provider).getDragonFightManager();
    		if(fightManager != null)
    		{
    			FieldAcess.method_dragonManager.invoke(fightManager);
    		}
    	}
    	catch(Throwable t)
    	{
    		t.printStackTrace();
    	}
	}

 

Posted (edited)
23 hours ago, diesieben07 said:

Once again you insist on doing things completely ass-backwards.

Vanilla manages cross-dimension teleports just fine: Via portals. No hacks or tick handlers or whatever the fuck needed.

You need to do the same thing and it will work.

Not to spam or anything but, this is weird when teleportation from my command from end to nether it doesn't add it to any of the word's new hash maps like loaded entities and loaded players I would even guess the chunk hash maps. 

[02:38:20] [Server thread/INFO] [STDOUT]: [com.EvilNotch.lib.minecraft.content.CMDDim:execute:94]: Ent List:[]
[02:38:20] [Server thread/INFO] [STDOUT]: [com.EvilNotch.lib.minecraft.content.CMDDim:execute:95]: EntHasPlayer:false

I call the vanilla method transfer player to dimension what else should I be calling?
https://gist.github.com/jredfox/9b81f4f26ebb81a9398618e330a7abae

I fire forge's respawn event since the respawn packet is there on vanilla player list travel player to dimension. Is this wrong should this not be considered as a respawn since the player is being transferred?

I will take a look at the entity method transfer to dimension but, the player list should be all I have to call for players.

Edited by jredfox
Posted (edited)
19 minutes ago, diesieben07 said:

So far no you didn't. But your approach when something doesn't work is completely wrong.

You refuse to take a step back and figure out why what you are doing doesn't work and instead insist on tacking on quick fixes and hacks to make your initial solution work no matter what.

 

Things like this is what I mean. You do not need to care about any hash maps internal to Minecraft. Do not hack around internals.

 

Things I observed about your code (can't test it because you have not provided a working repository):

  • Why the f*** are you firing FML's respawn event? You are not respawning anything. And if you did, you would not have to fire the event manually.
  • You are setting the location first, then teleporting to the target dimension. This is broken.
  • Traveling to a dimension happens via Entity::travelToDimension, this is what portals use for example.

Entity travelToDimension seems to be non existent but, I did eventually find changeDimension which I don't see called anywhere in playerlist guess it's bugged going to give this a try or vanilla always expects that to fire first which means it's called elsewhere either way going to give it a try soon.

Edit: that method I found above doesn't do what I need it to do it doesn't even add them to the hashmaps.

Setting the location without packets it's a set of varibles. If I transfered the player to the dimension then set the location it lags alot so I set the location first therefore only loading the chunks your xyz is suppose to be at. And if I detect it's still not re positioned then I do it again this time with networks being involved

Edited by jredfox
Posted (edited)
4 minutes ago, diesieben07 said:

Yeah, I meant changeDimension, sorry.

Why would playerlist call it? The only thing in Minecraft that teleports across dimensions are portals. And they use changeDimension. Why would you expect PlayerList to use this? What for? Why do you think it's bugged? You just blurt out random statements without anything to back them up. This is not helpful.

 

WHAT?

 

WHAT! WHAT WHAT WHWAHTAHHH

I give up.

Look at my method call:
 

p.getServer().getPlayerList().transferPlayerToDimension(p,traveldim, new EntityTeleporter(p.getServer().getWorld(traveldim)));



That is what I call to change dimensions and it does work but, the world hashmaps and possibly other data isn't synced right? What other thing should I be calling?

That method is what perfect spawn calls and what vanilla calls is my guess somewhere. 

Edited by jredfox
Posted
1 minute ago, diesieben07 said:

What the fuck are "world hashmaps"?

sorry arraylists very tired right now.

loadedEntities, playerEntities that's the first two things I checked and were blank after calling my tp command from end to nether

Posted (edited)
3 minutes ago, diesieben07 said:

Why are you checking them? Why do you care? As far as I know it would take a few ticks for the player to fully transfer over.

I checked them after the dimension change. I care because the @p command no longer works and it's going to cause mod incompatibilities when it can't find the player. 

I gave it a full 2 seconds before trying to transfer from the nether back to the end but, couldn't find @p. you probably are right on the arraylists taking a couple ticks to update but, what is causing it then?

going to have a tick checker firing every second will post resaults

Edited by jredfox
Posted (edited)

After 5 seconds with this code on tick this was still printing and didn't print until I teleported straight from the end to the nether. I tried teleporting from the nether to end before and it didn't print so it only occurs from end to nether then it bugs out.
 

		if(!event.player.world.loadedEntityList.contains(event.player))
			System.out.println("ERR:" + event.player.getName() );

 

It appears player list has some broken if statements that will never fire because they say if false && method() well it's never going to fire.

Edited by jredfox
Posted
9 minutes ago, diesieben07 said:

And I don't know why that is nor can I test it since you did not include a working repository.

Ok I am currently using evil notch lib for the command. It will be in a separate mod eventually
https://github.com/jredfox/evilnotchlib

I found a fix but, I know it's not proper since the entity player could already be added to the chunk list and it's not calling the proper method in the first place that I know of.

                	if(!newWorld.loadedEntityList.contains(p) || !newWorld.playerEntities.contains(p))
                	{
                		System.out.println("ERR Player Not Added To World:" + p.getName());
                		newWorld.spawnEntity(p);
                	}

 

Posted (edited)
1 hour ago, diesieben07 said:

Did you borrow your commit names from Reika?

Your repository is also completely broken, it contains duplicate classes.

And I doubt you own evilnotch.com.

dupe classes well I will take a look at that.

Of course I own evil notch lib just go to curseforge then take a look at evil notch lib the owner says it was me if it wasn't it would have been a fork which is detectable on github. I am in the middle of a huge update and I am not going to say this is 2.0 it's just a huge update so I could do builds or snapshots this time I decided snapshots since each stage had little to no bugs.

Wow that's alot of dupes I wonder how src wound up there. Fixing it now new repository should be same link.
https://github.com/jredfox/evilnotchlib

So you going to test why the entity player gets added to the world arrays sometimes and not others by calling player list travel to dimension?

evilnotch.com no I don't It's the failed team's name that originally planned on updating evil minecraft mod but, I got way too busy with utility mods and the rest of the team quit on me. But, I did succeed in writing a legacy mod to fix minecraft to be more like 1.2.5 in 1.7.10 called evil notch core. The code was rushed and although the code looked clean in most areas had bugs since I didn't understand how everything worked. I plan on making evil notch core re-write once the lib nessary for it has been done as well as silkspawners and mob spawnage updates and dungeon tweaks

 

the original coding team for evil notch quit( evil notch himself didn't and was constantly asking for a new team of coders all the way up to early 2014 sad nobody responded)

Edited by jredfox
Posted (edited)
15 minutes ago, diesieben07 said:

Why did you kill your complete commit history? Do you not know how Git works?!

You are now missing your build.gradle.

 

This is not at all what I said. Package names are domain names. If you do not own the domain evilnotch.com you should not use that as your package name.

no it's com.evilnotch.lib  most programs have their package base retaliative to their program name. And in all previous versions of how to make a mod and even program tatorials for java say use three packages com(program option),org(library and api only),net(don't remember second option). Then it says what is the author usually and the third dot is what is the program used for. This rules out package and classes getting overridden by other java programs in memory.

No I don't own mc user EvilNotch but, I do own the Team EvilNotch do you know what I am saying? I was trying to revive old ideas but, all the other coders quit on me so the actual source plan me and another agreed we would do (update evil minecraft) never happened.

I forgot about the build.gradle I just reset the repository so I forgot to add it back thanks. It's up now. The only thing I edited though was options.encoding = "UTF-8" under compile java

Edited by jredfox
Posted (edited)
10 minutes ago, diesieben07 said:

That's not how package names work.

 

You still do way too much crap in your teleport method. Why are you firing the respawn event? Clean this up.

I could comment out the respawn method even though the packet for respawn is there in the player list transfer dimension aka vanilla respawns but, not forge. So I thought why not fire it on forges side to. It could mess up things either way so I just left it there. But, I will comment it out for the tp command.

What other crap is there? I told you why I had the code to re position the entity before changing dimensions because the way the transfer works is set the players location on the connection from the players current position thus alot more chunks would load. If you got a better idea for doing this or a manual method idea I am all ears. Also if you looked I didn't say player.connection.setlocation meaning that it's not going to send any packets and before the tick is even up the player changes to that specified dimension at that location.

The package name is named right:
The prefix is com:
the domain is evilnotch

the function aka program is lib


So team evil notch has a lib. I know it's only three chars but, I didn't want any more then I had to name and com.evilnotch.library sounded wrong and unprofessional 

Edited by jredfox
Posted

this is an improper fix this is what I am worried about please help me on this.
Line 86:

                	if(!newWorld.loadedEntityList.contains(p) || !newWorld.playerEntities.contains(p))
                	{
                		System.out.println("ERR Player Not Added To World:" + p.getName());
                		newWorld.spawnEntity(p);
                	}

 

Posted

Ok I think I might have figured out why it's only bugging out if your tping from the end to any other dim it's because they have a hard coded if statement if it's not the end dim spawn entity into new world. What the heck? This is garbage it should always do that and they should have a different teleporter for the end instead of always trying to use the nether teleporter instead they give you garbage so you either code around it or make your own method because you can't use it as is since it don't work.

Vanilla hard coded if is end do nothing:

        if (lastDimension != 1)
        {
            oldWorldIn.profiler.startSection("placing");
            d0 = (double)MathHelper.clamp((int)d0, -29999872, 29999872);
            d1 = (double)MathHelper.clamp((int)d1, -29999872, 29999872);

            if (entityIn.isEntityAlive())
            {
                entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
                teleporter.placeInPortal(entityIn, f);
                toWorldIn.spawnEntity(entityIn);
                toWorldIn.updateEntityWithOptionalForce(entityIn, false);
            }

            oldWorldIn.profiler.endSection();
        }



Work Around:

                	if(oldWorld.provider.getDimension() == 1)
                	{
                		System.out.println("End to Another Dim Patching Vanilla:" + p.getName());
                		tele.placeInPortal(p, p.rotationYaw);
                                newWorld.spawnEntity(p);
                                newWorld.updateEntityWithOptionalForce(p, false);
                	}



Vanilla needs to have proper object orientation for teleportation shouldn't have to do that work around myself but, you know....

Posted (edited)

tumblr_ljh0puClWT1qfkt17.gif

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
18 hours ago, diesieben07 said:

That's not how package names work.

 

You still do way too much crap in your teleport method. Why are you firing the respawn event? Clean this up.

Ok I figured out the two issues but, I have a new one. Players don't update to other players once either teleported from another dimension.

What packet should I send to what players to update them?

Edit nevermind vanilla's transfer player to dimension is highly bugged copied code from another mod worked perfect no syncing issues.

Edited by jredfox

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.