mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 18:09:44 +00:00
Change to Hitbox to use Scale instead
This commit is contained in:
1 parent
e3c41ad856
commit
1e51d6b243
4 files changed
+26
-25
No files matched your search
@@ -6,7 +6,7 @@ import noppes.npcs.controllers.data.HitboxData;
|
||||
|
||||
public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldListener
|
||||
{
|
||||
private HitboxData hitboxData;
|
||||
private final HitboxData hitboxData;
|
||||
public SubGuiCustomHitbox(HitboxData hitboxData){
|
||||
this.hitboxData = hitboxData;
|
||||
setBackground("menubg.png");
|
||||
@@ -22,12 +22,12 @@ public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldLis
|
||||
addButton(new GuiNpcButtonYesNo(0,guiLeft + 122, guiTop + 30, 56, 20 ,hitboxData.isHitboxEnabled()));
|
||||
if(hitboxData.isHitboxEnabled()){
|
||||
addLabel(new GuiNpcLabel(3,"hitbox.width", guiLeft + 5, guiTop + 57));
|
||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, hitboxData.getWidth() + ""));
|
||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, hitboxData.getWidthScale() + ""));
|
||||
getTextField(2).floatsOnly = true;
|
||||
getTextField(2).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 20);
|
||||
|
||||
addLabel(new GuiNpcLabel(4,"hitbox.height", guiLeft + 5, guiTop + 79));
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 122, guiTop + 75, 50, 18, hitboxData.getHeight() + ""));
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 122, guiTop + 75, 50, 18, hitboxData.getHeightScale() + ""));
|
||||
getTextField(3).floatsOnly = true;
|
||||
getTextField(3).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 20);
|
||||
}
|
||||
@@ -50,10 +50,10 @@ public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldLis
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if(textfield.id == 2){
|
||||
hitboxData.setWidth(textfield.getFloat());
|
||||
hitboxData.setWidthScale(textfield.getFloat());
|
||||
}
|
||||
if(textfield.id == 3){
|
||||
hitboxData.setHeight(textfield.getFloat());
|
||||
hitboxData.setHeightScale(textfield.getFloat());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class HitboxData {
|
||||
|
||||
private float width = 1f;
|
||||
private float height = 1.8f;
|
||||
private float widthScale = 1f;
|
||||
private float heightScale = 1f;
|
||||
private boolean hitboxEnabled = false;
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setBoolean("HitboxEnabled", hitboxEnabled);
|
||||
if(hitboxEnabled) {
|
||||
nbttagcompound.setFloat("HitboxWidth", width);
|
||||
nbttagcompound.setFloat("HitboxHeight", height);
|
||||
nbttagcompound.setFloat("HitboxWidthScale", widthScale);
|
||||
nbttagcompound.setFloat("HitboxHeightScale", heightScale);
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
@@ -20,25 +20,25 @@ public class HitboxData {
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
hitboxEnabled = nbttagcompound.getBoolean("HitboxEnabled");
|
||||
if(hitboxEnabled) {
|
||||
width = nbttagcompound.getFloat("HitboxWidth");
|
||||
height = nbttagcompound.getFloat("HitboxHeight");
|
||||
widthScale = nbttagcompound.getFloat("HitboxWidthScale");
|
||||
heightScale = nbttagcompound.getFloat("HitboxHeightScale");
|
||||
}
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return width;
|
||||
public float getWidthScale() {
|
||||
return widthScale;
|
||||
}
|
||||
|
||||
public void setWidth(float width) {
|
||||
this.width = width;
|
||||
public void setWidthScale(float widthScale) {
|
||||
this.widthScale = widthScale;
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return height;
|
||||
public float getHeightScale() {
|
||||
return heightScale;
|
||||
}
|
||||
|
||||
public void setHeight(float height) {
|
||||
this.height = height;
|
||||
public void setHeightScale(float heightScale) {
|
||||
this.heightScale = heightScale;
|
||||
}
|
||||
|
||||
public boolean isHitboxEnabled() {
|
||||
|
||||
@@ -1087,16 +1087,17 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
width = (width / 5f) * display.modelSize;
|
||||
height = (height / 5f) * display.modelSize;
|
||||
|
||||
if(display.hitboxData.isHitboxEnabled()){
|
||||
width = width * display.hitboxData.getWidthScale();
|
||||
height = height * display.hitboxData.getHeightScale();
|
||||
}
|
||||
|
||||
if(isKilled() && stats.hideKilledBody) {
|
||||
width = 0.00001f;
|
||||
}
|
||||
if(width / 2 > worldObj.MAX_ENTITY_RADIUS) {
|
||||
worldObj.MAX_ENTITY_RADIUS = width / 2;
|
||||
}
|
||||
if(display.hitboxData.isHitboxEnabled()){
|
||||
width = display.hitboxData.getWidth();
|
||||
height = display.hitboxData.getHeight();
|
||||
}
|
||||
this.setPosition(posX, posY, posZ);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user