Search in sources :

Example 16 with PlayerEntityBridge

use of io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge in project Arclight by IzzelAliz.

the class WorkbenchContainerMixin method getBukkitView.

@Override
public CraftInventoryView getBukkitView() {
    if (bukkitEntity != null) {
        return bukkitEntity;
    }
    CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftMatrix, this.craftResult);
    bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
    return bukkitEntity;
}
Also used : CraftInventoryCrafting(org.bukkit.craftbukkit.v.inventory.CraftInventoryCrafting) Container(net.minecraft.inventory.container.Container) WorkbenchContainer(net.minecraft.inventory.container.WorkbenchContainer) CraftInventoryView(org.bukkit.craftbukkit.v.inventory.CraftInventoryView) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge)

Example 17 with PlayerEntityBridge

use of io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge in project Arclight by IzzelAliz.

the class GrindstoneContainerMixin method getBukkitView.

@Override
public CraftInventoryView getBukkitView() {
    if (bukkitEntity != null) {
        return bukkitEntity;
    }
    CraftInventoryGrindstone inventory = new CraftInventoryGrindstone(this.inputInventory, this.outputInventory);
    bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
    return bukkitEntity;
}
Also used : Container(net.minecraft.inventory.container.Container) GrindstoneContainer(net.minecraft.inventory.container.GrindstoneContainer) CraftInventoryView(org.bukkit.craftbukkit.v.inventory.CraftInventoryView) CraftInventoryGrindstone(org.bukkit.craftbukkit.v.inventory.CraftInventoryGrindstone) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge)

Example 18 with PlayerEntityBridge

use of io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge in project Arclight by IzzelAliz.

the class BeaconContainerMixin method getBukkitView.

@Override
public CraftInventoryView getBukkitView() {
    if (bukkitEntity != null) {
        return bukkitEntity;
    }
    CraftInventory inventory = new CraftInventoryBeacon(this.tileBeacon);
    bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
    return bukkitEntity;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v.inventory.CraftInventory) Container(net.minecraft.inventory.container.Container) BeaconContainer(net.minecraft.inventory.container.BeaconContainer) CraftInventoryView(org.bukkit.craftbukkit.v.inventory.CraftInventoryView) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge) CraftInventoryBeacon(org.bukkit.craftbukkit.v.inventory.CraftInventoryBeacon)

Example 19 with PlayerEntityBridge

use of io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge in project Arclight by IzzelAliz.

the class PlayerListMixin method recreatePlayerEntity.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public ServerPlayerEntity recreatePlayerEntity(ServerPlayerEntity playerIn, DimensionType dimension, boolean conqueredEnd) {
    Location location = arclight$loc;
    arclight$loc = null;
    boolean avoidSuffocation = arclight$suffo == null ? true : arclight$suffo;
    arclight$suffo = null;
    playerIn.stopRiding();
    org.bukkit.World fromWorld = ((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().getWorld();
    ServerWorld world = server.getWorld(dimension);
    if (world == null)
        dimension = playerIn.getSpawnDimension();
    else if (!world.getDimension().canRespawnHere())
        dimension = world.getDimension().getRespawnDimension(playerIn);
    if (server.getWorld(dimension) == null)
        dimension = DimensionType.OVERWORLD;
    this.removePlayer(playerIn);
    // Forge: keep data until copyFrom called
    playerIn.getServerWorld().removePlayer(playerIn, true);
    BlockPos blockpos = playerIn.getBedLocation(dimension);
    boolean flag = playerIn.isSpawnForced(dimension);
    // playerIn.dimension = dimension;
    PlayerInteractionManager playerinteractionmanager;
    if (this.server.isDemo()) {
        playerinteractionmanager = new DemoPlayerInteractionManager(this.server.getWorld(playerIn.dimension));
    } else {
        playerinteractionmanager = new PlayerInteractionManager(this.server.getWorld(playerIn.dimension));
    }
    playerIn.queuedEndExit = false;
    if (location == null) {
        boolean isBedSpawn = false;
        CraftWorld cworld = (CraftWorld) Bukkit.getWorld(((PlayerEntityBridge) playerIn).bridge$getSpawnWorld());
        if (cworld != null && blockpos != null) {
            Optional<Vec3d> optional = PlayerEntity.checkBedValidRespawnPosition(cworld.getHandle(), blockpos, flag);
            if (optional.isPresent()) {
                Vec3d vec3d = optional.get();
                isBedSpawn = true;
                location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z);
            } else {
                this.bridge$setSpawnPoint(playerIn, null, true, playerIn.dimension, false);
                playerIn.connection.sendPacket(new SChangeGameStatePacket(0, 0.0f));
            }
        }
        if (location == null) {
            cworld = (CraftWorld) Bukkit.getWorlds().get(0);
            blockpos = ((ServerPlayerEntityBridge) playerIn).bridge$getSpawnPoint(cworld.getHandle());
            location = new Location(cworld, blockpos.getX() + 0.5f, blockpos.getY() + 0.1f, blockpos.getZ() + 0.5f);
        }
        Player respawnPlayer = this.cserver.getPlayer(playerIn);
        PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
        this.cserver.getPluginManager().callEvent(respawnEvent);
        if (((ServerPlayNetHandlerBridge) playerIn.connection).bridge$isDisconnected()) {
            return playerIn;
        }
        location = respawnEvent.getRespawnLocation();
        if (location.getWorld() == null) {
            location.setWorld(((WorldBridge) this.server.getWorld(dimension)).bridge$getWorld());
        }
        dimension = ((CraftWorld) location.getWorld()).getHandle().dimension.getType();
        if (!flag) {
            ((ServerPlayerEntityBridge) playerIn).bridge$reset();
        }
    } else {
        location.setWorld(((WorldBridge) this.server.getWorld(dimension)).bridge$getWorld());
    }
    playerIn.dimension = dimension;
    ServerPlayerEntity serverplayerentity = new ServerPlayerEntity(this.server, this.server.getWorld(playerIn.dimension), playerIn.getGameProfile(), playerinteractionmanager);
    // Forward to new player instance
    ((InternalEntityBridge) playerIn).internal$getBukkitEntity().setHandle(serverplayerentity);
    ((EntityBridge) serverplayerentity).bridge$setBukkitEntity(((InternalEntityBridge) playerIn).internal$getBukkitEntity());
    if ((Object) serverplayerentity instanceof MobEntity) {
        ((MobEntity) (Object) serverplayerentity).clearLeashed(true, false);
    }
    serverplayerentity.connection = playerIn.connection;
    serverplayerentity.copyFrom(playerIn, conqueredEnd);
    // Forge: clone event had a chance to see old data, now discard it
    playerIn.remove(false);
    serverplayerentity.dimension = dimension;
    serverplayerentity.setEntityId(playerIn.getEntityId());
    serverplayerentity.setPrimaryHand(playerIn.getPrimaryHand());
    for (String s : playerIn.getTags()) {
        serverplayerentity.addTag(s);
    }
    ServerWorld serverworld = ((CraftWorld) location.getWorld()).getHandle();
    serverplayerentity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    serverplayerentity.connection.captureCurrentPosition();
    this.setPlayerGameTypeBasedOnOther(serverplayerentity, playerIn, serverworld);
    while (avoidSuffocation && !this.bridge$worldNoCollision(serverworld, serverplayerentity) && serverplayerentity.posY < 256.0D) {
        serverplayerentity.setPosition(serverplayerentity.posX, serverplayerentity.posY + 1.0D, serverplayerentity.posZ);
    }
    if (fromWorld.getEnvironment() == ((WorldBridge) serverworld).bridge$getWorld().getEnvironment()) {
        serverplayerentity.connection.sendPacket(this.bridge$respawnPacket((((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, serverworld.getWorldInfo().getSeed(), serverworld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
    }
    WorldInfo worldinfo = serverplayerentity.world.getWorldInfo();
    NetworkHooks.sendDimensionDataPacket(serverplayerentity.connection.netManager, serverplayerentity);
    serverplayerentity.connection.sendPacket(this.bridge$respawnPacket(((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType(), worldinfo.getSeed(), worldinfo.getGenerator(), serverplayerentity.interactionManager.getGameType()));
    serverplayerentity.connection.sendPacket(new SUpdateViewDistancePacket(((WorldBridge) serverworld).bridge$spigotConfig().viewDistance));
    BlockPos blockpos1 = serverworld.getSpawnPoint();
    serverplayerentity.connection.setPlayerLocation(serverplayerentity.posX, serverplayerentity.posY, serverplayerentity.posZ, serverplayerentity.rotationYaw, serverplayerentity.rotationPitch);
    serverplayerentity.connection.sendPacket(new SSpawnPositionPacket(blockpos1));
    serverplayerentity.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
    serverplayerentity.connection.sendPacket(new SSetExperiencePacket(serverplayerentity.experience, serverplayerentity.experienceTotal, serverplayerentity.experienceLevel));
    this.sendWorldInfo(serverplayerentity, serverworld);
    this.updatePermissionLevel(serverplayerentity);
    if (!((ServerPlayNetHandlerBridge) serverplayerentity.connection).bridge$isDisconnected()) {
        serverworld.addRespawnedPlayer(serverplayerentity);
        this.addPlayer(serverplayerentity);
        this.uuidToPlayerMap.put(serverplayerentity.getUniqueID(), serverplayerentity);
    }
    serverplayerentity.addSelfToInternalCraftingInventory();
    serverplayerentity.setHealth(serverplayerentity.getHealth());
    this.sendInventory(serverplayerentity);
    serverplayerentity.sendPlayerAbilities();
    serverplayerentity.func_213846_b(((CraftWorld) fromWorld).getHandle());
    if (fromWorld != location.getWorld()) {
        PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity(), fromWorld);
        Bukkit.getPluginManager().callEvent(event);
    }
    BasicEventHooks.firePlayerRespawnEvent(serverplayerentity, conqueredEnd);
    System.out.println("pos " + serverplayerentity.getBedLocation());
    return serverplayerentity;
}
Also used : DimensionTypeBridge(io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge) ServerPlayNetHandlerBridge(io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge) PlayerRespawnEvent(org.bukkit.event.player.PlayerRespawnEvent) SChangeGameStatePacket(net.minecraft.network.play.server.SChangeGameStatePacket) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) ServerWorld(net.minecraft.world.server.ServerWorld) WorldBridge(io.izzel.arclight.common.bridge.world.WorldBridge) ServerWorldBridge(io.izzel.arclight.common.bridge.world.server.ServerWorldBridge) WorldInfo(net.minecraft.world.storage.WorldInfo) BlockPos(net.minecraft.util.math.BlockPos) CraftWorld(org.bukkit.craftbukkit.v.CraftWorld) InternalEntityBridge(io.izzel.arclight.common.bridge.entity.InternalEntityBridge) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge) SSetExperiencePacket(net.minecraft.network.play.server.SSetExperiencePacket) Player(org.bukkit.entity.Player) SUpdateViewDistancePacket(net.minecraft.network.play.server.SUpdateViewDistancePacket) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d) SServerDifficultyPacket(net.minecraft.network.play.server.SServerDifficultyPacket) PlayerChangedWorldEvent(org.bukkit.event.player.PlayerChangedWorldEvent) PlayerInteractionManager(net.minecraft.server.management.PlayerInteractionManager) DemoPlayerInteractionManager(net.minecraft.server.management.DemoPlayerInteractionManager) DemoPlayerInteractionManager(net.minecraft.server.management.DemoPlayerInteractionManager) MobEntity(net.minecraft.entity.MobEntity) SSpawnPositionPacket(net.minecraft.network.play.server.SSpawnPositionPacket) Location(org.bukkit.Location) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 20 with PlayerEntityBridge

use of io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge in project Arclight by IzzelAliz.

the class LeadItemMixin_1_15 method bindPlayerMobs.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public static ActionResultType bindPlayerMobs(PlayerEntity player, World worldIn, BlockPos fence) {
    LeashKnotEntity leashknotentity = null;
    boolean flag = false;
    double d0 = 7.0D;
    int i = fence.getX();
    int j = fence.getY();
    int k = fence.getZ();
    for (MobEntity mobentity : worldIn.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB((double) i - 7.0D, (double) j - 7.0D, (double) k - 7.0D, (double) i + 7.0D, (double) j + 7.0D, (double) k + 7.0D))) {
        if (mobentity.getLeashHolder() == player) {
            if (leashknotentity == null) {
                leashknotentity = LeashKnotEntity.create(worldIn, fence);
                HangingPlaceEvent event = new HangingPlaceEvent((Hanging) ((EntityBridge) leashknotentity).bridge$getBukkitEntity(), player != null ? (Player) ((PlayerEntityBridge) player).bridge$getBukkitEntity() : null, CraftBlock.at(worldIn, fence), BlockFace.SELF);
                Bukkit.getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    leashknotentity.remove();
                    return ActionResultType.PASS;
                }
            }
            if (CraftEventFactory.callPlayerLeashEntityEvent(mobentity, leashknotentity, player).isCancelled()) {
                continue;
            }
            mobentity.setLeashHolder(leashknotentity, true);
            flag = true;
        }
    }
    return flag ? ActionResultType.SUCCESS : ActionResultType.PASS;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Player(org.bukkit.entity.Player) HangingPlaceEvent(org.bukkit.event.hanging.HangingPlaceEvent) LeashKnotEntity(net.minecraft.entity.item.LeashKnotEntity) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge) MobEntity(net.minecraft.entity.MobEntity) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

PlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge)20 Container (net.minecraft.inventory.container.Container)15 CraftInventoryView (org.bukkit.craftbukkit.v.inventory.CraftInventoryView)15 CraftInventory (org.bukkit.craftbukkit.v.inventory.CraftInventory)5 Player (org.bukkit.entity.Player)5 Overwrite (org.spongepowered.asm.mixin.Overwrite)5 EntityBridge (io.izzel.arclight.common.bridge.entity.EntityBridge)4 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)4 MobEntity (net.minecraft.entity.MobEntity)3 PlayerInventory (net.minecraft.entity.player.PlayerInventory)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 LeashKnotEntity (net.minecraft.entity.item.LeashKnotEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 IInventory (net.minecraft.inventory.IInventory)2 EnchantmentContainer (net.minecraft.inventory.container.EnchantmentContainer)2 ItemStack (net.minecraft.item.ItemStack)2 BlockPos (net.minecraft.util.math.BlockPos)2 HangingPlaceEvent (org.bukkit.event.hanging.HangingPlaceEvent)2 InternalEntityBridge (io.izzel.arclight.common.bridge.entity.InternalEntityBridge)1 PlayerInventoryBridge (io.izzel.arclight.common.bridge.entity.player.PlayerInventoryBridge)1