Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/main/java/betterquesting/client/gui2/GuiQuest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class GuiQuest extends GuiScreenCanvas implements IPEventListener, INeedsRefresh {

Expand Down Expand Up @@ -390,13 +391,8 @@ private void refreshTaskPanel() {
for (int i = 0; i < entries.size(); i++) {
ITask tsk = entries.get(i).getValue();

String taskName = (i + 1) + ". " + QuestTranslation.translate(tsk.getUnlocalisedName());
if (tsk instanceof TaskRetrieval) {
EnumLogic entryLogic = ((TaskRetrieval) tsk).getEntryLogic();
if (entryLogic != EnumLogic.AND)
taskName += " (" + entryLogic + ")";
}
PanelTextBox titleReward = new PanelTextBox(new GuiTransform(new Vector4f(), 0, yOffset, rectTask.getWidth(), 12, 0), taskName);
String titleText = (i + 1) + ". " + getTaskTitle(tsk, QuestingAPI.getQuestingUUID(mc.player));
PanelTextBox titleReward = new PanelTextBox(new GuiTransform(new Vector4f(), 0, yOffset, rectTask.getWidth(), 12, 0), titleText);
titleReward.setColor(PresetColor.TEXT_HEADER.getColor()).setAlignment(1);
titleReward.setEnabled(true);
csTask.addPanel(titleReward);
Expand Down Expand Up @@ -425,6 +421,20 @@ private void refreshTaskPanel() {

}

private static String getTaskTitle(ITask task, UUID uuid) {
String taskName = QuestTranslation.translate(task.getUnlocalisedName());
if (task instanceof TaskRetrieval retrieval) {
EnumLogic entryLogic = retrieval.getEntryLogic();
if (entryLogic != EnumLogic.AND) {
taskName += " (" + entryLogic + ")";
}
}
if (task.ignored(uuid)) {
return QuestTranslation.translate("bq_standard.task.is_optional") + " " + taskName;
}
return taskName;
}

private void refreshDescPanel(boolean hasReward) {
if (hasReward) {
csDesc = new CanvasScrolling(new GuiTransform(new Vector4f(0F, 0F, 0.5F, 0.5F), new GuiPadding(0, 0, 16, 16), 0));
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/betterquesting/questing/tasks/TaskAdvancement.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package betterquesting.questing.tasks;

import betterquesting.NBTUtil;
import betterquesting.api.questing.IQuest;
import betterquesting.api.questing.tasks.ITask;
import betterquesting.api2.client.gui.misc.IGuiRect;
Expand Down Expand Up @@ -27,6 +28,11 @@
import java.util.*;

public class TaskAdvancement implements ITask {

private static final boolean DEFAULT_OPTIONAL = false;

public boolean optional = DEFAULT_OPTIONAL;

private final Set<UUID> completeUsers = new TreeSet<>();
public ResourceLocation advID;

Expand Down Expand Up @@ -124,16 +130,23 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) {

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);
nbt.setString("advancement_id", advID == null ? "" : advID.toString());
return nbt;
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);
String id = nbt.getString("advancement_id");
advID = StringUtils.isNullOrEmpty(id) ? null : new ResourceLocation(id);
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
return Collections.singletonList(advID.toString());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/betterquesting/questing/tasks/TaskBlockBreak.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package betterquesting.questing.tasks;

import betterquesting.NBTUtil;
import betterquesting.NbtBlockType;
import betterquesting.api.questing.IQuest;
import betterquesting.api.questing.tasks.ITask;
Expand Down Expand Up @@ -34,6 +35,9 @@
import java.util.*;

public class TaskBlockBreak implements ITask {
private static final boolean DEFAULT_OPTIONAL = false;

public boolean optional = DEFAULT_OPTIONAL;
private final Set<UUID> completeUsers = new TreeSet<>();
private final TreeMap<UUID, int[]> userProgress = new TreeMap<>();
public final List<NbtBlockType> blockTypes = new ArrayList<>();
Expand Down Expand Up @@ -116,6 +120,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) {

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);
NBTTagList bAry = new NBTTagList();
for (NbtBlockType block : blockTypes) {
bAry.appendTag(block.writeToNBT(new NBTTagCompound(), reduce));
Expand All @@ -127,6 +132,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {

@Override
public void readFromNBT(NBTTagCompound nbt) {
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);
blockTypes.clear();
NBTTagList bList = nbt.getTagList("blocks", 10);
for (int i = 0; i < bList.tagCount(); i++) {
Expand Down Expand Up @@ -269,6 +275,11 @@ private void setBulkProgress(@Nonnull List<Tuple<UUID, int[]>> list) {
list.forEach((entry) -> setUserProgress(entry.getFirst(), entry.getSecond()));
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
List<String> texts = new ArrayList<>();
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/betterquesting/questing/tasks/TaskCheckbox.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package betterquesting.questing.tasks;

import betterquesting.NBTUtil;
import betterquesting.api.questing.IQuest;
import betterquesting.api.questing.tasks.ITask;
import betterquesting.api2.client.gui.misc.IGuiRect;
Expand All @@ -25,6 +26,9 @@
import java.util.UUID;

public class TaskCheckbox implements ITask {
private static final boolean DEFAULT_OPTIONAL = false;

public boolean optional = DEFAULT_OPTIONAL;
private final Set<UUID> completeUsers = new TreeSet<>();

@Override
Expand Down Expand Up @@ -64,11 +68,13 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) {

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);
return nbt;
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);
}

@Override
Expand Down Expand Up @@ -113,6 +119,11 @@ public GuiScreen getTaskEditor(GuiScreen parent, DBEntry<IQuest> quest) {
return null;
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public boolean displaysCenteredAlone() {
return true;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/betterquesting/questing/tasks/TaskCrafting.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class TaskCrafting implements ITask {
private static final boolean DEFAULT_ALLOW_ANVIL = false;
private static final boolean DEFAULT_ALLOW_SMELT = true;
private static final boolean DEFAULT_ALLOW_CRAFT = true;
private static final boolean DEFAULT_OPTIONAL = false;
private final Set<UUID> completeUsers = new TreeSet<>();
public final NonNullList<BigItemStack> requiredItems = NonNullList.create();
public final TreeMap<UUID, int[]> userProgress = new TreeMap<>();
Expand All @@ -45,6 +46,7 @@ public class TaskCrafting implements ITask {
public boolean allowAnvil = DEFAULT_ALLOW_ANVIL;
public boolean allowSmelt = DEFAULT_ALLOW_SMELT;
public boolean allowCraft = DEFAULT_ALLOW_CRAFT;
public boolean optional = DEFAULT_OPTIONAL;

@Override
public ResourceLocation getFactoryID() {
Expand Down Expand Up @@ -135,6 +137,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setBoolean(nbt, "allowCraft", allowCraft, DEFAULT_ALLOW_CRAFT, reduce);
NBTUtil.setBoolean(nbt, "allowSmelt", allowSmelt, DEFAULT_ALLOW_SMELT, reduce);
NBTUtil.setBoolean(nbt, "allowAnvil", allowAnvil, DEFAULT_ALLOW_ANVIL, reduce);
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);

NBTTagList itemArray = new NBTTagList();
for (BigItemStack stack : this.requiredItems) {
Expand All @@ -152,6 +155,7 @@ public void readFromNBT(NBTTagCompound nbt) {
allowCraft = NBTUtil.getBoolean(nbt, "allowCraft", DEFAULT_ALLOW_CRAFT);
allowSmelt = NBTUtil.getBoolean(nbt, "allowSmelt", DEFAULT_ALLOW_SMELT);
allowAnvil = NBTUtil.getBoolean(nbt, "allowAnvil", DEFAULT_ALLOW_ANVIL);
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);

requiredItems.clear();
NBTTagList iList = nbt.getTagList("requiredItems", 10);
Expand Down Expand Up @@ -276,6 +280,11 @@ private void setBulkProgress(@Nonnull List<Tuple<UUID, int[]>> list) {
list.forEach((entry) -> setUserProgress(entry.getFirst(), entry.getSecond()));
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
List<String> texts = new ArrayList<>();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/betterquesting/questing/tasks/TaskFluid.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TaskFluid implements ITaskInventory, IFluidTask, IItemTask {
private static final boolean DEFAULT_CONSUME = false;
private static final boolean DEFAULT_GROUP_DETECT = false;
private static final boolean DEFAULT_AUTO_CONSUME = false;
private static final boolean DEFAULT_OPTIONAL = false;
private final Set<UUID> completeUsers = new ObjectOpenHashSet<>();
public final NonNullList<FluidStack> requiredFluids = NonNullList.create();
public final Map<UUID, int[]> userProgress = new Object2ObjectOpenHashMap<>();
Expand All @@ -54,6 +55,7 @@ public class TaskFluid implements ITaskInventory, IFluidTask, IItemTask {
public boolean consume = DEFAULT_CONSUME;
public boolean groupDetect = DEFAULT_GROUP_DETECT;
public boolean autoConsume = DEFAULT_AUTO_CONSUME;
public boolean optional = DEFAULT_OPTIONAL;
private boolean progressChanged = false;

@Override
Expand Down Expand Up @@ -311,6 +313,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setBoolean(nbt, "consume", consume, DEFAULT_CONSUME, reduce);
NBTUtil.setBoolean(nbt, "groupDetect", groupDetect, DEFAULT_GROUP_DETECT, reduce);
NBTUtil.setBoolean(nbt, "autoConsume", autoConsume, DEFAULT_AUTO_CONSUME, reduce);
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);

NBTTagList itemArray = new NBTTagList();
for (FluidStack stack : this.requiredFluids) {
Expand All @@ -328,6 +331,7 @@ public void readFromNBT(NBTTagCompound nbt) {
consume = NBTUtil.getBoolean(nbt, "consume", DEFAULT_CONSUME);
groupDetect = NBTUtil.getBoolean(nbt, "groupDetect", DEFAULT_GROUP_DETECT);
autoConsume = NBTUtil.getBoolean(nbt, "autoConsume", DEFAULT_AUTO_CONSUME);
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);

requiredFluids.clear();
NBTTagList fList = nbt.getTagList("requiredFluids", 10);
Expand Down Expand Up @@ -558,6 +562,11 @@ public ItemStack submitItem(UUID owner, DBEntry<IQuest> quest, ItemStack input)
return hasDrained ? handler.getContainer() : item;
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
List<String> texts = new ArrayList<>();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/betterquesting/questing/tasks/TaskHunt.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public class TaskHunt implements ITask {
private static final int DEFAULT_REQUIRED = 1;
private static final boolean DEFAULT_IGNORE_NBT = true;
private static final boolean DEFAULT_SUBTYPES = true;
private static final boolean DEFAULT_OPTIONAL = false;
private final Set<UUID> completeUsers = new TreeSet<>();
private final TreeMap<UUID, Integer> userProgress = new TreeMap<>();
public String idName = DEFAULT_ENTITY;
public String damageType = DEFAULT_DAMAGE_TYPE;
public int required = DEFAULT_REQUIRED;
public boolean ignoreNBT = DEFAULT_IGNORE_NBT;
public boolean subtypes = DEFAULT_SUBTYPES;
public boolean optional = DEFAULT_OPTIONAL;

/**
* NBT representation of the intended target. Used only for NBT comparison checks
Expand Down Expand Up @@ -127,6 +129,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setBoolean(nbt, "ignoreNBT", ignoreNBT, DEFAULT_IGNORE_NBT, reduce);
NBTUtil.setTag(nbt, "targetNBT", targetTags, reduce);
NBTUtil.setString(nbt, "damageType", damageType, DEFAULT_DAMAGE_TYPE, reduce);
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);
return nbt;
}

Expand All @@ -138,6 +141,7 @@ public void readFromNBT(NBTTagCompound nbt) {
ignoreNBT = NBTUtil.getBoolean(nbt, "ignoreNBT", DEFAULT_IGNORE_NBT);
targetTags = nbt.getCompoundTag("targetNBT");
damageType = NBTUtil.getString(nbt, "damageType", DEFAULT_DAMAGE_TYPE);
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);
}

@Override
Expand Down Expand Up @@ -244,6 +248,11 @@ private List<Tuple<UUID, Integer>> getBulkProgress(@Nonnull List<UUID> uuids) {
return list;
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
return Collections.singletonList(idName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class TaskInteractEntity implements ITask {
private static final boolean DEFAULT_ON_INTERACT = true;
private static final boolean DEFAULT_ON_HIT = false;
private static final int DEFAULT_REQUIRED = 1;
private static final boolean DEFAULT_OPTIONAL = false;
private final Set<UUID> completeUsers = new TreeSet<>();
private final TreeMap<UUID, Integer> userProgress = new TreeMap<>();

Expand All @@ -59,6 +60,7 @@ public class TaskInteractEntity implements ITask {
public boolean onInteract = DEFAULT_ON_INTERACT;
public boolean onHit = DEFAULT_ON_HIT;
public int required = DEFAULT_REQUIRED;
public boolean optional = DEFAULT_OPTIONAL;

@Override
public String getUnlocalisedName() {
Expand Down Expand Up @@ -238,6 +240,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce) {
NBTUtil.setInteger(nbt, "requiredUses", required, DEFAULT_REQUIRED, reduce);
NBTUtil.setBoolean(nbt, "onInteract", onInteract, DEFAULT_ON_INTERACT, reduce);
NBTUtil.setBoolean(nbt, "onHit", onHit, DEFAULT_ON_HIT, reduce);
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);
return nbt;
}

Expand All @@ -257,6 +260,7 @@ public void readFromNBT(NBTTagCompound nbt) {
required = NBTUtil.getInteger(nbt, "requiredUses", DEFAULT_REQUIRED);
onInteract = NBTUtil.getBoolean(nbt, "onInteract", DEFAULT_ON_INTERACT);
onHit = NBTUtil.getBoolean(nbt, "onHit", DEFAULT_ON_HIT);
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);
}

private void setUserProgress(UUID uuid, int progress) {
Expand All @@ -275,6 +279,11 @@ private List<Tuple<UUID, Integer>> getBulkProgress(@Nonnull List<UUID> uuids) {
return list;
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
List<String> texts = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class TaskInteractItem implements ITask {
private static final boolean DEFAULT_ON_INTERACT = true;
private static final boolean DEFAULT_ON_HIT = false;
private static final int DEFAULT_REQUIRED = 1;
private static final boolean DEFAULT_OPTIONAL = false;
private final Set<UUID> completeUsers = new TreeSet<>();
private final TreeMap<UUID, Integer> userProgress = new TreeMap<>();

Expand All @@ -56,6 +57,7 @@ public class TaskInteractItem implements ITask {
public boolean onInteract = DEFAULT_ON_INTERACT;
public boolean onHit = DEFAULT_ON_HIT;
public int required = DEFAULT_REQUIRED;
public boolean optional = DEFAULT_OPTIONAL;

@Override
public String getUnlocalisedName() {
Expand Down Expand Up @@ -227,6 +229,7 @@ public synchronized NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean reduce
NBTUtil.setInteger(nbt, "requiredUses", required, DEFAULT_REQUIRED, reduce);
NBTUtil.setBoolean(nbt, "onInteract", onInteract, DEFAULT_ON_INTERACT, reduce);
NBTUtil.setBoolean(nbt, "onHit", onHit, DEFAULT_ON_HIT, reduce);
NBTUtil.setBoolean(nbt, "optional", optional, DEFAULT_OPTIONAL, reduce);
return nbt;
}

Expand All @@ -241,6 +244,7 @@ public synchronized void readFromNBT(NBTTagCompound nbt) {
required = NBTUtil.getInteger(nbt, "requiredUses", DEFAULT_REQUIRED);
onInteract = NBTUtil.getBoolean(nbt, "onInteract", DEFAULT_ON_INTERACT);
onHit = NBTUtil.getBoolean(nbt, "onHit", DEFAULT_ON_HIT);
optional = NBTUtil.getBoolean(nbt, "optional", DEFAULT_OPTIONAL);
}

private void setUserProgress(UUID uuid, Integer progress) {
Expand All @@ -259,6 +263,11 @@ private List<Tuple<UUID, Integer>> getBulkProgress(@Nonnull List<UUID> uuids) {
return list;
}

@Override
public boolean ignored(UUID uuid) {
return optional;
}

@Override
public List<String> getTextForSearch() {
List<String> texts = new ArrayList<>();
Expand Down
Loading
Loading