Skip to content

Commit

Permalink
Update to 24w34a
Browse files Browse the repository at this point in the history
  • Loading branch information
DrexHD committed Aug 22, 2024
1 parent 974d718 commit d06ec29
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 51 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
10 changes: 5 additions & 5 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
minecraft = "1.21"
yarn-mappings = "1.21+build.1"
fabric-loader = "0.15.11"
minecraft = "24w34a"
yarn-mappings = "24w34a+build.3"
fabric-loader = "0.16.2"

fabric-api = "0.100.1+1.21"
fabric-api = "0.102.3+1.21.2"

# Kotlin
kotlin = "2.0.0"
Expand Down Expand Up @@ -48,7 +48,7 @@ wdmcf = { module = "me.bymartrixx:wdmcf", version.ref = "wdmcf" }
[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detect" }
loom = { id = "fabric-loom", version = "1.6.+" }
loom = { id = "fabric-loom", version = "1.7.+" }
git_hooks = { id = "com.github.jakemarsden.git-hooks", version = "0.0.2" }
# https://github.com/johnrengelman/shadow/issues/894
shadow = { id = "io.github.goooler.shadow", version = "8.1.7" }
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,31 @@
import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.utility.PlayerCausable;
import com.github.quiltservertools.ledger.utility.Sources;
import java.util.function.BiConsumer;
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.server.world.ServerWorld;
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"
value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;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) {
private void ledgerBlockExplodeCallback(BlockState state, ServerWorld world, BlockPos pos, Explosion explosion, BiConsumer<ItemStack, BlockPos> stackMerger, CallbackInfo ci) {
LivingEntity entity;
if (explosion.getCausingEntity() instanceof PlayerCausable playerCausable && playerCausable.getCausingPlayer() != null) {
entity = playerCausable.getCausingPlayer();
Expand All @@ -45,9 +44,9 @@ private void ledgerBlockExplodeCallback(BlockState blockState, World world, Bloc

BlockBreakCallback.EVENT.invoker().breakBlock(
world,
blockPos,
blockState,
world.getBlockEntity(blockPos) != null ? world.getBlockEntity(blockPos) : null,
pos,
state,
world.getBlockEntity(pos) != null ? world.getBlockEntity(pos) : null,
source,
entity instanceof PlayerEntity player ? player : null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public BlockItemMixin(Settings settings) {

@Inject(
method = "place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;",
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;success(Z)Lnet/minecraft/util/ActionResult;")
at = @At(
value = "FIELD",
target = "Lnet/minecraft/util/ActionResult;SUCCESS_SERVER:Lnet/minecraft/util/ActionResult$Success;"
)
)
public void ledgerPlayerPlaceBlockCallback(ItemPlacementContext context, CallbackInfoReturnable<ActionResult> cir) {
World world = context.getWorld();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.BucketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -73,7 +72,7 @@ private void logWaterlog(PlayerEntity player, World world, BlockPos pos, BlockHi
}

@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;)V", ordinal = 0))
private void logFluidPickup(World world, PlayerEntity player, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir, @Local(ordinal = 0) BlockPos pos, @Local BlockState blockState) {
private void logFluidPickup(World world, PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir, @Local(ordinal = 0) BlockPos pos, @Local BlockState blockState) {
if (blockState.getBlock() instanceof Waterloggable) {
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.github.quiltservertools.ledger.utility.PlayerCausable;
import com.github.quiltservertools.ledger.utility.Sources;
import com.llamalad7.mixinextras.sugar.Local;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
import java.util.List;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
Expand All @@ -13,7 +13,7 @@
import net.minecraft.registry.Registries;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.explosion.ExplosionImpl;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -22,8 +22,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Explosion.class)
public abstract class ExplosionMixin {
@Mixin(ExplosionImpl.class)
public abstract class ExplosionImplMixin {
@Shadow
@Final
private World world;
Expand All @@ -37,14 +37,13 @@ public abstract class ExplosionMixin {
private Entity entity;

@Inject(
method = "affectWorld",
method = "createFire",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"
target = "Lnet/minecraft/server/world/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"
)
)
private void ledgerExplosionFireCallback(boolean particles, CallbackInfo ci,
@Local ObjectListIterator<BlockPos> affectedBlocks, @Local BlockPos blockPos) {
private void ledgerExplosionFireCallback(List<BlockPos> positions, CallbackInfo ci, @Local BlockPos blockPos) {
BlockState blockState = AbstractFireBlock.getState(world, blockPos);

LivingEntity entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.component.type.JukeboxPlayableComponent;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -22,7 +22,7 @@ public abstract class JukeboxPlayableComponentMixin {

@Inject(method = "tryPlayStack", at = @At(value = "INVOKE",
target = "Lnet/minecraft/block/entity/JukeboxBlockEntity;setStack(Lnet/minecraft/item/ItemStack;)V"))
private static void ledgerPlayerInsertMusicDisc(World world, BlockPos pos, ItemStack itemStack, PlayerEntity player, CallbackInfoReturnable<ItemActionResult> cir) {
private static void ledgerPlayerInsertMusicDisc(World world, BlockPos pos, ItemStack itemStack, PlayerEntity player, CallbackInfoReturnable<ActionResult> cir) {
BlockState blockState = world.getBlockState(pos);

BlockChangeCallback.EVENT.invoker().changeBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -62,7 +61,7 @@ private static void ledgerLogCakeEatAndRemove(
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z",
shift = At.Shift.AFTER))
private void ledgerLogCakeAddCandle(
ItemStack itemStack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult blockHitResult, CallbackInfoReturnable<ItemActionResult> cir) {
ItemStack itemStack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult blockHitResult, CallbackInfoReturnable<ActionResult> cir) {
BlockChangeCallback.EVENT.invoker().changeBlock(
player.getWorld(),
pos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -35,7 +35,7 @@ public abstract class CampfireBlockMixin {
@Inject(method = "onUseWithItem", at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/player/PlayerEntity;incrementStat(Lnet/minecraft/util/Identifier;)V")
)
public void logCampfireAddItem(ItemStack itemStack, BlockState blockState, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult blockHitResult, CallbackInfoReturnable<ItemActionResult> cir, @Local BlockEntity oldBlockEntity) {
public void logCampfireAddItem(ItemStack itemStack, BlockState blockState, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult blockHitResult, CallbackInfoReturnable<ActionResult> cir, @Local BlockEntity oldBlockEntity) {
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, blockState, world.getBlockState(pos), oldBlockEntity, world.getBlockEntity(pos), Sources.INSERT, player);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.block.WireOrientation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -31,7 +32,7 @@ public void logDoorInteraction(BlockState state, World world, BlockPos pos, Play
}

@Inject(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void logRedstoneDoorInteraction(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify, CallbackInfo ci) {
public void logRedstoneDoorInteraction(BlockState state, World world, BlockPos pos, Block sourceBlock, WireOrientation wireOrientation, boolean notify, CallbackInfo ci) {
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state, state.cycle(OPEN), null, null, Sources.REDSTONE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.block.WireOrientation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -31,7 +32,7 @@ public void logFenceGateInteraction(BlockState state, World world, BlockPos pos,
}

@Inject(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void logRedstoneFenceGateInteraction(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify, CallbackInfo ci) {
public void logRedstoneFenceGateInteraction(BlockState state, World world, BlockPos pos, Block sourceBlock, WireOrientation wireOrientation, boolean notify, CallbackInfo ci) {
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state, state.cycle(OPEN), null, null, Sources.REDSTONE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.block.WireOrientation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -28,7 +29,7 @@ public void logTrapdoorInteraction(BlockState state, World world, BlockPos pos,
}

@Inject(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void logTrapdoorRedstoneInteraction(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify, CallbackInfo ci) {
public void logTrapdoorRedstoneInteraction(BlockState state, World world, BlockPos pos, Block sourceBlock, WireOrientation wireOrientation, boolean notify, CallbackInfo ci) {
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state, state.cycle(OPEN), null, null, Sources.REDSTONE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PlayerEntity getCausingPlayer() {
return causingPlayer;
}

@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;"))
@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;)V"))
public void correctEndCrystalEntitySource(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (source.getSource() instanceof PlayerEntity player) {
this.causingPlayer = player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.github.quiltservertools.ledger.mixin.entities;

import com.github.quiltservertools.ledger.callbacks.ItemDropCallback;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin {
@Inject(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;setPickupDelay(I)V"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void logPlayerItemDrop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, CallbackInfoReturnable<ItemEntity> cir, double d, ItemEntity itemEntity) {
@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin {
@Inject(method = "dropPlayerItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;setPickupDelay(I)V"))
private void logPlayerItemDrop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, CallbackInfoReturnable<ItemEntity> cir, @Local ItemEntity itemEntity) {
PlayerEntity player = (PlayerEntity) (Object) this;
ItemDropCallback.EVENT.invoker().drop(itemEntity, player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.github.quiltservertools.ledger.utility.UUID
import com.github.quiltservertools.ledger.utility.getWorld
import net.minecraft.entity.Entity
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.SpawnReason
import net.minecraft.nbt.StringNbtReader
import net.minecraft.registry.Registries
import net.minecraft.server.MinecraftServer
Expand All @@ -23,7 +24,7 @@ class EntityKillActionType : AbstractActionType() {
val entityType = Registries.ENTITY_TYPE.getOrEmpty(objectIdentifier)
if (entityType.isEmpty) return

val entity: LivingEntity = (entityType.get().create(world) as LivingEntity?)!!
val entity: LivingEntity = (entityType.get().create(world, SpawnReason.COMMAND) as LivingEntity?)!!
entity.readNbt(StringNbtReader.parse(extraData))
entity.health = entity.defaultMaxHealth.toFloat()
entity.velocity = Vec3d.ZERO
Expand Down Expand Up @@ -53,7 +54,7 @@ class EntityKillActionType : AbstractActionType() {

val entityType = Registries.ENTITY_TYPE.getOrEmpty(objectIdentifier)
if (entityType.isPresent) {
val entity = entityType.get().create(world)!!
val entity = entityType.get().create(world, SpawnReason.COMMAND)!!
entity.readNbt(StringNbtReader.parse(extraData))
entity.velocity = Vec3d.ZERO
entity.fireTicks = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class ObjectParameter : SimpleParameter<List<Identifier>>() {
return if (builder.remaining.startsWith("#")) {
CommandSource.suggestIdentifiers(
mutableListOf<Identifier>().apply {
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())
addAll(Registries.BLOCK.streamTags().map { it.tag.id }.toList())
addAll(Registries.ITEM.streamTags().map { it.tag.id }.toList())
addAll(Registries.ENTITY_TYPE.streamTags().map { it.tag.id }.toList())
},
builder.createOffset(builder.start + 1)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object TeleportCommand : BuildableCommand {
private fun teleport(context: Context, world: ServerWorld, posArg: PosArgument): Int {
val player = context.source.playerOrThrow
val pos = posArg.toAbsolutePos(context.source)
player.teleport(world, pos.x, pos.y, pos.z, player.yaw, player.pitch)
player.teleport(world, pos.x, pos.y, pos.z, player.yaw, player.pitch, true)

return 1
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"ledger.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.10",
"fabricloader": ">=0.16.2",
"fabric": ">=${fabricApi}",
"fabric-language-kotlin": ">=${fabricKotlin}",
"minecraft": ">=${minecraft}"
"minecraft": ">=1.21.2-alpha.24.34.a"
},
"breaks": {
"cardboard": "*"
Expand Down
Loading

0 comments on commit d06ec29

Please sign in to comment.