net.minecraft.util.TypedActionResult Java Examples

The following examples show how to use net.minecraft.util.TypedActionResult. 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: GuiItem.java    From LibGui with MIT License 6 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	if (world.isClient) {
		openScreen(); // In its own method to prevent class loading issues
	}
	
	return new TypedActionResult<ItemStack>(ActionResult.SUCCESS, (hand==Hand.MAIN_HAND) ? player.getMainHandStack() : player.getOffHandStack());
}
 
Example #2
Source File: ThermalArmorItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override //should sync with server
public TypedActionResult<ItemStack> use(World world_1, PlayerEntity playerEntity_1, Hand hand_1) {
    SimpleInventoryComponent inv = ((GCPlayerAccessor) playerEntity_1).getGearInventory();
    ItemStack thermalPiece = inv.getStack(getSlotIdForType(getSlotType()));
    if (thermalPiece.isEmpty()) {
        inv.setStack(getSlotIdForType(getSlotType()), playerEntity_1.getStackInHand(hand_1));
        return new TypedActionResult<>(ActionResult.SUCCESS, ItemStack.EMPTY);
    }
    return super.use(world_1, playerEntity_1, hand_1);
}
 
Example #3
Source File: OxygenGearItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (((GCPlayerAccessor) user).getGearInventory().getStack(5).isEmpty()) {
        ((GCPlayerAccessor) user).getGearInventory().setStack(5, user.getStackInHand(hand));
        return new TypedActionResult<>(ActionResult.SUCCESS, ItemStack.EMPTY);
    }
    return super.use(world, user, hand);
}
 
Example #4
Source File: OxygenTankItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { //should sync with server
    if (((GCPlayerAccessor) player).getGearInventory().getStack(6).isEmpty()) {
        ((GCPlayerAccessor) player).getGearInventory().setStack(6, player.getStackInHand(hand).copy());
        return new TypedActionResult<>(ActionResult.SUCCESS, ItemStack.EMPTY);
    } else if (((GCPlayerAccessor) player).getGearInventory().getStack(7).isEmpty()) {
        ((GCPlayerAccessor) player).getGearInventory().setStack(7, player.getStackInHand(hand).copy());
        return new TypedActionResult<>(ActionResult.SUCCESS, ItemStack.EMPTY);
    }
    return new TypedActionResult<>(ActionResult.PASS, player.getStackInHand(hand));
}
 
Example #5
Source File: OxygenMaskItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (((GCPlayerAccessor) user).getGearInventory().getStack(4).isEmpty()) {
        ((GCPlayerAccessor) user).getGearInventory().setStack(4, user.getStackInHand(hand));
        return new TypedActionResult<>(ActionResult.SUCCESS, ItemStack.EMPTY);
    }
    return super.use(world, user, hand);
}
 
Example #6
Source File: HallowCharmItem.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	if (world.getDimension().getType() == HallowedDimensions.THE_HALLOW) {
		player.setCurrentHand(hand);
		player.playSound(SoundEvents.BLOCK_PORTAL_TRIGGER, 1F, 1F);
		return new TypedActionResult<>(ActionResult.SUCCESS, player.getActiveItem());
	} else {
		return ITrinket.equipTrinket(player, hand);
	}
}
 
Example #7
Source File: TrumpetItem.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	ItemStack stack = player.getStackInHand(hand);
	
	float soundPitch = (((player.pitch - 90) * 1) / -90);
	
	if (player.isSneaking()) {
		player.playSound(HallowedSounds.MEGALADOOT, 0.8f, 1.0f);
	} else {
		player.playSound(HallowedSounds.DOOT, 0.8f, soundPitch);
	}
	
	return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
 
Example #8
Source File: ClubItem.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	ItemStack stack = player.getStackInHand(hand);
	return new TypedActionResult<>(ActionResult.CONSUME, stack);
}
 
Example #9
Source File: PaperBagItem.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	return ITrinket.equipTrinket(player, hand);
}
 
Example #10
Source File: PumpkinRingItem.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	return ITrinket.equipTrinket(player, hand);
}
 
Example #11
Source File: SkirtCostumeItem.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world_1, PlayerEntity playerEntity, Hand hand) {
	return ITrinket.equipTrinket(playerEntity, hand);
}