Skip to content

Commit

Permalink
update: 1.19.3 (#191)
Browse files Browse the repository at this point in the history
Co-authored-by: Potatoboy9999 <[email protected]>
  • Loading branch information
DrexHD and PotatoPresident authored Dec 10, 2022
1 parent 4d7a836 commit f9f40a6
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 64 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official
org.gradle.jvmargs=-Xmx1G

# Mod Properties
modVersion = 1.2.5
modVersion = 1.2.6
mavenGroup = com.github.quiltservertools
modId = ledger
modName = Ledger
Expand Down
14 changes: 7 additions & 7 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[versions]
minecraft = "1.19"
yarn-mappings = "1.19+build.4"
fabric-loader = "0.14.8"
minecraft = "1.19.3"
yarn-mappings = "1.19.3+build.2"
fabric-loader = "0.14.11"

fabric-api = "0.58.0+1.19"
fabric-api = "0.68.1+1.19.3"

# Kotlin
kotlin = "1.7.10"
# Also modrinth version in gradle.properties
fabric-kotlin = "1.8.2+kotlin.1.7.10"
fabric-kotlin = "1.8.7+kotlin.1.7.22"

fabric-permissions = "0.1-SNAPSHOT"
translations = "1.4.16+1.19"
fabric-permissions = "0.2-SNAPSHOT"
translations = "1.4.18+1.19.2"

exposed = "0.38.2"
sqlite-jdbc = "3.36.0.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(EndCrystalEntity.class)
public abstract class EndCrystalEntityMixin implements EndCrystalDuck {
Expand All @@ -23,13 +23,12 @@ public PlayerEntity getCausingPlayer() {
return causingPlayer;
}

@ModifyArgs(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/world/explosion/Explosion$DestructionType;)Lnet/minecraft/world/explosion/Explosion;"))
public void correctEndCrystalEntitySource(Args args, DamageSource source, float amount) {
@Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/damage/DamageSource;Lnet/minecraft/world/explosion/ExplosionBehavior;DDDFZLnet/minecraft/world/World$ExplosionSourceType;)Lnet/minecraft/world/explosion/Explosion;"))
public void correctEndCrystalEntitySource(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (source.getSource() instanceof PlayerEntity player) {
this.causingPlayer = player;
} else if (source.getSource() instanceof ProjectileEntity projectile && projectile.getOwner() instanceof PlayerEntity player) {
this.causingPlayer = player;
}
args.set(0, (EndCrystalEntity) (Object) this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import net.minecraft.entity.mob.CreeperEntity;
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.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -63,7 +63,7 @@ private void ledgerBlockExplodeCallback(
var entity = getCausingEntity();

if (entity != null && !(entity instanceof PlayerEntity)) {
source = Registry.ENTITY_TYPE.getId(entity.getType()).getPath();
source = Registries.ENTITY_TYPE.getId(entity.getType()).getPath();
} else {
if (this.entity instanceof EndCrystalEntity endCrystal) {
// If the source is an end portal, we obtain the source player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.dimension.AreaHelper;
import net.minecraft.world.dimension.NetherPortal;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AreaHelper.class)
public abstract class AreaHelperMixin {
@Mixin(NetherPortal.class)
public abstract class NetherPortalMixin {
@Shadow
@Final
private WorldAccess world;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import net.minecraft.entity.mob.RavagerEntity;
import net.minecraft.registry.Registries;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
Expand All @@ -15,6 +15,6 @@ public abstract class RavagerEntityMixin {
public void logRavagerBreakingLeaves(Args args) {
BlockPos pos = args.get(0);
var world = ((RavagerEntity) (Object) this).world;
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, world.getBlockState(pos), world.getBlockEntity(pos), Registry.ENTITY_TYPE.getId(((RavagerEntity) (Object) this).getType()).getPath());
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, world.getBlockState(pos), world.getBlockEntity(pos), Registries.ENTITY_TYPE.getId(((RavagerEntity) (Object) this).getType()).getPath());
}
}
17 changes: 6 additions & 11 deletions src/main/kotlin/com/github/quiltservertools/ledger/Ledger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ import com.github.quiltservertools.ledger.listeners.registerWorldEventListeners
import com.github.quiltservertools.ledger.network.Networking
import com.github.quiltservertools.ledger.registry.ActionRegistry
import com.uchuhimo.konf.Config
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.*
import net.fabricmc.api.DedicatedServerModInitializer
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.util.Identifier
import net.minecraft.util.WorldSavePath
import net.minecraft.util.registry.Registry
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import java.nio.file.Files
import java.util.UUID
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import kotlin.coroutines.CoroutineContext
import kotlin.time.Duration
Expand Down Expand Up @@ -83,9 +78,9 @@ object Ledger : DedicatedServerModInitializer, CoroutineScope {
Networking

val idSet = setOf<Identifier>()
.plus(Registry.BLOCK.ids)
.plus(Registry.ITEM.ids)
.plus(Registry.ENTITY_TYPE.ids)
.plus(Registries.BLOCK.ids)
.plus(Registries.ITEM.ids)
.plus(Registries.ENTITY_TYPE.ids)

Ledger.launch {
logInfo("Inserting ${idSet.size} registry keys into the database...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import net.minecraft.block.BlockState
import net.minecraft.block.Blocks
import net.minecraft.nbt.StringNbtReader
import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.text.HoverEvent
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import net.minecraft.util.Util
import net.minecraft.util.registry.Registry

open class BlockChangeActionType : AbstractActionType() {
override val identifier = "block-change"
Expand Down Expand Up @@ -90,7 +90,7 @@ open class BlockChangeActionType : AbstractActionType() {
fun newBlockState() = checkForBlockState(objectIdentifier, blockState)

private fun checkForBlockState(identifier: Identifier, checkState: BlockState?): BlockState {
val block = Registry.BLOCK.getOrEmpty(identifier)
val block = Registries.BLOCK.getOrEmpty(identifier)
if (block.isEmpty) {
logWarn("Unknown block $identifier")
return Blocks.AIR.defaultState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.github.quiltservertools.ledger.utility.getWorld
import net.minecraft.entity.Entity
import net.minecraft.entity.LivingEntity
import net.minecraft.nbt.StringNbtReader
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.util.math.Vec3d
import net.minecraft.util.registry.Registry

class EntityKillActionType : AbstractActionType() {
override val identifier = "entity-kill"
Expand All @@ -16,7 +16,7 @@ class EntityKillActionType : AbstractActionType() {
override fun rollback(server: MinecraftServer): Boolean {
val world = server.getWorld(world)

val entityType = Registry.ENTITY_TYPE.getOrEmpty(objectIdentifier)
val entityType = Registries.ENTITY_TYPE.getOrEmpty(objectIdentifier)
if (entityType.isPresent) {
val entity: LivingEntity = (entityType.get().create(world) as LivingEntity?)!!
entity.readNbt(StringNbtReader.parse(extraData))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import net.minecraft.inventory.Inventory
import net.minecraft.item.BlockItem
import net.minecraft.item.ItemStack
import net.minecraft.nbt.StringNbtReader
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.HoverEvent
import net.minecraft.text.Text
import net.minecraft.util.Util
import net.minecraft.util.registry.Registry

abstract class ItemChangeActionType : AbstractActionType() {
override fun getTranslationType(): String {
val item = Registry.ITEM.get(objectIdentifier)
val item = Registries.ITEM.get(objectIdentifier)
return if (item is BlockItem) {
"block"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import net.minecraft.entity.damage.DamageSource
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.registry.Registries
import net.minecraft.util.math.BlockPos
import net.minecraft.util.registry.Registry
import net.minecraft.world.World

object ActionFactory {
Expand Down Expand Up @@ -86,8 +86,8 @@ object ActionFactory {
) {
action.pos = pos
action.world = world.registryKey.value
action.objectIdentifier = Registry.BLOCK.getId(state.block)
action.oldObjectIdentifier = Registry.BLOCK.getId(oldState.block)
action.objectIdentifier = Registries.BLOCK.getId(state.block)
action.oldObjectIdentifier = Registries.BLOCK.getId(oldState.block)
action.blockState = state
action.oldBlockState = oldState
action.sourceName = source
Expand Down Expand Up @@ -158,7 +158,7 @@ object ActionFactory {
) {
action.pos = pos
action.world = world.registryKey.value
action.objectIdentifier = Registry.ITEM.getId(stack.item)
action.objectIdentifier = Registries.ITEM.getId(stack.item)
action.sourceName = source
action.extraData = stack.writeNbt(NbtCompound())?.asString()
}
Expand All @@ -173,7 +173,7 @@ object ActionFactory {
action.sourceProfile = killer.gameProfile
}
killer != null -> {
val source = Registry.ENTITY_TYPE.getId(killer.type).path
val source = Registries.ENTITY_TYPE.getId(killer.type).path
setEntityData(action, pos, world, entity, source)
}
else -> setEntityData(action, pos, world, entity, cause.name)
Expand All @@ -191,7 +191,7 @@ object ActionFactory {
) {
action.pos = pos
action.world = world.registryKey.value
action.objectIdentifier = Registry.ENTITY_TYPE.getId(entity.type)
action.objectIdentifier = Registries.ENTITY_TYPE.getId(entity.type)
action.sourceName = source
action.extraData = entity.writeNbt(NbtCompound())?.asString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import com.mojang.brigadier.suggestion.Suggestions
import com.mojang.brigadier.suggestion.SuggestionsBuilder
import net.minecraft.command.CommandSource
import net.minecraft.command.argument.IdentifierArgumentType
import net.minecraft.registry.Registries
import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.tag.TagKey
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import java.util.concurrent.CompletableFuture

class ObjectParameter : SimpleParameter<List<Identifier>>() {
private val identifiers = mutableListOf<Identifier>().apply {
addAll(Registry.ITEM.ids)
addAll(Registry.BLOCK.ids)
addAll(Registry.ENTITY_TYPE.ids)
addAll(Registries.ITEM.ids)
addAll(Registries.BLOCK.ids)
addAll(Registries.ENTITY_TYPE.ids)
}

override fun parse(stringReader: StringReader): List<Identifier> {
Expand All @@ -25,14 +26,14 @@ class ObjectParameter : SimpleParameter<List<Identifier>>() {
stringReader.skip()
val tagId = IdentifierArgumentType.identifier().parse(stringReader)

val blockTag = TagKey.of(Registry.BLOCK_KEY, tagId)
if (blockTag != null) return Registry.BLOCK.iterateEntries(blockTag).map { Registry.BLOCK.getId(it.value()) }
val blockTag = TagKey.of(RegistryKeys.BLOCK, tagId)
if (blockTag != null) return Registries.BLOCK.iterateEntries(blockTag).map { Registries.BLOCK.getId(it.value()) }

val itemTag = TagKey.of(Registry.ITEM_KEY, tagId)
if (itemTag != null) Registry.ITEM.iterateEntries(itemTag).map { Registry.ITEM.getId(it.value()) }
val itemTag = TagKey.of(RegistryKeys.ITEM, tagId)
if (itemTag != null) Registries.ITEM.iterateEntries(itemTag).map { Registries.ITEM.getId(it.value()) }

val entityTag = TagKey.of(Registry.ENTITY_TYPE_KEY, tagId)
if (entityTag != null) return Registry.ENTITY_TYPE.iterateEntries(entityTag).map { Registry.ENTITY_TYPE.getId(it.value()) }
val entityTag = TagKey.of(RegistryKeys.ENTITY_TYPE, tagId)
if (entityTag != null) return Registries.ENTITY_TYPE.iterateEntries(entityTag).map { Registries.ENTITY_TYPE.getId(it.value()) }
}

return listOf(IdentifierArgumentType.identifier().parse(stringReader))
Expand All @@ -45,9 +46,9 @@ class ObjectParameter : SimpleParameter<List<Identifier>>() {
return if (builder.remaining.startsWith("#")) {
CommandSource.suggestIdentifiers(
mutableListOf<Identifier>().apply {
addAll(Registry.BLOCK.streamTags().map { it.id }.toList())
addAll(Registry.ITEM.streamTags().map { it.id }.toList())
addAll(Registry.ENTITY_TYPE.streamTags().map { it.id }.toList())
addAll(Registries.BLOCK.streamTags().map { it.id }.toList())
addAll(Registries.ITEM.streamTags().map { it.id }.toList())
addAll(Registries.ENTITY_TYPE.streamTags().map { it.id }.toList())
},
builder.createOffset(builder.start + 1)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.quiltservertools.ledger.utility

import net.minecraft.registry.RegistryKey
import net.minecraft.registry.RegistryKeys
import net.minecraft.server.MinecraftServer
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.text.MutableText
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import net.minecraft.util.registry.RegistryKey

fun MutableText.appendWithSpace(text: Text) {
this.append(text)
Expand All @@ -21,4 +21,4 @@ fun ServerCommandSource.hasPlayer() = this.entity is ServerPlayerEntity

// fun String.translate(vararg args: Any) = TranslatableText(this, args)

fun MinecraftServer.getWorld(identifier: Identifier?) = getWorld(RegistryKey.of(Registry.WORLD_KEY, identifier))
fun MinecraftServer.getWorld(identifier: Identifier?) = getWorld(RegistryKey.of(RegistryKeys.WORLD, identifier))
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import net.fabricmc.fabric.api.util.NbtType
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtHelper
import net.minecraft.registry.Registries
import net.minecraft.util.Identifier

private const val PROPERTIES = "Properties"

object NbtUtils {
fun blockStateToProperties(state: BlockState): NbtCompound? {
val stateTag = NbtHelper.fromBlockState(state)
Expand All @@ -18,7 +20,6 @@ object NbtUtils {
val stateTag = NbtCompound()
stateTag.putString("Name", name.toString())
stateTag.put(PROPERTIES, tag)

return NbtHelper.toBlockState(stateTag)
return NbtHelper.toBlockState(Registries.BLOCK.readOnlyWrapper, stateTag)
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"fabricloader": "*",
"fabric": ">=${fabricApi}",
"fabric-language-kotlin": ">=${fabricKotlin}",
"minecraft": ">=1.19.0"
"minecraft": ">=1.19.3"
},
"breaks": {
"cardboard": "*"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/ledger.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"package": "com.github.quiltservertools.ledger.mixin",
"mixins": [
"AnvilScreenHandlerMixin",
"AreaHelperMixin",
"AxeItemMixin",
"BlockItemMixin",
"BlockMixin",
Expand All @@ -21,6 +20,7 @@
"LivingEntityMixin",
"LockableContainerBlockEntityMixin",
"MusicDiscItemMixin",
"NetherPortalMixin",
"RavagerEntityMixin",
"ScreenHandlerMixin",
"SetBlockCommandMixin",
Expand Down

0 comments on commit f9f40a6

Please sign in to comment.