Search in sources :

Example 1 with DroneFakePlayer

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone.DroneFakePlayer in project pnc-repressurized by TeamPneumatic.

the class TileEntityProgrammableController method initializeFakePlayer.

private void initializeFakePlayer() {
    fakePlayer = new DroneFakePlayer((WorldServer) getWorld(), new GameProfile(getOwnerUUID(), ownerName), this);
    fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {

        private ItemStack oldStack = ItemStack.EMPTY;

        @Override
        public int getSizeInventory() {
            return getDroneSlots();
        }

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                for (EntityEquipmentSlot ee : EntityEquipmentSlot.values()) {
                    if (!oldStack.isEmpty()) {
                        getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers(ee));
                    }
                    if (!stack.isEmpty()) {
                        getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(ee));
                    }
                }
                oldStack = stack;
            }
        }
    };
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) DroneFakePlayer(me.desht.pneumaticcraft.common.entity.living.EntityDrone.DroneFakePlayer) NetworkManager(net.minecraft.network.NetworkManager) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)1 DroneFakePlayer (me.desht.pneumaticcraft.common.entity.living.EntityDrone.DroneFakePlayer)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 ItemStack (net.minecraft.item.ItemStack)1 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)1 NetworkManager (net.minecraft.network.NetworkManager)1 WorldServer (net.minecraft.world.WorldServer)1