Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
Add maxRooms variable to limit increment to villager and find room ta…
Browse files Browse the repository at this point in the history
…sks.
  • Loading branch information
BONNe committed Oct 27, 2024
1 parent a6fe1af commit df53c6f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ minecraft {
property 'forge.enabledGameTestNamespaces', mod_id
}

client2 {
parent runs.client
args '--username=Dev2'
}

server {
workingDirectory = project.file('run/server')
property 'forge.enabledGameTestNamespaces', mod_id
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ mod_description=Mod for Fixing Bingo Tasks
# The version of Vault Hunters Mod
vault_hunters_version=5601579
# The mod version. See https://semver.org/
mod_version=1.0.0
mod_version=1.1.0
# The change Log
changelog=Check changelog in CurseForge page
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Created by BONNe
// Copyright - 2024
//


package lv.id.bonne.vaulthunters.bingofix.mixin;


import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.Optional;

import iskallia.vault.core.data.adapter.Adapters;
import iskallia.vault.core.vault.objective.BingoObjective;
import iskallia.vault.task.counter.TargetTaskCounter;


@Mixin(value = BingoObjective.class, remap = false)
public class MixinBingoObjective
{
@Redirect(method = "lambda$tickServer$4",
at = @At(value = "INVOKE", target = "Liskallia/vault/task/counter/TargetTaskCounter;setTarget(Ljava/lang/Object;)V"))
private void limitMaxRoomValue(TargetTaskCounter instance, Object target)
{
Optional<Integer> maxRooms = instance.get("maxRooms", Adapters.INT);

if (maxRooms.isPresent())
{
instance.setTarget(Math.min(maxRooms.get(), (int) target));
}
else
{
instance.setTarget(target);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,19 @@ private static void readjustRoomTargetCounter(TaskCounter<?, ?> counter, int roo

// Reload tag
BingoFixMod.LOGGER.debug("Change target counter for task.");
counter.readNbt(tag);
}
else
{
BingoFixMod.LOGGER.debug("Add maxRooms variable.");
}

if (tag.contains("variables"))
{
CompoundTag variables = tag.getCompound("variables");
variables.putInt("maxRooms", roomCount);
}

counter.readNbt(tag);
});
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.bingo_fix.vault_hunters.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_8",
"refmap": "bingo_fix.refmap.json",
"mixins": [
"MixinBingoObjective",
"MixinBingoTask"
],
"client": [
Expand Down

0 comments on commit df53c6f

Please sign in to comment.