Java Code Examples for net.minecraft.entity.player.EntityPlayer#isSneaking()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#isSneaking() .
These examples are extracted from open source projects.
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: ToroQuest File: EntityShopkeeper.java License: GNU General Public License v3.0 | 6 votes |
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) { boolean flag = stack != null && stack.getItem() == Items.SPAWN_EGG; if (!flag && isEntityAlive() && !isTrading() && !isChild() && !player.isSneaking()) { if (!this.world.isRemote) { RepData rep = getReputation(player); if (rep.rep.equals(ReputationLevel.OUTCAST) || rep.rep.equals(ReputationLevel.ENEMY) || rep.rep.equals(ReputationLevel.VILLAIN)) { chat(player, "I WILL NOT TRADE WITH A " + rep.rep); } else { this.setCustomer(player); player.displayVillagerTradeGui(this); } } player.addStat(StatList.TALKED_TO_VILLAGER); return true; } else { return super.processInteract(player, hand); } }
Example 2
Source Project: WirelessRedstone File: WirelessPart.java License: MIT License | 6 votes |
@Override public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack held) { if (hit.sideHit == (side() ^ 1) && player.isSneaking()) { int r = rotation(); setRotation((r + 1) % 4); if (!tile().canReplacePart(this, this)) { setRotation(r); return false; } if (!world().isRemote) { updateChange(); onPartChanged(this); } else { setRotation(r); } return true; } return false; }
Example 3
Source Project: Cyberware File: BlockScanner.java License: MIT License | 6 votes |
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityScanner) { if (player.isCreative() && player.isSneaking()) { TileEntityScanner scanner = ((TileEntityScanner) tileentity); scanner.ticks = CyberwareConfig.SCANNER_TIME - 200; } player.openGui(Cyberware.INSTANCE, 3, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; }
Example 4
Source Project: enderutilities File: ItemPickupManager.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote == false) { TileEntity te = world.getTileEntity(pos); // When sneak-right-clicking on an inventory or an Ender Chest, and the installed Link Crystal is a block type crystal, // then bind the crystal to the block clicked on. if (player.isSneaking() && te != null && (te.getClass() == TileEntityEnderChest.class || te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))) { ItemStack stack = player.getHeldItem(hand); UtilItemModular.setTarget(stack, player,pos, side, hitX, hitY, hitZ, false, false); } } return EnumActionResult.SUCCESS; }
Example 5
Source Project: WearableBackpacks File: BlockBackpack.java License: MIT License | 5 votes |
@Override @SuppressWarnings("deprecation") public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) { // Equipping a backpack is faster than breaking it. // Trying to equip a backpack when not possible will make it appear unbreakable. float hardness = super.getPlayerRelativeBlockHardness(state, player, worldIn, pos); boolean sneaking = player.isSneaking(); boolean canEquip = BackpackHelper.canEquipBackpack(player); return (sneaking && !canEquip) ? -1.0F /* Unbreakable */ : (hardness * (sneaking ? 4 : 1)); }
Example 6
Source Project: PneumaticCraft File: ItemRemote.java License: GNU General Public License v3.0 | 5 votes |
private void openGui(EntityPlayer player, ItemStack remote){ if(player.isSneaking()) { if(isAllowedToEdit(player, remote)) { player.openGui(PneumaticCraft.instance, EnumGuiId.REMOTE_EDITOR.ordinal(), player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ); NetworkHandler.sendTo(new PacketNotifyVariablesRemote(GlobalVariableManager.getInstance().getAllActiveVariableNames()), (EntityPlayerMP)player); } } else { player.openGui(PneumaticCraft.instance, EnumGuiId.REMOTE.ordinal(), player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ); } }
Example 7
Source Project: enderutilities File: BlockInserter.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty() && player.getHeldItemOffhand().isEmpty()) { if (world.isRemote == false) { TileEntityInserter te = getTileEntitySafely(world, pos, TileEntityInserter.class); if (te != null) { Pair<Part, EnumFacing> key = this.getPointedElementId(world, pos, state.getActualState(world, pos).getValue(FACING), player); // Targeting one of the side outputs if (key != null && key.getLeft() == Part.SIDE) { side = key.getRight(); } if (side == te.getFacing() || side == te.getFacing().getOpposite()) { te.setFacing(te.getFacing().getOpposite()); } else { te.toggleOutputSide(side); } } } return true; } return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); }
Example 8
Source Project: GregTech File: MetaTileEntity.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * Called when player clicks wrench on specific side of this meta tile entity * * @return true if something happened, so wrench will get damaged and animation will be played */ public boolean onWrenchClick(EntityPlayer playerIn, EnumHand hand, EnumFacing wrenchSide, CuboidRayTraceResult hitResult) { if (playerIn.isSneaking()) { if (wrenchSide == getFrontFacing() || !isValidFrontFacing(wrenchSide) || !hasFrontFacing()) { return false; } if (wrenchSide != null && !getWorld().isRemote) { setFrontFacing(wrenchSide); } return true; } return false; }
Example 9
Source Project: GT-Classic File: GTTileMultiLESU.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing facing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.onNetworkEvent(player, 0); if (this.isSimulating()) { IC2.platform.messagePlayer(player, this.getRedstoneMode()); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example 10
Source Project: GregTech File: MetaTileEntityBlockBreaker.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onWrenchClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, CuboidRayTraceResult hitResult) { if (!playerIn.isSneaking()) { EnumFacing currentOutputSide = getOutputFacing(); if (currentOutputSide == facing || getFrontFacing() == facing) return false; setOutputFacing(facing); return true; } return super.onWrenchClick(playerIn, hand, facing, hitResult); }
Example 11
Source Project: Wizardry File: BlockManaBattery.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (playerIn.isCreative() && playerIn.isSneaking()) { buildStructure(worldIn, pos); } else { TileManaBattery tile = (TileManaBattery) worldIn.getTileEntity(pos); if (tile == null) return false; tile.revealStructure = !tile.revealStructure; tile.markDirty(); } return true; }
Example 12
Source Project: enderutilities File: ItemHandyBag.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { // If the bag is sneak + right clicked on an inventory, then we try to dump all the contents to that inventory if (player.isSneaking()) { this.tryMoveItems(world, pos, side, player.getHeldItem(hand), player); return EnumActionResult.SUCCESS; } return super.onItemUse(player,world, pos, hand, side, hitX, hitY, hitZ); }
Example 13
Source Project: Electro-Magic-Tools File: ItemElectricBootsTraveller.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if ((!player.capabilities.isFlying) && (player.moveForward > 0.0F)) { if ((player.worldObj.isRemote) && (!player.isSneaking())) { if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(player.getEntityId()))) { Thaumcraft.instance.entityEventHandler.prevStep.put(Integer.valueOf(player.getEntityId()), Float.valueOf(player.stepHeight)); } player.stepHeight = 1.0F; } if ((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F) { player.moveFlying(0F, 1F, speedBonus); player.jumpMovementFactor = jumpBonus; } } }
Example 14
Source Project: enderutilities File: ItemLocationBoundModular.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { if (world.isRemote == false) { ItemStack stack = player.getHeldItem(hand); if (this.useBindLocking(stack) == false || this.isBindLocked(stack) == false) { boolean adjustPosHit = UtilItemModular.getSelectedModuleTier(stack, ModuleType.TYPE_LINKCRYSTAL) == ItemLinkCrystal.TYPE_LOCATION; this.setTarget(stack, player, pos, side, hitX, hitY, hitZ, adjustPosHit, false); player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.itemboundtolocation"), true); } else { player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.itembindlocked"), true); } } return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
Example 15
Source Project: ExtraCells1 File: ItemStorageFluid.java License: MIT License | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack i, World w, EntityPlayer p) { if (p.isSneaking()) { if (Util.getCellRegistry().getHandlerForCell(i).storedItemCount() == 0 && p.inventory.addItemStackToInventory(new ItemStack(ItemEnum.STORAGECASING.getItemInstance(), 1, 1))) return new ItemStack(ItemEnum.STORAGECOMPONENT.getItemInstance(), 1, i.getItemDamage() + 4); // offset of 4 because FLUID cell } return i; }
Example 16
Source Project: ExtraCells1 File: BlockTerminalFluid.java License: MIT License | 5 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsetZ) { if (!world.isRemote) { if (world.getBlockTileEntity(x, y, z) == null || player.isSneaking()) { return false; } player.openGui(Extracells.instance, 1, world, x, y, z); } return true; }
Example 17
Source Project: enderutilities File: EntityEndermanFighter.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Nullable protected EntityPlayer getClosestVulnerablePlayer(double x, double y, double z, double distance) { double closest = -1.0d; EntityPlayer player = null; List<EntityPlayer> players = this.getEntityWorld().getPlayers(EntityPlayer.class, EntitySelectors.NOT_SPECTATING); for (EntityPlayer playerTmp : players) { if (playerTmp.capabilities.disableDamage == false && playerTmp.isEntityAlive() && this.isPlayerHoldingSummonItem(playerTmp) == false) { double distTmp = playerTmp.getDistanceSq(x, y, z); double distSight =playerTmp.isSneaking() ? distance * 0.8d : distance; if (playerTmp.isInvisible()) { float f = playerTmp.getArmorVisibility(); if (f < 0.1f) { f = 0.1f; } distSight *= (0.7d * f); } if ((distance < 0.0d || distTmp < (distSight * distSight)) && (closest == -1.0d || distTmp < closest)) { closest = distTmp; player = playerTmp; } } } return player; }
Example 18
Source Project: Cyberware File: BlockComponentBox.java License: MIT License | 5 votes |
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityComponentBox) { /*if (player.isCreative() && player.isSneaking()) { TileEntityScanner scanner = ((TileEntityScanner) tileentity); scanner.ticks = CyberwareConfig.SCANNER_TIME - 200; }*/ if (player.isSneaking()) { TileEntityComponentBox box = (TileEntityComponentBox) tileentity; ItemStack toDrop = this.getStack(box); if (player.inventory.mainInventory[player.inventory.currentItem] == null) { player.inventory.mainInventory[player.inventory.currentItem] = toDrop; } else { if (!player.inventory.addItemStackToInventory(toDrop)) { InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), toDrop); } } box.doDrop = false; worldIn.setBlockToAir(pos); } else { player.openGui(Cyberware.INSTANCE, 5, worldIn, pos.getX(), pos.getY(), pos.getZ()); } } return true; }
Example 19
Source Project: Signals File: ClientEventHandler.java License: GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onWorldRender(RenderWorldLastEvent event){ Tessellator t = Tessellator.getInstance(); BufferBuilder b = t.getBuffer(); EntityPlayer player = Minecraft.getMinecraft().player; if(!shouldRender()) return; double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.getPartialTicks(); double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.getPartialTicks(); double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.getPartialTicks(); int dimensionID = player.world.provider.getDimension(); GL11.glPushMatrix(); GL11.glTranslated(-playerX, -playerY, -playerZ); GL11.glPointSize(10); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); b.setTranslation(0, 0, 0); NetworkVisualizationSettings visualizationSettings = player.isSneaking() ? SignalsConfig.client.networkVisualization.sneaking : SignalsConfig.client.networkVisualization.notSneaking; switch(visualizationSettings.renderType){ case EDGES: edgeRenderer.render(dimensionID, b); break; case PATHS: pathRenderer.render(dimensionID, b); break; case SECTION: blockSectionRenderer.render(dimensionID, b); break; } //claimRenderer.render(b); if(visualizationSettings.renderDirectionality) { directionalityRenderer.render(dimensionID, b); } b.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); List<NetworkStation<MCPos>> stations = RailNetworkManager.getClientInstance().getNetwork().railObjects.getStations(); for(int i = 0; i < stations.size(); i++) { NetworkStation<MCPos> station1 = stations.get(i); if(station1.getPos().getDimID() != dimensionID) continue; for(int j = 0; j < i; j++) { NetworkStation<MCPos> station2 = stations.get(j); if(station2.getPos().getDimID() != dimensionID) continue; if(station1.stationName.equals(station2.stationName) && station1.getPos().getDimID() == station2.getPos().getDimID()) { drawBetween(b, station1.getPos().getPos(), station2.getPos().getPos(), 1, 0, 1, 0, 1); } } } t.draw(); GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); GL11.glPopMatrix(); }
Example 20
Source Project: ExtraCells1 File: BlockCertusTank.java License: MIT License | 4 votes |
@Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID, float offsetX, float offsetY, float offsetZ) { ItemStack current = entityplayer.inventory.getCurrentItem(); if (entityplayer.isSneaking() && current == null) { dropBlockAsItem_do(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z)); worldObj.destroyBlock(x, y, z, false); return true; } if (current != null) { FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); TileEntityCertusTank tank = (TileEntityCertusTank) worldObj.getBlockTileEntity(x, y, z); if (liquid != null) { int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true); if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode) { if (current.stackSize > 1) { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1; entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItemStack(current)); } else { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem().getContainerItemStack(current); } } return true; // Handle empty containers } else { FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; if (available != null) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); liquid = FluidContainerRegistry.getFluidForFilledItem(filled); if (liquid != null) { if (!entityplayer.capabilities.isCreativeMode) { if (current.stackSize > 1) { if (!entityplayer.inventory.addItemStackToInventory(filled)) { tank.fill(ForgeDirection.UNKNOWN, new FluidStack(liquid, liquid.amount), true); return false; } else { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1; } } else { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = filled; } } tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true); return true; } } } } return false; }