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

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Oct 27, 2024
1 parent b4728cf commit 23392fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import iskallia.vault.task.counter.TargetTaskCounter;


/**
* This mixin injects into code that adjust objective counter based on players joined the vault.
*/
@Mixin(value = BingoObjective.class, remap = false)
public class MixinBingoObjective
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import net.minecraft.resources.ResourceLocation;


/**
* This mixin removes impossible bingo tasks, and add limitation on how much they can be increased.
*/
@Mixin(value = BingoTask.class, remap = false)
public class MixinBingoTask
{
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/lv/id/bonne/vaulthunters/bingofix/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package lv.id.bonne.vaulthunters.bingofix.util;


import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -31,6 +32,11 @@

public class Util
{
/**
* This method predicts vault rooms from given Vault object.
* @param vault The vault object that stores all information.
* @return List of vault rooms that are predicted to be inside vault.
*/
public static List<ResourceLocation> collectVaultRooms(Vault vault)
{
WorldManager worldManager = vault.get(Vault.WORLD);
Expand Down Expand Up @@ -70,7 +76,6 @@ public static List<ResourceLocation> collectVaultRooms(Vault vault)
boolean roomFound = true;

// Continue while rooms are found in each completed ring

while (roomFound)
{
roomFound = false;
Expand All @@ -84,6 +89,7 @@ public static List<ResourceLocation> collectVaultRooms(Vault vault)

if (Math.abs(x) <= range && Math.abs(z) <= range)
{
// Vault rooms are every 2 ring. Tunnels are in between.
RegionPos region = RegionPos.of(x << 1, z << 1, cellX, cellZ);
VaultLayout.PieceType type = layout.getType(vault, region);

Expand All @@ -96,6 +102,7 @@ public static List<ResourceLocation> collectVaultRooms(Vault vault)
roomIDList.add(resourceLocation);
}

// mark that there is room in ring.
roomFound = true;
}
}
Expand All @@ -122,19 +129,29 @@ public static List<ResourceLocation> collectVaultRooms(Vault vault)
}


static ResourceLocation processRegion(Vault vault,
/**
* This method returns room resource location that should be at given region position.
* @param vault The vault that stores information.
* @param gridLayout The grid layout for vault.
* @param region The room location.
* @return Room resource location or null.
*/
@Nullable
private static ResourceLocation processRegion(Vault vault,
ClassicVaultLayout gridLayout,
RegionPos region)
{
ChunkRandom random = ChunkRandom.any();

// Change random to the vault seed and region location. Salt is same as in VH core.
random.setRegionSeed(vault.get(Vault.SEED), region.getX(), region.getZ(), 1234567890L);

PlacementSettings settings = (new PlacementSettings(new ProcessorContext(vault, random))).setFlags(3);
PlacementSettings settings = new PlacementSettings(new ProcessorContext(vault, random)).setFlags(3);
// As we do not care about actual storing into cache, we just get the template.
Template template = gridLayout.getTemplate(gridLayout.getType(vault, region), vault, region, random, settings);

if (template instanceof JigsawTemplate jigsawTemplate)
{
// I hope this will never crash :)
return jigsawTemplate.getRoot().getKey().getId();
}
else
Expand Down

0 comments on commit 23392fd

Please sign in to comment.