Skip to content

Commit

Permalink
Revert "Update to 1.20.4 (QuiltServerTools#235)"
Browse files Browse the repository at this point in the history
This reverts commit a85a1e2.
  • Loading branch information
sasha0552 authored Apr 8, 2024
1 parent e00d049 commit 4c4a4ce
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 110 deletions.
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.7.10"
id("fabric-loom") version "1.4.+"
id("fabric-loom") version "0.12.+"
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 @@ -81,6 +81,9 @@ 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-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 9 additions & 6 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
[versions]
minecraft = "1.20.4"
yarn-mappings = "1.20.4+build.1"
fabric-loader = "0.15.1"
minecraft = "1.20.2"
yarn-mappings = "1.20.2+build.1"
fabric-loader = "0.14.22"

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

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

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

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 @@ -40,5 +41,7 @@ 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: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pluginManagement {
}
}

enableFeaturePreview("VERSION_CATALOGS")

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
Expand Down

This file was deleted.

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

import com.github.quiltservertools.ledger.callbacks.BlockPlaceCallback;
import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.PlayerCausable;
import com.github.quiltservertools.ledger.utility.Sources;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.Block;
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 @@ -21,6 +23,7 @@
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 @@ -37,15 +40,22 @@ 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;)Z"
)
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
)
private void ledgerExplosionFireCallback(boolean particles, CallbackInfo ci,
@Local ObjectListIterator<BlockPos> affectedBlocks, @Local BlockPos blockPos) {
BlockState blockState = AbstractFireBlock.getState(world, blockPos);
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;

LivingEntity entity;
if (this.entity instanceof PlayerCausable playerCausable && playerCausable.getCausingPlayer() != null) {
Expand All @@ -60,14 +70,35 @@ private void ledgerExplosionFireCallback(boolean particles, CallbackInfo ci,
} 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;
// }
// }

BlockPlaceCallback.EVENT.invoker().place(
world,
blockPos,
blockState,
world.getBlockEntity(blockPos) != null ? world.getBlockEntity(blockPos) : null,
source,
entity instanceof PlayerEntity player ? player : null
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
Expand Up @@ -3,10 +3,8 @@
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 @@ -20,7 +18,9 @@
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,16 +30,10 @@ 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<CachedBlockPosition> filter,
CallbackInfoReturnable<Integer> cir,
@Local BlockPos pos) {
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) {
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 @@ -76,7 +76,7 @@ private fun onBlockAttack(

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

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

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
import com.github.quiltservertools.ledger.config.ColorSpec
import com.github.quiltservertools.ledger.config.config

@Suppress("MagicNumber")
object TextColorPallet {
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())
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]))
}

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

0 comments on commit 4c4a4ce

Please sign in to comment.