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;
}
java类net.minecraft.world.WorldServer的实例源码
EntityThrowable.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
SelectionListener.java 文件源码
项目:HardVox
阅读 25
收藏 0
点赞 0
评论 0
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());
}
}
MinecraftServer.java 文件源码
项目:BaseClient
阅读 25
收藏 0
点赞 0
评论 0
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;
}
CraftPlayer.java 文件源码
项目:Uranium
阅读 18
收藏 0
点赞 0
评论 0
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));
}
TileEntityStructure.java 文件源码
项目:Backmemed
阅读 25
收藏 0
点赞 0
评论 0
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;
}
}
SifStorageServer.java 文件源码
项目:PurificatiMagicae
阅读 17
收藏 0
点赞 0
评论 0
@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);
}
}
}
ObservationFromServer.java 文件源码
项目:Proyecto-DASI
阅读 19
收藏 0
点赞 0
评论 0
/** 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
}
InfernalMonumentGenerator.java 文件源码
项目:Infernum
阅读 17
收藏 0
点赞 0
评论 0
@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;
}
SpellSoulDrain.java 文件源码
项目:Infernum
阅读 18
收藏 0
点赞 0
评论 0
@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));
}
}
}
}
}
EntityShulkerBullet.java 文件源码
项目:Backmemed
阅读 20
收藏 0
点赞 0
评论 0
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();
}
PlayerList.java 文件源码
项目:CustomWorldGen
阅读 22
收藏 0
点赞 0
评论 0
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);
}
}
}
}
HandlerWorldCraft.java 文件源码
项目:CraftingParadiseMod
阅读 20
收藏 0
点赞 0
评论 0
@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;
}
EntityLivingBase.java 文件源码
项目:CustomWorldGen
阅读 18
收藏 0
点赞 0
评论 0
/**
* 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()));
}
}
}
MinecraftServer.java 文件源码
项目:DecompiledMinecraft
阅读 20
收藏 0
点赞 0
评论 0
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;
}
PlayerList.java 文件源码
项目:Backmemed
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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)));
}
}
MinecraftServer.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
}
}
}
OinkWorldGenerator.java 文件源码
项目:TheOink
阅读 17
收藏 0
点赞 0
评论 0
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());
}
}
}
}
ServerConfigurationManager.java 文件源码
项目:DecompiledMinecraft
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
MinecraftServer.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
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;
}
CustomLootTable.java 文件源码
项目:Loot-Slash-Conquer
阅读 17
收藏 0
点赞 0
评论 0
@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);
}
}
}
MinecraftServer.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
}
ServerConfigurationManager.java 文件源码
项目:BaseClient
阅读 20
收藏 0
点赞 0
评论 0
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);
}
CommandSaveOff.java 文件源码
项目:BaseClient
阅读 17
收藏 0
点赞 0
评论 0
/**
* 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]);
}
}
LootContext.java 文件源码
项目:Backmemed
阅读 17
收藏 0
点赞 0
评论 0
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;
}
TileEntityProgrammableController.java 文件源码
项目:pnc-repressurized
阅读 24
收藏 0
点赞 0
评论 0
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;
}
}
};
}
ServerConfigurationManager.java 文件源码
项目:BaseClient
阅读 20
收藏 0
点赞 0
评论 0
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);
}
GenesisTeleporter.java 文件源码
项目:Genesis
阅读 15
收藏 0
点赞 0
评论 0
public GenesisTeleporter(WorldServer world) {
super(world);
if (!world.customTeleporters.contains(this)) {
world.customTeleporters.add(this);
}
}
OpSendChunks.java 文件源码
项目:HardVox
阅读 21
收藏 0
点赞 0
评论 0
@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;
}
EntityLivingBase.java 文件源码
项目:DecompiledMinecraft
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
}
CmdSetcorners.java 文件源码
项目:World-Border
阅读 16
收藏 0
点赞 0
评论 0
@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));
}