net.minecraft.util.EnumActionResult Java Examples
The following examples show how to use
net.minecraft.util.EnumActionResult.
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 File: SoftHammerBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (world.isRemote || world.isAirBlock(pos)) { return EnumActionResult.PASS; } ItemStack stack = player.getHeldItem(hand); TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity != null) { IControllable controllable = tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, side); if (controllable != null) { if (controllable.isWorkingEnabled()) { controllable.setWorkingEnabled(false); } else { controllable.setWorkingEnabled(true); } GTUtility.doDamageItem(stack, cost, false); return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
Example #2
Source File: ObsidianReplaceModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
private void handlePlaceRequest(final Minecraft minecraft, final PlacementRequest placementRequest) { final BlockPos structurePosition = placementRequest.getStructurePosition(); final IBlockState structureBlockState = minecraft.world.getBlockState(structurePosition); final boolean blockActivated = structureBlockState.getBlock().onBlockActivated(minecraft.world, structurePosition, structureBlockState, minecraft.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0.0f, 0.0f, 0.0f); if (blockActivated) minecraft.player.connection.sendPacket(new CPacketEntityAction(minecraft.player, CPacketEntityAction.Action.START_SNEAKING)); if (minecraft.playerController.processRightClickBlock(minecraft.player, minecraft.world, structurePosition, placementRequest.getPlaceDirection(), Vec3d.ZERO, EnumHand.MAIN_HAND) != EnumActionResult.FAIL) minecraft.player.swingArm(EnumHand.MAIN_HAND); if (blockActivated) minecraft.player.connection.sendPacket(new CPacketEntityAction(minecraft.player, CPacketEntityAction.Action.STOP_SNEAKING)); }
Example #3
Source File: ItemComponentBox.java From Cyberware with MIT License | 6 votes |
@Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (playerIn.isSneaking()) { EnumActionResult res = super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); if (res == EnumActionResult.SUCCESS && playerIn.isCreative()) { playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null; } return res; } else { playerIn.openGui(Cyberware.INSTANCE, 6, worldIn, 0, 0, 0); } return EnumActionResult.SUCCESS; }
Example #4
Source File: ItemSeeds.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); IBlockState state = worldIn.getBlockState(pos); if (facing == EnumFacing.UP && player.canPlayerEdit(pos.offset(facing), facing, itemstack) && state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up())) { worldIn.setBlockState(pos.up(), content.plant.createState()); if (player instanceof EntityPlayerMP) { CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP) player, pos.up(), itemstack); } itemstack.shrink(1); return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
Example #5
Source File: ItemSakuraDiamond.java From Sakura_mod with MIT License | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, false); if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && worldIn.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.END_PORTAL_FRAME) { return new ActionResult<ItemStack>(EnumActionResult.PASS, itemstack); } if (worldIn.isRemote) { int j = worldIn.rand.nextInt(2) * 2 - 1; int k = worldIn.rand.nextInt(2) * 2 - 1; double d0 = playerIn.getPosition().getX() + 0.25D * j; double d1 = playerIn.getPosition().getY() + 1D; double d2 = playerIn.getPosition().getZ() + 0.25D * k; double d3 = worldIn.rand.nextFloat() * j * 0.1D; double d4 = (worldIn.rand.nextFloat() * 0.055D) + 0.015D; double d5 = worldIn.rand.nextFloat() * k * 0.1D; SakuraMain.proxy.spawnParticle(SakuraParticleType.LEAVESSAKURA, d0, d1, d2, d3, -d4, d5); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); }
Example #6
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getOrCreateNbtData(playerStack); if (nbt.hasKey(COLOR)) { int i = nbt.getInteger(COLOR); if (i + 1 > 15) { nbt.setInteger(COLOR, 0); } else { nbt.setInteger(COLOR, i + 1); } } else { nbt.setInteger(COLOR, 0); } if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.cutterUse); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } return ActionResult.newResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); }
Example #7
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand handIn) { if (!playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getNbtData(playerStack); if (nbt.hasKey(COLOR)) { EnumDyeColor dye = EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)); if (colorBlock(world.getBlockState(pos), world, pos, null, dye)) { if (playerStack.getItemDamage() < playerStack.getMaxDamage()) { playerStack.damageItem(1, playerIn); if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.painterUse); } } else { playerIn.setHeldItem(handIn, GTMaterialGen.get(GTItems.sprayCanEmpty)); if (!IC2.platform.isSimulating()) { playerIn.playSound(SoundEvents.ENTITY_ITEM_BREAK, 1.0F, 1.0F); } } return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; }
Example #8
Source File: HandItem.java From pycode-minecraft with MIT License | 6 votes |
@Override public EnumActionResult onItemUse(ItemStack stackIn, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (world.isRemote) { return EnumActionResult.PASS; } if (stackIn.stackSize != 0) { float yaw = player.getHorizontalFacing().getHorizontalAngle(); NBTTagCompound compound = stackIn.getTagCompound(); HandEntity entity = new HandEntity(world, compound, pos.getX() + .5, pos.getY() + 1.0, pos.getZ() + .5, yaw); world.spawnEntityInWorld(entity); --stackIn.stackSize; return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
Example #9
Source File: EasyPlaceUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean handleEasyPlaceWithMessage(Minecraft mc) { if (isHandling) { return false; } isHandling = true; EnumActionResult result = handleEasyPlace(mc); isHandling = false; // Only print the warning message once per right click if (isFirstClickEasyPlace && result == EnumActionResult.FAIL) { InfoUtils.showMessage(Configs.InfoOverlays.EASY_PLACE_WARNINGS.getOptionListValue(), MessageType.WARNING, 1000, "litematica.message.easy_place_fail"); } isFirstClickEasyPlace = false; return result != EnumActionResult.PASS; }
Example #10
Source File: ItemTofuHoe.java From TofuCraftReload with MIT License | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (!player.canPlayerEdit(pos.offset(facing), facing, itemstack)) { return EnumActionResult.FAIL; } else { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (block == BlockLoader.MOMENTOFU || block == BlockLoader.tofuTerrain) { this.setBlock(itemstack, player, worldIn, pos, BlockLoader.TOFUFARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } }
Example #11
Source File: ScaffoldModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
private void placeBlock(BlockPos pos) { final Minecraft mc = Minecraft.getMinecraft(); BlockPos[][] posit = {{pos.add(0, 0, 1), pos.add(0, 0, -1)}, {pos.add(0, 1, 0), pos.add(0, -1, 0)}, {pos.add(1, 0, 0),pos.add(-1, 0, 0)}}; EnumFacing[][] facing = {{EnumFacing.NORTH, EnumFacing.SOUTH}, {EnumFacing.DOWN, EnumFacing.UP}, {EnumFacing.WEST, EnumFacing.EAST}}; // Facing reversed as blocks are placed while facing in the opposite direction for (int i=0; i<6; i++) { final Block block = mc.world.getBlockState(posit[i/2][i%2]).getBlock(); final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); if (block != null && block != Blocks.AIR && !(block instanceof BlockLiquid)) { if (activated) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); if (mc.playerController.processRightClickBlock(mc.player, mc.world, posit[i/2][i%2], facing[i/2][i%2], new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) mc.player.swingArm(EnumHand.MAIN_HAND); if (activated) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); } } }
Example #12
Source File: ItemThatMakesYouSayDab.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if(!world.isRemote) { String text = Math.random() >= 0.01 ? "Dab" : "Neat (is a mod by Vazkii)"; world.getMinecraftServer().getPlayerList().sendMessage(new TextComponentTranslation("chat.type.text", player.getName(), text)); if(Dabbbbb.whenUBoppin) { for(int i = 0; i < 10; i++) { world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1, (i / 10f) + 0.5f); } player.motionY += 10; player.velocityChanged = true; } } return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); }
Example #13
Source File: ItemRainStick.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack heldStack = player.getHeldItem(hand); if (!player.capabilities.isCreativeMode) heldStack.shrink(1); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SKELETON_DEATH, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { WorldInfo worldinfo = world.getWorldInfo(); worldinfo.setCleanWeatherTime(0); worldinfo.setRainTime(1200); worldinfo.setThunderTime(1200); worldinfo.setRaining(true); worldinfo.setThundering(false); } else player.sendMessage(new TextComponentString("Dark clouds start forming in the sky")); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, heldStack); }
Example #14
Source File: ItemRailConfigurator.java From Signals with GNU General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand){ if(!world.isRemote) { TileEntity te = world.getTileEntity(pos); if(te != null) { CapabilityDestinationProvider cap = te.getCapability(CapabilityDestinationProvider.INSTANCE, null); if(cap != null) { List<IDestinationProvider> providers = cap.getApplicableDestinationProviders(); List<IDestinationProvider> guiProviders = new ArrayList<>(); for(IDestinationProvider provider : providers) if(provider.hasGui(te)) guiProviders.add(provider); if(guiProviders.size() > 1) { player.openGui(Signals.instance, EnumGuiId.SELECT_DESTINATION_PROVIDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); return EnumActionResult.SUCCESS; } else if(!guiProviders.isEmpty()) { guiProviders.get(0).openGui(te, player); return EnumActionResult.SUCCESS; } } } } return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand); }
Example #15
Source File: ItemBomb.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (!world.isRemote) { EntityBomb bomb = new EntityBomb(world, player); bomb.setBombItem(stack); bomb.setPosition(player.posX, player.posY + player.eyeHeight, player.posZ); bomb.shoot(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); stack.shrink(1); world.spawnEntity(bomb); bomb.velocityChanged = true; } player.getCooldownTracker().setCooldown(this, 20); return new ActionResult<>(EnumActionResult.PASS, stack); }
Example #16
Source File: GTItemDuctTape.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (player.isSneaking()) { return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else if (tileEntity instanceof IInsulationModifieableConductor) { IInsulationModifieableConductor wire = (IInsulationModifieableConductor) tileEntity; if (wire.tryAddInsulation()) { player.getHeldItem(hand).damageItem(1, player); IC2.audioManager.playOnce(player, Ic2Sounds.painterUse); return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } } else { return EnumActionResult.FAIL; } }
Example #17
Source File: ItemRailConfigurator.java From Signals with GNU General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ ItemStack stack = playerIn.getHeldItem(hand); if(!worldIn.isRemote) { TileEntity te = worldIn.getTileEntity(pos); if(te instanceof TileEntityRailLinkBase && playerIn.isSneaking()) { TileEntityRailLinkBase railLinkBase = (TileEntityRailLinkBase)te; MCPos railPos = getLinkedRail(stack); if(railPos != null) { if(railLinkBase.setLinkedPos(railPos, playerIn)) { playerIn.sendMessage(new TextComponentString("Linked to " + railPos)); } } } else { IBlockState state = worldIn.getBlockState(pos); IRail r = RailManager.getInstance().getRail(worldIn, pos, state); if(r != null) { setLinkedRail(stack, new MCPos(worldIn, pos)); playerIn.sendMessage(new TextComponentString("Pos: " + pos)); } } } return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); }
Example #18
Source File: ItemPebble.java From ExNihiloAdscensio with MIT License | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { stack.stackSize--; world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { ItemStack thrown = stack.copy(); thrown.stackSize = 1; ProjectileStone projectile = new ProjectileStone(world, player); projectile.setStack(thrown); projectile.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 0.5F); world.spawnEntity(projectile); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
Example #19
Source File: GTItemDestructoPack.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (playerIn.isSneaking() && playerIn.isCreative()) { for (int i = 0; i < playerIn.inventory.getSizeInventory(); i++) { Item item = playerIn.inventory.getStackInSlot(i).getItem(); if (!(item instanceof GTItemDestructoPack || item instanceof GTItemCreativeScanner || item instanceof GTItemSurvivalScanner || item instanceof GTItemMagnifyingGlass)) { playerIn.inventory.setInventorySlotContents(i, ItemStack.EMPTY); } } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } if (IC2.platform.isSimulating()) { IC2.platform.launchGui(playerIn, this.getInventory(playerIn, handIn, playerIn.getHeldItem(handIn)), handIn); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); }
Example #20
Source File: ItemTicket.java From Signals with GNU General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand){ ItemStack stack = player.getHeldItem(hand); if(!world.isRemote) { TileEntity te = world.getTileEntity(pos); if(te instanceof TileEntityStationMarker) { TileEntityStationMarker stationMarker = (TileEntityStationMarker)te; String stationName = stationMarker.getStationName(); appendDestination(stack, stationName); String concatDestinations = getConcattedDestinations(stack); player.sendMessage(new TextComponentTranslation("signals.message.added_destination", TextFormatting.GOLD + stationName + TextFormatting.WHITE, TextFormatting.GOLD + concatDestinations + TextFormatting.WHITE)); return EnumActionResult.SUCCESS; } } return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand); }
Example #21
Source File: ItemExpCapsule.java From Cyberware with MIT License | 6 votes |
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (!playerIn.capabilities.isCreativeMode) { --stack.stackSize; } int xp = 0; if (stack.hasTagCompound()) { NBTTagCompound c = stack.getTagCompound(); if (c.hasKey("xp")) { xp = c.getInteger("xp"); } } playerIn.addExperience(xp); return new ActionResult(EnumActionResult.SUCCESS, stack); }
Example #22
Source File: GTItemFluidTube.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public ActionResult<ItemStack> tryPickUpFluid(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand, ItemStack itemstack, FluidStack fluidStack) { RayTraceResult mop = this.rayTrace(world, player, true); ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(player, world, itemstack, mop); if (ret != null) return ret; if (mop == null) { return ActionResult.newResult(EnumActionResult.PASS, itemstack); } BlockPos clickPos = mop.getBlockPos(); if (world.isBlockModifiable(player, clickPos)) { FluidActionResult result = FluidUtil.tryPickUpFluid(itemstack, player, world, clickPos, mop.sideHit); if (result.isSuccess()) { ItemHandlerHelper.giveItemToPlayer(player, result.getResult()); itemstack.shrink(1); return ActionResult.newResult(EnumActionResult.SUCCESS, itemstack); } } return ActionResult.newResult(EnumActionResult.FAIL, itemstack); }
Example #23
Source File: GTItemSensorStick.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (IC2.platform.isRendering()) { IC2.audioManager.playOnce(player, Ic2Sounds.wrenchUse); return EnumActionResult.SUCCESS; } TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof IGTCoordinateTile) { return tryParseCoords((IGTCoordinateTile) tileEntity, world, player, hand); } else { NBTTagCompound nbt = StackUtil.getOrCreateNbtData(player.getHeldItem(hand)); nbt.setIntArray(POS, new int[] { pos.getX(), pos.getY(), pos.getZ(), world.provider.getDimension() }); String blockName = world.getBlockState(pos).getBlock().getLocalizedName(); nbt.setString(BLOCK, blockName); IC2.platform.messagePlayer(player, "Coordinates set to " + blockName); } return EnumActionResult.SUCCESS; }
Example #24
Source File: ItemSeedBase.java From ExNihiloAdscensio with MIT License | 6 votes |
@Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!facing.equals(EnumFacing.UP)) return EnumActionResult.PASS; if (player.canPlayerEdit(pos, facing, stack) && player.canPlayerEdit(pos.add(0, 1, 0), facing, stack)) { IBlockState soil = world.getBlockState(pos); if (soil != null && soil.getBlock().canSustainPlant(soil, world, pos, EnumFacing.UP, this) && world.isAirBlock(pos.add(0, 1, 0)) && this.getPlant(world, pos) != null) { world.setBlockState(pos.add(0, 1, 0), this.getPlant(world, pos)); --stack.stackSize; return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
Example #25
Source File: CoverPlaceBehavior.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { TileEntity tileEntity = world.getTileEntity(pos); ICoverable coverable = tileEntity == null ? null : tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_COVERABLE, null); if (coverable == null) { return EnumActionResult.PASS; } EnumFacing coverSide = ICoverable.rayTraceCoverableSide(coverable, player); if (coverable.getCoverAtSide(coverSide) != null || !coverable.canPlaceCoverOnSide(coverSide)) { return EnumActionResult.PASS; } if (!world.isRemote) { ItemStack itemStack = player.getHeldItem(hand); boolean result = coverable.placeCoverOnSide(coverSide, itemStack, coverDefinition); if (result && !player.capabilities.isCreativeMode) { itemStack.shrink(1); } return result ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } return EnumActionResult.SUCCESS; }
Example #26
Source File: GTItemBaseToggleItem.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { IC2.audioManager.playOnce(playerIn, toggleSound); if (IC2.platform.isSimulating()) { NBTTagCompound nbt = StackUtil.getOrCreateNbtData(playerIn.getHeldItem(handIn)); boolean result = !nbt.getBoolean(ACTIVE); nbt.setBoolean(ACTIVE, result); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); }
Example #27
Source File: ItemFood.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); if (playerIn.canEat(content.alwaysEdible.get(stack.getMetadata()).orElse(false))) { playerIn.setActiveHand(handIn); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } else { return new ActionResult<>(EnumActionResult.FAIL, stack); } }
Example #28
Source File: ItemFakeHaloBauble.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.getBlockState(pos).getBlock() == ModBlocks.ALTAR_SACRAMENT) { return EnumActionResult.SUCCESS; } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); }
Example #29
Source File: ItemSlab.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (!itemstack.isEmpty() && player.canPlayerEdit(pos.offset(facing), facing, itemstack)) { int subtype = getMetadata(itemstack); IBlockState currentState = worldIn.getBlockState(pos); if (currentState.getBlock() == singleSlab) { int subtype1 = this.singleSlabCS.getSubtype(currentState); net.minecraft.block.BlockSlab.EnumBlockHalf half = currentState.getValue(net.minecraft.block.BlockSlab.HALF); if ((facing == EnumFacing.UP && half == net.minecraft.block.BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && half == net.minecraft.block.BlockSlab.EnumBlockHalf.TOP) && subtype1 == subtype) { IBlockState stateDouble = this.makeState(subtype1); AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos); if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11)) { SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); itemstack.shrink(1); } return EnumActionResult.SUCCESS; } } return this.tryPlace(player, itemstack, worldIn, pos.offset(facing), subtype) ? EnumActionResult.SUCCESS : super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else { return EnumActionResult.FAIL; } }
Example #30
Source File: ColorSprayBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (!player.canPlayerEdit(pos, side, stack)) { return EnumActionResult.FAIL; } if (!tryPaintBlock(world, pos, side)) { return EnumActionResult.PASS; } useItemDurability(player, hand, stack, empty.copy()); return EnumActionResult.SUCCESS; }