Java 类net.minecraft.world.WorldServer 实例源码

项目:BaseClient    文件:EntityThrowable.java   
public EntityLivingBase getThrower()
{
    if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0)
    {
        this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);

        if (this.thrower == null && this.worldObj instanceof WorldServer)
        {
            try
            {
                Entity entity = ((WorldServer)this.worldObj).getEntityFromUuid(UUID.fromString(this.throwerName));

                if (entity instanceof EntityLivingBase)
                {
                    this.thrower = (EntityLivingBase)entity;
                }
            }
            catch (Throwable var2)
            {
                this.thrower = null;
            }
        }
    }

    return this.thrower;
}
项目:HardVox    文件:SelectionListener.java   
private void dueProcess(PlayerInteractEvent event, BiFunction<RegionSelector<?, ?>, Vector3i, String> selector) {
    if (event.getWorld().isRemote) {
        // don't process on client
        // perhaps we can cancel on client if we do config sync
        return;
    }

    if (event.getItemStack().getItem() == HardVoxConfig.getSelectionWand()) {
        // cancel event, fire selection
        event.setCanceled(true);

        WorldServer ws = (WorldServer) event.getWorld();
        SessionManager.getInstance()
                .getSession(ws.getMinecraftServer(), event.getEntityPlayer())
                .performRegionCommand(sel -> selector.apply(sel, VecBridge.toFlow(event.getPos())));
        // send an update to the player so the block re-appears?
        ws.getPlayerChunkMap().markBlockForUpdate(event.getPos());
    }
}
项目:BaseClient    文件:MinecraftServer.java   
public Entity getEntityFromUuid(UUID uuid)
{
    for (WorldServer worldserver : this.worldServers)
    {
        if (worldserver != null)
        {
            Entity entity = worldserver.getEntityFromUuid(uuid);

            if (entity != null)
            {
                return entity;
            }
        }
    }

    return null;
}
项目:Uranium    文件:CraftPlayer.java   
public void showPlayer(Player player) {
    Validate.notNull(player, "shown player cannot be null");
    if (getHandle().playerNetServerHandler == null) return;
    if (equals(player)) return;
    if (!hiddenPlayers.contains(player.getUniqueId())) return;
    hiddenPlayers.remove(player.getUniqueId());

    EntityTracker tracker = ((WorldServer) entity.worldObj).theEntityTracker;
    EntityPlayerMP other = ((CraftPlayer) player).getHandle();
    EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntityIDs.lookup(other.getEntityId());
    if (entry != null) {
        entry.removePlayerFromTracker(getHandle());
    }

    getHandle().playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(player.getPlayerListName(), false, 9999));
}
项目:Backmemed    文件:TileEntityStructure.java   
public boolean save(boolean p_189712_1_)
{
    if (this.mode == TileEntityStructure.Mode.SAVE && !this.world.isRemote && !StringUtils.isNullOrEmpty(this.name))
    {
        BlockPos blockpos = this.getPos().add(this.position);
        WorldServer worldserver = (WorldServer)this.world;
        MinecraftServer minecraftserver = this.world.getMinecraftServer();
        TemplateManager templatemanager = worldserver.getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
        template.takeBlocksFromWorld(this.world, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(this.author);
        return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
    }
    else
    {
        return false;
    }
}
项目:PurificatiMagicae    文件:SifStorageServer.java   
@Override
public void set(GlobalChunkPos pos, float value)
{
    if (loaded.containsKey(pos))
        if (loaded.get(pos).equals(value))
            return;
    loaded.put(pos, value);
    WorldServer wrld = DimensionManager.getWorld(pos.getDimension());
    wrld.getChunkFromChunkCoords(pos.getX(), pos.getZ()).markDirty();
    PlayerChunkMapEntry map = wrld.getPlayerChunkMap().getEntry(pos.getX(), pos.getZ());
    if (map != null)
    {
        for (EntityPlayerMP p : map.players)
        {
            NetworkManager.sendTo(new CPacketSyncSif(pos, value), p);
        }
    }
}
项目:Proyecto-DASI    文件:ObservationFromServer.java   
/** IMPORTANT: Call this from the onMessage method in the subclass. */
public IMessage processMessage(final ObservationRequestMessage message, final MessageContext ctx)
{
    IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.worldObj;
    mainThread.addScheduledTask(new Runnable() {
        @Override
        public void run() {
            EntityPlayerMP player = ctx.getServerHandler().playerEntity;
            JsonObject json = new JsonObject();
            buildJson(json, player, message, ctx);
            // Send this message back again now we've filled in the json stats.
            Map<String, String> returnData = new HashMap<String, String>();
            returnData.put("json", json.toString());
            message.addReturnData(returnData);
            MalmoMod.network.sendTo(new MalmoMod.MalmoMessage(MalmoMessageType.SERVER_OBSERVATIONSREADY, message.id, returnData), player);
        }
    });
    return null; // no response in this case
}
项目:Infernum    文件:InfernalMonumentGenerator.java   
@Override
public boolean generate(World worldIn, Random rand, BlockPos posIn) {

    if (!(worldIn instanceof WorldServer)) {
        return false;
    }

    WorldServer world = (WorldServer) worldIn;

    if (world.provider.getDimension() != -1) {
        return false;
    }

    if (world.rand.nextInt(rarity) == 0) {
        int y = findPosY(world, posIn);
        if (y > 0) {
            BlockPos pos = new BlockPos(posIn.getX(), findPosY(world, posIn), posIn.getZ());
            generateMonument(world, pos, rand);
        }
        return true;
    }

    return false;

}
项目:Infernum    文件:SpellSoulDrain.java   
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
    if (!world.isRemote) {
        BlockPos centerPos = player.getPosition();
        AxisAlignedBB area = new AxisAlignedBB(centerPos).expandXyz(3F);
        for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(player, area)) {
            if (entity instanceof EntityLivingBase) {
                WorldServer worldServer = (WorldServer) world;
                if (player.getItemInUseCount() % 10 == 0 && consumePower(player)) {
                    MessageSoulDrainFX message = new MessageSoulDrainFX(entity.posX,
                            entity.posY + (entity.height / 2.0F), entity.posZ, player.posX,
                            player.posY + (player.height / 2.0F), player.posZ);
                    PacketHandler.INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(
                            player.dimension, player.posX, player.posY, player.posZ, 128));
                    entity.attackEntityFrom(DamageSource.magic, 1);
                    world.spawnEntity(new EntityXPOrb(world, entity.posX, entity.posY + 0.5, entity.posZ, 1));
                }
            }
        }
    }
}
项目:Backmemed    文件:EntityShulkerBullet.java   
protected void bulletHit(RayTraceResult result)
{
    if (result.entityHit == null)
    {
        ((WorldServer)this.world).spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 2, 0.2D, 0.2D, 0.2D, 0.0D, new int[0]);
        this.playSound(SoundEvents.ENTITY_SHULKER_BULLET_HIT, 1.0F, 1.0F);
    }
    else
    {
        boolean flag = result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.owner).setProjectile(), 4.0F);

        if (flag)
        {
            this.applyEnchantments(this.owner, result.entityHit);

            if (result.entityHit instanceof EntityLivingBase)
            {
                ((EntityLivingBase)result.entityHit).addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200));
            }
        }
    }

    this.setDead();
}
项目:CustomWorldGen    文件:PlayerList.java   
public void setViewDistance(int distance)
{
    this.viewDistance = distance;

    if (this.mcServer.worldServers != null)
    {
        for (WorldServer worldserver : this.mcServer.worldServers)
        {
            if (worldserver != null)
            {
                worldserver.getPlayerChunkMap().setPlayerViewRadius(distance);
                worldserver.getEntityTracker().setViewDistance(distance);
            }
        }
    }
}
项目:CraftingParadiseMod    文件:HandlerWorldCraft.java   
@Override
public IMessage onMessage(final MessageWorldCraft message, final MessageContext ctx)
{
    if(ctx.side != Side.SERVER)
    {
        System.err.println("MessageWorldCraft received on wrong side:" + ctx.side);
        return null;
    }

    final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player;
    if(sendingPlayer == null)
    {
        System.err.println("MessageWorldCraft received with null player.");
        return null;
    }

    final WorldServer playerWorldServer = sendingPlayer.getServerWorld();
    playerWorldServer.addScheduledTask(() -> processMessage(message, ctx, playerWorldServer));
    return null;
}
项目:CustomWorldGen    文件:EntityLivingBase.java   
/**
 * Called when the entity picks up an item.
 */
public void onItemPickup(Entity entityIn, int quantity)
{
    if (!entityIn.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (entityIn instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
        }

        if (entityIn instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
        }

        if (entityIn instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
        }
    }
}
项目:DecompiledMinecraft    文件:MinecraftServer.java   
public Entity getEntityFromUuid(UUID uuid)
{
    for (WorldServer worldserver : this.worldServers)
    {
        if (worldserver != null)
        {
            Entity entity = worldserver.getEntityFromUuid(uuid);

            if (entity != null)
            {
                return entity;
            }
        }
    }

    return null;
}
项目:Backmemed    文件:PlayerList.java   
/**
 * Updates the time and weather for the given player to those of the given world
 */
public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn)
{
    WorldBorder worldborder = this.mcServer.worldServers[0].getWorldBorder();
    playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE));
    playerIn.connection.sendPacket(new SPacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));
    BlockPos blockpos = worldIn.getSpawnPoint();
    playerIn.connection.sendPacket(new SPacketSpawnPosition(blockpos));

    if (worldIn.isRaining())
    {
        playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F));
        playerIn.connection.sendPacket(new SPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
        playerIn.connection.sendPacket(new SPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
    }
}
项目:DecompiledMinecraft    文件:MinecraftServer.java   
/**
 * par1 indicates if a log message should be output.
 */
protected void saveAllWorlds(boolean dontLog)
{
    if (!this.worldIsBeingDeleted)
    {
        for (WorldServer worldserver : this.worldServers)
        {
            if (worldserver != null)
            {
                if (!dontLog)
                {
                    logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName());
                }

                try
                {
                    worldserver.saveAllChunks(true, (IProgressUpdate)null);
                }
                catch (MinecraftException minecraftexception)
                {
                    logger.warn(minecraftexception.getMessage());
                }
            }
        }
    }
}
项目:TheOink    文件:OinkWorldGenerator.java   
private void generateOverworldStructures(World world, Random random, int posX, int posZ) {

        if(OinkConfig.piggyActive) {
            WorldServer server = (WorldServer) world;
            TemplateManager manager = server.getStructureTemplateManager();

            Template piggy = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(TheOink.MODID, "pigstructure"));

            if ((int) (Math.random() * OinkConfig.piggyStructChance) == 0) {
                int randX = posX + (int) (Math.random() * 16);
                int randZ = posZ + (int) (Math.random() * 16);
                int groundY = getGroundFromAbove(world, randX, randZ);
                BlockPos pos = new BlockPos(randX, groundY, randZ);

                if (canSpawnHere(piggy, world, pos)) {
                    TheOink.LOGGER.info("Generating Pig at " + pos);
                    piggy.addBlocksToWorld(world, pos, new PlacementSettings());
                    handleDataBlocks(piggy, world, pos, new PlacementSettings());
                }
            }
        }
    }
项目:DecompiledMinecraft    文件:ServerConfigurationManager.java   
/**
 * moves provided player from overworld to nether or vice versa
 */
public void transferPlayerToDimension(EntityPlayerMP playerIn, int dimension)
{
    int i = playerIn.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.dimension = dimension;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.playerNetServerHandler.sendPacket(new S07PacketRespawn(playerIn.dimension, playerIn.worldObj.getDifficulty(), playerIn.worldObj.getWorldInfo().getTerrainType(), playerIn.theItemInWorldManager.getGameType()));
    worldserver.removePlayerEntityDangerously(playerIn);
    playerIn.isDead = false;
    this.transferEntityToWorld(playerIn, i, worldserver, worldserver1);
    this.preparePlayer(playerIn, worldserver);
    playerIn.playerNetServerHandler.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.theItemInWorldManager.setWorld(worldserver1);
    this.updateTimeAndWeatherForPlayer(playerIn, worldserver1);
    this.syncPlayerInventory(playerIn);

    for (PotionEffect potioneffect : playerIn.getActivePotionEffects())
    {
        playerIn.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), potioneffect));
    }
}
项目:DecompiledMinecraft    文件:MinecraftServer.java   
public Entity getEntityFromUuid(UUID uuid)
{
    for (WorldServer worldserver : this.worldServers)
    {
        if (worldserver != null)
        {
            Entity entity = worldserver.getEntityFromUuid(uuid);

            if (entity != null)
            {
                return entity;
            }
        }
    }

    return null;
}
项目:Loot-Slash-Conquer    文件:CustomLootTable.java   
@Override
public void fillInventory(IInventory inventory, Random rand, LootContext context)
{
    TileEntityChest chest = (TileEntityChest) inventory;
    CustomLootContext.Builder context$builder = new CustomLootContext.Builder((WorldServer) chest.getWorld());
    context$builder.withChestPos(chest.getPos());
    CustomLootContext customContext = context$builder.build();

    List<ItemStack> list = this.generateLootForPools(rand, customContext);
    List<Integer> list1 = this.getEmptySlotsRandomized(inventory, rand);
    this.shuffleItems(list, list1.size(), rand);

    for (ItemStack itemstack : list)
    {
        if (list1.isEmpty())
        {
            LootSlashConquer.LOGGER.warn("Tried to over-fill a container");
            return;
        }

        if (itemstack.isEmpty())
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), ItemStack.EMPTY);
        }
        else
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), itemstack);
        }
    }
}
项目:BaseClient    文件:MinecraftServer.java   
/**
 * Saves all necessary data as preparation for stopping the server.
 */
public void stopServer()
{
    if (!this.worldIsBeingDeleted)
    {
        logger.info("Stopping server");

        if (this.getNetworkSystem() != null)
        {
            this.getNetworkSystem().terminateEndpoints();
        }

        if (this.serverConfigManager != null)
        {
            logger.info("Saving players");
            this.serverConfigManager.saveAllPlayerData();
            this.serverConfigManager.removeAllPlayers();
        }

        if (this.worldServers != null)
        {
            logger.info("Saving worlds");
            this.saveAllWorlds(false);

            for (int i = 0; i < this.worldServers.length; ++i)
            {
                WorldServer worldserver = this.worldServers[i];
                worldserver.flush();
            }
        }

        if (this.usageSnooper.isSnooperRunning())
        {
            this.usageSnooper.stopSnooper();
        }
    }
}
项目:BaseClient    文件:ServerConfigurationManager.java   
public void preparePlayer(EntityPlayerMP playerIn, WorldServer worldIn)
{
    WorldServer worldserver = playerIn.getServerForPlayer();

    if (worldIn != null)
    {
        worldIn.getPlayerManager().removePlayer(playerIn);
    }

    worldserver.getPlayerManager().addPlayer(playerIn);
    worldserver.theChunkProviderServer.loadChunk((int)playerIn.posX >> 4, (int)playerIn.posZ >> 4);
}
项目:BaseClient    文件:CommandSaveOff.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    boolean flag = false;

    for (int i = 0; i < minecraftserver.worldServers.length; ++i)
    {
        if (minecraftserver.worldServers[i] != null)
        {
            WorldServer worldserver = minecraftserver.worldServers[i];

            if (!worldserver.disableLevelSaving)
            {
                worldserver.disableLevelSaving = true;
                flag = true;
            }
        }
    }

    if (flag)
    {
        notifyOperators(sender, this, "commands.save.disabled", new Object[0]);
    }
    else
    {
        throw new CommandException("commands.save-off.alreadyOff", new Object[0]);
    }
}
项目:Backmemed    文件:LootContext.java   
public LootContext(float luckIn, WorldServer worldIn, LootTableManager lootTableManagerIn, @Nullable Entity lootedEntityIn, @Nullable EntityPlayer playerIn, @Nullable DamageSource damageSourceIn)
{
    this.luck = luckIn;
    this.worldObj = worldIn;
    this.lootTableManager = lootTableManagerIn;
    this.lootedEntity = lootedEntityIn;
    this.player = playerIn;
    this.damageSource = damageSourceIn;
}
项目:pnc-repressurized    文件:TileEntityProgrammableController.java   
private void initializeFakePlayer() {
    String playerName = "Drone";
    fakePlayer = new DroneFakePlayer((WorldServer) getWorld(), new GameProfile(null, playerName), this);
    fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {
        private ItemStack oldStack;

        @Override
        public int getSizeInventory() {
            return getDroneSlots();
        }

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                for (EntityEquipmentSlot ee : EntityEquipmentSlot.values()) {
                    if (!oldStack.isEmpty()) {
                        getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers(ee));
                    }
                    if (!stack.isEmpty()) {
                        getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(ee));
                    }
                }
                oldStack = stack;
            }
        }
    };
}
项目:BaseClient    文件:ServerConfigurationManager.java   
public void preparePlayer(EntityPlayerMP playerIn, WorldServer worldIn)
{
    WorldServer worldserver = playerIn.getServerForPlayer();

    if (worldIn != null)
    {
        worldIn.getPlayerManager().removePlayer(playerIn);
    }

    worldserver.getPlayerManager().addPlayer(playerIn);
    worldserver.theChunkProviderServer.loadChunk((int)playerIn.posX >> 4, (int)playerIn.posZ >> 4);
}
项目:Genesis    文件:GenesisTeleporter.java   
public GenesisTeleporter(WorldServer world) {
    super(world);

    if (!world.customTeleporters.contains(this)) {
        world.customTeleporters.add(this);
    }
}
项目:HardVox    文件:OpSendChunks.java   
@Override
public int performOperation(Region region, PositionIterator chunk, World world, Chunk c, VectorMap<BlockData> blockMap,
        MutableVectorMap<IBlockState> hitStore) {
    // send the whole chunk again
    PlayerChunkMapEntry entry = ((WorldServer) world).getPlayerChunkMap().getEntry(c.x, c.z);
    if (entry != null) {
        entry.sendPacket(new SPacketChunkData(c, SPCD_SEND_ALL));
    }
    return 1;
}
项目:DecompiledMinecraft    文件:EntityLivingBase.java   
/**
 * Swings the item the player is holding.
 */
public void swingItem()
{
    if (!this.isSwingInProgress || this.swingProgressInt >= this.getArmSwingAnimationEnd() / 2 || this.swingProgressInt < 0)
    {
        this.swingProgressInt = -1;
        this.isSwingInProgress = true;

        if (this.worldObj instanceof WorldServer)
        {
            ((WorldServer)this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new S0BPacketAnimation(this, 0));
        }
    }
}
项目:World-Border    文件:CmdSetcorners.java   
@Override
public void execute(ICommandSender sender, EntityPlayerMP player, List<String> params, String worldName)
{
    if (worldName == null)
        worldName = Worlds.getWorldName(player.worldObj);
    else
    {
        WorldServer worldTest = Worlds.getWorld(worldName);
        if (worldTest == null)
            Util.chat(sender, "The world you specified (\"" + worldName + "\") could not be found on the server, but data for it will be stored anyway.");
    }

    try
    {
        double x1 = Double.parseDouble(params.get(0));
        double z1 = Double.parseDouble(params.get(1));
        double x2 = Double.parseDouble(params.get(2));
        double z2 = Double.parseDouble(params.get(3));
        Config.setBorderCorners(worldName, x1, z1, x2, z2);
    }
    catch(NumberFormatException ex)
    {
        sendErrorAndHelp(sender, "The x1, z1, x2, and z2 coordinate values must be numerical.");
        return;
    }

    if(player != null)
        Util.chat(sender, "Border has been set. " + Config.BorderDescription(worldName));
}
项目:CustomWorldGen    文件:CommandTime.java   
protected void incrementAllWorldTimes(MinecraftServer server, int amount)
{
    for (int i = 0; i < server.worldServers.length; ++i)
    {
        WorldServer worldserver = server.worldServers[i];
        worldserver.setWorldTime(worldserver.getWorldTime() + (long)amount);
    }
}
项目:VoidApi    文件:HandlerTileData.java   
@Override
public void handleData(NBTTagCompound data) 
{
    DimBlockPos dbp = new DimBlockPos();
    dbp.deserializeNBT(data.getCompoundTag("blockPosData"));
    NBTTagCompound tileData = data.getCompoundTag("tileData");
    if (MC.getSide() == Side.CLIENT)
    {
        VoidApi.proxy.getClientListener().addScheduledTask(() -> {
                if (VoidApi.proxy.getClientWorld().isBlockLoaded(dbp.pos) && VoidApi.proxy.getClientWorld().getTileEntity(dbp.pos) != null)
                   {
                       Optional.ofNullable(VoidApi.proxy.getClientWorld().getTileEntity(dbp.pos)).ifPresent(t -> t.deserializeNBT(tileData));
                   }

                VoidApi.proxy.getClientWorld().markBlockRangeForRenderUpdate(dbp.pos.down().north().west(), dbp.pos.up().west().south());
        });
    }
    else
    {
        // Server deserializing a tile from client data?..
        WorldServer ws = DimensionManager.getWorld(dbp.dim);
        ws.addScheduledTask(() -> {
                if (ws.isBlockLoaded(dbp.pos) && ws.getTileEntity(dbp.pos) != null)
                   {
                       Optional.ofNullable(ws.getTileEntity(dbp.pos)).ifPresent(t -> t.deserializeNBT(tileData));
                   }
        });
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayServer.java   
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        double dist = playerEntity.interactionManager.getBlockReachDistance() + 3;
        dist *= dist;
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
    itemstack = this.playerEntity.getHeldItem(enumhand);

    if (itemstack != null && itemstack.stackSize == 0)
    {
        this.playerEntity.setHeldItem(enumhand, (ItemStack)null);
        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.playerEntity, itemstack, enumhand);
    }
}
项目:harshencastle    文件:HarshenSoulOre.java   
@Override
public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) {
    if(world != null && pos != null)
    if (world instanceof WorldServer)
        ((WorldServer)world).spawnParticle(EnumParticleTypes.CLOUD, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 4,  0.7, 0.8, 0.6, 0, new int[EnumParticleTypes.CLOUD.getArgumentCount()]);
    return super.addHitEffects(state, worldObj, target, manager);
}
项目:Backmemed    文件:NetHandlerPlayServer.java   
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation, (byte)2));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
项目:BaseClient    文件:CommandSaveOn.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    boolean flag = false;

    for (int i = 0; i < minecraftserver.worldServers.length; ++i)
    {
        if (minecraftserver.worldServers[i] != null)
        {
            WorldServer worldserver = minecraftserver.worldServers[i];

            if (worldserver.disableLevelSaving)
            {
                worldserver.disableLevelSaving = false;
                flag = true;
            }
        }
    }

    if (flag)
    {
        notifyOperators(sender, this, "commands.save.enabled", new Object[0]);
    }
    else
    {
        throw new CommandException("commands.save-on.alreadyOn", new Object[0]);
    }
}
项目:DecompiledMinecraft    文件:ServerConfigurationManager.java   
/**
 * Called when a player disconnects from the game. Writes player data to disk and removes them from the world.
 */
public void playerLoggedOut(EntityPlayerMP playerIn)
{
    playerIn.triggerAchievement(StatList.leaveGameStat);
    this.writePlayerData(playerIn);
    WorldServer worldserver = playerIn.getServerForPlayer();

    if (playerIn.ridingEntity != null)
    {
        worldserver.removePlayerEntityDangerously(playerIn.ridingEntity);
        logger.debug("removing player mount");
    }

    worldserver.removeEntity(playerIn);
    worldserver.getPlayerManager().removePlayer(playerIn);
    this.playerEntityList.remove(playerIn);
    UUID uuid = playerIn.getUniqueID();
    EntityPlayerMP entityplayermp = (EntityPlayerMP)this.uuidToPlayerMap.get(uuid);

    if (entityplayermp == playerIn)
    {
        this.uuidToPlayerMap.remove(uuid);
        this.playerStatFiles.remove(uuid);
    }

    this.sendPacketToAllPlayers(new S38PacketPlayerListItem(S38PacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {playerIn}));
}
项目:InControl    文件:LostCitySupport.java   
public static <T> boolean isBuilding(IEventQuery<T> query, T event) {
    World world = query.getWorld(event);
    WorldServer ws = (WorldServer) world;
    if (ws.getChunkProvider().chunkGenerator instanceof ILostChunkGenerator) {
        ILostChunkGenerator gen = (ILostChunkGenerator) ws.getChunkProvider().chunkGenerator;
        BlockPos pos = query.getPos(event);
        ILostChunkInfo chunkInfo = gen.getChunkInfo(pos.getX() >> 4, pos.getZ() >> 4);
        return chunkInfo.isCity() && chunkInfo.getBuildingType() != null;
    }
    return false;
}
项目:InControl    文件:CmdKillMobs.java   
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length <= 0) {
        ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Use 'all', 'passive', 'hostile' or name of the mob followed by optional dimension id"));
        InControl.logger.error("Use 'all', 'passive', 'hostile', 'entity' or name of the mob followed by optional dimension id");
        return;
    }
    int dimension = (sender instanceof EntityPlayer) ? sender.getEntityWorld().provider.getDimension() : 0;
    if (args.length > 1) {
        dimension = Integer.parseInt(args[1]);
    }
    String arg0 = args[0].toLowerCase();
    boolean all = "all".equals(arg0);
    boolean passive = "passive".equals(arg0);
    boolean hostile = "hostile".equals(arg0);
    boolean entity = "entity".equals(arg0);

    WorldServer worldServer = server.worldServerForDimension(dimension);
    List<Entity> entities = worldServer.getEntities(Entity.class, input -> {
        if (all) {
            return !(input instanceof EntityPlayer);
        } else if (passive) {
            return input instanceof IAnimals && !(input instanceof IMob);
        } else if (hostile) {
            return input instanceof IMob;
        } else if (entity) {
            return !(input instanceof IAnimals) && !(input instanceof EntityPlayer);
        } else {
            String id = EntityTools.findEntityIdByClass(input.getClass());
            return arg0.equals(id);
        }
    });
    for (Entity e : entities) {
        worldServer.removeEntity(e);
    }
    ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.YELLOW + "Removed " + entities.size() + " entities!"));
}
项目:Backmemed    文件:EntityShulkerBullet.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (!this.world.isRemote)
    {
        this.playSound(SoundEvents.ENTITY_SHULKER_BULLET_HURT, 1.0F, 1.0F);
        ((WorldServer)this.world).spawnParticle(EnumParticleTypes.CRIT, this.posX, this.posY, this.posZ, 15, 0.2D, 0.2D, 0.2D, 0.0D, new int[0]);
        this.setDead();
    }

    return true;
}