Search in sources :

Example 46 with World

use of net.minecraft.server.v1_14_R1.World in project RoseStacker by Rosewood-Development.

the class StackedSpawnerTileImpl method c.

@Override
public void c() {
    World level = this.a();
    if (level == null)
        return;
    // Only tick the spawner if a player is nearby
    this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
    if (this.playersTimeSinceLastCheck == 0)
        this.playersNearby = this.isNearPlayer(level, this.blockPos);
    if (!this.playersNearby)
        return;
    SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
    // Handle redstone deactivation if enabled
    if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
        if (this.redstoneTimeSinceLastCheck == 0) {
            boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
            if (this.redstoneDeactivated && !hasSignal) {
                this.redstoneDeactivated = false;
                this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
                this.updateTile();
            } else if (!this.redstoneDeactivated && hasSignal) {
                this.redstoneDeactivated = true;
                this.requiredPlayerRange = 0;
                this.updateTile();
            }
            if (this.redstoneDeactivated)
                return;
        }
        this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
    }
    // Count down spawn timer unless we are ready to spawn
    if (this.spawnDelay > 0) {
        this.spawnDelay--;
        return;
    }
    // Reset spawn delay
    this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
    this.updateTile();
    // Execute spawning method
    try {
        if (this.spawnData != null) {
            MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
            if (resourceLocation != null) {
                NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
                EntityType entityType = this.fromKey(namespacedKey);
                if (entityType != null)
                    new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    // Randomize spawn potentials
    if (!this.mobs.isEmpty())
        this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
Also used : EntityType(org.bukkit.entity.EntityType) SpawnerStackSettings(dev.rosewood.rosestacker.stack.settings.SpawnerStackSettings) MobSpawningMethod(dev.rosewood.rosestacker.spawner.spawning.MobSpawningMethod) CraftNamespacedKey(org.bukkit.craftbukkit.v1_16_R2.util.CraftNamespacedKey) NamespacedKey(org.bukkit.NamespacedKey) World(net.minecraft.server.v1_16_R2.World) MinecraftKey(net.minecraft.server.v1_16_R2.MinecraftKey)

Example 47 with World

use of net.minecraft.server.v1_14_R1.World in project RoseStacker by Rosewood-Development.

the class StackedSpawnerTileImpl method updateTile.

private void updateTile() {
    World level = this.a();
    if (level != null) {
        level.b(this.blockPos, this.blockEntity);
        IBlockData var1 = this.a().getType(this.b());
        this.a().notify(this.blockPos, var1, var1, 3);
    }
}
Also used : IBlockData(net.minecraft.server.v1_16_R2.IBlockData) World(net.minecraft.server.v1_16_R2.World)

Example 48 with World

use of net.minecraft.server.v1_14_R1.World in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method setChestName.

@Override
public void setChestName(Location chest, String name) {
    World world = ((CraftWorld) chest.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(chest.getBlockX(), chest.getBlockY(), chest.getBlockZ());
    TileEntityChest tileEntityChest = (TileEntityChest) world.getTileEntity(blockPosition);
    tileEntityChest.a(name);
}
Also used : TileEntityChest(net.minecraft.server.v1_8_R3.TileEntityChest) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 49 with World

use of net.minecraft.server.v1_14_R1.World in project Frequency by ElevatedDev.

the class InvalidD method process.

@Override
public void process(final Object object) {
    if (object instanceof WrappedPlayInFlying) {
        final WrappedPlayInFlying wrapper = (WrappedPlayInFlying) object;
        if (wrapper.hasPos()) {
            // Get position values from wrapper
            final double posX = wrapper.getX();
            final double posZ = wrapper.getZ();
            // Calculate the basic horizontal distance and the acceleration
            final double horizontalDistance = MathUtil.magnitude(posX - lastPosX, posZ - lastPosZ);
            final double acceleration = Math.abs(horizontalDistance - lastHorizontalDistance);
            /*
                * The theory is, when the player attacks an entity they get slowed down by 0.6. Here we're simply checking
                * if the player had any sort of slowdown when attacking a player. If not, that means that the player's
                * motion was not messed with. When that happens, increase a buffer to reduce possible false positives.
                 */
            motion: {
                final Entity target = playerData.getTarget().get();
                /*
                    * The player only gets slowed down in Minecraft when he's hitting another player. Not if
                    * he is hitting a mob. Thus, we need to make sure that the entity attacked is surely a
                    * player, and not a mob or this check is going to false to bits since the theory is wrong then,
                     */
                final boolean exists = target instanceof Player;
                final boolean exempt = this.isExempt(ExemptType.TPS, ExemptType.TELEPORTING);
                /*
                    * We don't want to run the check if the player has not attacked or if the entity attacked
                    * was not a player of if the player did not attack at all. Thus, we're breaking on these scenarios.
                     */
                if (exempt || !exists || !attacked)
                    break motion;
                /*
                    * The check only is valid if the player is sprinting, so we also need to make sure that the player'ss
                    * sprinting status are true, or the check again is not going to work as expected.
                     */
                final boolean accelerated = acceleration < 1e-04 && horizontalDistance > lastHorizontalDistance * 0.99;
                final boolean sprinting = playerData.getSprinting().get();
                if (accelerated && sprinting) {
                    buffer += 0.25;
                    if (buffer > 1.25)
                        fail();
                } else {
                    buffer = Math.max(buffer - 0.25, 0);
                }
                attacked = false;
            }
            lastHorizontalDistance = horizontalDistance;
            lastPosX = posX;
            lastPosZ = posZ;
        }
    } else if (object instanceof WrappedPlayInUseEntity) {
        final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
        final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
        final World world = entityPlayer.world;
        attacked: {
            if (wrapper.getAction() != PacketPlayInUseEntity.EnumEntityUseAction.ATTACK)
                break attacked;
            if (wrapper.getTarget(world) instanceof Player) {
                attacked = true;
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) PacketPlayInUseEntity(net.minecraft.server.v1_8_R3.PacketPlayInUseEntity) WrappedPlayInUseEntity(xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) WrappedPlayInUseEntity(xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) WrappedPlayInFlying(xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying) World(net.minecraft.server.v1_8_R3.World)

Example 50 with World

use of net.minecraft.server.v1_14_R1.World in project Citizens2 by CitizensDev.

the class EntityHumanNPC method initialise.

private void initialise(MinecraftServer minecraftServer) {
    Socket socket = new EmptySocket();
    NetworkManager conn = null;
    try {
        conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
        playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
        conn.setPacketListener(playerConnection);
        socket.close();
    } catch (IOException e) {
    // swallow
    }
    AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(this);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    invulnerableTicks = 0;
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
    EmptyAdvancementDataPlayer.clear(this.getAdvancementData());
    NMSImpl.setAdvancement(this.getBukkitEntity(), new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_14_R1.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_14_R1.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_14_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_14_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_14_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_14_R1.util.PlayerControllerJump) IOException(java.io.IOException) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_14_R1.util.EmptyAdvancementDataPlayer) EmptyNetworkManager(net.citizensnpcs.nms.v1_14_R1.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_14_R1.NetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_14_R1.network.EmptySocket)

Aggregations

Location (org.bukkit.Location)26 World (net.minecraft.server.v1_16_R3.World)17 World (net.minecraft.server.v1_8_R3.World)16 World (net.minecraft.server.v1_12_R1.World)15 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)15 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)15 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)15 ArrayList (java.util.ArrayList)11 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)11 List (java.util.List)10 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)10 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)10 CraftWorld (org.bukkit.craftbukkit.v1_14_R1.CraftWorld)9 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8