9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-03 06:12:19 +00:00

checkpoint - 18

This commit is contained in:
XiaoMoMi
2024-07-01 01:34:19 +08:00
parent 53a6dc20bb
commit 4eb4ff901a
48 changed files with 775 additions and 154 deletions

View File

@@ -102,6 +102,10 @@ public class VersionHelper {
return version >= 20.0;
}
public static boolean isVersionNewerThan1_20_5() {
return version >= 20.5;
}
public boolean isNewerThan1_20_5() {
return version >= 20.5;
}

View File

@@ -17,6 +17,17 @@ public class AbstractItem<R, I> implements Item<I> {
this.item = item;
}
@Override
public Item<I> damage(Integer data) {
factory.damage(item, data);
return this;
}
@Override
public Optional<Integer> damage() {
return factory.damage(item);
}
@Override
public Item<I> customModelData(Integer data) {
factory.customModelData(item, data);

View File

@@ -9,6 +9,10 @@ public interface Item<I> {
Optional<Integer> customModelData();
Item<I> damage(Integer data);
Optional<Integer> damage();
Item<I> displayName(String displayName);
Optional<String> displayName();

View File

@@ -56,4 +56,8 @@ public abstract class ItemFactory<P extends CustomFishingPlugin, R, I> {
protected abstract Optional<Boolean> glint(R item);
protected abstract void glint(R item, Boolean glint);
protected abstract Optional<Integer> damage(R item);
protected abstract void damage(R item, Integer damage);
}

View File

@@ -0,0 +1,15 @@
package net.momirealms.customfishing.common.util;
import java.util.Objects;
import java.util.function.Function;
public interface TriFunction<T, U, V, R> {
R apply(T var1, U var2, V var3);
default <W> TriFunction<T, U, V, W> andThen(Function<? super R, ? extends W> after) {
Objects.requireNonNull(after);
return (t, u, v) -> {
return after.apply(this.apply(t, u, v));
};
}
}

View File

@@ -25,8 +25,11 @@ import java.util.Map;
/**
* Utility class for selecting random items based on weights.
*/
@SuppressWarnings("DuplicatedCode")
public class WeightUtils {
private WeightUtils() {}
/**
* Get a random item from a list of pairs, each associated with a weight.
*