Search in sources :

Example 1 with DroneFakePlayer

use of pneumaticCraft.common.entity.living.EntityDrone.DroneFakePlayer in project PneumaticCraft by MineMaarten.

the class TileEntityProgrammableController method initializeFakePlayer.

private void initializeFakePlayer() {
    String playerUUID = null;
    String playerName = "Drone";
    fakePlayer = new DroneFakePlayer((WorldServer) worldObj, new GameProfile(playerUUID != null ? UUID.fromString(playerUUID) : null, playerName), new FakePlayerItemInWorldManager(worldObj, fakePlayer, this), this);
    fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), new NetworkManager(false), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {

        private ItemStack oldStack;

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

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                if (oldStack != null) {
                    getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers());
                }
                if (stack != null) {
                    getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers());
                }
                oldStack = stack;
            }
        }
    };
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) DroneFakePlayer(pneumaticCraft.common.entity.living.EntityDrone.DroneFakePlayer) NetworkManager(net.minecraft.network.NetworkManager) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) FakePlayerItemInWorldManager(pneumaticCraft.common.ai.FakePlayerItemInWorldManager)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)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 FakePlayerItemInWorldManager (pneumaticCraft.common.ai.FakePlayerItemInWorldManager)1 DroneFakePlayer (pneumaticCraft.common.entity.living.EntityDrone.DroneFakePlayer)1