Java Code Examples for net.minecraft.server.MinecraftServer#getServer()
The following examples show how to use
net.minecraft.server.MinecraftServer#getServer() .
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: SoulNetworkHandler.java From Framez with GNU General Public License v3.0 | 6 votes |
public static void setCurrentEssence(String ownerName, int essence) { if (MinecraftServer.getServer() == null) { return; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } data.currentEssence = essence; data.markDirty(); }
Example 2
Source File: SoulNetworkHandler.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static int getCurrentEssence(String ownerName) { if (MinecraftServer.getServer() == null) { return 0; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } return data.currentEssence; }
Example 3
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@SubscribeEvent @SuppressWarnings("unchecked") public void onWorldTick(TickEvent.ServerTickEvent event) { if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER) return; if (EtFuturum.enablePlayerSkinOverlay) if (playerLoggedInCooldown != null) if (--playerLoggedInCooldown <= 0) { for (World world : MinecraftServer.getServer().worldServers) for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) { NBTTagCompound nbt = player.getEntityData(); if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) { boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY); EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex)); } } playerLoggedInCooldown = null; } }
Example 4
Source File: SoulNetworkHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
/** * A method to add to an owner's network up to a maximum value. * * @param ownerName * @param addedEssence * @param maximum * @return amount added to the network */ public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) { if (MinecraftServer.getServer() == null) { return 0; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } int currEss = data.currentEssence; if(currEss>=maximum) { return 0; } int newEss = Math.min(maximum, currEss+addedEssence); data.currentEssence = newEss; return newEss-currEss; }
Example 5
Source File: PneumaticCraftUtils.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static World getWorldForDimension(int dimension){ for(WorldServer w : MinecraftServer.getServer().worldServers) { if(w.provider.dimensionId == dimension) { return w; } } return null; }
Example 6
Source File: PacketCustom.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void handle(final INetHandler netHandler, final String channel, final PacketCustom packet) { if (netHandler instanceof NetHandlerPlayServer) { MinecraftServer mc = MinecraftServer.getServer(); if (!mc.isCallingFromMinecraftThread()) mc.addScheduledTask(new Runnable() { public void run() { handle(netHandler, channel, packet); } }); else handler.handlePacket(packet, ((NetHandlerPlayServer) netHandler).playerEntity, (INetHandlerPlayServer) netHandler); } else System.err.println("Invalid INetHandler for PacketCustom on channel: " + channel); }
Example 7
Source File: SoulNetworkHandler.java From Framez with GNU General Public License v3.0 | 5 votes |
public static EntityPlayer getPlayerFromUUID(UUID uuid) { MinecraftServer server = MinecraftServer.getServer(); GameProfile gameProfile; gameProfile = server.func_152358_ax().func_152652_a(uuid); return null; }
Example 8
Source File: FakeWorldServer.java From Framez with GNU General Public License v3.0 | 5 votes |
private FakeWorldServer(World world) { super(MinecraftServer.getServer(), new NonSavingHandler(), world.getWorldInfo().getWorldName(), world.provider.dimensionId, new WorldSettings(world.getWorldInfo()), world.theProfiler); DimensionManager.setWorld(world.provider.dimensionId, (WorldServer) world); chunkProvider = world.getChunkProvider(); }
Example 9
Source File: NEIServerConfig.java From NotEnoughItems with MIT License | 5 votes |
public static void load(World world) { if (MinecraftServer.getServer() != server) { logger.debug("Loading NEI Server"); server = MinecraftServer.getServer(); saveDir = new File(DimensionManager.getCurrentSaveRootDirectory(), "NEI"); dimTags.clear(); loadConfig(); loadBannedItems(); } loadWorld(world); }
Example 10
Source File: SoulNetworkHandler.java From Framez with GNU General Public License v3.0 | 5 votes |
/** * A method to add to an owner's network up to a maximum value. * * @param ownerName * @param addedEssence * @param maximum * @return amount added to the network */ public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) { if (MinecraftServer.getServer() == null) { return 0; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } int currEss = data.currentEssence; if (currEss >= maximum) { return 0; } int newEss = Math.min(maximum, currEss + addedEssence); data.currentEssence = newEss; return newEss - currEss; }
Example 11
Source File: ModData.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private static File geDefaultDirectory() { MinecraftServer server = MinecraftServer.getServer(); if(server != null && server.getEntityWorld() != null) { File file = server.getEntityWorld().getSaveHandler().getWorldDirectory(); if(file != null) { return new File(file, Gadomancy.MODID); } } return null; }
Example 12
Source File: CauldronCommand.java From Thermos with GNU General Public License v3.0 | 5 votes |
private boolean getToggle(CommandSender sender, String[] args) { try { Setting toggle = MinecraftServer.getServer().cauldronConfig.getSettings().get(args[1]); // check config directly if (toggle == null && MinecraftServer.getServer().cauldronConfig.isSet(args[1])) { if (MinecraftServer.getServer().cauldronConfig.isBoolean(args[1])) { toggle = new BoolSetting(MinecraftServer.getServer().cauldronConfig, args[1], MinecraftServer.getServer().cauldronConfig.getBoolean(args[1], false), ""); } else if (MinecraftServer.getServer().cauldronConfig.isInt(args[1])) { toggle = new IntSetting(MinecraftServer.getServer().cauldronConfig, args[1], MinecraftServer.getServer().cauldronConfig.getInt(args[1], 1), ""); } if (toggle != null) { MinecraftServer.getServer().cauldronConfig.getSettings().put(toggle.path, toggle); MinecraftServer.getServer().cauldronConfig.load(); } } if (toggle == null) { sender.sendMessage(ChatColor.RED + "Could not find option: " + args[1]); return false; } Object value = toggle.getValue(); String option = (Boolean.TRUE.equals(value) ? ChatColor.GREEN : ChatColor.RED) + " " + value; sender.sendMessage(ChatColor.GOLD + args[1] + " " + option); } catch (Exception ex) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); ex.printStackTrace(); } return true; }
Example 13
Source File: TileEntityCommand.java From Thermos with GNU General Public License v3.0 | 5 votes |
private boolean getToggle(CommandSender sender, String[] args) { try { Setting toggle = MinecraftServer.getServer().tileEntityConfig.getSettings().get(args[1]); // check config directly if (toggle == null && MinecraftServer.getServer().tileEntityConfig.isSet(args[1])) { if (MinecraftServer.getServer().tileEntityConfig.isBoolean(args[1])) { toggle = new BoolSetting(MinecraftServer.getServer().tileEntityConfig, args[1], MinecraftServer.getServer().tileEntityConfig.getBoolean(args[1], false), ""); } else if (MinecraftServer.getServer().tileEntityConfig.isInt(args[1])) { toggle = new IntSetting(MinecraftServer.getServer().tileEntityConfig, args[1], MinecraftServer.getServer().tileEntityConfig.getInt(args[1], 1), ""); } if (toggle != null) { MinecraftServer.getServer().tileEntityConfig.getSettings().put(toggle.path, toggle); MinecraftServer.getServer().tileEntityConfig.load(); } } if (toggle == null) { sender.sendMessage(ChatColor.RED + "Could not find option: " + args[1]); return false; } Object value = toggle.getValue(); String option = (Boolean.TRUE.equals(value) ? ChatColor.GREEN : ChatColor.RED) + " " + value; sender.sendMessage(ChatColor.GOLD + args[1] + " " + option); } catch (Exception ex) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); ex.printStackTrace(); } return true; }
Example 14
Source File: SushchestvoCommand.java From Thermos with GNU General Public License v3.0 | 5 votes |
private boolean setToggle(CommandSender sender, String[] args) { try { Setting toggle = MinecraftServer.getServer().sushchestvoConfig.getSettings().get(args[1]); // check config directly if (toggle == null && MinecraftServer.getServer().sushchestvoConfig.isSet(args[1])) { toggle = new BoolSetting(MinecraftServer.getServer().sushchestvoConfig, args[1], MinecraftServer.getServer().sushchestvoConfig.getBoolean(args[1], false), ""); MinecraftServer.getServer().sushchestvoConfig.getSettings().put(toggle.path, toggle); MinecraftServer.getServer().sushchestvoConfig.load(); } if (toggle == null) { sender.sendMessage(ChatColor.RED + "Could not find option: " + args[1]); return false; } if (args.length == 2) { sender.sendMessage(ChatColor.RED + "Usage: " + args[0] + " " + args[1] + " [value]"); return false; } toggle.setValue(args[2]); Object value = toggle.getValue(); String option = (Boolean.TRUE.equals(value) ? ChatColor.GREEN : ChatColor.RED) + " " + value; sender.sendMessage(ChatColor.GOLD + args[1] + " " + option); MinecraftServer.getServer().sushchestvoConfig.save(); } catch (Exception ex) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); ex.printStackTrace(); } return true; }
Example 15
Source File: SoulNetworkHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static int syphonFromNetwork(ItemStack ist, int damageToBeDone) { if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) { String ownerName = ist.getTagCompound().getString("ownerName"); if (MinecraftServer.getServer() == null) { return 0; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } if (data.currentEssence >= damageToBeDone) { data.currentEssence -= damageToBeDone; data.markDirty(); return damageToBeDone; } } return 0; }
Example 16
Source File: ItemRemote.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private boolean isAllowedToEdit(EntityPlayer player, ItemStack remote){ NBTTagCompound tag = remote.getTagCompound(); if(tag != null) { if(tag.hasKey("securityX")) { int x = tag.getInteger("securityX"); int y = tag.getInteger("securityY"); int z = tag.getInteger("securityZ"); int dimensionId = tag.getInteger("securityDimension"); WorldServer world = null; for(WorldServer w : MinecraftServer.getServer().worldServers) { if(w.provider.dimensionId == dimensionId) { world = w; break; } } if(world != null) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntitySecurityStation) { boolean canAccess = ((TileEntitySecurityStation)te).doesAllowPlayer(player); if(!canAccess) { player.addChatComponentMessage(new ChatComponentTranslation("gui.remote.noEditRights", x, y, z)); } return canAccess; } } } } return true; }
Example 17
Source File: AdvancedFakePlayer.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
public AdvancedFakePlayer(WorldServer world, UUID uuid, String name) { super(world, new GameProfile(uuid, name)); this.playerNetServerHandler = new FakeNetServerHandler(MinecraftServer.getServer(), this); }
Example 18
Source File: Entity.java From TickDynamic with MIT License | 4 votes |
/** * Teleports the entity to another dimension. Params: Dimension number to teleport to */ public void travelToDimension(int p_71027_1_) { if (!this.worldObj.isRemote && !this.isDead) { this.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = MinecraftServer.getServer(); int j = this.dimension; WorldServer worldserver = minecraftserver.worldServerForDimension(j); WorldServer worldserver1 = minecraftserver.worldServerForDimension(p_71027_1_); this.dimension = p_71027_1_; if (j == 1 && p_71027_1_ == 1) { worldserver1 = minecraftserver.worldServerForDimension(0); this.dimension = 0; } this.worldObj.removeEntity(this); this.isDead = false; this.worldObj.theProfiler.startSection("reposition"); minecraftserver.getConfigurationManager().transferEntityToWorld(this, j, worldserver, worldserver1); this.worldObj.theProfiler.endStartSection("reloading"); Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1); if (entity != null) { entity.copyDataFrom(this, true); if (j == 1 && p_71027_1_ == 1) { ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint(); chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ); entity.setLocationAndAngles((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ, entity.rotationYaw, entity.rotationPitch); } worldserver1.spawnEntityInWorld(entity); } this.isDead = true; this.worldObj.theProfiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); this.worldObj.theProfiler.endSection(); } }
Example 19
Source File: CauldronCommand.java From Thermos with GNU General Public License v3.0 | 4 votes |
private boolean setToggle(CommandSender sender, String[] args) { try { Setting toggle = MinecraftServer.getServer().cauldronConfig.getSettings().get(args[1]); // check config directly if (toggle == null && MinecraftServer.getServer().cauldronConfig.isSet(args[1])) { toggle = new BoolSetting(MinecraftServer.getServer().cauldronConfig, args[1], MinecraftServer.getServer().cauldronConfig.getBoolean(args[1], false), ""); MinecraftServer.getServer().cauldronConfig.getSettings().put(toggle.path, toggle); MinecraftServer.getServer().cauldronConfig.load(); } if (toggle == null) { sender.sendMessage(ChatColor.RED + "Could not find option: " + args[1]); return false; } if (args.length == 2) { sender.sendMessage(ChatColor.RED + "Usage: " + args[0] + " " + args[1] + " [value]"); return false; } toggle.setValue(args[2]); Object value = toggle.getValue(); String option = (Boolean.TRUE.equals(value) ? ChatColor.GREEN : ChatColor.RED) + " " + value; sender.sendMessage(ChatColor.GOLD + args[1] + " " + option); // Special case for load-on-request if (toggle == MinecraftServer.getServer().cauldronConfig.loadChunkOnRequest) { for (net.minecraft.world.WorldServer world : MinecraftServer.getServer().worlds) { world.theChunkProviderServer.loadChunkOnProvideRequest = MinecraftServer.getServer().cauldronConfig.loadChunkOnRequest.getValue(); } } MinecraftServer.getServer().cauldronConfig.save(); } catch (Exception ex) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); ex.printStackTrace(); } return true; }
Example 20
Source File: EntityDrone.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
private void initializeFakePlayer(){ fakePlayer = new DroneFakePlayer((WorldServer)worldObj, new GameProfile(playerUUID != null ? UUID.fromString(playerUUID) : null, playerName), new FakePlayerItemInWorldManager(worldObj, fakePlayer, this), this); fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), new NetworkManager(false), fakePlayer); fakePlayer.inventory = new InventoryFakePlayer(fakePlayer); }