net.minecraft.entity.player.EntityPlayer Java Examples

The following examples show how to use net.minecraft.entity.player.EntityPlayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: OpenModsLib   Author: OpenMods   File: CalcState.java    License: MIT License 6 votes vote down vote up
@Override
protected Calculator<?, ExprType> newCalculator(final SenderHolder holder) {
	final Calculator<TypedValue, ExprType> calculator = TypedValueCalculatorFactory.create();

	final TypedValue nullValue = calculator.environment.nullValue();
	final TypeDomain domain = nullValue.domain;
	calculator.environment.setGlobalSymbol("player", new NullaryFunction.Direct<TypedValue>() {

		@Override
		protected TypedValue call() {
			if (holder.sender instanceof EntityPlayer) {
				final EntityPlayerWrapper wrapper = new EntityPlayerWrapper((EntityPlayer)holder.sender, nullValue);
				return StructWrapper.create(domain, wrapper);
			}

			return nullValue;
		}

	});

	return calculator;
}
 
Example #2
Source Project: Artifacts   Author: Draco18s   File: ComponentLightning.java    License: MIT License 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer player, EntityLivingBase entityLiving) {
	if(player.worldObj.isRemote) {
		PacketBuffer out = new PacketBuffer(Unpooled.buffer());
			//System.out.println("Building packet...");
			out.writeInt(PacketHandlerServer.LIGHTNING);
			out.writeInt(player.getEntityId());
			//EntityPlayer par3EntityPlayer = (EntityPlayer) par3EntityLivingBase;
			out.writeInt(player.inventory.currentItem);
			//out.writeFloat(par3EntityPlayer.getHealth()+1);
			CToSMessage packet = new CToSMessage(out);
			DragonArtifacts.artifactNetworkWrapper.sendToServer(packet);
			//par1ItemStack.damageItem(1, par2EntityPlayer);
			return true;
		
	}
	return false;
}
 
Example #3
Source Project: Gadomancy   Author: makeo   File: AdvancedFakePlayer.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean isFakePlayer(EntityPlayer player) {
    if(!player.worldObj.isRemote) {
        if(player.getClass() != EntityPlayerMP.class) {
            return true;
        }
        EntityPlayerMP mp = (EntityPlayerMP) player;

        if(mp.playerNetServerHandler == null
                || !MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player)
                || mp.getPlayerIP() == null || mp.getPlayerIP().trim().isEmpty()) {
            return true;
        }

        try {
            mp.playerNetServerHandler.netManager.getSocketAddress().toString();
        } catch (Exception e) {
            return true;
        }
    }
    return false;
}
 
Example #4
Source Project: WearableBackpacks   Author: copygirl   File: ItemBackpack.java    License: MIT License 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn,
                                        EntityLivingBase target, EnumHand hand) {
	// When right clicking a non-player entity with a backpack in
	// creative, make the target entity equip the held backpack.
	if (playerIn.world.isRemote || !playerIn.isCreative() ||
	    !BackpackRegistry.canEntityWearBackpacks(target) ||
	    (target instanceof EntityPlayer)) return false;
	
	// If the target entity is already wearing a backpack, call
	// onFaultyRemoval, which may for example drop the backpack's items.
	IBackpack backpack = BackpackHelper.getBackpack(target);
	if (backpack != null) backpack.getType().onFaultyRemoval(target, backpack);
	
	stack = stack.splitStack(1); // This reduces the held stack's size while
	                             // giving us a copy with a stack size of 1.
	// (Not necessary since in creative, but this is the right way to do things!)
	IBackpackData data = BackpackHelper.getBackpackType(stack).createBackpackData(stack);
	BackpackHelper.setEquippedBackpack(target, stack, data);
	
	return true;
}
 
Example #5
Source Project: TFC2   Author: Deadrik   File: ContainerPlayerTFC.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onContainerClosed(EntityPlayer player)
{
	if(!player.world.isRemote)
	{
		super.onContainerClosed(player);

		for (int i = 0; i < 9; ++i)
		{
			ItemStack itemstack = this.craftMatrix.removeStackFromSlot(i);
			if (!itemstack.isEmpty())
				player.dropItem(itemstack, false);
		}

		this.craftResult.setInventorySlotContents(0, ItemStack.EMPTY);
	}
}
 
Example #6
Source Project: Levels   Author: TheXFactor117   File: EventSoulBound.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
	EntityPlayer player = event.getEntityPlayer();
	Item item;
	
	for (int i = 0; i < event.getDrops().size(); i++)
	{
		item = event.getDrops().get(i).getEntityItem().getItem();
		
		if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow))
		{
			ItemStack stack = event.getDrops().get(i).getEntityItem();
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (nbt != null)
			{
				if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt))
				{
					event.getDrops().remove(i);
					player.inventory.addItemStackToInventory(stack);
				}
			}
		}
	}
}
 
Example #7
Source Project: GT-Classic   Author: e99999   File: GTTileMagicEnergyAbsorber.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean isConvertingBookItem() {
	ItemStack inputStack = this.getStackInSlot(slotInput);
	int level = GTHelperStack.getBookEnchantmentLevel(inputStack);
	if (level > 0 && !this.isFull()) {
		int generate = world.rand.nextInt(20000 * level);
		ItemStack blankBook = GTMaterialGen.get(Items.BOOK);
		if (!GTHelperStack.canMerge(blankBook, this.getStackInSlot(slotOutput))) {
			return false;
		}
		this.addEnergy(generate);
		this.setStackInSlot(slotOutput, StackUtil.copyWithSize(blankBook, this.getStackInSlot(slotOutput).getCount()
				+ 1));
		inputStack.shrink(1);
		world.playSound((EntityPlayer) null, this.pos, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, 0.75F
				+ world.rand.nextFloat());
		return true;
	}
	return false;
}
 
Example #8
Source Project: litematica   Author: maruohon   File: InputHandler.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean nudgeSelection(int amount, ToolMode mode, EntityPlayer player)
{
    if (mode.getUsesAreaSelection())
    {
        DataManager.getSelectionManager().moveSelectedElement(EntityUtils.getClosestLookingDirection(player), amount);
        return true;
    }
    else if (mode.getUsesSchematic())
    {
        EnumFacing direction = EntityUtils.getClosestLookingDirection(player);
        DataManager.getSchematicPlacementManager().nudgePositionOfCurrentSelection(direction, amount);
        return true;
    }

    return false;
}
 
Example #9
Source Project: AdvancedRocketry   Author: zmaster587   File: TilePlanetSelector.java    License: MIT License 6 votes vote down vote up
@Override
public List<ModuleBase> getModules(int ID, EntityPlayer player) {

	List<ModuleBase> modules = new LinkedList<ModuleBase>();

	container = new ModulePlanetSelector(0, TextureResources.starryBG, this, true);
	container.setOffset(1000, 1000);
	modules.add(container);

	//Transfer discovery values
	if(!world.isRemote) {
		markDirty();
	}

	return modules;
}
 
Example #10
Source Project: Wizardry   Author: TeamWizardry   File: CapeHandler.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void resolve(EntityPlayer player, Point point) {
	float yaw = (float) Math.toRadians(player.renderYawOffset);
	float height;
	float back;
	if (player.isSneaking()) {
		height = 1.15F;
		back = getBack(player, 0.135F);
	} else {
		height = 1.38F;
		back = getBack(player, 0.14F);
	}
	float vx = MathHelper.cos(yaw) * x + MathHelper.cos(yaw - (float) Math.PI / 2) * back;
	float vz = MathHelper.sin(yaw) * x + MathHelper.sin(yaw - (float) Math.PI / 2) * back;
	point.posX = (float) player.posX + vx;
	point.posY = (float) player.posY + height + y;
	point.posZ = (float) player.posZ + vz;
}
 
Example #11
Source Project: Sakura_mod   Author: 0999312   File: BlockBarrelDistillation.java    License: MIT License 6 votes vote down vote up
@Override
  public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
      if (world.isRemote) {
          return true;
      }
ItemStack stack = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityDistillation) {
    IFluidHandlerItem handler = FluidUtil.getFluidHandler(ItemHandlerHelper.copyStackWithSize(stack, 1));
    if (handler != null) {
        FluidUtil.interactWithFluidHandler(player, hand, tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side));
        return true;
    }
    player.openGui(SakuraMain.instance, SakuraGuiHandler.ID_DISTILLATION, world, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
return true;
  }
 
Example #12
Source Project: ToroQuest   Author: ToroCraft   File: MessageQuestUpdate.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void processDonate(EntityPlayer player, Province province, IVillageLordInventory inventory) {
	ItemStack donation = inventory.getDonationItem();

	if (MessageSetItemReputationAmount.isNoteForLord(province, donation)) {
		writeReplyNote(inventory, donation);
		return;
	}

	if (MessageSetItemReputationAmount.isStolenItemForProvince(province, donation)) {
		handleReturnStolenItem(player, province, inventory, donation);
		return;
	}

	DonationReward reward = getRepForDonation(donation);
	if (reward != null) {
		PlayerCivilizationCapabilityImpl.get(player).adjustReputation(province.civilization, reward.rep);
		inventory.setDonationItem(ItemStack.EMPTY);
		inventory.setReturnItems(l(new ItemStack(reward.item)));
	}
}
 
Example #13
Source Project: enderutilities   Author: maruohon   File: ItemLinkCrystal.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean doKeyBindingAction(EntityPlayer player, ItemStack stack, int key)
{
    // Alt + Shift + Toggle mode: Store the player's current location, including rotation
    if (EnumKey.TOGGLE.matches(key, HotKeys.MOD_SHIFT_ALT))
    {
        if (stack.getMetadata() == TYPE_PORTAL)
        {
            return false;
        }
        else
        {
            this.setTarget(stack, player, true);
            return true;
        }
    }

    return super.doKeyBindingAction(player, stack, key);
}
 
Example #14
Source Project: Electro-Magic-Tools   Author: TeamAmeriFrance   File: ItemShieldFocus.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world, EntityPlayer player, int count) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);

    // Player Level
    if ((player.worldObj.getBlock(x + 1, y, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x - 1, y, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y, z + 1) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y, z - 1) == IC2BlockRegistry.shield)) {
        player.worldObj.setBlockToAir(x + 1, y, z);
        player.worldObj.setBlockToAir(x - 1, y, z);
        player.worldObj.setBlockToAir(x, y, z + 1);
        player.worldObj.setBlockToAir(x, y, z - 1);
    }

    // Above the player
    if ((player.worldObj.getBlock(x + 1, y + 1, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x - 1, y + 1, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y + 1, z + 1) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y + 1, z - 1) == IC2BlockRegistry.shield)) {
        player.worldObj.setBlockToAir(x + 1, y + 1, z);
        player.worldObj.setBlockToAir(x - 1, y + 1, z);
        player.worldObj.setBlockToAir(x, y + 1, z + 1);
        player.worldObj.setBlockToAir(x, y + 1, z - 1);
    }

    ItemStack milk = (new ItemStack(Items.milk_bucket));
    player.curePotionEffects(milk);
}
 
Example #15
Source Project: Sakura_mod   Author: 0999312   File: BlockNoodle.java    License: MIT License 6 votes vote down vote up
@Override
  public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
  		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  	if (worldIn.isRemote) {
          return true;
      }
int i = this.getCutting(state);
ItemStack stack = playerIn.getHeldItem(hand);
if(!isReady(state)){
    if(stack.getItem() instanceof ItemKnifeNoodle){
    	if(!playerIn.isCreative()) stack.damageItem(1, playerIn);
    	 if (worldIn.rand.nextInt(8) == 0) {
    		 worldIn.setBlockState(pos, this.withCutting(i + 1), 2);
    		 return true;
    	 }
    }
}else{
	worldIn.setBlockToAir(pos);
	spawnAsEntity(worldIn, pos, getNoodle());
}
return true;
  }
 
Example #16
Source Project: Artifacts   Author: Draco18s   File: ComponentObscurity.java    License: MIT License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world,	EntityPlayer player) {
	UtilsForComponents.sendPotionPacket(14, 600, 0, player);
	player.addPotionEffect(new PotionEffect(14, 600, 0));
	ArtifactClientEventHandler.cloaked = true;
	//System.out.println("Cloaking player.");
	UtilsForComponents.sendItemDamagePacket(player, player.inventory.currentItem, 1); //itemStack.damageItem(1, player);
	itemStack.stackTagCompound.setInteger("onItemRightClickDelay", 200);
	return itemStack;
}
 
Example #17
Source Project: Et-Futurum   Author: ganymedes01   File: EntityArmourStand.java    License: The Unlicense 5 votes vote down vote up
@Override
public boolean interact(EntityPlayer player) {
	if (worldObj.isRemote) {
		EtFuturum.networkWrapper.sendToServer(new ArmourStandInteractMessage(worldObj.provider.dimensionId, this, player));
		return true;
	}
	return false;
}
 
Example #18
Source Project: enderutilities   Author: maruohon   File: EntityEnderArrow.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public EntityEnderArrow(World worldIn, EntityLivingBase shooter, EntityLivingBase par3EntityLivingBase, float par4, float par5)
{
    super(worldIn);
    this.shootingEntity = shooter;
    this.shooterUUID = shooter.getUniqueID();

    if (shooter instanceof EntityPlayer)
    {
        this.canBePickedUp = 1;

        if (((EntityPlayer)shooter).capabilities.isCreativeMode)
        {
            this.canBePickedUp = 2;
        }
    }

    this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D;
    double d0 = par3EntityLivingBase.posX - shooter.posX;
    double d1 = par3EntityLivingBase.getEntityBoundingBox().minY + (double)(par3EntityLivingBase.height / 3.0F) - this.posY;
    double d2 = par3EntityLivingBase.posZ - shooter.posZ;
    double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D)
    {
        float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
        float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
        double d4 = d0 / d3;
        double d5 = d2 / d3;
        this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3);
        float f4 = (float)d3 * 0.2F;
        this.shoot(d0, d1 + (double)f4, d2, par4, par5);
    }
}
 
Example #19
Source Project: PneumaticCraft   Author: MineMaarten   File: HackableCow.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onHackFinished(Entity entity, EntityPlayer player){
    if(!entity.worldObj.isRemote) {
        entity.setDead();
        EntityMooshroom entitycow = new EntityMooshroom(entity.worldObj);
        entitycow.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
        entitycow.setHealth(((EntityCow)entity).getHealth());
        entitycow.renderYawOffset = ((EntityCow)entity).renderYawOffset;
        entity.worldObj.spawnEntityInWorld(entitycow);
        entity.worldObj.spawnParticle("largeexplode", entity.posX, entity.posY + entity.height / 2.0F, entity.posZ, 0.0D, 0.0D, 0.0D);
    }
}
 
Example #20
Source Project: AgriCraft   Author: AgriCraft   File: ItemJournal.java    License: MIT License 5 votes vote down vote up
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (world.isRemote) {
        player.openGui(AgriCraft.instance, GuiHandler.JOURNAL_GUI_ID, world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
    }
    return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
 
Example #21
Source Project: WirelessRedstone   Author: Chicken-Bones   File: RedstoneEther.java    License: MIT License 5 votes vote down vote up
public void setFrequencyRange(String username, int firstfreq, int lastfreq, boolean jam) {
    if (!remote) {
        EntityPlayer player = ServerUtils.getPlayer(username);
        if (player != null)
            WRCoreSPH.sendSetFrequencyRangeTo(player, firstfreq, lastfreq, jam);
    }

    if (lastfreq > numfreqs)
        lastfreq = numfreqs;

    boolean[] jammedFreqs = getJammedFreqs(username);
    for (int settingfreq = firstfreq; settingfreq <= lastfreq; settingfreq++)
        jammedFreqs[settingfreq - 1] = jam;
}
 
Example #22
Source Project: BaseMetals   Author: cyanobacterium   File: ItemMetalIngot.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
   public void onCreated(final ItemStack item, final World world, final EntityPlayer crafter) {
   	super.onCreated(item, world, crafter);
   	crafter.addStat(Achievements.this_is_new, 1);

   	if(metal == Materials.aquarium) crafter.addStat(Achievements.aquarium_maker, 1);
   	if(metal == Materials.brass) crafter.addStat(Achievements.brass_maker, 1);
   	if(metal == Materials.bronze) crafter.addStat(Achievements.bronze_maker, 1);
   	if(metal == Materials.electrum) crafter.addStat(Achievements.electrum_maker, 1);
   	if(metal == Materials.steel) crafter.addStat(Achievements.steel_maker, 1);
   	if(metal == Materials.invar) crafter.addStat(Achievements.invar_maker, 1);
	if(metal == Materials.mithril) crafter.addStat(Achievements.mithril_maker, 1);
	if(metal == Materials.cupronickel) crafter.addStat(Achievements.cupronickel_maker, 1);
}
 
Example #23
Source Project: AdvancedRocketry   Author: zmaster587   File: PacketInvalidLocationNotify.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void executeClient(EntityPlayer thePlayer) {

FxErrorBlock fx3 = new FxErrorBlock(thePlayer.world,  toPos.x, toPos.y, toPos.z );
Minecraft.getMinecraft().effectRenderer.addEffect(fx3);
	
}
 
Example #24
Source Project: PneumaticCraft   Author: MineMaarten   File: HackableHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static IHackableBlock getHackableForCoord(IBlockAccess world, int x, int y, int z, EntityPlayer player){
    //clean up the map
    Iterator<Map.Entry<WorldAndCoord, IHackableBlock>> iterator = getInstance().trackedHackableBlocks.entrySet().iterator();
    while(iterator.hasNext()) {
        Map.Entry<WorldAndCoord, IHackableBlock> entry = iterator.next();
        Class<? extends IHackableBlock> hackableBlockClazz = PneumaticCraftAPIHandler.getInstance().hackableBlocks.get(entry.getKey().getBlock());
        if(hackableBlockClazz != entry.getValue().getClass() || !entry.getValue().canHack(entry.getKey().world, entry.getKey().x, entry.getKey().y, entry.getKey().z, player) && !isInDisplayCooldown(entry.getValue(), entry.getKey().world, entry.getKey().x, entry.getKey().y, entry.getKey().z, player)) iterator.remove();
    }

    Block block = world.getBlock(x, y, z);
    if(block instanceof IHackableBlock && ((IHackableBlock)block).canHack(world, x, y, z, player)) return (IHackableBlock)block;
    IHackableBlock hackable = getInstance().trackedHackableBlocks.get(new WorldAndCoord(world, x, y, z));
    if(hackable == null) {
        if(!PneumaticCraftAPIHandler.getInstance().hackableBlocks.containsKey(block)) return null;
        try {
            hackable = PneumaticCraftAPIHandler.getInstance().hackableBlocks.get(block).newInstance();
            if(hackable.canHack(world, x, y, z, player)) {
                getInstance().trackedHackableBlocks.put(new WorldAndCoord(world, x, y, z), hackable);
            } else {
                hackable = null;
            }
        } catch(Exception e) {
            //shouldn't happen, checked earlier.
            e.printStackTrace();
        }
    }
    return hackable;
}
 
Example #25
Source Project: WirelessRedstone   Author: Chicken-Bones   File: ItemWirelessPart.java    License: MIT License 5 votes vote down vote up
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 vhit) {
    BlockCoord onPos = pos.copy().offset(side ^ 1);
    if (!world.isSideSolid(onPos.x, onPos.y, onPos.z, ForgeDirection.getOrientation(side)))
        return null;

    WirelessPart part = getPart(item.getItemDamage());
    part.setupPlacement(player, side);
    return part;
}
 
Example #26
Source Project: WirelessRedstone   Author: Chicken-Bones   File: ItemWirelessRemote.java    License: MIT License 5 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {
    if (!(entity instanceof EntityPlayer))
        return;

    int freq = getItemFreq(stack);
    EntityPlayer player = (EntityPlayer) entity;

    if (getTransmitting(stack) && (!held || !RedstoneEtherAddons.get(world.isRemote).isRemoteOn(player, freq)) &&
            !RedstoneEtherAddons.get(world.isRemote).deactivateRemote(world, player))
        stack.setItemDamage(freq);
}
 
Example #27
Source Project: Cyberware   Author: Flaxbeard   File: ItemEngineeringTable.java    License: MIT License 5 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	if (facing != EnumFacing.UP)
	{
		return EnumActionResult.FAIL;
	}
	else
	{
		IBlockState iblockstate = worldIn.getBlockState(pos);
		Block block = iblockstate.getBlock();

		if (!block.isReplaceable(worldIn, pos))
		{
			pos = pos.offset(facing);
		}

		if (playerIn.canPlayerEdit(pos, facing, stack) && this.block.canPlaceBlockAt(worldIn, pos))
		{
			EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);
			int i = enumfacing.getFrontOffsetX();
			int j = enumfacing.getFrontOffsetZ();
			placeDoor(worldIn, pos, enumfacing, this.block);
			SoundType soundtype = this.block.getSoundType();
			worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
			--stack.stackSize;
			return EnumActionResult.SUCCESS;
		}
		else
		{
			return EnumActionResult.FAIL;
		}
	}
}
 
Example #28
Source Project: enderutilities   Author: maruohon   File: ItemChairWand.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
    if (player.getEntityWorld().isRemote == false && entity instanceof EntityChair)
    {
        entity.setDead();
        return true;
    }

    return super.onLeftClickEntity(stack, player, entity);
}
 
Example #29
Source Project: AdvancedRocketry   Author: zmaster587   File: TileSatelliteBuilder.java    License: MIT License 5 votes vote down vote up
@Override
public void useNetworkData(EntityPlayer player, Side side, byte id,
		NBTTagCompound nbt) {
	super.useNetworkData(player, side, id, nbt);


	onInventoryButtonPressed(id - 100);
}
 
Example #30
Source Project: NOVA-Core   Author: NOVA-Team   File: PacketPlayerItem.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handleServerSide(EntityPlayer player) {
	ItemStack stack = player.inventory.getStackInSlot(this.slotId);

	if (stack != null && stack.getItem() instanceof Syncable) {
		MCPacket mcPacket = new MCPacket(data);
		mcPacket.setID(data.readInt());
		((Syncable) stack.getItem()).read(mcPacket);
	}
}