-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.java
38 lines (32 loc) · 1.71 KB
/
Utils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package net.mehvahdjukaar.selene.util;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.context.UseOnContext;
import java.util.Random;
public class Utils {
public static void swapItem( Player player, InteractionHand hand, ItemStack oldItem, ItemStack newItem, boolean bothsides){
if(!player.level.isClientSide || bothsides)
player.setItemInHand(InteractionHand, ItemUtils.createFilledResult(oldItem.copy(), player, newItem, player.isCreative()));
}
public static void swapItem(Player player, InteractionHand hand, ItemStack oldItem, ItemStack newItem){
if(!player.level.isClientSide)
player.setItemInHand(InteractionHand, ItemUtils.createFilledResult(oldItem.copy(), player, newItem, player.isCreative()));
}
public static void swapItemNBT(Player player, InteractionHand hand, ItemStack oldItem, ItemStack newItem){
if(!player.level.isClientSide)
player.setItemInHand(InteractionHand, ItemUtils.createFilledResult(oldItem.copy(), player, newItem,false));
}
public static void swapItem(Player player, InteractionHand hand, ItemStack newItem){
if(!player.level.isClientSide)
player.setItemInHand(InteractionHand, ItemUtils.createFilledResult(player.getItemInHand(hand).copy(), player, newItem, player.isCreative()));
}
//xp bottle logic
public static int getXPinaBottle(int bottleCount, Random rand){
int xp = 0;
for(int i = 0; i<bottleCount; i++) xp += (3 + rand.nextInt(5) + rand.nextInt(5));
return xp;
}
}