Search in sources :

Example 1 with FakePlayerItemInWorldManager

use of pneumaticCraft.common.ai.FakePlayerItemInWorldManager in project PneumaticCraft by MineMaarten.

the class EntityDrone method initializeFakePlayer.

private void initializeFakePlayer() {
    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 InventoryFakePlayer(fakePlayer);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) NetworkManager(net.minecraft.network.NetworkManager) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) FakePlayerItemInWorldManager(pneumaticCraft.common.ai.FakePlayerItemInWorldManager)

Example 2 with FakePlayerItemInWorldManager

use of pneumaticCraft.common.ai.FakePlayerItemInWorldManager 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)2 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)2 NetworkManager (net.minecraft.network.NetworkManager)2 WorldServer (net.minecraft.world.WorldServer)2 FakePlayerItemInWorldManager (pneumaticCraft.common.ai.FakePlayerItemInWorldManager)2 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 DroneFakePlayer (pneumaticCraft.common.entity.living.EntityDrone.DroneFakePlayer)1