Merge branch 'dev' into syntax-highlighter-unified

This commit is contained in:
bigguy345 committed 2026-02-04 05:22:19 +02:00
commit bd9d0a3889
46 files changed
+2067 -698

No files matched your search

+39 -8
View File
@@ -385,18 +385,49 @@ public class DataAbilities {
lastTarget = target;
ability.start(target);
// Spawn telegraph and send to clients
spawnTelegraph(ability, target);
// Play wind up sound if configured
playAbilitySound(ability.getWindUpSound());
// Play wind up animation if configured
playAbilityAnimation(ability.getWindUpAnimation());
if (ability.getPhase() == AbilityPhase.ACTIVE) {
// Windup was 0 — skip telegraph/windup and go straight to active
executeImmediate(ability, target);
} else {
// Normal windup flow
spawnTelegraph(ability, target);
playAbilitySound(ability.getWindUpSound());
playAbilityAnimation(ability.getWindUpAnimation());
}
return true;
}
/**
* Execute an ability immediately (no windup).
* Called when windUpTicks is 0.
*/
private void executeImmediate(Ability ability, EntityLivingBase target) {
// Lock rotation if movement is locked during ACTIVE phase
if (ability.isMovementLockedDuringActive()) {
captureLockedRotation();
}
// Play active sound and animation
playAbilitySound(ability.getActiveSound());
playAbilityAnimation(ability.getActiveAnimation());
// Fire execute event (cancelable)
AbilityEvent.ExecuteEvent executeEvent = new AbilityEvent.ExecuteEvent(
npc.wrappedNPC, ability, target);
if (NpcAPI.EVENT_BUS.post(executeEvent)) {
return;
}
// Call onExecute
ability.onExecute(npc, target, npc.worldObj);
// Check if ability completed during onExecute
if (ability.getPhase() == AbilityPhase.IDLE) {
handleAbilityCompletion(target);
}
}
/**
* Play a sound at the NPC's location.
*/
@@ -475,7 +475,7 @@ public class ClientProxy extends CommonProxy {
animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
save = false;
}
return new GuiNPCManageAnimations(animNpc, save);
return new GuiNPCManageAnimations(animNpc, save, npc != null);
} else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinked(npc);
@@ -511,7 +511,7 @@ public class ClientProxy extends CommonProxy {
abilityNpc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld);
abilityNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
}
return new GuiNpcManageAbilities(abilityNpc);
return new GuiNpcManageAbilities(abilityNpc, npc != null);
}
else if (gui == EnumGuiType.MainMenuGlobal)
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket;
import kamkeel.npcs.network.packets.request.ability.CustomAbilitySavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
@@ -568,7 +569,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
AbilitySlot slot = npcSlots.get(selectedAbilityIndex);
if (slot.isReference()) {
// For reference slots, save back to controller
// (The resolved copy was edited in-place)
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT()));
} else {
// For inline slots, replace with the updated ability
npcSlots.set(selectedAbilityIndex, AbilitySlot.inline(ability));
@@ -359,6 +359,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
@Override
public void close() {
GuiNpcTextField.unfocus();
applyToAbility();
callback.onAbilitySaved(ability);
super.close();
@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IScrollData;
@@ -39,6 +40,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
private HashMap<String, Integer> rawData = new HashMap<>();
private GuiCustomScroll scroll;
private String search = "";
private boolean waitingForLoad = false;
private int pendingLoadMode = -1;
@@ -48,7 +50,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
setBackground("menubg.png");
xSize = 220;
ySize = 180;
ySize = 216;
PacketClient.sendClient(new CustomAbilitiesGetPacket());
}
@@ -59,7 +61,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
setBackground("menubg.png");
xSize = 220;
ySize = 180;
ySize = 216;
PacketClient.sendClient(new CustomAbilitiesGetPacket());
}
@@ -75,7 +77,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
scroll.setSize(200, 110);
scroll.setSize(200, 140);
}
scroll.guiLeft = guiLeft + 10;
scroll.guiTop = y;
@@ -85,7 +87,12 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
}
addScroll(scroll);
y += 115;
y += 143;
// Search bar
addTextField(new GuiNpcTextField(10, this, fontRendererObj, guiLeft + 10, y, 200, 20, search));
y += 24;
addButton(new GuiNpcButton(0, guiLeft + 10, y, 95, 20, "gui.load"));
addButton(new GuiNpcButton(2, guiLeft + 115, y, 95, 20, "gui.cancel"));
@@ -94,7 +101,16 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
}
private List<String> getFilteredList() {
return new ArrayList<>(displayToUuid.keySet());
if (search.isEmpty()) {
return new ArrayList<>(displayToUuid.keySet());
}
List<String> list = new ArrayList<>();
for (String name : displayToUuid.keySet()) {
if (name.toLowerCase().contains(search.toLowerCase())) {
list.add(name);
}
}
return list;
}
@Override
@@ -116,6 +132,19 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
}
}
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
if (getTextField(10) != null && getTextField(10).isFocused()) {
String newSearch = getTextField(10).getText();
if (!search.equals(newSearch)) {
search = newSearch;
scroll.resetScroll();
scroll.setList(getFilteredList());
}
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiAbilityLoadMode) {
@@ -0,0 +1,95 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* SubGui for selecting an ability type when creating a new ability.
*/
public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomScrollListener {
private GuiCustomScroll scroll;
private final HashMap<String, String> displayNameToTypeId = new HashMap<>();
private String selectedTypeId = null;
public SubGuiAbilityTypeSelect() {
setBackground("menubg.png");
xSize = 200;
ySize = 216;
}
@Override
public void initGui() {
super.initGui();
addLabel(new GuiNpcLabel(0, "ability.selectType", guiLeft + 5, guiTop + 5));
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
scroll.setSize(190, 165);
}
scroll.guiLeft = guiLeft + 5;
scroll.guiTop = guiTop + 16;
addScroll(scroll);
List<String> list = buildTypeList();
scroll.setList(list);
addButton(new GuiNpcButton(0, guiLeft + 5, guiTop + 188, 90, 20, "gui.add"));
getButton(0).setEnabled(scroll.hasSelected());
addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 188, 90, 20, "gui.cancel"));
}
private List<String> buildTypeList() {
List<String> list = new ArrayList<>();
displayNameToTypeId.clear();
String[] types = AbilityController.Instance.getTypes();
for (String typeId : types) {
String displayName = I18n.format(typeId);
list.add(displayName);
displayNameToTypeId.put(displayName, typeId);
}
return list;
}
@Override
public void buttonEvent(GuiButton guibutton) {
if (guibutton.id == 0 && scroll.hasSelected()) {
String displayName = scroll.getSelected();
selectedTypeId = displayNameToTypeId.get(displayName);
close();
} else if (guibutton.id == 1) {
selectedTypeId = null;
close();
}
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
if (guiCustomScroll.id == 0) {
getButton(0).setEnabled(scroll.hasSelected());
}
}
@Override
public void customScrollDoubleClicked(String selection, GuiCustomScroll guiCustomScroll) {
if (guiCustomScroll.id == 0 && selection != null) {
selectedTypeId = displayNameToTypeId.get(selection);
close();
}
}
public String getSelectedTypeId() {
return selectedTypeId;
}
}
@@ -51,8 +51,8 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
// Track if current animation is built-in
private boolean currentIsBuiltIn = false;
public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save) {
super(npc);
public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save, boolean hasMenuNpc) {
super(npc, hasMenuNpc);
this.setSave(save);
this.xOffset = -148 + 70;
this.yOffset = -170 + 137;
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.global;
import kamkeel.npcs.client.renderer.TelegraphRenderer;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import java.util.UUID;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.CustomAbilitiesGetPacket;
@@ -15,6 +16,7 @@ import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.advanced.SubGuiAbilityTypeSelect;
import noppes.npcs.client.gui.util.AbilityPreviewExecutor;
import noppes.npcs.client.gui.util.GuiAbilityInterface;
import noppes.npcs.client.gui.util.GuiCustomScroll;
@@ -64,8 +66,8 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
private AbilityPreviewExecutor previewExecutor;
private long prevTick = 0;
public GuiNpcManageAbilities(EntityNPCInterface npc) {
super(npc);
public GuiNpcManageAbilities(EntityNPCInterface npc, boolean hasMenuNpc) {
super(npc, hasMenuNpc);
// Layout offset
this.xOffset = -148 + 110;
@@ -87,14 +89,17 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
public void initGui() {
super.initGui();
// Edit button (above Remove)
addButton(new GuiNpcButton(100, guiLeft + 368, guiTop + 8, 45, 20, "gui.edit"));
getButton(100).setEnabled(selected != null && !selected.isEmpty() && selectedAbility != null);
// Add button
addButton(new GuiNpcButton(2, guiLeft + 368, guiTop + 8, 45, 20, "gui.add"));
// Remove button
addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 30, 45, 20, "gui.remove"));
getButton(1).setEnabled(selected != null && !selected.isEmpty() && displayToUuid.containsKey(selected));
// Edit button
addButton(new GuiNpcButton(100, guiLeft + 368, guiTop + 52, 45, 20, "gui.edit"));
getButton(100).setEnabled(selected != null && !selected.isEmpty() && selectedAbility != null);
// Scroll list of saved abilities (right side)
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
@@ -211,7 +216,10 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
int id = guibutton.id;
if (id == 1 && selected != null && selectedUuid != null) {
if (id == 2) {
// Add — open type selection
setSubGui(new SubGuiAbilityTypeSelect());
} else if (id == 1 && selected != null && selectedUuid != null) {
GuiYesNo guiyesno = new GuiYesNo(this, selected, StatCollector.translateToLocal("gui.delete"), 1);
displayGuiScreen(guiyesno);
} else if (id == 100 && selectedAbility != null) {
@@ -329,6 +337,24 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiAbilityTypeSelect) {
String typeId = ((SubGuiAbilityTypeSelect) subgui).getSelectedTypeId();
if (typeId != null) {
Ability newAbility = AbilityController.Instance.create(typeId);
if (newAbility != null) {
newAbility.setId(UUID.randomUUID().toString());
newAbility.setName(newAbility.getTypeId());
// Save to server, then open config GUI
PacketClient.sendClient(new CustomAbilitySavePacket(newAbility.writeNBT()));
selectedAbility = newAbility;
selected = newAbility.getName();
selectedUuid = newAbility.getId();
previewExecutor.stop();
setSubGui(selectedAbility.createConfigGui(this));
return;
}
}
}
initGui();
}
@@ -81,7 +81,6 @@ public class AbilityPreviewExecutor {
this.previewAbility = ability;
this.previewNpc = npc;
this.phase = AbilityPhase.WINDUP;
this.currentTick = 0;
this.playing = true;
this.paused = false;
@@ -103,21 +102,30 @@ public class AbilityPreviewExecutor {
parentGui.startTrackingMovement();
}
// Create telegraph for preview
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
if (ability.getWindUpTicks() <= 0) {
// No windup — go straight to active
this.phase = AbilityPhase.ACTIVE;
transitionToActive();
} else {
// Normal windup flow
this.phase = AbilityPhase.WINDUP;
// Start windup animation
Animation windUpAnim = ability.getWindUpAnimation();
if (windUpAnim != null) {
AnimationData data = npc.display.animationData;
data.setEnabled(true);
data.setAnimation(windUpAnim);
data.animation.paused = false;
}
// Create telegraph for preview
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
// Spawn preview entity on first tick if ability spawns during windup
if (ability.spawnPreviewDuringWindup()) {
spawnPreviewEntity();
// Start windup animation
Animation windUpAnim = ability.getWindUpAnimation();
if (windUpAnim != null) {
AnimationData data = npc.display.animationData;
data.setEnabled(true);
data.setAnimation(windUpAnim);
data.animation.paused = false;
}
// Spawn preview entity on first tick if ability spawns during windup
if (ability.spawnPreviewDuringWindup()) {
spawnPreviewEntity();
}
}
}
@@ -74,7 +74,16 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
public int yOffset = 0;
public GuiAbilityInterface(EntityNPCInterface npc) {
super(npc);
this(npc, true);
}
/**
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
public GuiAbilityInterface(EntityNPCInterface npc, boolean hasMenuNpc) {
super(hasMenuNpc ? npc : null);
this.npc = npc;
this.playerdata = ((EntityCustomNpc) npc).modelData;
this.drawDefaultBackground = false;
@@ -246,7 +246,10 @@ public abstract class GuiContainerNPCInterface extends GuiContainer {
}
public void closeSubGui(SubGuiInterface gui) {
subgui = null;
// Only null out subgui if it wasn't replaced by a new one during subGuiClosed
if (subgui == gui) {
subgui = null;
}
}
public boolean hasSubGui() {
@@ -30,10 +30,18 @@ public class GuiModelInterface2 extends GuiNPCInterface2 {
public EntityNPCInterface npc;
public GuiModelInterface2(EntityNPCInterface npc) {
super(npc);
this(npc, true);
}
/**
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
public GuiModelInterface2(EntityNPCInterface npc, boolean hasMenuNpc) {
super(hasMenuNpc ? npc : null);
this.npc = npc;
playerdata = ((EntityCustomNpc) npc).modelData;
//xSize = 380;
drawDefaultBackground = false;
}
@@ -535,7 +535,10 @@ public abstract class GuiNPCInterface extends GuiScreen {
pendingSubGuiResult = null;
handler.accept(gui);
}
subgui = null;
// Only null out subgui if it wasn't replaced by a new one during subGuiClosed
if (subgui == gui) {
subgui = null;
}
initGui();
}
@@ -229,16 +229,37 @@ public class PlayerAbilityData implements IPlayerAbilityData {
currentTarget = null; // Players don't have auto-targets
ability.start(null);
// Spawn telegraph
spawnTelegraph(ability, player, null);
// Play wind up sound and animation
playAbilitySound(player, ability.getWindUpSound());
playAbilityAnimation(ability.getWindUpAnimation());
if (ability.getPhase() == AbilityPhase.ACTIVE) {
// Windup was 0 — skip telegraph/windup and go straight to active
executeImmediate(ability, player);
} else {
// Normal windup flow
spawnTelegraph(ability, player, null);
playAbilitySound(player, ability.getWindUpSound());
playAbilityAnimation(ability.getWindUpAnimation());
}
return true;
}
/**
* Execute an ability immediately (no windup).
* Called when windUpTicks is 0.
*/
private void executeImmediate(Ability ability, EntityPlayer player) {
// Play active sound and animation
playAbilitySound(player, ability.getActiveSound());
playAbilityAnimation(ability.getActiveAnimation());
// Call onExecute
ability.onExecute(player, currentTarget, player.worldObj);
// Check if ability completed during onExecute
if (ability.getPhase() == AbilityPhase.IDLE) {
handleAbilityCompletion(player);
}
}
// ═══════════════════════════════════════════════════════════════════
// CLIENT SYNC
// ═══════════════════════════════════════════════════════════════════
@@ -12,14 +12,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.EnumNpcToolMaterial;
import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.EntityMagicProjectile;
import noppes.npcs.entity.EntityProjectile;
import noppes.npcs.util.IProjectileCallback;
import org.lwjgl.opengl.GL11;
@@ -108,10 +106,11 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
combat.damage = damage;
combat.explosive = true;
EnergyColorData colorData = new EnergyColorData(getOrbColor(stack, false), getOrbColor(stack, true));
EnergyDisplayData colorData = new EnergyDisplayData(getOrbColor(stack, false), getOrbColor(stack, true));
EnergyLightningData lightning = new EnergyLightningData();
EnergyLifespanData lifespan = new EnergyLifespanData(100, 72000);
EnergyHomingData homing = new EnergyHomingData();
EnergyTrajectoryData trajectory = new EnergyTrajectoryData();
homing.speed = 0.5f;
homing.homingStrength = 0.35f;
@@ -120,7 +119,7 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
EntityAbilityOrb orb = new EntityAbilityOrb(
player.worldObj, player, null,
player.posX, player.posY + player.getEyeHeight(), player.posZ,
1.0f, colorData, combat, homing, lightning, lifespan
1.0f, colorData, combat, homing, lightning, lifespan, trajectory
);
orb.setupCharging(
@@ -17,7 +17,7 @@ import java.util.List;
* Mixin to inject auction information into item tooltips when viewing auction GUIs.
*/
@Mixin(Item.class)
public class MixinItem {
public abstract class MixinItem {
@SideOnly(Side.CLIENT)
@Inject(method = "addInformation", at = @At("HEAD"))
@@ -1,20 +1,9 @@
package noppes.npcs.mixin;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.util.AttributeItemUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.player.GuiAuctionInterface;
import noppes.npcs.client.gui.player.GuiAuctionListing;
import noppes.npcs.config.ConfigMarket;
import noppes.npcs.containers.ContainerAuctionListing;
import noppes.npcs.controllers.data.AuctionListing;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -14,4 +14,5 @@ public class EntityType {
public static final int ARROW = 10;
public static final int THROWABLE = 11;
public static final int FISH_HOOK = 12;
public static final int ENERGY_PROJECTILE = 13;
}