Search in sources :

Example 6 with WorldServer

use of net.minecraft.server.level.WorldServer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_18_R1 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.er();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.a_(blockPosition);
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.world.level.block.state.IBlockData) BlockPosition(net.minecraft.core.BlockPosition) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) WorldServer(net.minecraft.server.level.WorldServer) ItemStack(net.minecraft.world.item.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 7 with WorldServer

use of net.minecraft.server.level.WorldServer in project BedWars1058 by andrei1058.

the class Silverfish method spawn.

public static LivingEntity spawn(Location loc, ITeam team, double speed, double health, int despawn, double damage) {
    WorldServer mcWorld = ((CraftWorld) loc.getWorld()).getHandle();
    Silverfish customEnt = new Silverfish(EntityTypes.aA, mcWorld, team);
    customEnt.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    customEnt.getAttributeInstance(GenericAttributes.a).setValue(health);
    customEnt.getAttributeInstance(GenericAttributes.d).setValue(speed);
    customEnt.getAttributeInstance(GenericAttributes.f).setValue(damage);
    customEnt.setPersistent();
    ((CraftLivingEntity) customEnt.getBukkitEntity()).setRemoveWhenFarAway(false);
    customEnt.setCustomNameVisible(true);
    mcWorld.addEntity(customEnt, CreatureSpawnEvent.SpawnReason.CUSTOM);
    customEnt.getBukkitEntity().setCustomName(Language.getDefaultLanguage().m(Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME).replace("{despawn}", String.valueOf(despawn).replace("{health}", StringUtils.repeat(Language.getDefaultLanguage().m(Messages.FORMATTING_DESPAWNABLE_UTILITY_NPC_HEALTH) + " ", 10)).replace("{TeamColor}", team.getColor().chat().toString())));
    return (LivingEntity) customEnt.getBukkitEntity();
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity) WorldServer(net.minecraft.server.level.WorldServer) EntitySilverfish(net.minecraft.world.entity.monster.EntitySilverfish) CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 8 with WorldServer

use of net.minecraft.server.level.WorldServer in project BedWars1058 by andrei1058.

the class IGolem method spawn.

public static LivingEntity spawn(Location loc, ITeam bedWarsTeam, double speed, double health, int despawn) {
    WorldServer mcWorld = ((CraftWorld) Objects.requireNonNull(loc.getWorld())).getHandle();
    IGolem customEnt = new IGolem(EntityTypes.P, mcWorld, bedWarsTeam);
    customEnt.a(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    ((CraftLivingEntity) customEnt.getBukkitEntity()).setRemoveWhenFarAway(false);
    Objects.requireNonNull(customEnt.a(GenericAttributes.a)).a(health);
    Objects.requireNonNull(customEnt.a(GenericAttributes.d)).a(speed);
    if (!CraftEventFactory.doEntityAddEventCalling(mcWorld, customEnt, CreatureSpawnEvent.SpawnReason.CUSTOM)) {
        mcWorld.P.a(customEnt);
    }
    mcWorld.a(customEnt);
    customEnt.getBukkitEntity().setPersistent(true);
    customEnt.getBukkitEntity().setCustomNameVisible(true);
    customEnt.getBukkitEntity().setCustomName(Language.getDefaultLanguage().m(Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME).replace("{despawn}", String.valueOf(despawn).replace("{health}", StringUtils.repeat(Language.getDefaultLanguage().m(Messages.FORMATTING_DESPAWNABLE_UTILITY_NPC_HEALTH) + " ", 10)).replace("{TeamColor}", bedWarsTeam.getColor().chat().toString())));
    return (LivingEntity) customEnt.getBukkitEntity();
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity) WorldServer(net.minecraft.server.level.WorldServer) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 9 with WorldServer

use of net.minecraft.server.level.WorldServer in project BedWars1058 by andrei1058.

the class Silverfish method spawn.

public static LivingEntity spawn(Location loc, ITeam team, double speed, double health, int despawn, double damage) {
    WorldServer mcWorld = ((CraftWorld) loc.getWorld()).getHandle();
    Silverfish customEnt = new Silverfish(EntityTypes.aA, mcWorld, team);
    customEnt.a(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    customEnt.a(GenericAttributes.a).a(health);
    customEnt.a(GenericAttributes.d).a(speed);
    customEnt.a(GenericAttributes.f).a(damage);
    if (!CraftEventFactory.doEntityAddEventCalling(mcWorld, customEnt, CreatureSpawnEvent.SpawnReason.CUSTOM)) {
        mcWorld.P.a(customEnt);
    }
    ((CraftLivingEntity) customEnt.getBukkitEntity()).setRemoveWhenFarAway(false);
    ((CraftLivingEntity) customEnt.getBukkitEntity()).setRemoveWhenFarAway(true);
    ((CraftLivingEntity) customEnt.getBukkitEntity()).setPersistent(true);
    customEnt.getBukkitEntity().setCustomName(Language.getDefaultLanguage().m(Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME).replace("{despawn}", String.valueOf(despawn).replace("{health}", StringUtils.repeat(Language.getDefaultLanguage().m(Messages.FORMATTING_DESPAWNABLE_UTILITY_NPC_HEALTH) + " ", 10)).replace("{TeamColor}", team.getColor().chat().toString())));
    return (LivingEntity) customEnt.getBukkitEntity();
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity) WorldServer(net.minecraft.server.level.WorldServer) EntitySilverfish(net.minecraft.world.entity.monster.EntitySilverfish) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 10 with WorldServer

use of net.minecraft.server.level.WorldServer in project TheAPI by TheDevTec.

the class v1_17_R1 method packetRespawn.

@Override
public Object packetRespawn(Player player) {
    EntityPlayer entityPlayer = (EntityPlayer) getPlayer(player);
    WorldServer worldserver = entityPlayer.getWorldServer();
    return new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), entityPlayer.d.getGameMode(), entityPlayer.d.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true);
}
Also used : EntityPlayer(net.minecraft.server.level.EntityPlayer) WorldServer(net.minecraft.server.level.WorldServer) PacketPlayOutRespawn(net.minecraft.network.protocol.game.PacketPlayOutRespawn)

Aggregations

WorldServer (net.minecraft.server.level.WorldServer)27 EntityItem (net.minecraft.world.entity.item.EntityItem)9 BlockPosition (net.minecraft.core.BlockPosition)8 EntityPlayer (net.minecraft.server.level.EntityPlayer)7 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)6 Field (java.lang.reflect.Field)5 PacketPlayOutSpawnEntity (net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity)5 Entity (net.minecraft.world.entity.Entity)5 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)5 Method (java.lang.reflect.Method)4 World (org.bukkit.World)4 LivingEntity (org.bukkit.entity.LivingEntity)4 PacketType (com.comphenix.protocol.PacketType)3 PacketContainer (com.comphenix.protocol.events.PacketContainer)3 InteractionVisualizer (com.loohp.interactionvisualizer.InteractionVisualizer)3 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)3 BoundingBox (com.loohp.interactionvisualizer.objectholders.BoundingBox)3 ChunkPosition (com.loohp.interactionvisualizer.objectholders.ChunkPosition)3 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)3 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)3