Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BuiltinPermission {
public static final Identifier INTERACTBLOCK = register("interact_block", new ItemStackTemplate(Items.GOLD_NUGGET), "Generic permission for block interaction.", "Fallback to OPENCONTAINER", "Gets used for all blocks OPENCONTAINER doesn't check for");
public static final Identifier INTERACTSIGN = register("interact_sign", new ItemStackTemplate(Items.BIRCH_SIGN), "Permission to edit signs (e.g. dyeing them)");
public static final Identifier ANVIL = register("anvil", new ItemStackTemplate(Items.ANVIL), "Permission to use anvils");
public static final Identifier BED = register("bed", new ItemStackTemplate(Items.RED_BED), "Permission to use beds");
public static final Identifier BED = register("bed", new ItemStackTemplate(Items.BED.red()), "Permission to use beds");
public static final Identifier BEACON = register("beacon", new ItemStackTemplate(Items.BEACON), "Permission to use beacons");
public static final Identifier DOOR = register("door", new ItemStackTemplate(Items.OAK_DOOR), "Permission to use doors");
public static final Identifier FENCEGATE = register("fence_gate", new ItemStackTemplate(Items.OAK_FENCE_GATE), "Permission to use fence gates");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Tuple;
import com.mojang.datafixers.util.Pair;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.storage.LevelData;
Expand Down Expand Up @@ -545,17 +545,17 @@ public static boolean readGriefPreventionData(MinecraftServer server, CommandSou
}
for (File parent : intFileMap.values()) {
try {
Tuple<ServerLevel, Claim> parentClaim = parseFromYaml(parent, yml, server, perms);
Pair<ServerLevel, Claim> parentClaim = parseFromYaml(parent, yml, server, perms);
List<File> childs = subClaimMap.get(parent);
if (childs != null && !childs.isEmpty()) {
for (File childF : childs)
parentClaim.getB().addSubClaimGriefprevention(parseFromYaml(childF, yml, server, perms).getB());
parentClaim.getSecond().addSubClaimGriefprevention(parseFromYaml(childF, yml, server, perms).getSecond());
}
ClaimStorage storage = ClaimStorage.get(parentClaim.getA());
Set<DisplayBox> conflicts = storage.conflicts(parentClaim.getB(), null);
ClaimStorage storage = ClaimStorage.get(parentClaim.getFirst());
Set<DisplayBox> conflicts = storage.conflicts(parentClaim.getSecond(), null);
if (conflicts.isEmpty()) {
parentClaim.getB().setClaimID(storage.generateUUID());
storage.addClaim(parentClaim.getB());
parentClaim.getSecond().setClaimID(storage.generateUUID());
storage.addClaim(parentClaim.getSecond());
} else {
src.sendSuccess(() -> ClaimUtils.translatedText("flan.readConflict", parent.getName(), conflicts, ChatFormatting.DARK_RED), false);
for (DisplayBox claim : conflicts) {
Expand Down Expand Up @@ -584,7 +584,7 @@ private static Set<Identifier> complementOf(Identifier... perms) {
return set;
}

private static Tuple<ServerLevel, Claim> parseFromYaml(File file, Yaml yml, MinecraftServer server,
private static Pair<ServerLevel, Claim> parseFromYaml(File file, Yaml yml, MinecraftServer server,
Map<String, Set<Identifier>> perms) throws IOException {
FileReader reader = new FileReader(file);
Map<String, Object> values = yml.load(reader);
Expand Down Expand Up @@ -646,7 +646,7 @@ private static Tuple<ServerLevel, Claim> parseFromYaml(File file, Yaml yml, Mine
accessors.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Accessors", true));
}
}
return new Tuple<>(level, claim);
return Pair.of(level, claim);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public record ClaimAllowListKey<T>(Identifier id, String translationKey,
() -> new ItemStack(Items.DIAMOND_PICKAXE),
Registries.BLOCK, claim -> AllowedRegistryList.ofItemLike(BuiltInRegistries.BLOCK, claim));
public static final ClaimAllowListKey<Block> BLOCK_USE = new ClaimAllowListKey<>("block_use", "flan.screenMenuBlockUse",
() -> new ItemStack(Items.RED_BANNER),
() -> new ItemStack(Items.BANNER.red()),
Registries.BLOCK, claim -> AllowedRegistryList.ofItemLike(BuiltInRegistries.BLOCK, claim));
public static final ClaimAllowListKey<EntityType<?>> ENTITY_ATTACK = new ClaimAllowListKey<>("entity_attack", "flan.screenMenuEntityAttack",
() -> new ItemStack(Items.DIAMOND_SWORD),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Tuple;
import com.mojang.datafixers.util.Pair;

import java.util.Set;

Expand Down Expand Up @@ -52,7 +52,7 @@ private static int expandClaim(CommandContext<CommandSourceStack> context) throw
return 0;
}
ClaimBox dims = claim.getDimensions();
Tuple<BlockPos, BlockPos> corners = calculateCorners(dims, facing, amount, claim.parentClaim() != null ? claim.parentClaim().getDimensions() : null);
Pair<BlockPos, BlockPos> corners = calculateCorners(dims, facing, amount, claim.parentClaim() != null ? claim.parentClaim().getDimensions() : null);
boolean success = performExpansion(player, storage, claim, corners);
if (!success) {
sendExpandError(context.getSource(), "flan.expandFailed");
Expand All @@ -63,25 +63,25 @@ private static int expandClaim(CommandContext<CommandSourceStack> context) throw
}

//change expand tuple to own methode for more usability
private static Tuple<BlockPos, BlockPos> calculateCorners(ClaimBox dims, Direction facing, int amount, ClaimBox restriction) {
private static Pair<BlockPos, BlockPos> calculateCorners(ClaimBox dims, Direction facing, int amount, ClaimBox restriction) {
return switch (facing) {
case SOUTH -> new Tuple<>(
case SOUTH -> Pair.of(
new BlockPos(dims.maxX(), dims.minY(), dims.maxZ()),
new BlockPos(dims.maxX(), dims.maxY(), restriction != null ? Math.min(dims.maxZ() + amount, restriction.maxZ()) : dims.maxZ() + amount));
case EAST -> new Tuple<>(
case EAST -> Pair.of(
new BlockPos(dims.maxX(), dims.minY(), dims.maxZ()),
new BlockPos(restriction != null ? Math.min(dims.maxX() + amount, restriction.maxX()) : dims.maxX() + amount, dims.maxY(), dims.maxZ()));
case NORTH -> new Tuple<>(
case NORTH -> Pair.of(
new BlockPos(dims.minX(), dims.minY(), dims.minZ()),
new BlockPos(dims.minX(), dims.maxY(), restriction != null ? Math.max(dims.minZ() - amount, restriction.minZ()) : dims.minZ() - amount));
case WEST -> new Tuple<>(
case WEST -> Pair.of(
new BlockPos(dims.minX(), dims.minY(), dims.minZ()),
new BlockPos(restriction != null ? Math.max(dims.minX() - amount, restriction.minX()) : dims.minX() - amount, dims.maxY(), dims.minZ()));
//adding up and down for diagonical logic in future
case UP -> new Tuple<>(
case UP -> Pair.of(
new BlockPos(dims.minX(), dims.maxY(), dims.minZ()),
new BlockPos(dims.maxX(), restriction != null ? Math.min(dims.maxY() + amount, restriction.maxY()) : dims.maxY() + amount, dims.maxZ()));
case DOWN -> new Tuple<>(
case DOWN -> Pair.of(
new BlockPos(dims.minX(), dims.minY(), dims.minZ()),
new BlockPos(dims.maxX(), restriction != null ? Math.max(dims.minY() - amount, restriction.minY()) : dims.minY() - amount, dims.maxZ()));
};
Expand All @@ -104,16 +104,16 @@ private static Claim findClaim(CommandSourceStack source, ServerPlayer player, C
return claim;
}

private static boolean performExpansion(ServerPlayer player, ClaimStorage storage, Claim claim, Tuple<BlockPos, BlockPos> corners) {
private static boolean performExpansion(ServerPlayer player, ClaimStorage storage, Claim claim, Pair<BlockPos, BlockPos> corners) {
if (claim.isSubclaim()) {
Claim parent = claim.parentClaim();
if (parent == null) {
return false;
}
Set<Claim> conflicts = parent.resizeSubclaim(claim, corners.getA(), corners.getB());
Set<Claim> conflicts = parent.resizeSubclaim(claim, corners.getFirst(), corners.getSecond());
return conflicts.isEmpty();
} else {
return storage.resizeClaim(claim, corners.getA(), corners.getB(), player);
return storage.resizeClaim(claim, corners.getFirst(), corners.getSecond(), player);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.github.flemmli97.flan.platform.integration.currency.CurrencyUtils;
import io.github.flemmli97.flan.player.PlayerClaimData;
import net.minecraft.ChatFormatting;
import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.advancements.predicates.ItemPredicate;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import io.github.flemmli97.flan.Flan;
import io.github.flemmli97.flan.api.permission.BuiltinPermission;
import io.github.flemmli97.flan.api.permission.PermissionManager;
import net.minecraft.advancements.criterion.DataComponentMatchers;
import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.advancements.criterion.MinMaxBounds;
import net.minecraft.advancements.predicates.DataComponentMatchers;
import net.minecraft.advancements.predicates.ItemPredicate;
import net.minecraft.advancements.predicates.MinMaxBounds;
import net.minecraft.core.HolderSet;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public static boolean growBonemeal(UseOnContext context) {
if (state.getBlock() instanceof BonemealableFeaturePlacerBlock bonemealable) {
VegetationPatchConfiguration cfg = featureRange(registry, ((BonemealableBlockAccess) bonemealable).getFeature(), VegetationPatchConfiguration.class);
if (cfg != null) {
range = cfg.xzRadius.maxInclusive() + 1;
pos.set(pos.getX(), pos.getY() + cfg.verticalRange + 1, pos.getZ());
range = cfg.xzRadius().maxInclusive() + 1;
pos.set(pos.getX(), pos.getY() + cfg.verticalRange() + 1, pos.getZ());
}
} else if (state.getBlock() instanceof GrassBlock) {
range = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ protected void fillInventoryWith() {
for (int i = 0; i < this.inventory.getContainerSize(); i++) {
switch (i) {
case 3 -> {
ItemStack stack = ServerScreenHelper.createStack(Items.GREEN_WOOL,
ItemStack stack = ServerScreenHelper.createStack(Items.WOOL.green(),
ServerScreenHelper.coloredGuiText("flan.screenYes", ChatFormatting.GREEN));
this.slots.get(i).set(stack);
}
case 5 -> {
ItemStack stack = ServerScreenHelper.createStack(Items.RED_WOOL,
ItemStack stack = ServerScreenHelper.createStack(Items.WOOL.red(),
ServerScreenHelper.coloredGuiText("flan.screenNo", ChatFormatting.RED));
this.slots.get(i).set(stack);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Component getDisplayName() {

private ItemStack listModeItem() {
boolean blacklist = this.data.claim.allowedEntries.get(this.data.key).blacklist();
ItemStack stack = ServerScreenHelper.createStack(blacklist ? Items.BLACK_BANNER : Items.WHITE_BANNER,
ItemStack stack = ServerScreenHelper.createStack(blacklist ? Items.BANNER.black() : Items.BANNER.white(),
ServerScreenHelper.coloredGuiText(blacklist ? "flan.screenMenuBlacklist" : "flan.screenMenuWhitelist", ChatFormatting.GOLD));
List<Component> components = new ArrayList<>();
components.add(ServerScreenHelper.coloredGuiText("flan.screenMenuListModeDesc", ChatFormatting.GRAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ServerScreenHelper {
public static final String PERMISSION_KEY = Flan.MODID + ".permission";

public static ItemStack emptyFiller() {
return createStack(Items.GRAY_STAINED_GLASS_PANE, ClaimUtils.translatedText(""));
return createStack(Items.STAINED_GLASS_PANE.gray(), ClaimUtils.translatedText(""));
}

public static ItemStack createStack(Item item, Component name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public void tick(Claim currentClaim) {
BlockPos pos = ItemInteractEvents.rayTargetPos(this.player);
if (pos != null && !pos.equals(this.firstCorner)) {
this.clientBlockDisplayTracker.displayFakeBlocks(this.display3D,
new ClientBlockDisplayTracker.DisplayData(pos, Blocks.YELLOW_WOOL.defaultBlockState()));
new ClientBlockDisplayTracker.DisplayData(pos, Blocks.WOOL.yellow().defaultBlockState()));
} else {
this.clientBlockDisplayTracker.resetFakeBlocks(this.display3D);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.github.flemmli97.flan.claim.ClaimStorage;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Tuple;
import com.mojang.datafixers.util.Pair;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.phys.Vec3;
Expand All @@ -23,16 +23,16 @@ public static Vec3 getTeleportPos(Entity entity, Vec3 playerPos, ClaimStorage st
}

public static Vec3 getTeleportPos(Entity entity, Vec3 entityPos, ClaimStorage storage, Area2D dim, boolean checkSub, BlockPos.MutableBlockPos bPos, BiFunction<Claim, BlockPos, Boolean> check) {
Tuple<Direction, Vec3> pos = nearestOutside(dim, entityPos);
bPos.set(pos.getB().x(), pos.getB().y(), pos.getB().z());
Pair<Direction, Vec3> pos = nearestOutside(dim, entityPos);
bPos.set(pos.getSecond().x(), pos.getSecond().y(), pos.getSecond().z());
Claim claim = storage.getClaimAt(bPos);
if (checkSub) {
Claim sub = claim != null ? claim.getSubClaim(bPos) : null;
if (sub != null)
claim = sub;
}
if (claim == null || check.apply(claim, bPos)) {
Vec3 ret = pos.getB();
Vec3 ret = pos.getSecond();
BlockPos rounded = roundedBlockPos(ret);
int y = entity.level().getChunk(rounded.getX() >> 4, rounded.getZ() >> 4)
.getHeight(Heightmap.Types.MOTION_BLOCKING, rounded.getX() & 15, rounded.getZ() & 15);
Expand All @@ -42,7 +42,7 @@ public static Vec3 getTeleportPos(Entity entity, Vec3 entityPos, ClaimStorage st
return new Vec3(rounded.getX() + 0.5, y + 1, rounded.getZ() + 0.5);
}
ClaimBox newDim = claim.getDimensions();
switch (pos.getA()) {
switch (pos.getFirst()) {
case NORTH -> dim.minZ = newDim.minZ();
case SOUTH -> dim.maxZ = newDim.maxZ();
case EAST -> dim.maxX = newDim.maxX();
Expand All @@ -51,29 +51,29 @@ public static Vec3 getTeleportPos(Entity entity, Vec3 entityPos, ClaimStorage st
return getTeleportPos(entity, entityPos, storage, dim, checkSub, bPos, check);
}

private static Tuple<Direction, Vec3> nearestOutside(Area2D dim, Vec3 from) {
private static Pair<Direction, Vec3> nearestOutside(Area2D dim, Vec3 from) {
double northDist = Math.abs(from.z() - dim.minZ);
double southDist = Math.abs(dim.maxZ - from.z());
double westDist = Math.abs(from.x() - dim.minX);
double eastDist = Math.abs(dim.maxX - from.x());
if (northDist > southDist) {
if (eastDist > westDist) {
if (southDist > westDist)
return new Tuple<>(Direction.WEST, new Vec3(dim.minX - 1.5, from.y(), from.z()));
return new Tuple<>(Direction.SOUTH, new Vec3(from.x(), from.y(), dim.maxZ + 1.5));
return Pair.of(Direction.WEST, new Vec3(dim.minX - 1.5, from.y(), from.z()));
return Pair.of(Direction.SOUTH, new Vec3(from.x(), from.y(), dim.maxZ + 1.5));
}
if (southDist > eastDist)
return new Tuple<>(Direction.EAST, new Vec3(dim.maxX + 1.5, from.y(), from.z()));
return new Tuple<>(Direction.SOUTH, new Vec3(from.x(), from.y(), dim.maxZ + 1.5));
return Pair.of(Direction.EAST, new Vec3(dim.maxX + 1.5, from.y(), from.z()));
return Pair.of(Direction.SOUTH, new Vec3(from.x(), from.y(), dim.maxZ + 1.5));
}
if (eastDist > westDist) {
if (northDist > westDist)
return new Tuple<>(Direction.WEST, new Vec3(dim.minX - 1.5, from.y(), from.z()));
return new Tuple<>(Direction.NORTH, new Vec3(from.x(), from.y(), dim.minZ - 1.5));
return Pair.of(Direction.WEST, new Vec3(dim.minX - 1.5, from.y(), from.z()));
return Pair.of(Direction.NORTH, new Vec3(from.x(), from.y(), dim.minZ - 1.5));
}
if (northDist > eastDist)
return new Tuple<>(Direction.EAST, new Vec3(dim.maxX + 1.5, from.y(), from.z()));
return new Tuple<>(Direction.NORTH, new Vec3(from.x(), from.y(), dim.minZ - 1.5));
return Pair.of(Direction.EAST, new Vec3(dim.maxX + 1.5, from.y(), from.z()));
return Pair.of(Direction.NORTH, new Vec3(from.x(), from.y(), dim.minZ - 1.5));
}

public static class Area2D {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
org.gradle.jvmargs=-Xmx4G
jvm=25
minecraft_version=26.1.2
neoForm_version=26.1.2-1
minecraft_version=26.2
neoForm_version=26.2-1
# NeoForge Properties
neoforge_version=26.1.2.30-beta
neoforge_version=26.2.0.6-beta
# Fabric Properties
fabric_loader_version=0.18.4
fabric_loader_version=0.19.3

# Mod Properties
mod_version=1.12.7
Expand All @@ -14,9 +14,9 @@ mod_id=flan
mod_author=flemmli97

# Dependencies
fabric_api_version=0.147.0+26.1.2
fabric_api_version=0.152.1+26.2
fabric_permissions_api=0.7.0
lingua_bib=26.1.2-1.0.6
lingua_bib=26.2-1.0.6

# Compat Dependencies
dynmap_fabric=curse.maven:dynmap-59433:5442994
Expand All @@ -40,14 +40,14 @@ dicemcmm=curse.maven:dicemc-money-mod-406972:5934828
beconomy=CpGrhJed

# Curse properties
curseforge_versions=26.1.2, Java 25
curseforge_versions=26.2, Java 25
curseforge_page_fabric=https://www.curseforge.com/minecraft/mc-mods/flan
curseforge_id_fabric=404578
curseforge_dep_fabric=fabric-api
curseforge_page_neoforge=https://www.curseforge.com/minecraft/mc-mods/flan-forge
curseforge_id_neoforge=493246
curseforge_dep_neoforge=
modrinth_versions=26.1.2
modrinth_versions=26.2
modrinth_page=https://modrinth.com/mod/flan
modrinth_id=Si383TIH
modrinth_dep_fabric=fabric-api
Expand Down