Skip to content

Commit

Permalink
Bump to 1.18.2, add option to not save roll list
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsupermanhd committed Mar 4, 2022
1 parent 8a86ec9 commit 1a73a1f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '0.11-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -47,4 +47,4 @@ tasks.withType(JavaCompile).configureEach {

configurations.modImplementation {
exclude group: 'club.minnced' // fuck you
}
}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
org.gradle.jvmargs=-Xmx2G

# Fabric (https://fabricmc.net/versions.html)
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.14
loader_version=0.12.12
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.1
loader_version=0.13.3

# Mod Properties
mod_version=1.2.1
mod_version=1.2.2
maven_group=meteordevelopment.addons
archives_base_name=villager-roller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class VillagerInteractMixin {
public void interactMob(CallbackInfoReturnable<ActionResult> cir) {
VillagerRoller roller = Modules.get().get(VillagerRoller.class);
if (VillagerRoller.currentState == VillagerRoller.State.WaitingForTargetVillager) {
VillagerRoller.currentState = VillagerRoller.State.RollingBreakingBlock;
roller.rollingVillager = (VillagerEntity) (Object) this;
roller.info("We got your villager");
VillagerRoller.currentState = VillagerRoller.State.RollingBreakingBlock;
cir.setReturnValue(ActionResult.CONSUME);
cir.cancel();
}
Expand Down
44 changes: 27 additions & 17 deletions src/main/java/maxsuperman/addons/roller/modules/VillagerRoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public class VillagerRoller extends Module {
.defaultValue(true)
.build());

private final Setting<Boolean> saveListToConfig = sgGeneral.add(new BoolSetting.Builder()
.name("save-list-to-config")
.description("Toggles saving and loading of rolling list to config and copypaste buffer")
.defaultValue(true)
.build());

private final Setting<Boolean> enablePlaySound = sgGeneral.add(new BoolSetting.Builder()
.name("enable-sound")
.description("Plays sound when it finds desired trade")
Expand Down Expand Up @@ -117,7 +123,7 @@ public enum State {
public Block rollingBlock;
public VillagerEntity rollingVillager;
public List<rollingEnchantment> searchingEnchants = new ArrayList<rollingEnchantment>();

public VillagerRoller() {
super(Categories.Misc, "villager-roller", "Rolls trades.");
}
Expand All @@ -142,27 +148,31 @@ public String getInfoString() {
@Override
public NbtCompound toTag() {
NbtCompound tag = super.toTag();
NbtList l = new NbtList();
for (rollingEnchantment e : searchingEnchants) {
l.add(e.toTag());
if (saveListToConfig.get()) {
NbtList l = new NbtList();
for (rollingEnchantment e : searchingEnchants) {
l.add(e.toTag());
}
tag.put("rolling", l);
}
tag.put("rolling", l);
return tag;
}

@Override
public Module fromTag(NbtCompound tag) {
NbtList l = tag.getList("rolling", NbtElement.COMPOUND_TYPE);
searchingEnchants.clear();
for (NbtElement e : l) {
if (e.getType() != NbtElement.COMPOUND_TYPE) {
info("Invalid list element");
continue;
super.fromTag(tag);
if (saveListToConfig.get()) {
NbtList l = tag.getList("rolling", NbtElement.COMPOUND_TYPE);
searchingEnchants.clear();
for (NbtElement e : l) {
if (e.getType() != NbtElement.COMPOUND_TYPE) {
info("Invalid list element");
continue;
}
searchingEnchants.add(new rollingEnchantment().fromTag((NbtCompound) e));
}
searchingEnchants.add(new rollingEnchantment().fromTag((NbtCompound) e));
}

return super.fromTag(tag);
return this;
}

public boolean loadSearchingFromFile(File f) {
Expand Down Expand Up @@ -220,7 +230,7 @@ private void fillWidget(GuiTheme theme, WVerticalList list) {
WSection loadDataSection = list.add(theme.section("Config Saving")).expandX().widget();

WTable control = loadDataSection.add(theme.table()).expandX().widget();

WTextBox nfname = control.add(theme.textBox("default")).expandWidgetX().expandCellX().expandX().widget();
WButton save = control.add(theme.button("Save")).expandX().widget();
save.action = () -> {
Expand Down Expand Up @@ -336,7 +346,7 @@ private void fillWidget(GuiTheme theme, WVerticalList list) {
fillWidget(theme, list);
};



table.row();
}
Expand Down Expand Up @@ -364,7 +374,7 @@ public void initWidgets() {
WButton a = table.add(theme.button("Select")).widget();
a.action = () -> {
callback.Selection(e);
onClose();
close();
};
table.row();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"depends": {
"java": "17",
"minecraft": "1.18.1",
"minecraft": "1.18.2",
"meteor-client": ">0.4.5"
}
}

0 comments on commit 1a73a1f

Please sign in to comment.