mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 14:34:52 +00:00
Merge branch 'dev' into pr-293
This commit is contained in:
commit
1d0b640c61
40 files changed
+460
-161
No files matched your search
@@ -786,7 +786,15 @@ public abstract class AbstractDataAbilities {
|
||||
fireTickEvent(currentAbility, target);
|
||||
|
||||
// Script may have completed/cancelled the ability during the tick event
|
||||
if (currentAbility == null || !currentAbility.isExecuting()) return;
|
||||
if (currentAbility == null) return;
|
||||
if (!currentAbility.isExecuting()) {
|
||||
// tick() itself can end the ability (DAZED -> IDLE). Run its completion here,
|
||||
// otherwise it stays the current ability forever and nothing else can start.
|
||||
if (phaseChanged && currentAbility.getPhase() == AbilityPhase.IDLE) {
|
||||
handleAbilityCompletion(target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Fire extender tick hook (e.g., per-tick resource drain)
|
||||
if (!AbilityController.Instance.fireOnAbilityTick(currentAbility, entity, target,
|
||||
|
||||
@@ -188,29 +188,34 @@ public class DataAbilities extends AbstractDataAbilities {
|
||||
if (maxCooldown > minCooldown) {
|
||||
baseCooldown = minCooldown + random.nextInt(maxCooldown - minCooldown + 1);
|
||||
}
|
||||
cooldownEndTime = npc.worldObj.getTotalWorldTime() + baseCooldown + ability.getCooldownTicks();
|
||||
long now = npc.worldObj.getTotalWorldTime();
|
||||
|
||||
// Additionally set per-ability cooldown if enabled
|
||||
if (ability.isPerAbilityCooldown() && ability.getCooldownTicks() > 0) {
|
||||
long endTime = npc.worldObj.getTotalWorldTime() + ability.getCooldownTicks();
|
||||
setPerAbilityCooldown(ability.getName(), endTime, ability.getCooldownTicks());
|
||||
// The ability's own cooldown is tracked against the ability, so the global timer
|
||||
// only paces how often the NPC acts. Folding the ability's cooldown into it as
|
||||
// well would always outlast the per-ability entry and make it unreachable.
|
||||
cooldownEndTime = now + baseCooldown;
|
||||
setPerAbilityCooldown(ability.getName(), now + ability.getCooldownTicks(), ability.getCooldownTicks());
|
||||
} else {
|
||||
cooldownEndTime = now + baseCooldown + ability.getCooldownTicks();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rollChainCooldown(ChainedAbility chain) {
|
||||
long now = npc.worldObj.getTotalWorldTime();
|
||||
boolean perAbility = chain.isPerAbilityCooldown() && chain.getCooldownTicks() > 0;
|
||||
|
||||
if (!chain.isIgnoreCooldown()) {
|
||||
int baseCooldown = minCooldown;
|
||||
if (maxCooldown > minCooldown) {
|
||||
baseCooldown = minCooldown + random.nextInt(maxCooldown - minCooldown + 1);
|
||||
}
|
||||
cooldownEndTime = npc.worldObj.getTotalWorldTime() + baseCooldown + chain.getCooldownTicks();
|
||||
cooldownEndTime = perAbility ? now + baseCooldown : now + baseCooldown + chain.getCooldownTicks();
|
||||
}
|
||||
|
||||
// Additionally set per-ability cooldown if enabled
|
||||
if (chain.isPerAbilityCooldown() && chain.getCooldownTicks() > 0) {
|
||||
long endTime = npc.worldObj.getTotalWorldTime() + chain.getCooldownTicks();
|
||||
setPerAbilityCooldown(chain.getName(), endTime, chain.getCooldownTicks());
|
||||
if (perAbility) {
|
||||
setPerAbilityCooldown(chain.getName(), now + chain.getCooldownTicks(), chain.getCooldownTicks());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.constants.EnumPotionType;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.controllers.data.Lines;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -13,11 +14,21 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class VersionCompatibility {
|
||||
public static int ModRev = 23;
|
||||
public static int ModRev = 24;
|
||||
|
||||
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound) {
|
||||
if (npc.npcVersion == ModRev)
|
||||
return;
|
||||
if (npc.npcVersion < 24) {
|
||||
// Fire projectiles used to ignite unconditionally. The ignite check now also requires
|
||||
// pBurnItem, which reads false when the key is absent, so restore it for anything
|
||||
// saved before the flag existed.
|
||||
if (compound.hasKey("pEffect") && !compound.hasKey("pBurnItem")) {
|
||||
if (EnumPotionType.fromOrdinal(compound.getInteger("pEffect")) == EnumPotionType.Fire) {
|
||||
compound.setBoolean("pBurnItem", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (npc.npcVersion < 23) {
|
||||
if (compound.hasKey("AimWhileShooting")) {
|
||||
boolean aimShot = compound.getBoolean("AimWhileShooting");
|
||||
|
||||
@@ -10,7 +10,10 @@ public class EntityAITransform extends EntityAIBase {
|
||||
|
||||
public EntityAITransform(EntityNPCInterface npc) {
|
||||
this.npc = npc;
|
||||
setMutexBits(AiMutex.PASSIVE);
|
||||
// No mutex: this only polls the world time and flips the transform, it drives nothing.
|
||||
// Claiming PASSIVE let any running movement or look task starve it, so the day/night
|
||||
// swap only fired in the gaps where those yielded - such as while saying a line.
|
||||
setMutexBits(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,10 +67,6 @@ public class BlockBorder extends BlockContainer {
|
||||
}
|
||||
|
||||
tile.rotation = l;
|
||||
|
||||
if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) {
|
||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Border, (EntityPlayer) par5EntityLivingBase);
|
||||
}
|
||||
}
|
||||
|
||||
private TileBorder getTile(World world, int x, int y, int z) {
|
||||
|
||||
@@ -49,13 +49,6 @@ public class BlockNpcRedstone extends BlockContainer {
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item) {
|
||||
if (entityliving instanceof EntityPlayer && world.isRemote) {
|
||||
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.RedstoneBlock, (EntityPlayer) entityliving);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {
|
||||
onBlockAdded(par1World, par2, par3, par4);
|
||||
|
||||
@@ -112,19 +112,19 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS
|
||||
}
|
||||
if (button.id == 10) {
|
||||
slot = 1;
|
||||
setSubGui(new GuiDialogSelection(availabitily.questId));
|
||||
setSubGui(new GuiDialogSelection(availabitily.dialogId));
|
||||
}
|
||||
if (button.id == 11) {
|
||||
slot = 2;
|
||||
setSubGui(new GuiDialogSelection(availabitily.quest2Id));
|
||||
setSubGui(new GuiDialogSelection(availabitily.dialog2Id));
|
||||
}
|
||||
if (button.id == 12) {
|
||||
slot = 3;
|
||||
setSubGui(new GuiDialogSelection(availabitily.quest3Id));
|
||||
setSubGui(new GuiDialogSelection(availabitily.dialog3Id));
|
||||
}
|
||||
if (button.id == 13) {
|
||||
slot = 4;
|
||||
setSubGui(new GuiDialogSelection(availabitily.quest4Id));
|
||||
setSubGui(new GuiDialogSelection(availabitily.dialog4Id));
|
||||
}
|
||||
if (button.id == 20) {
|
||||
availabitily.dialogId = -1;
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
|
||||
@@ -12,6 +13,25 @@ public class SubGuiTrapPresetSelector extends SubGuiInterface {
|
||||
|
||||
public String selectedPreset = null;
|
||||
|
||||
/**
|
||||
* Builds the trap editor's preset field.
|
||||
* <p>
|
||||
* This lives here rather than in AbilityTrap because the lambda below carries this class in
|
||||
* its method descriptor. AbilityTrap is a both-side class, and @SideOnly does not strip the
|
||||
* synthetic lambda methods it generates - so anything reflecting over its declared methods
|
||||
* on a server would resolve that descriptor and fail to find this client-only type.
|
||||
*/
|
||||
public static FieldDef createPresetField(java.util.function.Consumer<String> applyPreset) {
|
||||
return FieldDef.subGuiField("gui.applyPreset",
|
||||
SubGuiTrapPresetSelector::new,
|
||||
gui -> {
|
||||
SubGuiTrapPresetSelector selector = (SubGuiTrapPresetSelector) gui;
|
||||
if (selector.selectedPreset != null) {
|
||||
applyPreset.accept(selector.selectedPreset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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",
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
|
||||
@@ -12,6 +13,25 @@ public class SubGuiZonePresetSelector extends SubGuiInterface {
|
||||
|
||||
public String selectedPreset = null;
|
||||
|
||||
/**
|
||||
* Builds the zone editor's preset field.
|
||||
* <p>
|
||||
* This lives here rather than in AbilityZone because the lambda below carries this class in
|
||||
* its method descriptor. AbilityZone is a both-side class, and @SideOnly does not strip the
|
||||
* synthetic lambda methods it generates - so anything reflecting over its declared methods
|
||||
* on a server would resolve that descriptor and fail to find this client-only type.
|
||||
*/
|
||||
public static FieldDef createPresetField(java.util.function.Consumer<String> applyPreset) {
|
||||
return FieldDef.subGuiField("gui.applyPreset",
|
||||
SubGuiZonePresetSelector::new,
|
||||
gui -> {
|
||||
SubGuiZonePresetSelector selector = (SubGuiZonePresetSelector) gui;
|
||||
if (selector.selectedPreset != null) {
|
||||
applyPreset.accept(selector.selectedPreset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final String[] PRESET_NAMES = {"DEFAULT", "TOXIC", "INFERNO", "ARCANE", "ELECTRIC", "FROST"};
|
||||
private static final String[] PRESET_LABELS = {
|
||||
"ability.preset.default", "ability.preset.toxic", "ability.preset.inferno",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
@@ -11,6 +13,7 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
import noppes.npcs.controllers.data.Magic;
|
||||
import noppes.npcs.controllers.data.MagicData;
|
||||
import noppes.npcs.controllers.data.MagicEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -36,6 +39,30 @@ public class SubGuiAbilityMagic extends SubGuiInterface implements ICustomScroll
|
||||
|
||||
private GuiNpcTextField splitField;
|
||||
|
||||
/**
|
||||
* Builds the ability editor's magic field.
|
||||
* <p>
|
||||
* This lives here rather than in Ability because the lambdas below carry this class in
|
||||
* their method descriptors. Ability is a both-side class, and anything reflecting over its
|
||||
* declared methods on a server - Nashorn's adapter generator, for one - would resolve those
|
||||
* descriptors and fail to find this client-only type.
|
||||
*/
|
||||
public static FieldDef createMagicField(MagicData magicData) {
|
||||
return FieldDef.subGuiField("ability.magic.editor",
|
||||
() -> new SubGuiAbilityMagic(magicData.copy()),
|
||||
gui -> {
|
||||
MagicData result = ((SubGuiAbilityMagic) gui).magicData;
|
||||
magicData.getMagics().clear();
|
||||
for (Map.Entry<Integer, MagicEntry> e : result.getMagics().entrySet()) {
|
||||
magicData.getMagics().put(e.getKey(), e.getValue());
|
||||
}
|
||||
})
|
||||
.buttonLabel(() -> magicData.isEmpty()
|
||||
? StatCollector.translateToLocal("ability.magic.usesCaster")
|
||||
: magicData.getMagics().size() + " Magic(s)")
|
||||
.tab("General");
|
||||
}
|
||||
|
||||
public SubGuiAbilityMagic(MagicData data) {
|
||||
this.magicData = data;
|
||||
setBackground("menubg.png");
|
||||
|
||||
@@ -3,6 +3,8 @@ package noppes.npcs.client.gui.advanced;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import kamkeel.npcs.controllers.data.ability.conditions.ConditionHasEffect;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
@@ -25,6 +27,31 @@ import java.util.Map;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustomScrollListener, ITextfieldListener {
|
||||
|
||||
/**
|
||||
* Builds the condition editor's effect-select field.
|
||||
* <p>
|
||||
* This lives here rather than in ConditionHasEffect because the lambdas below carry this
|
||||
* class in their method descriptors. The condition is a both-side class, and @SideOnly does
|
||||
* not strip the synthetic lambda methods it generates - so anything reflecting over its
|
||||
* declared methods on a server would resolve those descriptors and fail to find this type.
|
||||
*/
|
||||
public static FieldDef createSelectField(ConditionHasEffect condition) {
|
||||
return FieldDef.subGuiField("condition.select_effect",
|
||||
() -> new SubGuiCustomEffectSelect(condition.getEffectId(), condition.getEffectIndex()),
|
||||
gui -> {
|
||||
SubGuiCustomEffectSelect sel = (SubGuiCustomEffectSelect) gui;
|
||||
if (sel.getSelectedEffectId() >= 0) {
|
||||
condition.setEffect(sel.getSelectedEffectId(), sel.getSelectedIndex());
|
||||
}
|
||||
})
|
||||
.buttonLabel(() -> {
|
||||
if (condition.getEffectId() < 0) return "None";
|
||||
CustomEffect effect = condition.getEffect();
|
||||
return effect != null ? effect.getName() : "ID:" + condition.getEffectId();
|
||||
})
|
||||
.clearable(() -> condition.setEffect(-1, 0));
|
||||
}
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private final HashMap<String, Integer> displayNameToId = new HashMap<>();
|
||||
private final HashMap<String, Integer> allDisplayNameToId = new HashMap<>();
|
||||
|
||||
@@ -39,6 +39,7 @@ public class QuestTrackingComponent extends HudComponent {
|
||||
if (turnIn != null && !turnIn.isEmpty()) {
|
||||
turnInLines.add(convertColorCodes(turnIn));
|
||||
}
|
||||
updateOverlayHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,6 +240,19 @@ public class QuestTrackingComponent extends HudComponent {
|
||||
}
|
||||
|
||||
// ---------- Helper rendering methods ----------- (methods unchanged) ...
|
||||
private void updateOverlayHeight() {
|
||||
int lineHeight = mc.fontRenderer.FONT_HEIGHT + 4;
|
||||
int contentHeight = 5;
|
||||
contentHeight += questTitleLines.size() * lineHeight + 8;
|
||||
contentHeight += questCategoryLines.size() * lineHeight + 8;
|
||||
contentHeight += objectiveLines.size() * lineHeight;
|
||||
if (!turnInLines.isEmpty()) {
|
||||
contentHeight += 8;
|
||||
}
|
||||
contentHeight += turnInLines.size() * lineHeight;
|
||||
overlayHeight = contentHeight;
|
||||
}
|
||||
|
||||
private int renderTextBlock(List<String> lines, int startY, int align, int color) {
|
||||
int y = startY;
|
||||
FontRenderer font = mc.fontRenderer;
|
||||
|
||||
@@ -429,6 +429,9 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC
|
||||
}
|
||||
|
||||
private boolean isMouseOverScrollbar(int mouseX, int mouseY) {
|
||||
if (maxScrollY <= 0)
|
||||
return false;
|
||||
|
||||
int scrollbarX = guiLeft + xSize + 30;
|
||||
int scrollbarY = guiTop + 27;
|
||||
int scrollbarHeight = ySize - 35;
|
||||
|
||||
@@ -21,6 +21,7 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
|
||||
private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png");
|
||||
private RoleTrader role;
|
||||
private boolean marketRelinked = false;
|
||||
|
||||
// Currency cost textfield IDs start at 100 (100-117 for slots 0-17)
|
||||
private static final int CURRENCY_FIELD_ID_START = 100;
|
||||
@@ -116,8 +117,14 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, false));
|
||||
// Linking to a different market already replaced the server's role with that market's
|
||||
// data. Pushing this GUI's pre-link state back would overwrite the market being linked to.
|
||||
if (marketRelinked)
|
||||
return;
|
||||
|
||||
// Save the role first so the market is written from the edited data, not the stale data.
|
||||
PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound())));
|
||||
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,6 +136,7 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
String name = guiNpcTextField.getText();
|
||||
if (!name.equalsIgnoreCase(role.marketName)) {
|
||||
role.marketName = name;
|
||||
marketRelinked = true;
|
||||
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, true));
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -2,6 +2,8 @@ package noppes.npcs.client.gui.select;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import kamkeel.npcs.controllers.data.ability.conditions.ConditionQuestCompleted;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
@@ -27,6 +29,31 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL
|
||||
private QuestCategory selectedCategory;
|
||||
public Quest selectedQuest;
|
||||
|
||||
/**
|
||||
* Builds the condition editor's quest-select field.
|
||||
* <p>
|
||||
* This lives here rather than in ConditionQuestCompleted because the lambdas below carry
|
||||
* this class in their method descriptors. The condition is a both-side class, and @SideOnly
|
||||
* does not strip the synthetic lambda methods it generates - so anything reflecting over its
|
||||
* declared methods on a server would resolve those descriptors and fail to find this type.
|
||||
*/
|
||||
public static FieldDef createConditionField(ConditionQuestCompleted condition) {
|
||||
return FieldDef.subGuiField("condition.select_quest",
|
||||
() -> new GuiQuestSelection(condition.getQuestId()),
|
||||
gui -> {
|
||||
GuiQuestSelection sel = (GuiQuestSelection) gui;
|
||||
if (sel.selectedQuest != null) {
|
||||
condition.setQuestId(sel.selectedQuest.id);
|
||||
}
|
||||
})
|
||||
.buttonLabel(() -> {
|
||||
if (condition.getQuestId() < 0) return "None";
|
||||
Quest q = QuestController.Instance.quests.get(condition.getQuestId());
|
||||
return q != null ? q.title : "ID:" + condition.getQuestId();
|
||||
})
|
||||
.clearable(() -> condition.setQuestId(-1));
|
||||
}
|
||||
|
||||
private GuiSelectionListener listener;
|
||||
private String catSearch = "";
|
||||
private String questSearch = "";
|
||||
|
||||
@@ -515,15 +515,28 @@ public abstract class GuiNPCInterface extends GuiScreen {
|
||||
}
|
||||
|
||||
boolean subGui = hasSubGui();
|
||||
|
||||
// Mouse.getDWheel() clears the accumulated delta, so only the first caller in a frame
|
||||
// ever sees it. Read it once here and let each widget take it in turn; anything that
|
||||
// consumes it zeroes it so later widgets - the script editor, for one - are not left
|
||||
// reading an already-drained wheel.
|
||||
mouseScroll = Mouse.getDWheel();
|
||||
|
||||
drawCenteredString(fontRendererObj, title, width / 2, guiTop + 4, 0xffffff);
|
||||
for (GuiNpcLabel label : labels.values())
|
||||
label.drawLabel(this, fontRendererObj);
|
||||
for (GuiCustomScroll scroll : scrolls.values()) {
|
||||
scroll.updateSubGUI(subGui);
|
||||
scroll.drawScreen(drawX, drawY, f, !subGui && scroll.isMouseOver(drawX, drawY) ? Mouse.getDWheel() : 0);
|
||||
int delta = !subGui && scroll.isMouseOver(drawX, drawY) ? mouseScroll : 0;
|
||||
if (delta != 0)
|
||||
mouseScroll = 0;
|
||||
scroll.drawScreen(drawX, drawY, f, delta);
|
||||
}
|
||||
for (GuiScrollWindow guiScrollableComponent : scrollWindows.values()) {
|
||||
guiScrollableComponent.drawScreen(drawX, drawY, f, !subGui && guiScrollableComponent.isMouseOver(drawX, drawY) ? Mouse.getDWheel() : 0);
|
||||
int delta = !subGui && guiScrollableComponent.isMouseOver(drawX, drawY) ? mouseScroll : 0;
|
||||
if (delta != 0)
|
||||
mouseScroll = 0;
|
||||
guiScrollableComponent.drawScreen(drawX, drawY, f, delta);
|
||||
}
|
||||
for (GuiDiagram diagram : diagrams.values()) {
|
||||
diagram.drawDiagram(drawX, drawY, subGui);
|
||||
|
||||
@@ -624,9 +624,11 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
int maxScroll = Math.max(0, getPaddedLineCount() - container.visibleLines);
|
||||
|
||||
// Handle mouse wheel scroll
|
||||
int wheelDelta = ((GuiNPCInterface) listener).mouseScroll = Mouse.getDWheel();
|
||||
// Take whatever the parent screen has left for this frame rather than polling the wheel
|
||||
// again - the poll is destructive and the parent has already drained it.
|
||||
int wheelDelta = listener instanceof GuiNPCInterface ? ((GuiNPCInterface) listener).mouseScroll : Mouse.getDWheel();
|
||||
if (listener instanceof GuiNPCInterface) {
|
||||
((GuiNPCInterface) listener).mouseScroll = wheelDelta;
|
||||
((GuiNPCInterface) listener).mouseScroll = 0;
|
||||
|
||||
// Intercept wheel scroll for tooltip (highest priority)
|
||||
// Only consume the wheel event when the tooltip actually has content to scroll;
|
||||
|
||||
@@ -486,9 +486,11 @@ public class GuiScriptTextArea1 extends GuiNpcTextField {
|
||||
int maxScroll = Math.max(0, getPaddedLineCount() - container.visibleLines);
|
||||
|
||||
// Handle mouse wheel scroll
|
||||
int wheelDelta = ((GuiNPCInterface) listener).mouseScroll = Mouse.getDWheel();
|
||||
// Take whatever the parent screen has left for this frame rather than polling the wheel
|
||||
// again - the poll is destructive and the parent has already drained it.
|
||||
int wheelDelta = listener instanceof GuiNPCInterface ? ((GuiNPCInterface) listener).mouseScroll : Mouse.getDWheel();
|
||||
if (listener instanceof GuiNPCInterface) {
|
||||
((GuiNPCInterface) listener).mouseScroll = wheelDelta;
|
||||
((GuiNPCInterface) listener).mouseScroll = 0;
|
||||
boolean canScroll = !KEYS_OVERLAY.isVisible() || KEYS_OVERLAY.isVisible() && !KEYS_OVERLAY.aboveOverlay;
|
||||
if (wheelDelta != 0 && canScroll)
|
||||
scroll.applyWheelScroll(wheelDelta, maxScroll);
|
||||
|
||||
@@ -325,78 +325,94 @@ public class TypeInfo {
|
||||
* @return A TypeInfo preserving the generic structure, or null if type is null
|
||||
*/
|
||||
public static TypeInfo fromGenericType(Type type) {
|
||||
return fromGenericType(type, new HashSet<TypeVariable<?>>());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resolving type variables whose bounds are currently being expanded, so a
|
||||
* self-referential bound such as {@code E extends Enum<E>} terminates
|
||||
*/
|
||||
private static TypeInfo fromGenericType(Type type, Set<TypeVariable<?>> resolving) {
|
||||
if (type == null) return null;
|
||||
|
||||
|
||||
if (type instanceof Class<?>) {
|
||||
// Plain class - no generic info
|
||||
return fromClass((Class<?>) type);
|
||||
}
|
||||
|
||||
|
||||
if (type instanceof ParameterizedType) {
|
||||
// Generic type like List<String>
|
||||
ParameterizedType paramType = (ParameterizedType) type;
|
||||
Type rawType = paramType.getRawType();
|
||||
|
||||
|
||||
if (!(rawType instanceof Class<?>)) {
|
||||
// Edge case - should not happen normally
|
||||
return rawType != null ? fromGenericType(rawType) : null;
|
||||
return rawType != null ? fromGenericType(rawType, resolving) : null;
|
||||
}
|
||||
|
||||
|
||||
// Get the raw type as TypeInfo
|
||||
TypeInfo rawTypeInfo = fromClass((Class<?>) rawType);
|
||||
|
||||
|
||||
// Recursively convert type arguments
|
||||
Type[] typeArgs = paramType.getActualTypeArguments();
|
||||
List<TypeInfo> appliedArgs = new ArrayList<>(typeArgs.length);
|
||||
for (Type arg : typeArgs) {
|
||||
TypeInfo argInfo = fromGenericType(arg);
|
||||
TypeInfo argInfo = fromGenericType(arg, resolving);
|
||||
if (argInfo != null) {
|
||||
appliedArgs.add(argInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return a parameterized TypeInfo
|
||||
if (!appliedArgs.isEmpty()) {
|
||||
return rawTypeInfo.parameterize(appliedArgs);
|
||||
}
|
||||
return rawTypeInfo;
|
||||
}
|
||||
|
||||
|
||||
if (type instanceof GenericArrayType) {
|
||||
// Array of generic type, e.g. T[] or List<String>[]
|
||||
GenericArrayType arrayType = (GenericArrayType) type;
|
||||
TypeInfo elementType = fromGenericType(arrayType.getGenericComponentType());
|
||||
TypeInfo elementType = fromGenericType(arrayType.getGenericComponentType(), resolving);
|
||||
if (elementType != null) {
|
||||
return arrayOf(elementType);
|
||||
}
|
||||
return fromClass(Object[].class);
|
||||
}
|
||||
|
||||
|
||||
if (type instanceof TypeVariable<?>) {
|
||||
TypeVariable<?> typeVar = (TypeVariable<?>) type;
|
||||
String varName = typeVar.getName();
|
||||
// Check for bounds - if bounded, create typeParameter with bound
|
||||
Type[] bounds = typeVar.getBounds();
|
||||
if (bounds != null && bounds.length > 0 && bounds[0] != Object.class) {
|
||||
return TypeInfo.typeParameter(varName, fromGenericType(bounds[0]));
|
||||
// Already expanding this variable - emit it unbounded rather than recursing forever
|
||||
if (!resolving.add(typeVar)) {
|
||||
return TypeInfo.typeParameter(varName);
|
||||
}
|
||||
try {
|
||||
// Check for bounds - if bounded, create typeParameter with bound
|
||||
Type[] bounds = typeVar.getBounds();
|
||||
if (bounds != null && bounds.length > 0 && bounds[0] != Object.class) {
|
||||
return TypeInfo.typeParameter(varName, fromGenericType(bounds[0], resolving));
|
||||
}
|
||||
return TypeInfo.typeParameter(varName);
|
||||
} finally {
|
||||
resolving.remove(typeVar);
|
||||
}
|
||||
return TypeInfo.typeParameter(varName);
|
||||
}
|
||||
|
||||
|
||||
if (type instanceof WildcardType) {
|
||||
// Wildcard like ? or ? extends Number or ? super Integer
|
||||
WildcardType wildcard = (WildcardType) type;
|
||||
Type[] upperBounds = wildcard.getUpperBounds();
|
||||
|
||||
|
||||
// Use the upper bound if available (most useful for ? extends T)
|
||||
if (upperBounds.length > 0 && upperBounds[0] != Object.class) {
|
||||
return fromGenericType(upperBounds[0]);
|
||||
return fromGenericType(upperBounds[0], resolving);
|
||||
}
|
||||
|
||||
|
||||
// For ? super T or plain ?, just use Object
|
||||
return fromClass(Object.class);
|
||||
}
|
||||
|
||||
|
||||
// Unknown type - shouldn't happen in practice
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ public class ModelMonkeyTail extends ModelRenderer {
|
||||
|
||||
public ModelMonkeyTail(ModelBiped base) {
|
||||
super(base);
|
||||
float heightFactor = -9.0f;
|
||||
// Cancels ModelTail's rotationPointY of 11 so the boxes land where JBRA puts them
|
||||
// on players: plain tail at 10, wrapped tail at 0.
|
||||
float heightFactor = -11.0f;
|
||||
|
||||
(this.monkey_large = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6);
|
||||
this.setRotation(this.monkey_large, -0.5235988f, 0.0f, 0.0f);
|
||||
|
||||
@@ -832,9 +832,8 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
currentTarget = null;
|
||||
lastAbilityActivationTime = -1;
|
||||
|
||||
// Clear cooldowns (fresh start after relog)
|
||||
cooldownEndTime = 0;
|
||||
resetAllPerAbilityCooldowns();
|
||||
// Cooldowns are absolute world-time deadlines and are restored from NBT, so relogging
|
||||
// must not clear them or it becomes a way to bypass them.
|
||||
interruptCooldownRolled = false;
|
||||
|
||||
// Reset sync tracking so next sync sends fresh state
|
||||
@@ -852,9 +851,10 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
if (currentAbility != null && currentAbility.isExecuting()) {
|
||||
interruptCurrentAbility(null, 0);
|
||||
}
|
||||
// Clear any remaining transient state (cooldowns, chains, locks)
|
||||
// Clear any remaining transient state (chains, locks)
|
||||
// Don't clear toggles — they were already saved to NBT by this point
|
||||
onEntityReconstructed(true, false);
|
||||
// Don't clear cooldowns — they persist across sessions
|
||||
onEntityReconstructed(false, false);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -1048,6 +1048,22 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
toggleList.appendTag(toggleNbt);
|
||||
}
|
||||
compound.setTag("ActiveToggles", toggleList);
|
||||
|
||||
// Cooldowns are absolute world-time deadlines, so they stay meaningful across sessions
|
||||
NBTTagCompound cooldowns = new NBTTagCompound();
|
||||
cooldowns.setLong("GlobalEnd", cooldownEndTime);
|
||||
cooldowns.setInteger("GlobalDuration", globalCooldownDuration);
|
||||
NBTTagList perAbilityList = new NBTTagList();
|
||||
for (Map.Entry<String, Long> entry : perAbilityCooldownEndTimes.entrySet()) {
|
||||
NBTTagCompound cooldownNbt = new NBTTagCompound();
|
||||
cooldownNbt.setString("Key", entry.getKey());
|
||||
cooldownNbt.setLong("End", entry.getValue());
|
||||
Integer duration = perAbilityCooldownDurations.get(entry.getKey());
|
||||
cooldownNbt.setInteger("Duration", duration == null ? 0 : duration);
|
||||
perAbilityList.appendTag(cooldownNbt);
|
||||
}
|
||||
cooldowns.setTag("PerAbility", perAbilityList);
|
||||
compound.setTag("AbilityCooldowns", cooldowns);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
@@ -1082,6 +1098,24 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
setToggleEntryDirect(key, state);
|
||||
}
|
||||
}
|
||||
|
||||
if (compound.hasKey("AbilityCooldowns")) {
|
||||
cooldownEndTime = 0;
|
||||
globalCooldownDuration = 0;
|
||||
resetAllPerAbilityCooldowns();
|
||||
|
||||
NBTTagCompound cooldowns = compound.getCompoundTag("AbilityCooldowns");
|
||||
cooldownEndTime = cooldowns.getLong("GlobalEnd");
|
||||
globalCooldownDuration = cooldowns.getInteger("GlobalDuration");
|
||||
NBTTagList perAbilityList = cooldowns.getTagList("PerAbility", 10); // 10 = TAG_COMPOUND
|
||||
for (int i = 0; i < perAbilityList.tagCount(); i++) {
|
||||
NBTTagCompound entry = perAbilityList.getCompoundTagAt(i);
|
||||
String key = entry.getString("Key");
|
||||
if (key == null || key.isEmpty()) continue;
|
||||
perAbilityCooldownEndTimes.put(key, entry.getLong("End"));
|
||||
perAbilityCooldownDurations.put(key, entry.getInteger("Duration"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -301,7 +301,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
|
||||
@Override
|
||||
public boolean getLeashed() {
|
||||
return false; //Prevents npcs from being leashed
|
||||
return false; // Prevents npcs from being leashed
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -94,6 +94,15 @@ public class RoleTrader extends RoleInterface {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
readFromNBT(nbttagcompound, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loadFromMarket pull the linked market's stored data over the compound just read.
|
||||
* False when the compound is an admin edit, which is authoritative and
|
||||
* would otherwise be overwritten by the market it is about to be saved to.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound, boolean loadFromMarket) {
|
||||
String oldMarket = marketName;
|
||||
marketName = nbttagcompound.getString("TraderMarket");
|
||||
readNBT(nbttagcompound);
|
||||
@@ -101,6 +110,9 @@ public class RoleTrader extends RoleInterface {
|
||||
// Register with MarketRegistry for linked market sync
|
||||
MarketRegistry.updateTraderMarket(oldMarket, marketName, this);
|
||||
|
||||
if (!loadFromMarket)
|
||||
return;
|
||||
|
||||
try {
|
||||
Market.getMarket(this, marketName);
|
||||
} catch (Exception ex) {
|
||||
|
||||
Reference in new issue
Block a user