Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.20.4 #235

Merged
merged 5 commits into from
Dec 21, 2023
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
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.modrinth.minotaur.TaskModrinthUpload

plugins {
kotlin("jvm") version "1.7.10"
id("fabric-loom") version "0.12.+"
id("fabric-loom") version "1.4.+"
id("maven-publish")
id("io.gitlab.arturbosch.detekt") version "1.19.0"
id("com.github.jakemarsden.git-hooks") version "0.0.2"
Expand Down Expand Up @@ -86,9 +86,6 @@ dependencies {
shadow(libs.exposed.java.time)
shadow(libs.sqlite.jdbc)

// Mixin
modImplementationAndInclude(libs.mixin.extras)

// Config
shadow(libs.konf.core)
shadow(libs.konf.toml)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 6 additions & 9 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
[versions]
minecraft = "1.20.2"
yarn-mappings = "1.20.2+build.1"
fabric-loader = "0.14.22"
minecraft = "1.20.4"
yarn-mappings = "1.20.4+build.1"
fabric-loader = "0.15.1"

fabric-api = "0.89.1+1.20.2"
fabric-api = "0.91.2+1.20.4"

# Kotlin
kotlin = "1.9.4"
# Also modrinth version in gradle.properties
fabric-kotlin = "1.9.4+kotlin.1.8.21"

fabric-permissions = "0.2-SNAPSHOT"
translations = "2.1.0+1.20.2-rc2"
fabric-permissions = "0.3-SNAPSHOT"
translations = "2.2.0+1.20.3-rc1"

exposed = "0.38.2"
sqlite-jdbc = "3.36.0.3"

konf = "1.1.2"
mixin-extras = "0.2.0-beta.8"

wdmcf = "1.0.2"

Expand All @@ -41,7 +40,5 @@ sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite-jdbc" }
konf-core = { module = "com.uchuhimo:konf-core", version.ref = "konf"}
konf-toml = { module = "com.uchuhimo:konf-toml", version.ref = "konf"}

mixin-extras = { module = "com.github.LlamaLad7:MixinExtras", version.ref = "mixin-extras"}

wdmcf = { module = "me.bymartrixx:wdmcf", version.ref = "wdmcf" }

2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ pluginManagement {
}
}

enableFeaturePreview("VERSION_CATALOGS")

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.PlayerCausable;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.function.BiConsumer;

@Mixin(AbstractBlock.class)
public abstract class AbstractBlockMixin {

@Inject(
method = "onExploded",
at = @At(
value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"
)
)
private void ledgerBlockExplodeCallback(BlockState blockState, World world, BlockPos blockPos, Explosion explosion, BiConsumer<ItemStack, BlockPos> biConsumer, CallbackInfo ci) {
LivingEntity entity;
if (explosion.getCausingEntity() instanceof PlayerCausable playerCausable && playerCausable.getCausingPlayer() != null) {
entity = playerCausable.getCausingPlayer();
} else {
entity = explosion.getCausingEntity();
}

String source;
if (explosion.getEntity() != null && !(explosion.getEntity() instanceof PlayerEntity)) {
source = Registries.ENTITY_TYPE.getId(explosion.getEntity().getType()).getPath();
} else {
source = Sources.EXPLOSION;
}

BlockBreakCallback.EVENT.invoker().breakBlock(
world,
blockPos,
blockState,
world.getBlockEntity(blockPos) != null ? world.getBlockEntity(blockPos) : null,
source,
entity instanceof PlayerEntity player ? player : null
);
}

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.callbacks.BlockPlaceCallback;
import com.github.quiltservertools.ledger.utility.PlayerCausable;
import com.github.quiltservertools.ledger.utility.Sources;
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import com.llamalad7.mixinextras.sugar.Local;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
import net.minecraft.block.Block;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -23,7 +21,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(Explosion.class)
public abstract class ExplosionMixin {
Expand All @@ -40,22 +37,15 @@ public abstract class ExplosionMixin {
private Entity entity;

@Inject(
method = "affectWorld",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"),
locals = LocalCapture.CAPTURE_FAILEXCEPTION
method = "affectWorld",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"
)
)
private void ledgerBlockExplodeCallback(
boolean bl,
CallbackInfo ci,
boolean bl2,
ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList,
boolean bl3,
ObjectListIterator<BlockPos> blocks,
BlockPos blockPos,
BlockState blockState,
Block block) {

if (blockState.isAir()) return;
private void ledgerExplosionFireCallback(boolean particles, CallbackInfo ci,
@Local ObjectListIterator<BlockPos> affectedBlocks, @Local BlockPos blockPos) {
BlockState blockState = AbstractFireBlock.getState(world, blockPos);

LivingEntity entity;
if (this.entity instanceof PlayerCausable playerCausable && playerCausable.getCausingPlayer() != null) {
Expand All @@ -70,35 +60,14 @@ private void ledgerBlockExplodeCallback(
} else {
source = Sources.EXPLOSION;
}

// if (entity != null && !(entity instanceof PlayerEntity)) {
// source = Registries.ENTITY_TYPE.getId(entity.getType()).getPath();
// } else {
// if (this.entity instanceof PlayerCausable hasCausingPlayer) {
// // If the source is an end portal, we obtain the source player
// var playerSource = hasCausingPlayer.getCausingPlayer();
//
// if (playerSource != null) {
// entity = playerSource;
// }
// }
// source = Sources.EXPLOSION;
// }

// if (this.entity instanceof CreeperEntity creeper) {
// var target = creeper.getTarget();
// if (target instanceof PlayerEntity player) {
// entity = player;
// }
// }

BlockBreakCallback.EVENT.invoker().breakBlock(
world,
blockPos,
blockState,
world.getBlockEntity(blockPos) != null ? world.getBlockEntity(blockPos) : null,
source,
entity instanceof PlayerEntity player ? player : null
BlockPlaceCallback.EVENT.invoker().place(
world,
blockPos,
blockState,
world.getBlockEntity(blockPos) != null ? world.getBlockEntity(blockPos) : null,
source,
entity instanceof PlayerEntity player ? player : null
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.callbacks.BlockPlaceCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -18,9 +20,7 @@
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.Iterator;
import java.util.List;

import java.util.function.Predicate;

@Mixin(FillCommand.class)
Expand All @@ -30,10 +30,16 @@ public abstract class FillCommandMixin {
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/command/argument/BlockStateArgument;setBlockState(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;I)Z"
),
locals = LocalCapture.CAPTURE_FAILHARD
)
)
private static void logFillChanges(ServerCommandSource source, BlockBox range, BlockStateArgument block, @Coerce Object mode, Predicate filter, CallbackInfoReturnable<Integer> cir, List list, ServerWorld serverWorld, int j, Iterator var9, BlockPos pos) {
private static void logFillChanges(
ServerCommandSource source,
BlockBox range,
BlockStateArgument block,
@Coerce Object mode,
Predicate<CachedBlockPosition> filter,
CallbackInfoReturnable<Integer> cir,
@Local BlockPos pos) {
ServerWorld world = source.getWorld();
BlockState oldState = world.getBlockState(pos);
BlockEntity oldBlockEntity = world.getBlockEntity(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private fun onBlockAttack(

private fun onJoin(networkHandler: ServerPlayNetworkHandler, packetSender: PacketSender, server: MinecraftServer) {
Ledger.launch {
DatabaseManager.logPlayer(networkHandler.player.uuid, networkHandler.player.entityName)
DatabaseManager.logPlayer(networkHandler.player.uuid, networkHandler.player.nameForScoreboard)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.github.quiltservertools.ledger.utility

import net.minecraft.text.Style
import net.minecraft.text.TextColor
import com.github.quiltservertools.ledger.config.ColorSpec
import com.github.quiltservertools.ledger.config.config
import com.mojang.serialization.DataResult
import net.minecraft.text.Style
import net.minecraft.text.TextColor

@Suppress("MagicNumber")
object TextColorPallet {
val primary: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.primary]))
val primaryVariant: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.primaryVariant]))
val secondary: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.secondary]))
val secondaryVariant: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.secondaryVariant]))
val light: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.light]))
val primary: Style
get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.primary]).getOrNull())

val primaryVariant: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.primaryVariant]).getOrNull())
val secondary: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.secondary]).getOrNull())
val secondaryVariant: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.secondaryVariant]).getOrNull())
val light: Style get() = Style.EMPTY.withColor(TextColor.parse(config[ColorSpec.light]).getOrNull())
}

fun DataResult<TextColor>.getOrNull(): TextColor? = this.get().left().orElse(null)
5 changes: 1 addition & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
{
"value": "com.github.quiltservertools.ledger.Ledger::INSTANCE"
}
],
"preLaunch": [
"com.llamalad7.mixinextras.MixinExtrasBootstrap::init"
]
},
"mixins": [
"ledger.mixins.json"
],
"depends": {
"fabricloader": "*",
"fabricloader": ">=0.15.0",
"fabric": ">=${fabricApi}",
"fabric-language-kotlin": ">=${fabricKotlin}",
"minecraft": ">=1.20.2"
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/ledger.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"required": true,
"package": "com.github.quiltservertools.ledger.mixin",
"mixins": [
"AbstractBlockMixin",
"AnvilScreenHandlerMixin",
"AxeItemMixin",
"BlockItemMixin",
Expand Down Expand Up @@ -63,5 +64,5 @@
],
"injectors": {
"defaultRequire": 1
}
}
}
Loading