use of net.minecraft.util.ActionResult in project ICBM-Classic by BuiltBrokenModding.
the class ItemRocketLauncher method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
ItemStack itemstack = player.getHeldItem(handIn);
long clickMs = System.currentTimeMillis();
if (clickTimePlayer.containsKey(player.getName())) {
if (clickMs - clickTimePlayer.get(player.getName()) < firingDelay) {
// TODO play weapon empty click audio to note the gun is reloading
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
}
}
player.setActiveHand(handIn);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
use of net.minecraft.util.ActionResult in project BuildCraft by BuildCraft.
the class PipeFlowFluids method tryExtractFluidInternal.
private ActionResult<FluidStack> tryExtractFluidInternal(int millibuckets, EnumFacing from, FluidExtractor extractor, boolean simulate) {
if (from == null || millibuckets <= 0) {
return FAILED_EXTRACT;
}
IFluidHandler fluidHandler = pipe.getHolder().getCapabilityFromPipe(from, CapUtil.CAP_FLUIDS);
if (fluidHandler == null) {
// FIXME: WRONG PLACE!!!
return PASSED_EXTRACT;
}
Section section = sections.get(EnumPipePart.fromFacing(from));
Section middle = sections.get(EnumPipePart.CENTER);
millibuckets = Math.min(millibuckets, capacity * 2 - section.amount - middle.amount);
if (millibuckets <= 0) {
return FAILED_EXTRACT;
}
FluidStack toAdd = extractor.extract(millibuckets, currentFluid, fluidHandler);
if (toAdd == null || toAdd.amount <= 0) {
return FAILED_EXTRACT;
}
millibuckets = toAdd.amount;
if (currentFluid == null && !simulate) {
setFluid(toAdd);
}
int reallyFilled = section.fillInternal(millibuckets, !simulate);
int leftOver = millibuckets - reallyFilled;
reallyFilled += middle.fillInternal(leftOver, !simulate);
if (!simulate) {
section.ticksInDirection = COOLDOWN_INPUT;
}
if (reallyFilled != millibuckets) {
BCLog.logger.warn(//
"[tryExtractFluidAdv] Filled " + reallyFilled + " != extracted " + millibuckets + " (handler = " + fluidHandler.getClass() + ") @" + pipe.getHolder().getPipePos());
}
return new ActionResult<>(EnumActionResult.SUCCESS, toAdd);
}
use of net.minecraft.util.ActionResult in project BuildCraft by BuildCraft.
the class ItemSchematicSingle method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = StackUtil.asNonNull(player.getHeldItem(hand));
if (world.isRemote) {
return new ActionResult<>(EnumActionResult.PASS, stack);
}
if (player.isSneaking()) {
NBTTagCompound itemData = NBTUtilBC.getItemData(stack);
itemData.removeTag(NBT_KEY);
if (itemData.hasNoTags()) {
stack.setTagCompound(null);
}
stack.setItemDamage(DAMAGE_CLEAN);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<>(EnumActionResult.PASS, stack);
}
use of net.minecraft.util.ActionResult in project BuildCraft by BuildCraft.
the class ItemMapLocation method clearMarkerData.
private static ActionResult<ItemStack> clearMarkerData(@Nonnull ItemStack stack) {
if (MapLocationType.getFromStack(stack) == MapLocationType.CLEAN) {
return new ActionResult<>(EnumActionResult.PASS, stack);
}
NBTTagCompound nbt = NBTUtilBC.getItemData(stack);
for (String key : STORAGE_TAGS) {
nbt.removeTag(key);
}
if (nbt.hasNoTags()) {
stack.setTagCompound(null);
}
MapLocationType.CLEAN.setToStack(stack);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
use of net.minecraft.util.ActionResult in project Almura by AlmuraDev.
the class CollectorWand method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
if (!worldIn.isRemote) {
final Player spongePlayer = (org.spongepowered.api.entity.living.player.Player) player;
if (!spongePlayer.hasPermission("almura.item.collector_wand") || spongePlayer.hasPermission("almura.singleplayer") && MalisisCore.isObfEnv) {
spongePlayer.sendMessage(Text.of(TextColors.WHITE + "Access denied, missing permission: ", TextColors.AQUA, "almura.item.light_repair_wand", TextColors.WHITE, "."));
return new ActionResult<>(EnumActionResult.FAIL, player.getHeldItem(handIn));
} else {
double radius = 10;
List<EntityItem> items = worldIn.getEntitiesWithinAABB(EntityItem.class, player.getEntityBoundingBox().grow(radius, radius, radius));
for (EntityItem it : items) {
double distX = player.posX - it.posX;
double distZ = player.posZ - it.posZ;
double distY = it.posY + 1.5D - player.posY;
double dir = Math.atan2(distZ, distX);
double speed = 1F / it.getDistance(player) * 2;
if (distY < 0) {
it.motionY += speed;
}
it.motionX = Math.cos(dir) * speed;
it.motionZ = Math.sin(dir) * speed;
}
}
}
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(handIn));
}
Aggregations