mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 04:09:57 +00:00
Introduce client-side trap presets and a visual "trigger reveal" for traps, plus related entity/renderer changes. - AbilityTrap: add TrapPreset enum and applyTrapPresetDefaults; wire a SubGuiTrapPresetSelector hook to apply presets from the GUI; pass visibility into created trap entities. - EntityAbilityZone: add visible flag, TRIGGER_FLASH_STATUS state, setEntityState usage to notify clients of triggers, handleHealthUpdate to start client-side flash, and adjust construction/serialization accordingly. - RenderAbilityZone: implement trigger-reveal visuals (revealFade, triggerReveal) that briefly show a burst when traps trigger, skip rendering for invisible traps unless revealing, and tweak flash/timing logic. - Minor cleanup: remove/condense comment blocks and refactor noisy helpers across AbilityZone/AbilityHazard, plus language entry update and new SubGuiTrapPresetSelector GUI class. These changes enable preset application for traps and improve client-side feedback when traps trigger.
73 lines
2.4 KiB
Java
73 lines
2.4 KiB
Java
package noppes.npcs.client.gui;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.client.gui.GuiButton;
|
|
import net.minecraft.util.StatCollector;
|
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class SubGuiTrapPresetSelector extends SubGuiInterface {
|
|
|
|
public String selectedPreset = null;
|
|
|
|
private static final String[] PRESET_NAMES = {"HIDDEN", "VENOM", "EXPLOSIVE", "CURSED", "SHOCK", "SNARE"};
|
|
private static final String[] PRESET_LABELS = {
|
|
"ability.preset.hidden", "ability.preset.venom", "ability.preset.explosive",
|
|
"ability.preset.cursed", "ability.preset.shock", "ability.preset.snare"
|
|
};
|
|
private static final int[] PRESET_COLORS = {0x888888, 0x44DD44, 0xFF6611, 0xAA44FF, 0x4488FF, 0x88CCFF};
|
|
|
|
public SubGuiTrapPresetSelector() {
|
|
xSize = 170;
|
|
ySize = 135;
|
|
setBackground("menubg.png");
|
|
}
|
|
|
|
@Override
|
|
public void initGui() {
|
|
super.initGui();
|
|
int btnW = 72;
|
|
int btnH = 20;
|
|
int gapY = 4;
|
|
int col1 = guiLeft + 7;
|
|
int col2 = col1 + btnW + 6;
|
|
int startY = guiTop + 22;
|
|
|
|
for (int i = 0; i < 6; i++) {
|
|
int x = (i % 2 == 0) ? col1 : col2;
|
|
int y = startY + (i / 2) * (btnH + gapY);
|
|
addButton(new GuiNpcButton(i, x, y, btnW, btnH, PRESET_LABELS[i]));
|
|
}
|
|
|
|
int cancelY = startY + 3 * (btnH + gapY) + 4;
|
|
addButton(new GuiNpcButton(10, guiLeft + xSize / 2 - 36, cancelY, 72, btnH, "gui.cancel"));
|
|
}
|
|
|
|
@Override
|
|
protected void actionPerformed(GuiButton btn) {
|
|
super.actionPerformed(btn);
|
|
if (btn.id >= 0 && btn.id < 6) {
|
|
selectedPreset = PRESET_NAMES[btn.id];
|
|
close();
|
|
} else if (btn.id == 10) {
|
|
close();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void drawScreen(int mouseX, int mouseY, float f) {
|
|
super.drawScreen(mouseX, mouseY, f);
|
|
drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.applyPreset"), guiLeft + xSize / 2, guiTop + 8, 0xFFFFFF);
|
|
for (int i = 0; i < 6; i++) {
|
|
GuiNpcButton btn = getButton(i);
|
|
if (btn != null && btn.visible) {
|
|
int x = btn.xPosition + 4;
|
|
int y = btn.yPosition + 5;
|
|
drawRect(x, y, x + 10, y + 10, 0xFF000000 | PRESET_COLORS[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|