Java 类net.minecraft.world.border.WorldBorder 实例源码

项目:DecompiledMinecraft    文件:World.java   
public boolean isInsideBorder(WorldBorder worldBorderIn, Entity entityIn)
{
    double d0 = worldBorderIn.minX();
    double d1 = worldBorderIn.minZ();
    double d2 = worldBorderIn.maxX();
    double d3 = worldBorderIn.maxZ();

    if (entityIn.isOutsideBorder())
    {
        ++d0;
        ++d1;
        --d2;
        --d3;
    }
    else
    {
        --d0;
        --d1;
        ++d2;
        ++d3;
    }

    return entityIn.posX > d0 && entityIn.posX < d2 && entityIn.posZ > d1 && entityIn.posZ < d3;
}
项目:DecompiledMinecraft    文件:World.java   
public boolean isInsideBorder(WorldBorder worldBorderIn, Entity entityIn)
{
    double d0 = worldBorderIn.minX();
    double d1 = worldBorderIn.minZ();
    double d2 = worldBorderIn.maxX();
    double d3 = worldBorderIn.maxZ();

    if (entityIn.isOutsideBorder())
    {
        ++d0;
        ++d1;
        --d2;
        --d3;
    }
    else
    {
        --d0;
        --d1;
        ++d2;
        ++d3;
    }

    return entityIn.posX > d0 && entityIn.posX < d2 && entityIn.posZ > d1 && entityIn.posZ < d3;
}
项目:BaseClient    文件:World.java   
public boolean isInsideBorder(WorldBorder worldBorderIn, Entity entityIn)
{
    double d0 = worldBorderIn.minX();
    double d1 = worldBorderIn.minZ();
    double d2 = worldBorderIn.maxX();
    double d3 = worldBorderIn.maxZ();

    if (entityIn.isOutsideBorder())
    {
        ++d0;
        ++d1;
        --d2;
        --d3;
    }
    else
    {
        --d0;
        --d1;
        ++d2;
        ++d3;
    }

    return entityIn.posX > d0 && entityIn.posX < d2 && entityIn.posZ > d1 && entityIn.posZ < d3;
}
项目:BaseClient    文件:World.java   
public boolean isInsideBorder(WorldBorder worldBorderIn, Entity entityIn)
{
    double d0 = worldBorderIn.minX();
    double d1 = worldBorderIn.minZ();
    double d2 = worldBorderIn.maxX();
    double d3 = worldBorderIn.maxZ();

    if (entityIn.isOutsideBorder())
    {
        ++d0;
        ++d1;
        --d2;
        --d3;
    }
    else
    {
        --d0;
        --d1;
        ++d2;
        ++d3;
    }

    return entityIn.posX > d0 && entityIn.posX < d2 && entityIn.posZ > d1 && entityIn.posZ < d3;
}
项目: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)));
    }
}
项目:CustomWorldGen    文件:World.java   
public boolean isInsideBorder(WorldBorder worldBorderIn, Entity entityIn)
{
    double d0 = worldBorderIn.minX();
    double d1 = worldBorderIn.minZ();
    double d2 = worldBorderIn.maxX();
    double d3 = worldBorderIn.maxZ();

    if (entityIn.isOutsideBorder())
    {
        ++d0;
        ++d1;
        --d2;
        --d3;
    }
    else
    {
        --d0;
        --d1;
        ++d2;
        ++d3;
    }

    return entityIn.posX > d0 && entityIn.posX < d2 && entityIn.posZ > d1 && entityIn.posZ < d3;
}
项目:justenoughdimensions    文件:WorldBorderUtils.java   
public static void setWorldBorderValues(World world)
{
    WorldBorder border = world.getWorldBorder();
    WorldInfo info = world.getWorldInfo();

    border.setCenter(info.getBorderCenterX(), info.getBorderCenterZ());
    border.setDamageAmount(info.getBorderDamagePerBlock());
    border.setDamageBuffer(info.getBorderSafeZone());
    border.setWarningDistance(info.getBorderWarningDistance());
    border.setWarningTime(info.getBorderWarningTime());

    if (info.getBorderLerpTime() > 0L)
    {
        border.setTransition(info.getBorderSize(), info.getBorderLerpTarget(), info.getBorderLerpTime());
    }
    else
    {
        border.setTransition(info.getBorderSize());
    }
}
项目:DecompiledMinecraft    文件:WorldProviderHell.java   
public WorldBorder getWorldBorder()
{
    return new WorldBorder()
    {
        public double getCenterX()
        {
            return super.getCenterX() / 8.0D;
        }
        public double getCenterZ()
        {
            return super.getCenterZ() / 8.0D;
        }
    };
}
项目:DecompiledMinecraft    文件:S44PacketWorldBorder.java   
public S44PacketWorldBorder(WorldBorder border, S44PacketWorldBorder.Action actionIn)
{
    this.action = actionIn;
    this.centerX = border.getCenterX();
    this.centerZ = border.getCenterZ();
    this.diameter = border.getDiameter();
    this.targetSize = border.getTargetSize();
    this.timeUntilTarget = border.getTimeUntilTarget();
    this.size = border.getSize();
    this.warningDistance = border.getWarningDistance();
    this.warningTime = border.getWarningTime();
}
项目:DecompiledMinecraft    文件:ServerConfigurationManager.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.playerNetServerHandler.sendPacket(new S44PacketWorldBorder(worldborder, S44PacketWorldBorder.Action.INITIALIZE));
    playerIn.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));

    if (worldIn.isRaining())
    {
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
    }
}
项目:DecompiledMinecraft    文件:WorldProviderHell.java   
public WorldBorder getWorldBorder()
{
    return new WorldBorder()
    {
        public double getCenterX()
        {
            return super.getCenterX() / 8.0D;
        }
        public double getCenterZ()
        {
            return super.getCenterZ() / 8.0D;
        }
    };
}
项目:DecompiledMinecraft    文件:S44PacketWorldBorder.java   
public S44PacketWorldBorder(WorldBorder border, S44PacketWorldBorder.Action actionIn)
{
    this.action = actionIn;
    this.centerX = border.getCenterX();
    this.centerZ = border.getCenterZ();
    this.diameter = border.getDiameter();
    this.targetSize = border.getTargetSize();
    this.timeUntilTarget = border.getTimeUntilTarget();
    this.size = border.getSize();
    this.warningDistance = border.getWarningDistance();
    this.warningTime = border.getWarningTime();
}
项目:DecompiledMinecraft    文件:ServerConfigurationManager.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.playerNetServerHandler.sendPacket(new S44PacketWorldBorder(worldborder, S44PacketWorldBorder.Action.INITIALIZE));
    playerIn.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));

    if (worldIn.isRaining())
    {
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
    }
}
项目:BaseClient    文件:WorldProviderHell.java   
public WorldBorder getWorldBorder()
{
    return new WorldBorder()
    {
        public double getCenterX()
        {
            return super.getCenterX() / 8.0D;
        }
        public double getCenterZ()
        {
            return super.getCenterZ() / 8.0D;
        }
    };
}
项目:BaseClient    文件:S44PacketWorldBorder.java   
public S44PacketWorldBorder(WorldBorder border, S44PacketWorldBorder.Action actionIn)
{
    this.action = actionIn;
    this.centerX = border.getCenterX();
    this.centerZ = border.getCenterZ();
    this.diameter = border.getDiameter();
    this.targetSize = border.getTargetSize();
    this.timeUntilTarget = border.getTimeUntilTarget();
    this.size = border.getSize();
    this.warningDistance = border.getWarningDistance();
    this.warningTime = border.getWarningTime();
}
项目:BaseClient    文件:ServerConfigurationManager.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.playerNetServerHandler.sendPacket(new S44PacketWorldBorder(worldborder, S44PacketWorldBorder.Action.INITIALIZE));
    playerIn.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));

    if (worldIn.isRaining())
    {
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
    }
}
项目:BaseClient    文件:WorldProviderHell.java   
public WorldBorder getWorldBorder()
{
    return new WorldBorder()
    {
        public double getCenterX()
        {
            return super.getCenterX() / 8.0D;
        }
        public double getCenterZ()
        {
            return super.getCenterZ() / 8.0D;
        }
    };
}
项目:BaseClient    文件:S44PacketWorldBorder.java   
public S44PacketWorldBorder(WorldBorder border, S44PacketWorldBorder.Action actionIn)
{
    this.action = actionIn;
    this.centerX = border.getCenterX();
    this.centerZ = border.getCenterZ();
    this.diameter = border.getDiameter();
    this.targetSize = border.getTargetSize();
    this.timeUntilTarget = border.getTimeUntilTarget();
    this.size = border.getSize();
    this.warningDistance = border.getWarningDistance();
    this.warningTime = border.getWarningTime();
}
项目:BaseClient    文件:ServerConfigurationManager.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.playerNetServerHandler.sendPacket(new S44PacketWorldBorder(worldborder, S44PacketWorldBorder.Action.INITIALIZE));
    playerIn.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));

    if (worldIn.isRaining())
    {
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
        playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
    }
}
项目:UniversalRemote    文件:WorldProviderProxyClient.java   
@Override
public WorldBorder createWorldBorder() {
    if(m_realProvider != null) {
        return m_realProvider.createWorldBorder();
    } else {
        return super.createWorldBorder();
    }
}
项目:UniversalRemote    文件:WorldServerProxy.java   
@Override
public WorldBorder getWorldBorder() {
    if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
        return m_proxyWorld.getWorldBorder();
    } else if (m_realWorld != null) {
        return m_realWorld.getWorldBorder();
    } else {
        return super.getWorldBorder();
    }
}
项目:UniversalRemote    文件:WorldProviderProxyServer.java   
@Override
public WorldBorder createWorldBorder() {
    if (m_proxyProvider != null && Util.isPrefixInCallStack(m_modPrefix)) {
        return m_proxyProvider.createWorldBorder();
    } else if (m_realProvider != null) {
        return m_realProvider.createWorldBorder();
    } else {
        return super.createWorldBorder();
    }
}
项目:LagGoggles    文件:Teleport.java   
private static void teleportPlayerToDimension(EntityPlayerMP playerIn, int suggestedDimensionId, double x, double y, double z) {
    WorldServer fromWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(playerIn.dimension);
    WorldServer toWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(suggestedDimensionId);
    playerIn.dimension = toWorld.provider.getDimension();
    ChunkPos pos = new ChunkPos(playerIn.getPosition());
    toWorld.getChunkProvider().loadChunk(pos.x, pos.z);
    final int dimensionId = playerIn.dimension;
    if (fromWorld != toWorld && fromWorld.provider.getDimensionType() == toWorld.provider.getDimensionType()) {
        playerIn.connection.sendPacket(new SPacketRespawn((dimensionId >= 0 ? -1 : 0), toWorld.getDifficulty(), toWorld.getWorldInfo().getTerrainType(), playerIn.interactionManager.getGameType()));
    }
    playerIn.connection.sendPacket(new SPacketRespawn(dimensionId, toWorld.getDifficulty(), toWorld.getWorldInfo().getTerrainType(), playerIn.interactionManager.getGameType()));
    fromWorld.removeEntityDangerously(playerIn);
    playerIn.isDead = false;
    playerIn.connection.setPlayerLocation(x, y, z, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.world = toWorld;
    playerIn.setWorld(toWorld);
    toWorld.spawnEntity(playerIn);
    toWorld.updateEntityWithOptionalForce(playerIn, false);
    WorldServer worldserver = playerIn.getServerWorld();
    fromWorld.getPlayerChunkMap().removePlayer(playerIn);
    worldserver.getPlayerChunkMap().addPlayer(playerIn);
    worldserver.getChunkProvider().provideChunk((int)playerIn.posX >> 4, (int)playerIn.posZ >> 4);
    playerIn.connection.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.interactionManager.setWorld(toWorld);
    WorldBorder worldborder = FMLCommonHandler.instance().getMinecraftServerInstance().worlds[0].getWorldBorder();
    playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE));
    playerIn.connection.sendPacket(new SPacketTimeUpdate(toWorld.getTotalWorldTime(), toWorld.getWorldTime(), toWorld.getGameRules().getBoolean("doDaylightCycle")));
    if (toWorld.isRaining()) {
        playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F));
        playerIn.connection.sendPacket(new SPacketChangeGameState(7, toWorld.getRainStrength(1.0F)));
        playerIn.connection.sendPacket(new SPacketChangeGameState(8, toWorld.getThunderStrength(1.0F)));
    }
    playerIn.sendContainerToPlayer(playerIn.inventoryContainer);
    playerIn.setPlayerHealthUpdated();
    playerIn.connection.sendPacket(new SPacketHeldItemChange(playerIn.inventory.currentItem));
}
项目:Backmemed    文件:WorldProviderHell.java   
public WorldBorder createWorldBorder()
{
    return new WorldBorder()
    {
        public double getCenterX()
        {
            return super.getCenterX() / 8.0D;
        }
        public double getCenterZ()
        {
            return super.getCenterZ() / 8.0D;
        }
    };
}
项目:Backmemed    文件:SPacketWorldBorder.java   
public SPacketWorldBorder(WorldBorder border, SPacketWorldBorder.Action actionIn)
{
    this.action = actionIn;
    this.centerX = border.getCenterX();
    this.centerZ = border.getCenterZ();
    this.diameter = border.getDiameter();
    this.targetSize = border.getTargetSize();
    this.timeUntilTarget = border.getTimeUntilTarget();
    this.size = border.getSize();
    this.warningDistance = border.getWarningDistance();
    this.warningTime = border.getWarningTime();
}
项目:CustomWorldGen    文件:WorldProviderHell.java   
public WorldBorder createWorldBorder()
{
    return new WorldBorder()
    {
        public double getCenterX()
        {
            return super.getCenterX() / 8.0D;
        }
        public double getCenterZ()
        {
            return super.getCenterZ() / 8.0D;
        }
    };
}
项目:CustomWorldGen    文件:SPacketWorldBorder.java   
public SPacketWorldBorder(WorldBorder border, SPacketWorldBorder.Action actionIn)
{
    this.action = actionIn;
    this.centerX = border.getCenterX();
    this.centerZ = border.getCenterZ();
    this.diameter = border.getDiameter();
    this.targetSize = border.getTargetSize();
    this.timeUntilTarget = border.getTimeUntilTarget();
    this.size = border.getSize();
    this.warningDistance = border.getWarningDistance();
    this.warningTime = border.getWarningTime();
}
项目:CustomWorldGen    文件:SPacketWorldBorder.java   
@SideOnly(Side.CLIENT)
public void apply(WorldBorder border)
{
    switch (this.action)
    {
        case SET_SIZE:
            border.setTransition(this.targetSize);
            break;
        case LERP_SIZE:
            border.setTransition(this.diameter, this.targetSize, this.timeUntilTarget);
            break;
        case SET_CENTER:
            border.setCenter(this.centerX, this.centerZ);
            break;
        case SET_WARNING_BLOCKS:
            border.setWarningDistance(this.warningDistance);
            break;
        case SET_WARNING_TIME:
            border.setWarningTime(this.warningTime);
            break;
        case INITIALIZE:
            border.setCenter(this.centerX, this.centerZ);

            if (this.timeUntilTarget > 0L)
            {
                border.setTransition(this.diameter, this.targetSize, this.timeUntilTarget);
            }
            else
            {
                border.setTransition(this.targetSize);
            }

            border.setSize(this.size);
            border.setWarningDistance(this.warningDistance);
            border.setWarningTime(this.warningTime);
    }
}
项目:CustomWorldGen    文件: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")));

    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)));
    }
}
项目:justenoughdimensions    文件:WorldUtils.java   
public static void findAndSetWorldSpawn(World world)
{
    WorldProvider provider = world.provider;
    NBTTagCompound nbt = WorldInfoUtils.getWorldInfoTag(world, provider.getDimension(), false, false);
    BlockPos pos = world.getSpawnPoint();

    if (nbt.hasKey("SpawnX") && nbt.hasKey("SpawnY") && nbt.hasKey("SpawnZ"))
    {
        JustEnoughDimensions.logInfo("WorldUtils.findAndSetWorldSpawn: Spawn point defined in dimension config " +
                                     "for dimension {}, skipping the search", provider.getDimension());
        pos = new BlockPos(nbt.getInteger("SpawnX"), nbt.getInteger("SpawnY"), nbt.getInteger("SpawnZ"));
    }
    else
    {
        JustEnoughDimensions.logInfo("WorldUtils.findAndSetWorldSpawn: Trying to find a world spawn for dimension {}...", provider.getDimension());
        pos = findSuitableSpawnpoint(world);
    }

    world.setSpawnPoint(pos);
    JustEnoughDimensions.logInfo("WorldUtils.findAndSetWorldSpawn: Set the world spawnpoint of dimension {} to {}", provider.getDimension(), pos);

    WorldBorder border = world.getWorldBorder();

    if (border.contains(pos) == false)
    {
        border.setCenter(pos.getX(), pos.getZ());
        JustEnoughDimensions.logInfo("WorldUtils.findAndSetWorldSpawn: Moved the WorldBorder of dimension {} " +
                                     "to the world's spawn, because the spawn was outside the border", provider.getDimension());
    }
}
项目:justenoughdimensions    文件:CommandTeleportJED.java   
public static Vec3d getClampedDestinationPosition(double x, double y, double z, World worldDst)
{
    WorldBorder border = worldDst.getWorldBorder();

    x = MathHelper.clamp(x, border.minX() + 2, border.maxX() - 2);
    z = MathHelper.clamp(z, border.minZ() + 2, border.maxZ() - 2);

    return new Vec3d(x, y, z);
}
项目:Weathers    文件:MixinServerConfigurationManager.java   
@Overwrite
public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn) {
    final WorldBorder worldborder = worldIn.getWorldBorder();
    playerIn.playerNetServerHandler.sendPacket(new S44PacketWorldBorder(worldborder, S44PacketWorldBorder.Action.INITIALIZE));
    playerIn.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(),
            worldIn.getGameRules().getGameRuleBooleanValue("doDaylightCycle")));

    final IMixinWorld world = (IMixinWorld) worldIn;
    playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7,
            getRainStrengthValue(world.getRainStrength())));
    playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8,
            getThunderStrengthValue(world.getRainStrength(), world.getDarkness())));
}
项目:enderutilities    文件:PositionUtils.java   
/**
 * Returns the given position scaled by the given scale factors, and clamped to within the world border
 * of the destination world, with the given margin to the border.
 */
public static Vec3d getScaledClampedPosition(Vec3d pos, @Nullable World world, double scaleX, double scaleY, double scaleZ, int margin)
{
    // The world border in other dimensions than the Overworld gets always
    // reset to the default 60M blocks when the dimensions loads.
    // The client side WorldBorder is synced on world load, so the
    // border _appears_ to be where the Overworld border is,
    // but on the server side the border is actually at 60M blocks,
    // unless the border has been changed using the commands,
    // because the border change listener will then update the border
    // size from the Overworld border to the other dimensions (see WorldServerMulti),
    // however that change only persists as long as the dimension stays loaded.

    // So we are just getting the border size from the Overworld for now...
    world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);

    int worldLimit = 30000000 - margin;
    // Note: getActualHeight() could be better (at least for the Nether), but it would return 128 for the End too...
    int worldHeight = world != null ? world.getHeight() : 256;
    double posX = MathHelper.clamp(pos.x * scaleX, -worldLimit, worldLimit);
    double posY = MathHelper.clamp(pos.y * scaleY, 0, worldHeight);
    double posZ = MathHelper.clamp(pos.z * scaleZ, -worldLimit, worldLimit);

    if (world != null)
    {
        WorldBorder border = world.getWorldBorder();
        margin = Math.min(margin, (int)(border.getDiameter() / 2));

        posX = MathHelper.clamp(pos.x * scaleX, border.minX() + margin, border.maxX() - margin);
        posZ = MathHelper.clamp(pos.z * scaleZ, border.minZ() + margin, border.maxZ() - margin);
        //System.out.printf("border size: %.2f posX: %.4f posY: %.4f posZ: %.4f\n", border.getDiameter(), posX, posY, posZ);
        //System.out.printf("border: %s (%s)\n", border.getClass().getName(), border);
    }

    return new Vec3d(posX, posY, posZ);
}
项目:harshencastle    文件:PontusWorldProvider.java   
public WorldBorder createWorldBorder()
{
    return new WorldBorder();
}
项目:DecompiledMinecraft    文件:WorldProvider.java   
public WorldBorder getWorldBorder()
{
    return new WorldBorder();
}
项目:DecompiledMinecraft    文件:World.java   
public List<AxisAlignedBB> getCollidingBoundingBoxes(Entity entityIn, AxisAlignedBB bb)
{
    List<AxisAlignedBB> list = Lists.<AxisAlignedBB>newArrayList();
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);
    WorldBorder worldborder = this.getWorldBorder();
    boolean flag = entityIn.isOutsideBorder();
    boolean flag1 = this.isInsideBorder(worldborder, entityIn);
    IBlockState iblockstate = Blocks.stone.getDefaultState();
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int k1 = i; k1 < j; ++k1)
    {
        for (int l1 = i1; l1 < j1; ++l1)
        {
            if (this.isBlockLoaded(blockpos$mutableblockpos.func_181079_c(k1, 64, l1)))
            {
                for (int i2 = k - 1; i2 < l; ++i2)
                {
                    blockpos$mutableblockpos.func_181079_c(k1, i2, l1);

                    if (flag && flag1)
                    {
                        entityIn.setOutsideBorder(false);
                    }
                    else if (!flag && !flag1)
                    {
                        entityIn.setOutsideBorder(true);
                    }

                    IBlockState iblockstate1 = iblockstate;

                    if (worldborder.contains(blockpos$mutableblockpos) || !flag1)
                    {
                        iblockstate1 = this.getBlockState(blockpos$mutableblockpos);
                    }

                    iblockstate1.getBlock().addCollisionBoxesToList(this, blockpos$mutableblockpos, iblockstate1, bb, list, entityIn);
                }
            }
        }
    }

    double d0 = 0.25D;
    List<Entity> list1 = this.getEntitiesWithinAABBExcludingEntity(entityIn, bb.expand(d0, d0, d0));

    for (int j2 = 0; j2 < list1.size(); ++j2)
    {
        if (entityIn.riddenByEntity != list1 && entityIn.ridingEntity != list1)
        {
            AxisAlignedBB axisalignedbb = ((Entity)list1.get(j2)).getCollisionBoundingBox();

            if (axisalignedbb != null && axisalignedbb.intersectsWith(bb))
            {
                list.add(axisalignedbb);
            }

            axisalignedbb = entityIn.getCollisionBox((Entity)list1.get(j2));

            if (axisalignedbb != null && axisalignedbb.intersectsWith(bb))
            {
                list.add(axisalignedbb);
            }
        }
    }

    return list;
}
项目:DecompiledMinecraft    文件:World.java   
public WorldBorder getWorldBorder()
{
    return this.worldBorder;
}
项目:DecompiledMinecraft    文件:CommandWorldBorder.java   
protected WorldBorder getWorldBorder()
{
    return MinecraftServer.getServer().worldServers[0].getWorldBorder();
}
项目:DecompiledMinecraft    文件:WorldProvider.java   
public WorldBorder getWorldBorder()
{
    return new WorldBorder();
}
项目:DecompiledMinecraft    文件:World.java   
public List<AxisAlignedBB> getCollidingBoundingBoxes(Entity entityIn, AxisAlignedBB bb)
{
    List<AxisAlignedBB> list = Lists.<AxisAlignedBB>newArrayList();
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);
    WorldBorder worldborder = this.getWorldBorder();
    boolean flag = entityIn.isOutsideBorder();
    boolean flag1 = this.isInsideBorder(worldborder, entityIn);
    IBlockState iblockstate = Blocks.stone.getDefaultState();
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int k1 = i; k1 < j; ++k1)
    {
        for (int l1 = i1; l1 < j1; ++l1)
        {
            if (this.isBlockLoaded(blockpos$mutableblockpos.func_181079_c(k1, 64, l1)))
            {
                for (int i2 = k - 1; i2 < l; ++i2)
                {
                    blockpos$mutableblockpos.func_181079_c(k1, i2, l1);

                    if (flag && flag1)
                    {
                        entityIn.setOutsideBorder(false);
                    }
                    else if (!flag && !flag1)
                    {
                        entityIn.setOutsideBorder(true);
                    }

                    IBlockState iblockstate1 = iblockstate;

                    if (worldborder.contains(blockpos$mutableblockpos) || !flag1)
                    {
                        iblockstate1 = this.getBlockState(blockpos$mutableblockpos);
                    }

                    iblockstate1.getBlock().addCollisionBoxesToList(this, blockpos$mutableblockpos, iblockstate1, bb, list, entityIn);
                }
            }
        }
    }

    double d0 = 0.25D;
    List<Entity> list1 = this.getEntitiesWithinAABBExcludingEntity(entityIn, bb.expand(d0, d0, d0));

    for (int j2 = 0; j2 < list1.size(); ++j2)
    {
        if (entityIn.riddenByEntity != list1 && entityIn.ridingEntity != list1)
        {
            AxisAlignedBB axisalignedbb = ((Entity)list1.get(j2)).getCollisionBoundingBox();

            if (axisalignedbb != null && axisalignedbb.intersectsWith(bb))
            {
                list.add(axisalignedbb);
            }

            axisalignedbb = entityIn.getCollisionBox((Entity)list1.get(j2));

            if (axisalignedbb != null && axisalignedbb.intersectsWith(bb))
            {
                list.add(axisalignedbb);
            }
        }
    }

    return list;
}