Java Code Examples for net.minecraft.world.World#getMinecraftServer()
The following examples show how to use
net.minecraft.world.World#getMinecraftServer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockTofuPortal.java From TofuCraftReload with MIT License | 5 votes |
/** * Called When an Entity Collided with the Block */ @Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) { MinecraftServer server = worldIn.getMinecraftServer(); if (server != null && entityIn.timeUntilPortal <= 0) { PlayerList playerList = server.getPlayerList(); int i = entityIn.dimension == DimensionType.OVERWORLD.getId() ? TofuMain.TOFU_DIMENSION.getId() : DimensionType.OVERWORLD.getId(); TofuTeleporter teleporter = new TofuTeleporter(server.getWorld(i)); entityIn.timeUntilPortal = 100; if (entityIn instanceof EntityPlayerMP) { playerList.transferPlayerToDimension((EntityPlayerMP) entityIn, i, teleporter); } else { int origin = entityIn.dimension; entityIn.dimension = i; worldIn.removeEntityDangerously(entityIn); entityIn.isDead = false; playerList.transferEntityToWorld(entityIn, origin, server.getWorld(origin), server.getWorld(i), teleporter); } } else entityIn.timeUntilPortal = Math.max(entityIn.getPortalCooldown(), 100); } }
Example 2
Source File: Nyan.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { final Entity entity = event.getEntity(); final World world = entity.getEntityWorld(); if(world.isRemote) { return; } final MinecraftServer server = world.getMinecraftServer(); final NBTTagCompound data = entity.getEntityData(); if(data.hasUniqueId(NYANED_ENTITY_UUID_KEY)) { final Entity nyanedEntity = server.getEntityFromUuid(data.getUniqueId(NYANED_ENTITY_UUID_KEY)); if(nyanedEntity == null || nyanedEntity.isDead) { world.removeEntity(entity); return; } } if(data.getBoolean(HAS_NYAN_ENTITY_KEY)) { updateNyanEntity(server, (WorldServer) world, entity, data); } else if(!data.hasKey(HAS_NYAN_ENTITY_KEY)) { if(entity instanceof EntityPlayer || random.nextInt(10) == 0) { data.setBoolean(HAS_NYAN_ENTITY_KEY, true); updateNyanEntity(server, (WorldServer) world, entity, data); } else { data.setBoolean(HAS_NYAN_ENTITY_KEY, false); } } }
Example 3
Source File: BlockPortal.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * Called When an Entity Collided with the Block */ @Override public void onEntityCollidedWithBlock(World worldObj, BlockPos pos, IBlockState state, Entity entityIn) { /*if( !worldObj.isRemote) { if(worldObj.provider.getDimension() == 0) { entityIn.changeDimension(2); } else if(worldObj.provider.getDimension() == 2) { entityIn.changeDimension(0); } }*/ if (!entityIn.isRiding() && !entityIn.isBeingRidden() && !worldObj.isRemote) { NBTTagCompound nbt = entityIn.getEntityData().getCompoundTag("TFC2"); if(Timekeeper.getInstance().getTotalTicks() - nbt.getLong("lastPortalTime") < 1000) return; MinecraftServer minecraftserver = worldObj.getMinecraftServer(); if(worldObj.provider.getDimension() == 0) { entityIn.changeDimension(2); nbt.setLong("lastPortalTime", Timekeeper.getInstance().getTotalTicks()); } else if(worldObj.provider.getDimension() == 2) { entityIn.changeDimension(0); nbt.setLong("lastPortalTime", Timekeeper.getInstance().getTotalTicks()); } } }