NovaViper Posted June 8, 2015 Posted June 8, 2015 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 Quote 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!
NovaViper Posted June 9, 2015 Author Posted June 9, 2015 Anyone know why I get that cloning whenever I put a non-player entity in my custom portal? Quote 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!
Guest Posted June 9, 2015 Posted June 9, 2015 Take a look at the vanilla nether portal code if you haven't already. it teleports both entities and players. Quote
NovaViper Posted June 9, 2015 Author Posted June 9, 2015 I have, but it takes the entity to the nether portal, not to my custom dimension Quote 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!
Guest Posted June 9, 2015 Posted June 9, 2015 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. Quote
NovaViper Posted June 9, 2015 Author Posted June 9, 2015 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 Quote 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!
Ernio Posted June 9, 2015 Posted June 9, 2015 Minecarts are the only vanilla entities that can travel through portal. Look them up. Quote 1.7.10 is no longer supported by forge, you are on your own.
NovaViper Posted June 9, 2015 Author Posted June 9, 2015 I know that but the problem is that non player entites of ANY kind are experiencing that cloning Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 I add a cooldown time to the entities also, but that makes the cloning even worse and causes even more lag Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 I tried doing what vanilla does, it only takes me to the nether dimension, not my dimension Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 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 Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 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(); } } Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 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(); } } Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 *Facepalm* Oh.. I feel stupid for not knowing Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 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(); } } Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 I thought that is the cooldown. Well, where am I suppose to get the cooldown from? Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 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(); } } Quote 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!
NovaViper Posted June 10, 2015 Author Posted June 10, 2015 I'm now confused now Quote 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!
Abastro Posted June 11, 2015 Posted June 11, 2015 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.. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
Recommended Posts
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.