Search in sources :

Example 66 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project BloodMagic by WayofTime.

the class ComplexNetworkHandler method getPlayerFromUUID.

public static EntityPlayer getPlayerFromUUID(UUID uuid) {
    MinecraftServer server = MinecraftServer.getServer();
    GameProfile gameProfile;
    gameProfile = server.func_152358_ax().func_152652_a(uuid);
    String str = uuid.toString();
    // TODO ServerConfigurationManager d.createPlayerForUser
    UUID.fromString(str);
    return null;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 67 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project artisan-worktables by codetaylor.

the class Util method anyPlayerHasContainerOpen.

public static boolean anyPlayerHasContainerOpen(WorldServer world, BlockPos pos) {
    MinecraftServer minecraftServer = world.getMinecraftServer();
    PlayerList playerList = minecraftServer.getPlayerList();
    List<EntityPlayerMP> players = playerList.getPlayers();
    for (EntityPlayerMP entityPlayerMP : players) {
        if (entityPlayerMP.openContainer instanceof AWContainer) {
            TileEntityBase tile = ((AWContainer) entityPlayerMP.openContainer).getTile();
            if (tile.getPos().equals(pos)) {
                return true;
            }
        }
    }
    return false;
}
Also used : AWContainer(com.codetaylor.mc.artisanworktables.modules.worktables.gui.AWContainer) PlayerList(net.minecraft.server.management.PlayerList) TileEntityBase(com.codetaylor.mc.artisanworktables.modules.worktables.tile.spi.TileEntityBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 68 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project Galacticraft by micdoodle8.

the class VenusTickHandlerServer method onServerTick.

@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    // Prevent issues when clients switch to LAN servers
    if (server == null) {
        return;
    }
    if (event.phase == Phase.END) {
        for (SolarModuleNetwork network : new ArrayList<>(solarModuleNetworks)) {
            if (!network.getTransmitters().isEmpty()) {
            // network.tickEnd();
            } else {
                solarModuleNetworks.remove(network);
            }
        }
        int maxPasses = 10;
        while (!solarTransmitterUpdates.isEmpty()) {
            LinkedList<TileEntitySolarTransmitter> pass = new LinkedList<>();
            pass.addAll(solarTransmitterUpdates);
            solarTransmitterUpdates.clear();
            for (TileEntitySolarTransmitter newTile : pass) {
                if (!newTile.isInvalid()) {
                    newTile.refresh();
                }
            }
            if (--maxPasses <= 0) {
                break;
            }
        }
    }
}
Also used : TileEntitySolarTransmitter(micdoodle8.mods.galacticraft.planets.venus.tile.TileEntitySolarTransmitter) SolarModuleNetwork(micdoodle8.mods.galacticraft.planets.venus.tile.SolarModuleNetwork) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) MinecraftServer(net.minecraft.server.MinecraftServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 69 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project Galacticraft by micdoodle8.

the class EntityTieredRocket method onUpdate.

@Override
public void onUpdate() {
    if (this.getWaitForPlayer()) {
        if (!this.getPassengers().isEmpty()) {
            Entity passenger = this.getPassengers().get(0);
            if (this.ticks >= 40) {
                if (!this.world.isRemote) {
                    this.removePassengers();
                    passenger.startRiding(this, true);
                    GCLog.debug("Remounting player in rocket.");
                }
                this.setWaitForPlayer(false);
                this.motionY = -0.5D;
            } else {
                this.motionX = this.motionY = this.motionZ = 0.0D;
                passenger.motionX = passenger.motionY = passenger.motionZ = 0;
            }
        } else {
            this.motionX = this.motionY = this.motionZ = 0.0D;
        }
    }
    super.onUpdate();
    if (!this.world.isRemote) {
        if (this.launchCooldown > 0) {
            this.launchCooldown--;
        }
        if (this.preGenIterator != null) {
            if (this.preGenIterator.hasNext()) {
                MinecraftServer mcserver;
                if (this.world instanceof WorldServer) {
                    mcserver = ((WorldServer) this.world).getMinecraftServer();
                    BlockVec3 coords = this.preGenIterator.next();
                    World w = mcserver.getWorld(coords.y);
                    if (w != null) {
                        w.getChunkFromChunkCoords(coords.x, coords.z);
                        // Pregen a second chunk if still on launchpad (low strain on server)
                        if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal() && this.preGenIterator.hasNext()) {
                            coords = this.preGenIterator.next();
                            w = mcserver.getWorld(coords.y);
                            w.getChunkFromChunkCoords(coords.x, coords.z);
                        }
                    }
                }
            } else {
                this.preGenIterator = null;
                EntityTieredRocket.preGenInProgress = false;
            }
        }
    }
    if (this.rumble > 0) {
        this.rumble--;
    } else if (this.rumble < 0) {
        this.rumble++;
    }
    final double rumbleAmount = this.rumble / (double) (37 - 5 * Math.max(this.getRocketTier(), 5));
    for (Entity passenger : this.getPassengers()) {
        passenger.posX += rumbleAmount;
        passenger.posZ += rumbleAmount;
    }
    if (this.launchPhase >= EnumLaunchPhase.IGNITED.ordinal()) {
        this.performHurtAnimation();
        this.rumble = (float) this.rand.nextInt(3) - 3;
    }
    if (!this.world.isRemote) {
        this.lastLastMotionY = this.lastMotionY;
        this.lastMotionY = this.motionY;
    }
}
Also used : ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 70 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project Galacticraft by micdoodle8.

the class WorldUtil method transferEntityToDimension.

/**
 * It is not necessary to use entity.setDead() following calling this method.
 * If the entity left the old world it was in, it will now automatically be removed from that old world before the next update tick.
 * (See WorldUtil.removeEntityFromWorld())
 */
public static Entity transferEntityToDimension(Entity entity, int dimensionID, WorldServer world, boolean transferInv, EntityAutoRocket ridingRocket) {
    if (!world.isRemote) {
        // GalacticraftCore.packetPipeline.sendToAll(new PacketSimple(EnumSimplePacket.C_UPDATE_PLANETS_LIST, WorldUtil.getPlanetList()));
        MinecraftServer mcServer = world.getMinecraftServer();
        if (mcServer != null) {
            final WorldServer var6 = mcServer.getWorld(dimensionID);
            if (var6 == null) {
                System.err.println("Cannot Transfer Entity to Dimension: Could not get World for Dimension " + dimensionID);
                return null;
            }
            final ITeleportType type = GalacticraftRegistry.getTeleportTypeForDimension(var6.provider.getClass());
            if (type != null) {
                return WorldUtil.teleportEntity(var6, entity, dimensionID, type, transferInv, ridingRocket);
            }
        }
    }
    return null;
}
Also used : ITeleportType(micdoodle8.mods.galacticraft.api.world.ITeleportType) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

MinecraftServer (net.minecraft.server.MinecraftServer)166 WorldServer (net.minecraft.world.WorldServer)35 BlockPos (net.minecraft.util.math.BlockPos)34 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)31 Player (org.spongepowered.api.entity.living.player.Player)30 PlayerConnection (org.spongepowered.api.network.PlayerConnection)30 CommandException (net.minecraft.command.CommandException)19 World (net.minecraft.world.World)18 Template (net.minecraft.world.gen.structure.template.Template)18 TextComponentString (net.minecraft.util.text.TextComponentString)16 ICommandSender (net.minecraft.command.ICommandSender)15 Entity (net.minecraft.entity.Entity)15 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)15 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 ResourceLocation (net.minecraft.util.ResourceLocation)14 Rotation (net.minecraft.util.Rotation)12 RCConfig (ivorius.reccomplex.RCConfig)11 TileEntity (net.minecraft.tileentity.TileEntity)11 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)10