Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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!

  • Author

Anyone know why I get that cloning whenever I put a non-player entity in my custom 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!

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

  • Author

I have, but it takes the entity to the nether portal, not to my custom dimension

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!

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.

  • Author

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!

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.

  • Author

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!

  • Author

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!

  • Author

I tried doing what vanilla does, it only takes me to the nether dimension, not my dimension

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!

  • Author

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!

  • Author

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!

  • Author

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!

  • Author

*Facepalm* Oh.. I feel stupid for not knowing

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!

  • Author

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!

  • Author

I thought that is the cooldown. Well, where am I suppose to get the cooldown from?

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!

  • Author

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!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.