Merge branch 'dev' into janino-scripts

This commit is contained in:
bigguy345 committed 2026-01-10 00:19:14 +02:00
commit fb0332e5cf
53 files changed
+3017 -376

No files matched your search

@@ -223,6 +223,7 @@ import java.util.Random;
public class ClientProxy extends CommonProxy {
public static KeyBinding NPCButton;
public static KeyBinding SpecialKey;
public static final Random RAND = new Random();
public static FontContainer Font;
@@ -289,8 +290,10 @@ public class ClientProxy extends CommonProxy {
Minecraft mc = Minecraft.getMinecraft();
NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_N, "key.categories.customnpc");
SpecialKey = new KeyBinding("key.customnpcs.special", Keyboard.KEY_C, "key.categories.customnpc");
ClientRegistry.registerKeyBinding(NPCButton);
ClientRegistry.registerKeyBinding(SpecialKey);
new PresetController(CustomNpcs.Dir);
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
import kamkeel.npcs.network.packets.player.InputDevicePacket;
import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
@@ -23,9 +24,12 @@ import noppes.npcs.client.gui.hud.EnumHudComponent;
import noppes.npcs.client.gui.hud.HudComponent;
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
import noppes.npcs.client.renderer.RenderNPCInterface;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.MarkType;
import noppes.npcs.controllers.data.MarkData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleMount;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import tconstruct.client.tabs.InventoryTabCustomNpc;
@@ -42,6 +46,7 @@ public class ClientTickHandler {
private int buttonPressed = -1;
private long buttonTime = 0L;
private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219};
private boolean lastSpecialKeyDown = false;
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onClientTick(TickEvent.ClientTickEvent event) {
@@ -52,6 +57,30 @@ public class ClientTickHandler {
}
this.prevWorld = mc.theWorld;
}
if (event.phase == Phase.START) {
EntityPlayer player = mc.thePlayer;
if (player != null) {
boolean specialKeyDown = ClientProxy.SpecialKey != null && Keyboard.isKeyDown(ClientProxy.SpecialKey.getKeyCode());
if (specialKeyDown != lastSpecialKeyDown) {
PlayerData data = CustomNpcs.proxy.getPlayerData(player);
if (data != null) {
data.setSpecialKeyDown(specialKeyDown);
}
SpecialKeyStatePacket.send(specialKeyDown);
lastSpecialKeyDown = specialKeyDown;
}
if (player.ridingEntity instanceof EntityNPCInterface) {
EntityNPCInterface mount = (EntityNPCInterface) player.ridingEntity;
if (mount.advanced.role == EnumRoleType.Mount && mount.roleInterface instanceof RoleMount) {
RoleMount role = (RoleMount) mount.roleInterface;
if (!role.isSprintAllowed() && player.isSprinting()) {
player.setSprinting(false);
}
}
}
}
}
if (event.phase == Phase.END) {
if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && ClientEventHandler.hasOverlays(mc.thePlayer)) {
renderCNPCPlayer.itemRenderer.updateEquippedItem();
@@ -66,6 +66,8 @@ public class MusicController {
this.playingSound.stopSound();
this.sounds.remove(this.playingSound.sound);
this.playingSound = null;
this.entity = null;
this.playDelay = 20; // Prevent immediate restart when music is stopped
} else if (soundHandler != null) {
try {
soundHandler.stopSounds();
@@ -193,4 +195,26 @@ public class MusicController {
}
this.sounds.clear();
}
/**
* Stops a specific sound by its resource key.
* This is used to stop dialog sounds without affecting Bard music.
* @param soundKey The sound resource key to stop
*/
public void stopSound(String soundKey) {
if (soundKey == null || soundKey.isEmpty()) {
return;
}
ScriptClientSound sound = this.sounds.remove(soundKey);
if (sound != null) {
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
if (soundHandler != null) {
try {
soundHandler.stopSound(sound);
} catch (Exception ignored) {
}
}
sound.stopSound();
}
}
}
@@ -706,10 +706,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
if (!questCatSearch.equals(newText)) {
questCatSearch = newText;
if (questCatScroll != null) {
if (selectedQuestCategory.isEmpty())
questCatScroll.setList(new ArrayList<>());
else
questCatScroll.setList(filterList(questCatData, questCatSearch));
questCatScroll.setList(filterList(questCatData, questCatSearch));
questCatScroll.resetScroll();
}
}
}
@@ -718,12 +716,14 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!questFinishedSearch.equals(newText)) {
questFinishedSearch = newText;
if (questFinishedScroll != null)
if (questFinishedScroll != null) {
questFinishedScroll.setList(
selectedQuestCategory.isEmpty() ?
new ArrayList<>() :
filterAndTrimListByCategory(questFinishedData, selectedQuestCategory, questFinishedSearch)
);
questFinishedScroll.resetScroll();
}
}
}
tf = getTextField(activeFieldId);
@@ -731,12 +731,14 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!questActiveSearch.equals(newText)) {
questActiveSearch = newText;
if (questActiveScroll != null)
if (questActiveScroll != null) {
questActiveScroll.setList(
selectedQuestCategory.isEmpty() ?
new ArrayList<>() :
filterAndTrimListByCategory(questActiveData, selectedQuestCategory, questActiveSearch)
);
questActiveScroll.resetScroll();
}
}
}
}
@@ -747,8 +749,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!questFinishedSearch.equals(newText)) {
questFinishedSearch = newText;
if (questFinishedScroll != null)
if (questFinishedScroll != null) {
questFinishedScroll.setList(filterList(questFinishedData, questFinishedSearch));
questFinishedScroll.resetScroll();
}
}
}
tf = getTextField(activeFieldId);
@@ -756,8 +760,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!questActiveSearch.equals(newText)) {
questActiveSearch = newText;
if (questActiveScroll != null)
if (questActiveScroll != null) {
questActiveScroll.setList(filterList(questActiveData, questActiveSearch));
questActiveScroll.resetScroll();
}
}
}
}
@@ -768,12 +774,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!dialogCatSearch.equals(newText)) {
dialogCatSearch = newText;
if (dialogCatScroll != null)
dialogCatScroll.setList(
selectedDialogCategory.isEmpty() ?
new ArrayList<>() :
filterList(dialogCatData, dialogCatSearch)
);
if (dialogCatScroll != null) {
dialogCatScroll.setList(filterList(dialogCatData, dialogCatSearch));
dialogCatScroll.resetScroll();
}
}
}
tf = getTextField(readFieldId);
@@ -781,12 +785,14 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!dialogReadSearch.equals(newText)) {
dialogReadSearch = newText;
if (dialogReadScroll != null)
if (dialogReadScroll != null) {
dialogReadScroll.setList(
selectedDialogCategory.isEmpty() ?
new ArrayList<>() :
filterAndTrimListByCategory(dialogReadData, selectedDialogCategory, dialogReadSearch)
);
dialogReadScroll.resetScroll();
}
}
}
}
@@ -797,8 +803,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!dialogCompactSearch.equals(newText)) {
dialogCompactSearch = newText;
if (dialogCompactScroll != null)
if (dialogCompactScroll != null) {
dialogCompactScroll.setList(filterList(dialogReadData, dialogCompactSearch));
dialogCompactScroll.resetScroll();
}
}
}
}
@@ -809,12 +817,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!transCatSearch.equals(newText)) {
transCatSearch = newText;
if (transCatScroll != null)
transCatScroll.setList(
selectedTransCategory.isEmpty() ?
new ArrayList<>() :
filterList(transCatData, transCatSearch)
);
if (transCatScroll != null) {
transCatScroll.setList(filterList(transCatData, transCatSearch));
transCatScroll.resetScroll();
}
}
}
tf = getTextField(locFieldId);
@@ -822,12 +828,14 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!transLocSearch.equals(newText)) {
transLocSearch = newText;
if (transLocScroll != null)
if (transLocScroll != null) {
transLocScroll.setList(
selectedTransCategory.isEmpty() ?
new ArrayList<>() :
filterAndTrimListByCategory(transLocData, selectedTransCategory, transLocSearch)
);
transLocScroll.resetScroll();
}
}
}
}
@@ -838,8 +846,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!transCompactSearch.equals(newText)) {
transCompactSearch = newText;
if (transCompactScroll != null)
if (transCompactScroll != null) {
transCompactScroll.setList(filterList(transLocData, transCompactSearch));
transCompactScroll.resetScroll();
}
}
}
}
@@ -850,8 +860,10 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
String newText = tf.getText().toLowerCase();
if (!singleSearch.equals(newText)) {
singleSearch = newText;
if (singleScroll != null)
if (singleScroll != null) {
singleScroll.setList(filterList(currentTab == 13 ? bankData : factionData, singleSearch));
singleScroll.resetScroll();
}
}
}
}
@@ -262,6 +262,7 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
public void setSelected(String selected) {
}
@Override
public void closeSubGui(SubGuiInterface gui) {
super.closeSubGui(gui);
if (gui instanceof GuiNpcMobSpawnerSelector && this.spawnEntryScroll.hasSelected()) {
@@ -270,6 +271,9 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
this.spawn.spawnCompounds.put(selected, selector.getCompound());
initGui();
}
if (gui instanceof SubGuiNpcBiomes || gui instanceof SubGuiNpcDimensions || gui instanceof SubGuiSpawningOptions) {
save();
}
}
@Override
@@ -125,12 +125,6 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
y += spacing;
// Attack Speed Field (integers only)
//addLabel(new GuiNpcLabel(13,"Attack Speed",x,y + 5, CustomNpcResourceListener.DefaultTextColor));
//y += spacing;
// TEXTURE field
addLabel(new GuiNpcLabel(3, "display.texture", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
addTextField(new GuiNpcTextField(2, this, x + 60, y, 200, 20, linkedItem.display.texture));
@@ -75,6 +75,12 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose {
*/
private boolean sentClosePacket = false;
/**
* Tracks the dialog sound that was played, so we can stop only this sound
* on close without affecting Bard music or other sounds.
*/
private String dialogSound = null;
public GuiDialogInteract(EntityNPCInterface npc, Dialog dialog) {
super(npc);
this.dialog = dialog;
@@ -671,8 +677,13 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose {
this.options = new ArrayList<Integer>();
if (dialog.sound != null && !dialog.sound.isEmpty()) {
// Stop any previous dialog sound before playing new one
if (this.dialogSound != null) {
MusicController.Instance.stopSound(this.dialogSound);
}
MusicController.Instance.stopMusic();
MusicController.Instance.playSound(dialog.sound, (float) npc.posX, (float) npc.posY, (float) npc.posZ);
this.dialogSound = dialog.sound;
}
if (!dialog.showPreviousBlocks) {
@@ -707,7 +718,11 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose {
super.close();
if (parent != null)
NoppesUtil.openGUI(player, parent);
MusicController.Instance.stopAllSounds();
// Only stop the dialog sound, not Bard music or other sounds
if (this.dialogSound != null) {
MusicController.Instance.stopSound(this.dialogSound);
this.dialogSound = null;
}
}
@Override
@@ -63,6 +63,12 @@ public class GuiModernDialogInteract extends GuiNPCInterface implements IGuiClos
*/
private boolean sentClosePacket = false;
/**
* Tracks the dialog sound that was played, so we can stop only this sound
* on close without affecting Bard music or other sounds.
*/
private String dialogSound = null;
public GuiModernDialogInteract(EntityNPCInterface npc, Dialog dialog) {
super(npc);
this.dialog = dialog;
@@ -380,8 +386,13 @@ public class GuiModernDialogInteract extends GuiNPCInterface implements IGuiClos
this.options = new ArrayList<Integer>();
if (dialog.sound != null && !dialog.sound.isEmpty()) {
// Stop any previous dialog sound before playing new one
if (this.dialogSound != null) {
MusicController.Instance.stopSound(this.dialogSound);
}
MusicController.Instance.stopMusic();
MusicController.Instance.playSound(dialog.sound, (float) npc.posX, (float) npc.posY, (float) npc.posZ);
this.dialogSound = dialog.sound;
}
if (!dialog.showPreviousBlocks) {
@@ -440,6 +451,11 @@ public class GuiModernDialogInteract extends GuiNPCInterface implements IGuiClos
}
closed();
}
// Only stop the dialog sound, not Bard music or other sounds
if (this.dialogSound != null) {
MusicController.Instance.stopSound(this.dialogSound);
this.dialogSound = null;
}
super.onGuiClosed();
}
}
@@ -4,7 +4,6 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.role.RoleSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -13,8 +12,6 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleMount;
import java.util.Locale;
public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener {
private final RoleMount role;
@@ -32,55 +29,82 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener
return;
}
int y = guiTop + 6;
addOffsetRow(0, "role.mount.offsetx", role.getOffsetX(), y);
y += 24;
addOffsetRow(1, "role.mount.offsety", role.getOffsetY(), y);
y += 24;
addOffsetRow(2, "role.mount.offsetz", role.getOffsetZ(), y);
y += 24;
addJumpRow(3, "role.mount.jumpheight", role.getJumpStrength(), y);
y += 24;
int leftLabelX = guiLeft + 4;
int leftFieldX = guiLeft + 116;
int leftY = guiTop + 6;
addLabel(new GuiNpcLabel(5, "role.mount.sprint", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(5, guiLeft + 140, y, 60, 20, new String[]{"gui.no", "gui.yes"}, role.isSprintAllowed() ? 1 : 0));
leftY = addOffsetRow(0, 10, "role.mount.offsetx", role.getOffsetX(), leftLabelX, leftFieldX, leftY);
leftY = addOffsetRow(1, 11, "role.mount.offsety", role.getOffsetY(), leftLabelX, leftFieldX, leftY);
leftY = addOffsetRow(2, 12, "role.mount.offsetz", role.getOffsetZ(), leftLabelX, leftFieldX, leftY);
leftY = addJumpRow(3, 13, "role.mount.jumpheight", role.getJumpStrength(), leftLabelX, leftFieldX, leftY);
addButton(new GuiNpcButton(4, guiLeft + 4, y + 30, 80, 20, "role.mount.reset"));
addLabel(new GuiNpcLabel(4, "role.mount.sprint", leftLabelX, leftY + 5));
addButton(new GuiNpcButton(101, leftFieldX, leftY, 60, 20, new String[]{"gui.no", "gui.yes"}, role.isSprintAllowed() ? 1 : 0));
leftY += 24;
GuiNpcLabel speedLabel = new GuiNpcLabel(6, "", guiLeft + 4, y + 56);
speedLabel.label = StatCollector.translateToLocalFormatted("role.mount.walkspeed", npc.ais.getWalkingSpeed());
addLabel(speedLabel);
int rightLabelX = guiLeft + 214;
int rightFieldX = guiLeft + 320;
int rightY = guiTop + 6;
addLabel(new GuiNpcLabel(20, "role.mount.fly", rightLabelX, rightY + 5));
addButton(new GuiNpcButton(102, rightFieldX, rightY, 60, 20, new String[]{"gui.no", "gui.yes"}, role.isFlyingMountEnabled() ? 1 : 0));
rightY += 24;
if (role.isFlyingMountEnabled()) {
addLabel(new GuiNpcLabel(21, "role.mount.hover", rightLabelX, rightY + 5));
addButton(new GuiNpcButton(103, rightFieldX, rightY, 60, 20, new String[]{"gui.no", "gui.yes"}, role.isHoverModeEnabled() ? 1 : 0));
rightY += 24;
rightY = addSpeedRow(22, 14, "role.mount.ascendspeed", role.getFlyingAscendSpeed(), rightLabelX, rightFieldX, rightY, 0.1F, 3.0F, 0.60F);
rightY = addSpeedRow(23, 15, "role.mount.descendspeed", role.getFlyingDescendSpeed(), rightLabelX, rightFieldX, rightY, 0.05F, 3.0F, 0.35F);
}
}
private void addOffsetRow(int id, String translationKey, float value, int y) {
addLabel(new GuiNpcLabel(id, translationKey, guiLeft + 4, y + 5));
GuiNpcTextField field = new GuiNpcTextField(id, this, guiLeft + 140, y, 80, 20, format(value));
private int addOffsetRow(int labelId, int fieldId, String translationKey, float value, int labelX, int fieldX, int y) {
addLabel(new GuiNpcLabel(labelId, translationKey, labelX, y + 5));
GuiNpcTextField field = new GuiNpcTextField(fieldId, this, fieldX, y, 80, 20, format(value));
field.floatsOnly = true;
field.setMinMaxDefaultFloat(-5.0F, 5.0F, 0.0F);
addTextField(field);
return y + 24;
}
private void addJumpRow(int id, String translationKey, float value, int y) {
addLabel(new GuiNpcLabel(id, translationKey, guiLeft + 4, y + 5));
GuiNpcTextField field = new GuiNpcTextField(id, this, guiLeft + 140, y, 80, 20, format(value));
private int addJumpRow(int labelId, int fieldId, String translationKey, float value, int labelX, int fieldX, int y) {
addLabel(new GuiNpcLabel(labelId, translationKey, labelX, y + 5));
GuiNpcTextField field = new GuiNpcTextField(fieldId, this, fieldX, y, 80, 20, format(value));
field.floatsOnly = true;
field.setMinMaxDefaultFloat(0.1F, 15.0F, 1.0F);
addTextField(field);
return y + 24;
}
private int addSpeedRow(int labelId, int fieldId, String translationKey, float value, int labelX, int fieldX, int y, float min, float max, float defaultValue) {
addLabel(new GuiNpcLabel(labelId, translationKey, labelX, y + 5));
GuiNpcTextField field = new GuiNpcTextField(fieldId, this, fieldX, y, 80, 20, format(value));
field.floatsOnly = true;
field.setMinMaxDefaultFloat(min, max, defaultValue);
addTextField(field);
return y + 24;
}
private String format(float value) {
return String.format(Locale.ROOT, "%.2f", value);
return String.format(java.util.Locale.ROOT, "%.2f", value);
}
@Override
public void buttonEvent(GuiButton guibutton) {
if (role == null)
return;
if (guibutton.id == 4) {
role.resetOffsets();
initGui();
} else if (guibutton.id == 5 && guibutton instanceof GuiNpcButton) {
role.setSprintAllowed(((GuiNpcButton) guibutton).getValue() == 1);
if (guibutton instanceof GuiNpcButton) {
GuiNpcButton button = (GuiNpcButton) guibutton;
if (guibutton.id == 101) {
role.setSprintAllowed(button.getValue() == 1);
} else if (guibutton.id == 102) {
role.setFlyingMountEnabled(button.getValue() == 1);
initGui();
} else if (guibutton.id == 103) {
role.setHoverModeEnabled(button.getValue() == 1);
}
}
}
@@ -90,32 +114,42 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener
return;
float value = textfield.isFloat() ? textfield.getFloat() : 0.0F;
switch (textfield.id) {
case 0:
case 10:
role.setOffsetX(value);
break;
case 1:
case 11:
role.setOffsetY(value);
break;
case 2:
case 12:
role.setOffsetZ(value);
break;
case 3:
case 13:
role.setJumpStrength(value);
break;
case 14:
role.setFlyingAscendSpeed(value);
break;
case 15:
role.setFlyingDescendSpeed(value);
break;
}
textfield.setText(format(valueForField(textfield.id)));
}
private float valueForField(int id) {
switch (id) {
case 0:
case 10:
return role.getOffsetX();
case 1:
case 11:
return role.getOffsetY();
case 2:
case 12:
return role.getOffsetZ();
case 3:
case 13:
return role.getJumpStrength();
case 14:
return role.getFlyingAscendSpeed();
case 15:
return role.getFlyingDescendSpeed();
default:
return 0.0F;
}