use of net.minecraft.util.ActionResult in project RFToolsDimensions by McJty.
the class DimensionMonitorItem method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
int id = player.getEntityWorld().provider.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (dimensionInformation == null) {
Logging.message(player, "Not an RFTools dimension!");
} else {
String name = dimensionInformation.getName();
DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
int power = storage != null ? storage.getEnergyLevel(id) : 0;
Logging.message(player, TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")" + TextFormatting.YELLOW + " Power: " + power + " RF");
if (player.isSneaking()) {
Logging.message(player, TextFormatting.RED + "Description: " + dimensionInformation.getDescriptor().getDescriptionString());
System.out.println("Description: = " + dimensionInformation.getDescriptor().getDescriptionString());
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project RFToolsDimensions by McJty.
the class KnownDimlet method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (world.isRemote) {
return new ActionResult<>(EnumActionResult.PASS, stack);
}
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
if (KnownDimletConfiguration.isSeedDimlet(key)) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
boolean locked = tagCompound.getBoolean("locked");
if (locked) {
Logging.message(player, TextFormatting.YELLOW + "This seed dimlet is locked. You cannot modify it!");
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
long forcedSeed = tagCompound.getLong("forcedSeed");
if (player.isSneaking()) {
if (forcedSeed == 0) {
Logging.message(player, TextFormatting.YELLOW + "This dimlet has no seed. You cannot lock it!");
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
tagCompound.setBoolean("locked", true);
Logging.message(player, "Dimlet locked!");
} else {
long seed = world.getSeed();
tagCompound.setLong("forcedSeed", seed);
Logging.message(player, "Seed set to: " + seed);
}
stack.setTagCompound(tagCompound);
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project SecurityCraft by Geforce132.
the class ItemModifiedBucket method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemStackIn = playerIn.getHeldItem(hand);
boolean flag = containedBlock == Blocks.AIR;
RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, flag);
ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(playerIn, worldIn, itemStackIn, raytraceresult);
if (ret != null)
return ret;
if (raytraceresult == null)
return new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn);
else if (raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK)
return new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn);
else {
BlockPos blockpos = raytraceresult.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
else if (flag) {
if (!playerIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemStackIn))
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
else {
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Material material = iblockstate.getMaterial();
if (material == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0) {
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 11);
playerIn.addStat(StatList.getObjectUseStats(this));
playerIn.playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, fillBucket(itemStackIn, playerIn, SCContent.fWaterBucket));
} else if (material == Material.LAVA && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0) {
playerIn.playSound(SoundEvents.ITEM_BUCKET_FILL_LAVA, 1.0F, 1.0F);
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 11);
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, fillBucket(itemStackIn, playerIn, SCContent.fLavaBucket));
} else
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
} else {
boolean flag1 = worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
BlockPos blockpos1 = flag1 && raytraceresult.sideHit == EnumFacing.UP ? blockpos : blockpos.offset(raytraceresult.sideHit);
if (!playerIn.canPlayerEdit(blockpos1, raytraceresult.sideHit, itemStackIn))
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
else if (this.tryPlaceContainedLiquid(playerIn, worldIn, blockpos1)) {
playerIn.addStat(StatList.getObjectUseStats(this));
return !playerIn.capabilities.isCreativeMode ? new ActionResult<ItemStack>(EnumActionResult.SUCCESS, new ItemStack(Items.BUCKET)) : new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
} else
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
}
}
use of net.minecraft.util.ActionResult in project SilentGems by SilentChaos512.
the class ItemDebug method clOnItemRightClick.
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
// playerIn.attackEntityFrom(DamageSource.inWall, 1.0f);
FoodStats food = playerIn.getFoodStats();
food.setFoodLevel(food.getFoodLevel() - 2);
food.setFoodSaturationLevel(food.getSaturationLevel() - 0.2f);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
use of net.minecraft.util.ActionResult in project SilentGems by SilentChaos512.
the class ItemSkillOrb method clOnItemRightClick.
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack offhand = player.getHeldItemOffhand();
// Orb in main hand, tool/armor in offhand.
if (hand != EnumHand.MAIN_HAND || StackHelper.isEmpty(offhand) || !(offhand.getItem() instanceof ITool || offhand.getItem() instanceof IArmor)) {
return new ActionResult<ItemStack>(EnumActionResult.PASS, player.getHeldItem(hand));
}
ItemStack orb = player.getHeldItemMainhand();
// Check for tool soul.
ToolSoul soul = SoulManager.getSoul(offhand);
if (soul == null) {
if (!world.isRemote) {
ChatHelper.sendMessage(player, SilentGems.localizationHelper.getItemSubText(Names.SKILL_ORB, "no_soul"));
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, orb);
}
// Check skill on orb.
SoulSkill skill = getSkill(orb);
if (skill == null) {
if (!world.isRemote) {
ChatHelper.sendMessage(player, SilentGems.localizationHelper.getItemSubText(Names.SKILL_ORB, "no_skill"));
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, orb);
}
if (world.isRemote) {
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
// Try to add or level up the skill.
if (soul.addOrLevelSkill(skill, offhand, player)) {
ToolHelper.recalculateStats(offhand);
StackHelper.shrink(orb, 1);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, orb);
} else {
ChatHelper.sendMessage(player, SilentGems.localizationHelper.getItemSubText(Names.SKILL_ORB, "max_level"));
return new ActionResult<ItemStack>(EnumActionResult.PASS, player.getHeldItem(hand));
}
}
Aggregations