mirror of
https://github.com/KAMKEEL/CustomNPC-Gecko-Addon.git
synced 2026-11-13 23:04:09 +00:00
Added "Extras" GUI with some settings
This commit is contained in:
1 parent
260df4d8af
commit
d9ee1bd10a
6 files changed
+111
-2
No files matched your search
@@ -0,0 +1,57 @@
|
||||
package com.goodbird.npcgecko.client.gui;
|
||||
|
||||
import com.goodbird.npcgecko.data.CustomModelData;
|
||||
import com.goodbird.npcgecko.mixin.IDataDisplay;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class SubGuiModelExtras extends SubGuiInterface implements ITextfieldListener, ISubGuiListener {
|
||||
public SubGuiModelExtras(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
closeOnEsc = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int y = guiTop + 44;
|
||||
addLabel(new GuiNpcLabel(1,"Head Bone Name", guiLeft - 85, y + 5,0xffffff));
|
||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 50, y, 200, 20, getModelData(npc).getHeadBoneName()));
|
||||
y+=23;
|
||||
addLabel(new GuiNpcLabel(2,"Transition Length (ticks)", guiLeft - 85, y + 5,0xffffff));
|
||||
GuiNpcTextField transitionLength = new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 50, y,
|
||||
200, 20, ""+getModelData(npc).getTransitionLengthTicks());
|
||||
transitionLength.setIntegersOnly();
|
||||
transitionLength.setMinMaxDefault(0, Integer.MAX_VALUE, getModelData(npc).getTransitionLengthTicks());
|
||||
addTextField(transitionLength);
|
||||
addButton(new GuiNpcButton(670, width - 22, 2, 20, 20, "X"));
|
||||
}
|
||||
|
||||
public CustomModelData getModelData(EntityNPCInterface npc){
|
||||
return ((IDataDisplay)npc.display).getCustomModelData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
if(button.id == 670){
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if(textfield.id == 1){
|
||||
getModelData(npc).setHeadBoneName(textfield.getText());
|
||||
}
|
||||
if(textfield.id == 2){
|
||||
getModelData(npc).setTransitionLengthTicks(textfield.getInteger());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subGuiInterface) {
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@ package com.goodbird.npcgecko.client.model;
|
||||
|
||||
import com.goodbird.npcgecko.entity.EntityCustomModel;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
|
||||
import software.bernie.geckolib3.core.processor.IBone;
|
||||
import software.bernie.geckolib3.model.AnimatedGeoModel;
|
||||
import software.bernie.geckolib3.model.provider.data.EntityModelData;
|
||||
|
||||
public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
|
||||
@Override
|
||||
@@ -19,4 +22,18 @@ public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
|
||||
public ResourceLocation getTextureLocation(EntityCustomModel entity) {
|
||||
return entity.textureResLoc;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void setLivingAnimations(EntityCustomModel entity, Integer uniqueID, AnimationEvent animationEvent) {
|
||||
super.setLivingAnimations(entity, uniqueID, animationEvent); //We call the super-function
|
||||
IBone head = this.getAnimationProcessor().getBone(entity.headBoneName); //Then we take the head bone
|
||||
if(head!=null) {
|
||||
//We get the model data for an entity
|
||||
EntityModelData extraData = (EntityModelData) animationEvent.getExtraDataOfType(EntityModelData.class).get(0);
|
||||
//And we set the head bone rotation to the interpolated pitch and yaw rotations of an entity
|
||||
head.setRotationY((extraData.netHeadYaw) * ((float) Math.PI / 180F));
|
||||
head.setRotationX((extraData.headPitch) * ((float) Math.PI / 180F));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,8 @@ public class CustomModelData {
|
||||
private String meleeAttackAnim = "";
|
||||
private String hurtAnim = "";
|
||||
private String rangedAttackAnim = "";
|
||||
|
||||
private String headBoneName = "head";
|
||||
private int transitionLengthTicks = 10;
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("Model", model);
|
||||
nbttagcompound.setString("AnimFile", animFile);
|
||||
@@ -19,6 +20,8 @@ public class CustomModelData {
|
||||
nbttagcompound.setString("MeleeAttackAnim", meleeAttackAnim);
|
||||
nbttagcompound.setString("RangedAttackAnim", rangedAttackAnim);
|
||||
nbttagcompound.setString("HurtAnim", hurtAnim);
|
||||
nbttagcompound.setString("HeadBoneName", headBoneName);
|
||||
nbttagcompound.setInteger("TransitionLengthTicks", transitionLengthTicks);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -31,6 +34,10 @@ public class CustomModelData {
|
||||
hurtAnim = nbttagcompound.getString("HurtAnim");
|
||||
meleeAttackAnim = nbttagcompound.getString("MeleeAttackAnim");
|
||||
rangedAttackAnim = nbttagcompound.getString("RangedAttackAnim");
|
||||
headBoneName = nbttagcompound.getString("HeadBoneName");
|
||||
if(nbttagcompound.hasKey("TransitionLengthTicks")){
|
||||
transitionLengthTicks = nbttagcompound.getInteger("TransitionLengthTicks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +96,20 @@ public class CustomModelData {
|
||||
public void setRangedAttackAnim(String rangedAttackAnim) {
|
||||
this.rangedAttackAnim = rangedAttackAnim;
|
||||
}
|
||||
|
||||
public String getHeadBoneName() {
|
||||
return headBoneName;
|
||||
}
|
||||
|
||||
public void setHeadBoneName(String headBoneName) {
|
||||
this.headBoneName = headBoneName;
|
||||
}
|
||||
|
||||
public int getTransitionLengthTicks() {
|
||||
return transitionLengthTicks;
|
||||
}
|
||||
|
||||
public void setTransitionLengthTicks(int transitionLengthTicks) {
|
||||
this.transitionLengthTicks = transitionLengthTicks;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class EntityCustomModel extends EntityCreature implements IAnimatable, IA
|
||||
public String hurtAnimName = "";
|
||||
public String meleeAttackAnimName = "";
|
||||
public String rangedAttackAnimName = "";
|
||||
public String headBoneName = "head";
|
||||
public AnimationBuilder dialogAnim = null;
|
||||
public AnimationBuilder manualAnim = null;
|
||||
public AnimationBuilder attackAnim = null;
|
||||
@@ -116,7 +117,6 @@ public class EntityCustomModel extends EntityCreature implements IAnimatable, IA
|
||||
public EntityCustomModel(World worldIn) {
|
||||
super(worldIn);
|
||||
this.ignoreFrustumCheck = true;
|
||||
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||
this.setSize(0.7F, 2F);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import software.bernie.geckolib3.core.controller.AnimationController;
|
||||
import software.bernie.geckolib3.core.manager.AnimationData;
|
||||
|
||||
@Mixin(GeckoAddon.class)
|
||||
public class MixinGeckoAddon {
|
||||
@@ -39,6 +41,11 @@ public class MixinGeckoAddon {
|
||||
modelEntity.hurtTime = npc.hurtTime;
|
||||
modelEntity.deathTime = npc.deathTime;
|
||||
modelEntity.tintData = npc.display.tintData;
|
||||
modelEntity.headBoneName = display.getCustomModelData().getHeadBoneName();
|
||||
AnimationData animationData = modelEntity.getFactory().getOrCreateAnimationData(modelEntity.getUniqueID().hashCode());
|
||||
for(AnimationController controller : animationData.getAnimationControllers().values()){
|
||||
controller.transitionLengthTicks = display.getCustomModelData().getTransitionLengthTicks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.goodbird.npcgecko.mixin.impl;
|
||||
|
||||
import com.goodbird.npcgecko.client.gui.GuiStringSelection;
|
||||
import com.goodbird.npcgecko.client.gui.SubGuiModelAnimation;
|
||||
import com.goodbird.npcgecko.client.gui.SubGuiModelExtras;
|
||||
import com.goodbird.npcgecko.entity.EntityCustomModel;
|
||||
import com.goodbird.npcgecko.mixin.IDataDisplay;
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
@@ -42,6 +43,7 @@ public class MixinGeckoAddonClient {
|
||||
|
||||
if(entity instanceof EntityCustomModel){
|
||||
creationScreen.addButton(new GuiNpcButton(202, creationScreen.guiLeft-60, creationScreen.guiTop+40, 180, 20, ((IDataDisplay)creationScreen.npc.display).getCustomModelData().getModel()));
|
||||
creationScreen.addButton(new GuiNpcButton(203, creationScreen.guiLeft-60, creationScreen.guiTop+62, 180, 20, "Extras"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +66,9 @@ public class MixinGeckoAddonClient {
|
||||
creationScreen.getButton(202).setDisplayText(name);
|
||||
}));
|
||||
}
|
||||
if(button.id == 203){
|
||||
creationScreen.setSubGui(new SubGuiModelExtras(creationScreen.npc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user