Search in sources :

Example 66 with FakePlayer

use of net.minecraftforge.common.util.FakePlayer in project Armourers-Workshop by RiskyKen.

the class EquipmentWardrobeHandler method onRender.

@SubscribeEvent(priority = EventPriority.HIGH)
public void onRender(RenderPlayerEvent.SetArmorModel event) {
    int slot = -event.slot + 3;
    if (slot > 3) {
        return;
    }
    EntityPlayer player = event.entityPlayer;
    if (player instanceof MannequinFakePlayer) {
        return;
    }
    if (player.getGameProfile() == null) {
        return;
    }
    if (player instanceof FakePlayer) {
        return;
    }
    int result = -1;
    // Hide the armour if it had been skinned.
    ItemStack stack = player.getCurrentArmor(event.slot);
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        result = -2;
    }
    // Hide the armour if the player has turned it off.
    PlayerPointer playerPointer = new PlayerPointer(player);
    if (equipmentWardrobeMap.containsKey(playerPointer)) {
        EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
        if (ewd.armourOverride.get(slot)) {
            result = -2;
        }
    }
    event.result = result;
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) FakePlayer(net.minecraftforge.common.util.FakePlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 67 with FakePlayer

use of net.minecraftforge.common.util.FakePlayer in project Armourers-Workshop by RiskyKen.

the class EquipmentWardrobeHandler method onRender.

@SubscribeEvent
public void onRender(RenderPlayerEvent.Pre event) {
    EntityPlayer player = event.entityPlayer;
    if (player instanceof MannequinFakePlayer) {
        return;
    }
    if (player.getGameProfile() == null) {
        return;
    }
    if (player instanceof FakePlayer) {
        return;
    }
    // Hide the head overlay if the player has turned it off.
    PlayerPointer playerPointer = new PlayerPointer(player);
    RenderPlayer renderer = event.renderer;
    if (equipmentWardrobeMap.containsKey(playerPointer)) {
        EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
        renderer.modelBipedMain.bipedHeadwear.isHidden = ewd.headOverlay;
        if (!ewd.headOverlay) {
            if (SkinModelRenderer.INSTANCE.playerHasCustomHead(player)) {
                renderer.modelBipedMain.bipedHeadwear.isHidden = true;
            }
        }
    }
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) FakePlayer(net.minecraftforge.common.util.FakePlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 68 with FakePlayer

use of net.minecraftforge.common.util.FakePlayer in project BiomesOPlenty by Glitchfiend.

the class BlockBOPPlant method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    switch((BOPPlants) state.getValue(this.variantProperty)) {
        case BERRYBUSH:
            // an activated berry bush turns into a regular bush and drops a berry
            worldIn.setBlockState(pos, paging.getVariantState(BOPPlants.BUSH));
            EntityItem berries = new EntityItem(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), new ItemStack(BOPItems.berries));
            if (!worldIn.isRemote) {
                worldIn.spawnEntity(berries);
                if (!(playerIn instanceof FakePlayer)) {
                    berries.onCollideWithPlayer(playerIn);
                }
            }
            return true;
    }
    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
Also used : BOPPlants(biomesoplenty.api.enums.BOPPlants) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 69 with FakePlayer

use of net.minecraftforge.common.util.FakePlayer in project BluePower by Qmunity.

the class TileDeployer method redstoneChanged.

@Override
protected void redstoneChanged(boolean newValue) {
    super.redstoneChanged(newValue);
    if (!level.isClientSide && newValue) {
        sendUpdatePacket();
        FakePlayer player = FakePlayerFactory.get((ServerWorld) level, FAKE_PLAYER_PROFILE);
        for (int i = 0; i < inventory.size(); i++) {
            ItemStack stack = inventory.get(i);
            player.inventory.setItem(i, stack);
        }
        rightClick(player, 9);
        for (int i = 0; i < inventory.size(); i++) {
            ItemStack stack = player.inventory.getItem(i);
            if (stack.isEmpty() || stack.getCount() <= 0) {
                inventory.set(i, ItemStack.EMPTY);
            } else {
                inventory.set(i, stack);
            }
            player.inventory.setItem(i, ItemStack.EMPTY);
        }
        for (int i = 0; i < player.inventory.getContainerSize(); i++) {
            ItemStack stack = player.inventory.getItem(i);
            if (!stack.isEmpty() && stack.getCount() > 0) {
                ItemStack remainder = IOHelper.insert(this, stack, getFacingDirection().getOpposite(), false);
                if (!remainder.isEmpty()) {
                    level.addFreshEntity(new ItemEntity(level, worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5, remainder));
                }
                player.inventory.setItem(i, ItemStack.EMPTY);
            }
        }
    }
}
Also used : ItemEntity(net.minecraft.entity.item.ItemEntity) ItemStack(net.minecraft.item.ItemStack) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 70 with FakePlayer

use of net.minecraftforge.common.util.FakePlayer in project BloodMagic by WayofTime.

the class CheatyItem method onItemRightClick.

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    World world = par3EntityPlayer.worldObj;
    if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer instanceof FakePlayer) {
        return par1ItemStack;
    }
    if (world != null) {
        double posX = par3EntityPlayer.posX;
        double posY = par3EntityPlayer.posY;
        double posZ = par3EntityPlayer.posZ;
        world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
        SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
    }
    if (par3EntityPlayer.worldObj.isRemote) {
        return par1ItemStack;
    }
    NBTTagCompound itemTag = par1ItemStack.getTagCompound();
    if (itemTag == null || itemTag.getString("ownerName").equals("")) {
        return par1ItemStack;
    }
    if (par3EntityPlayer.isSneaking()) {
        SoulNetworkHandler.setCurrentEssence(itemTag.getString("ownerName"), 0);
    } else {
        SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 1000000, Integer.MAX_VALUE);
    }
    return par1ItemStack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) World(net.minecraft.world.World) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Aggregations

FakePlayer (net.minecraftforge.common.util.FakePlayer)73 ItemStack (net.minecraft.item.ItemStack)26 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)17 EntityPlayer (net.minecraft.entity.player.EntityPlayer)16 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.math.BlockPos)11 EntityItem (net.minecraft.entity.item.EntityItem)10 World (net.minecraft.world.World)8 TileEntity (net.minecraft.tileentity.TileEntity)7 Block (net.minecraft.block.Block)6 BaseBlock (mcjty.lib.container.BaseBlock)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 IGregTechTileEntity (gregtech.api.interfaces.tileentity.IGregTechTileEntity)3 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)3 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)3 SacrificeKnifeUsedEvent (WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent)2 IMinerStats (cavern.api.IMinerStats)2