本文整理匯總了Java中net.minecraft.world.WorldServer類的典型用法代碼示例。如果您正苦於以下問題:Java WorldServer類的具體用法?Java WorldServer怎麽用?Java WorldServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WorldServer類屬於net.minecraft.world包,在下文中一共展示了WorldServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getThrower
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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;
}
示例2: dueProcess
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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());
}
}
示例3: getEntityFromUuid
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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;
}
示例4: showPlayer
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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));
}
示例5: save
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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;
}
}
示例6: set
import net.minecraft.world.WorldServer; //導入依賴的package包/類
@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);
}
}
}
示例7: processMessage
import net.minecraft.world.WorldServer; //導入依賴的package包/類
/** 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
}
示例8: generate
import net.minecraft.world.WorldServer; //導入依賴的package包/類
@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;
}
示例9: onCastTick
import net.minecraft.world.WorldServer; //導入依賴的package包/類
@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));
}
}
}
}
}
示例10: bulletHit
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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();
}
示例11: setViewDistance
import net.minecraft.world.WorldServer; //導入依賴的package包/類
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);
}
}
}
}
示例12: onMessage
import net.minecraft.world.WorldServer; //導入依賴的package包/類
@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;
}
示例13: onItemPickup
import net.minecraft.world.WorldServer; //導入依賴的package包/類
/**
* 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()));
}
}
}
示例14: updateTimeAndWeatherForPlayer
import net.minecraft.world.WorldServer; //導入依賴的package包/類
/**
* 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)));
}
}
示例15: saveAllWorlds
import net.minecraft.world.WorldServer; //導入依賴的package包/類
/**
* 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());
}
}
}
}
}