Fairy ring refactor

Reimplemented the travel log, fixes the issue where all the travel log interface text collapses in on itself
Travel log now displays the relevant code
Log sorting implemented
Fairy ring now remembers the last entered code and automatically re-enters it when opened
Fairy ring no longer skips letters
Direction clicks in quick succession now turn the wheel multiple times
This commit is contained in:
Ceikry
2024-10-06 10:21:58 +00:00
committed by Ryan
parent 8db9060a40
commit 6b0f942598
5 changed files with 129 additions and 104 deletions
+10 -1
View File
@@ -1253,10 +1253,19 @@ fun getVarbit (player: Player, varbitId: Int) : Int {
@JvmOverloads
fun setVarp (player: Player, varpIndex: Int, value: Int, save: Boolean = false) {
player.varpMap[varpIndex] = value
player.saveVarp[varpIndex] = save
if (player.saveVarp[varpIndex] != true && save)
player.saveVarp[varpIndex] = true //only set if we're choosing to save. Prevents accidental unsaving. if you REALLY want to unsave a varp, use unsaveVarp.
player.packetDispatch.sendVarp(varpIndex, value)
}
fun saveVarp (player: Player, varpIndex: Int) {
player.saveVarp[varpIndex] = true
}
fun unsaveVarp (player: Player, varpIndex: Int) {
player.saveVarp.remove(varpIndex)
}
@JvmOverloads
fun setVarbit (player: Player, def: VarbitDefinition, value: Int, save: Boolean = false) {
val mask = def.mask
@@ -34,7 +34,9 @@ public final class ContainerContext implements Context {
/**
* The items.
*/
private final Item[] items;
private Item[] items;
public int[] ids;
/**
* The length of the array to send.
@@ -115,6 +117,17 @@ public final class ContainerContext implements Context {
this.slots = null;
}
public ContainerContext(Player player, int interfaceId, int childId, int containerId, int[] items) {
this.player = player;
this.interfaceId = interfaceId;
this.childId = childId;
this.containerId = containerId;
this.ids = items;
this.length = items.length;
this.split = false;
this.slots = null;
}
/**
* Constructs a new {@code ContainerContext} {@code Object}.
* @param player The player.
@@ -42,19 +42,30 @@ public final class ContainerPacket implements OutgoingPacket<ContainerContext> {
}
}
} else {
buffer.putShort(context.getItems().length);
for (Item item : context.getItems())
if (item != null) {
int amount = item.getAmount();
if (amount < 0 || amount > 254) {
buffer.putS(255).putInt(amount);
} else {
buffer.putS(amount);
}
buffer.putShort(item.getId() + 1);
} else {
buffer.putS(0).putShort(0);
if (context.ids != null)
{
buffer.p2(context.getLength());
for (int i = 0; i < context.getLength(); i++)
{
buffer.putS(1);
buffer.p2(context.ids[i] + 1);
}
}
else {
buffer.putShort(context.getItems().length);
for (Item item : context.getItems())
if (item != null) {
int amount = item.getAmount();
if (amount < 0 || amount > 254) {
buffer.putS(255).putInt(amount);
} else {
buffer.putS(amount);
}
buffer.putShort(item.getId() + 1);
} else {
buffer.putS(0).putShort(0);
}
}
}
}
buffer.cypherOpcode(context.getPlayer().getSession().getIsaacPair().getOutput());context.getPlayer().getSession().write(buffer);