aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/api/mobhandler
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2022-08-23 00:17:48 +0200
committerGitHub <noreply@github.com>2022-08-23 00:17:48 +0200
commit5d1286092eac1545f819babbee27244504a212f0 (patch)
treea377af43657e1959a5a088a5e48dde0c2c2b9b22 /src/main/java/kubatech/api/mobhandler
parentc31a00ff0259c6f1a2c8098aacb3afc14384aa4b (diff)
downloadGT5-Unofficial-5d1286092eac1545f819babbee27244504a212f0.tar.gz
GT5-Unofficial-5d1286092eac1545f819babbee27244504a212f0.tar.bz2
GT5-Unofficial-5d1286092eac1545f819babbee27244504a212f0.zip
Add Config to override mob drops + some fixes (#8)
* Add overrides * GTNHCoreMod custom drops integration * Update buildscript * Bump * EEC blacklist * NEI info * Loops optimization * Warn when 0% loots are detected * Detect looting drops * No * Super rare drops * Keep the same naming * Crash * Fix meta * maybe * Run at least twice * Fix stupid TF Lich boss * Comments * Fix EEC blacklist
Diffstat (limited to 'src/main/java/kubatech/api/mobhandler')
-rw-r--r--src/main/java/kubatech/api/mobhandler/MobDrop.java99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/main/java/kubatech/api/mobhandler/MobDrop.java b/src/main/java/kubatech/api/mobhandler/MobDrop.java
new file mode 100644
index 0000000000..76942b3148
--- /dev/null
+++ b/src/main/java/kubatech/api/mobhandler/MobDrop.java
@@ -0,0 +1,99 @@
+package kubatech.api.mobhandler;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.util.HashMap;
+import kubatech.api.ConstructableItemStack;
+import kubatech.api.utils.GSONUtils;
+import net.minecraft.item.ItemStack;
+
+public class MobDrop {
+ public enum DropType {
+ Normal,
+ Rare,
+ Additional,
+ Infernal;
+ private static final DropType[] values = values();
+
+ public static DropType get(int ordinal) {
+ return values[ordinal];
+ }
+ }
+
+ @GSONUtils.SkipGSON
+ public ItemStack stack;
+
+ public ConstructableItemStack reconstructableStack;
+ public DropType type;
+ public int chance;
+ public Integer enchantable;
+ public HashMap<Integer, Integer> damages;
+ public boolean lootable = false;
+ public boolean playerOnly = false;
+
+ private MobDrop() {}
+
+ public MobDrop(
+ ItemStack stack,
+ DropType type,
+ int chance,
+ Integer enchantable,
+ HashMap<Integer, Integer> damages,
+ boolean lootable,
+ boolean playerOnly) {
+ this.stack = stack;
+ this.reconstructableStack = new ConstructableItemStack(stack);
+ this.type = type;
+ this.chance = chance;
+ this.enchantable = enchantable;
+ this.damages = damages;
+ this.lootable = lootable;
+ this.playerOnly = playerOnly;
+ }
+
+ public void reconstructStack() {
+ this.stack = reconstructableStack.construct();
+ }
+
+ private static final ByteBuf BufHelper = Unpooled.buffer();
+
+ public void writeToByteBuf(ByteBuf byteBuf) {
+ BufHelper.clear();
+ reconstructableStack.writeToByteBuf(BufHelper);
+ BufHelper.writeInt(type.ordinal());
+ BufHelper.writeInt(chance);
+ BufHelper.writeBoolean(enchantable != null);
+ if (enchantable != null) BufHelper.writeInt(enchantable);
+ BufHelper.writeBoolean(damages != null);
+ if (damages != null) {
+ BufHelper.writeInt(damages.size());
+ damages.forEach((k, v) -> {
+ BufHelper.writeInt(k);
+ BufHelper.writeInt(v);
+ });
+ }
+ BufHelper.writeBoolean(lootable);
+ BufHelper.writeBoolean(playerOnly);
+ byteBuf.writeInt(BufHelper.readableBytes());
+ byteBuf.writeBytes(BufHelper);
+ }
+
+ public static MobDrop readFromByteBuf(ByteBuf byteBuf) {
+ MobDrop mobDrop = new MobDrop();
+ int size = byteBuf.readInt();
+ mobDrop.reconstructableStack = ConstructableItemStack.readFromByteBuf(byteBuf);
+ mobDrop.type = DropType.get(byteBuf.readInt());
+ mobDrop.chance = byteBuf.readInt();
+ if (byteBuf.readBoolean()) mobDrop.enchantable = byteBuf.readInt();
+ else mobDrop.enchantable = null;
+ if (byteBuf.readBoolean()) {
+ mobDrop.damages = new HashMap<>();
+ int damagessize = byteBuf.readInt();
+ for (int i = 0; i < damagessize; i++) mobDrop.damages.put(byteBuf.readInt(), byteBuf.readInt());
+ } else mobDrop.damages = null;
+ mobDrop.lootable = byteBuf.readBoolean();
+ mobDrop.playerOnly = byteBuf.readBoolean();
+ mobDrop.reconstructStack();
+ return mobDrop;
+ }
+}