Jump to content

Recommended Posts

Posted

Hey, is it in anyway possible to make a custom portal that transports both entities and players? I started but it causes the non-player entity to be teleported to and from the dimensions rapidly, causing lots of lag and it ends up spawning multiple 'clones' of the same entity.

 

My code is up to date and posted on Github: https://github.com/NovaViper/ZeroQuest/tree/master/src/main/java/common/zeroquest/block/portal

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Take a look at the vanilla nether portal code if you haven't already. it teleports both entities and players.

Posted

if (player.timeUntilPortal > 0) {
     player.timeUntilPortal = 10;
}

 

This code looks suspicous. If I'm understanding it correctly you're resetting the timeUntilPortal field when it's more than zero. Also, I don't know for sure, but onEntityCollidedWithBlock might be called every tick the player is touching the block.

Posted

The code for teleporting the player works, but not for entities. And it ususally does call players, but I modified it to also call entites

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Minecarts are the only vanilla entities that can travel through portal. Look them up.

1.7.10 is no longer supported by forge, you are on your own.

Posted

I know that but the problem is that non player entites of ANY kind are experiencing that cloning

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

I add a cooldown time to the entities also, but that makes the cloning even worse and causes even more lag

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

I did that already

 

	private void travelToDimension(Entity entity, int id) {
	if (!entity.worldObj.isRemote && !entity.isDead) {
		entity.worldObj.theProfiler.startSection("changeDimension");
		MinecraftServer minecraftserver = MinecraftServer.getServer();
		int j = entity.dimension;
		WorldServer worldserver = minecraftserver.worldServerForDimension(j);
		WorldServer worldserver1 = minecraftserver.worldServerForDimension(id);
		entity.dimension = id;

		if (j == 1 && id == 1) {
			worldserver1 = minecraftserver.worldServerForDimension(0);
			entity.dimension = 0;
		}

		entity.worldObj.removeEntity(entity);
		entity.isDead = false;
		entity.worldObj.theProfiler.startSection("reposition");
		entity.timeUntilPortal = 10;
		minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new TeleporterNillax(worldserver1));
		entity.worldObj.theProfiler.endStartSection("reloading");
		Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

		if (entity1 != null) {
			entity1.copyDataFromOld(entity);

			if (j == 1 && id == 1) {
				BlockPos spawnPoint = worldserver1.getSpawnPoint();
				spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint);
				entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch);
			}

			worldserver1.spawnEntityInWorld(entity1);
		}

		entity.isDead = true;
		entity.worldObj.theProfiler.endSection();
		worldserver.resetUpdateEntityTick();
		worldserver1.resetUpdateEntityTick();
		entity.worldObj.theProfiler.endSection();
	}
}

 

The entity teleports but it rapidly teleports, which causes the cloning and lag

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

I took it out because it caused even more lag than before I added it in

 

	private void travelToDimension(Entity entity, int id) {
	if (!entity.worldObj.isRemote && !entity.isDead) {
		entity.worldObj.theProfiler.startSection("changeDimension");
		MinecraftServer minecraftserver = MinecraftServer.getServer();
		int j = entity.dimension;
		WorldServer worldserver = minecraftserver.worldServerForDimension(j);
		WorldServer worldserver1 = minecraftserver.worldServerForDimension(id);
		entity.dimension = id;

		if (j == 1 && id == 1) {
			worldserver1 = minecraftserver.worldServerForDimension(0);
			entity.dimension = 0;
		}

		entity.timeUntilPortal = 10;
		entity.worldObj.removeEntity(entity);
		entity.isDead = false;
		entity.worldObj.theProfiler.startSection("reposition");
		entity.timeUntilPortal = 10;
		minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new TeleporterNillax(worldserver1));
		entity.worldObj.theProfiler.endStartSection("reloading");
		Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

		if (entity1 != null) {
			entity1.copyDataFromOld(entity);

			if (j == 1 && id == 1) {
				BlockPos spawnPoint = worldserver1.getSpawnPoint();
				spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint);
				entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch);
			}

			worldserver1.spawnEntityInWorld(entity1);
			entity.timeUntilPortal = 10;
		}

		entity.isDead = true;
		entity.worldObj.theProfiler.endSection();
		worldserver.resetUpdateEntityTick();
		worldserver1.resetUpdateEntityTick();
		entity.worldObj.theProfiler.endSection();
	}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

So.. I should put the cooldown where it acutally transfers the entity to the dimension, like this?

 

	private void travelToDimension(Entity entity, int id) {
	if (!entity.worldObj.isRemote && !entity.isDead) {
		entity.worldObj.theProfiler.startSection("changeDimension");
		MinecraftServer minecraftserver = MinecraftServer.getServer();
		int j = entity.dimension;
		WorldServer worldserver = minecraftserver.worldServerForDimension(j);
		WorldServer worldserver1 = minecraftserver.worldServerForDimension(id);
		entity.dimension = id;

		if (j == 1 && id == 1) {
			worldserver1 = minecraftserver.worldServerForDimension(0);
			entity.dimension = 0;
		}

		entity.worldObj.removeEntity(entity);
		entity.isDead = false;
		entity.worldObj.theProfiler.startSection("reposition");
		minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new TeleporterNillax(worldserver1));
		entity.timeUntilPortal = 10;
		entity.worldObj.theProfiler.endStartSection("reloading");
		Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

		if (entity1 != null) {
			entity1.copyDataFromOld(entity);

			if (j == 1 && id == 1) {
				BlockPos spawnPoint = worldserver1.getSpawnPoint();
				spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint);
				entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch);
			}

			worldserver1.spawnEntityInWorld(entity1);
		}

		entity.isDead = true;
		entity.worldObj.theProfiler.endSection();
		worldserver.resetUpdateEntityTick();
		worldserver1.resetUpdateEntityTick();
		entity.worldObj.theProfiler.endSection();
	}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

It works for a little bit but then it begins to lag out, which leaves the entity stuck in the portal and cloning only in the Nillax Dimension

 

	private void travelToDimension(Entity entity, int id) {
	if (!entity.worldObj.isRemote && !entity.isDead) {
		entity.timeUntilPortal = 10;

		entity.worldObj.theProfiler.startSection("changeDimension");
		MinecraftServer minecraftserver = MinecraftServer.getServer();
		int j = entity.dimension;
		WorldServer worldserver = minecraftserver.worldServerForDimension(j);
		WorldServer worldserver1 = minecraftserver.worldServerForDimension(id);
		entity.dimension = id;

		if (j == 1 && id == 1) {
			worldserver1 = minecraftserver.worldServerForDimension(0);
			entity.dimension = 0;
		}

		entity.worldObj.removeEntity(entity);
		entity.isDead = false;
		entity.worldObj.theProfiler.startSection("reposition");
		minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new TeleporterNillax(worldserver1));
		entity.worldObj.theProfiler.endStartSection("reloading");
		Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

		if (entity1 != null) {
			entity1.copyDataFromOld(entity);

			if (j == 1 && id == 1) {
				BlockPos spawnPoint = worldserver1.getSpawnPoint();
				spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint);
				entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch);
			}

			worldserver1.spawnEntityInWorld(entity1);
		}

		entity.isDead = true;
		entity.worldObj.theProfiler.endSection();
		worldserver.resetUpdateEntityTick();
		worldserver1.resetUpdateEntityTick();
		entity.worldObj.theProfiler.endSection();
	}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

So, use getPortalCooldown() at the end of the method?

 

	private void travelToDimension(Entity entity, int id) {
	if (!entity.worldObj.isRemote && !entity.isDead) {
		entity.timeUntilPortal = 10;

		entity.worldObj.theProfiler.startSection("changeDimension");
		MinecraftServer minecraftserver = MinecraftServer.getServer();
		int j = entity.dimension;
		WorldServer worldserver = minecraftserver.worldServerForDimension(j);
		WorldServer worldserver1 = minecraftserver.worldServerForDimension(id);
		entity.dimension = id;

		if (j == 1 && id == 1) {
			worldserver1 = minecraftserver.worldServerForDimension(0);
			entity.dimension = 0;
		}

		entity.worldObj.removeEntity(entity);
		entity.isDead = false;
		entity.worldObj.theProfiler.startSection("reposition");
		minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new TeleporterNillax(worldserver1));
		entity.worldObj.theProfiler.endStartSection("reloading");
		Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

		if (entity1 != null) {
			entity1.copyDataFromOld(entity);

			if (j == 1 && id == 1) {
				BlockPos spawnPoint = worldserver1.getSpawnPoint();
				spawnPoint = entity.worldObj.getTopSolidOrLiquidBlock(spawnPoint);
				entity1.setLocationAndAngles(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), entity1.rotationYaw, entity1.rotationPitch);
			}

			worldserver1.spawnEntityInWorld(entity1);
		}

		entity.isDead = true;
		entity.worldObj.theProfiler.endSection();
		worldserver.resetUpdateEntityTick();
		worldserver1.resetUpdateEntityTick();
		entity.worldObj.theProfiler.endSection();
		entity.getPortalCooldown();
	}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

I'm now confused now

......

You should set Entity#timeUntilPortal to Entity#getPortalCooldown() when an entity is teleported,

and only teleport the entity when the counter is smaller than 0.

Then make the counter of the colliding entity decrease.

 

Please learn how to construct logic..

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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