From 6f7f2f857db94a8952613262e62a1c24e78f6563 Mon Sep 17 00:00:00 2001 From: Goodbird Date: Sun, 18 Feb 2024 17:25:55 +0300 Subject: [PATCH] Added a custom hitbox data class --- .../controllers/data/CustomHitboxData.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/noppes/npcs/controllers/data/CustomHitboxData.java diff --git a/src/main/java/noppes/npcs/controllers/data/CustomHitboxData.java b/src/main/java/noppes/npcs/controllers/data/CustomHitboxData.java new file mode 100644 index 000000000..8259d1059 --- /dev/null +++ b/src/main/java/noppes/npcs/controllers/data/CustomHitboxData.java @@ -0,0 +1,51 @@ +package noppes.npcs.controllers.data; + +import net.minecraft.nbt.NBTTagCompound; + +public class CustomHitboxData { + private float width = 1f; + private float height = 1.8f; + + private boolean customHitbox = false; + + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setBoolean("CustomHitbox", customHitbox); + if(customHitbox) { + nbttagcompound.setFloat("HitboxWidth", width); + nbttagcompound.setFloat("HitboxHeight", height); + } + return nbttagcompound; + } + + public void readFromNBT(NBTTagCompound nbttagcompound) { + customHitbox = nbttagcompound.getBoolean("CustomHitbox"); + if(customHitbox) { + width = nbttagcompound.getFloat("HitboxWidth"); + height = nbttagcompound.getFloat("HitboxHeight"); + } + } + + public float getWidth() { + return width; + } + + public void setWidth(float width) { + this.width = width; + } + + public float getHeight() { + return height; + } + + public void setHeight(float height) { + this.height = height; + } + + public boolean isCustomHitbox() { + return customHitbox; + } + + public void setCustomHitbox(boolean customHitbox) { + this.customHitbox = customHitbox; + } +}