Skip to content

Commit 950e8a9

Browse files
Genau6502yitzy299
andauthored
Fix mixin crashes & bump version to 1.2.3 (#155)
Co-authored-by: yitzy299 <yitzy299@users.noreply.github.com>
1 parent 5e5b929 commit 950e8a9

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

docs/actions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ These are the currently logged action types:
44

55
- block-break
66
- block-place
7+
- block-change
78
- item-insert
89
- item-remove
910
- entity-killed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ kotlin.code.style=official
22
org.gradle.jvmargs=-Xmx1G
33

44
# Mod Properties
5-
modVersion = 1.2.2
5+
modVersion = 1.2.3
66
mavenGroup = com.github.quiltservertools
77
modId = ledger
88
modName = Ledger

src/main/java/com/github/quiltservertools/ledger/mixin/FallingBlockEntityMixin.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ public abstract class FallingBlockEntityMixin {
2222
@Shadow
2323
private BlockState block;
2424

25-
@ModifyArgs(
25+
@Inject(
2626
method = "tick",
2727
at = @At(
2828
value = "INVOKE",
2929
target = "Lnet/minecraft/world/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
30-
private void ledgerBlockFallInvoker(Args args) {
30+
private void ledgerBlockFallInvoker(CallbackInfo ci) {
3131
FallingBlockEntity entity = (FallingBlockEntity) (Object) this;
32-
BlockPos pos = args.get(0);
33-
BlockBreakCallback.EVENT.invoker().breakBlock(entity.world, pos, this.block, this.block.hasBlockEntity() ? entity.world.getBlockEntity(pos) : null, Sources.GRAVITY);
32+
BlockBreakCallback.EVENT.invoker().breakBlock(entity.world, entity.getBlockPos(), this.block, this.block.hasBlockEntity() ? entity.world.getBlockEntity(entity.getBlockPos()) : null, Sources.GRAVITY);
3433
}
3534

3635
@ModifyArgs(

src/main/java/com/github/quiltservertools/ledger/mixin/blocks/CampfireBlockMixin.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ public void logCampfireAddItem(BlockState blockState, World world, BlockPos pos,
4141

4242
@Inject(method = "extinguish", at = @At(value = "INVOKE",
4343
target = "Lnet/minecraft/world/WorldAccess;emitGameEvent(Lnet/minecraft/entity/Entity;Lnet/minecraft/world/event/GameEvent;Lnet/minecraft/util/math/BlockPos;)V"))
44-
private static void logCampfireExtinguish(Entity entity, WorldAccess world, BlockPos pos, BlockState blockState, CallbackInfo ci) {
45-
if (entity instanceof PlayerEntity player) {
46-
BlockChangeCallback.EVENT.invoker().changeBlock((World) world, pos, blockState, blockState.with(LIT, Boolean.FALSE), world.getBlockEntity(pos), null, Sources.EXTINGUISH, player);
47-
} else {
48-
BlockChangeCallback.EVENT.invoker().changeBlock((World) world, pos, blockState, blockState.with(LIT, Boolean.FALSE), world.getBlockEntity(pos), null, Sources.EXTINGUISH);
44+
private static void logCampfireExtinguish(Entity entity, WorldAccess worldAccess, BlockPos pos, BlockState blockState, CallbackInfo ci) {
45+
if (worldAccess instanceof World world) {
46+
if (entity instanceof PlayerEntity player) {
47+
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, blockState, blockState.with(LIT, Boolean.FALSE), world.getBlockEntity(pos), null, Sources.EXTINGUISH, player);
48+
} else {
49+
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, blockState, blockState.with(LIT, Boolean.FALSE), world.getBlockEntity(pos), null, Sources.EXTINGUISH);
50+
}
4951
}
5052
}
5153

src/main/java/com/github/quiltservertools/ledger/mixin/blocks/CandleBlockMixin.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ public abstract class CandleBlockMixin {
2626
public static BooleanProperty LIT;
2727

2828
@Inject(method = "extinguish", at = @At(value = "RETURN"))
29-
private static void ledgerLogCandleExtinguish(PlayerEntity player, BlockState state, WorldAccess world, BlockPos pos, CallbackInfo ci) {
30-
BlockChangeCallback.EVENT.invoker().changeBlock(
31-
(World) world,
32-
pos,
33-
state,
34-
state.with(LIT, !state.get(LIT)),
35-
null,
36-
null,
37-
Sources.EXTINGUISH, player);
29+
private static void ledgerLogCandleExtinguish(PlayerEntity player, BlockState state, WorldAccess worldAccess, BlockPos pos, CallbackInfo ci) {
30+
if (worldAccess instanceof World world) {
31+
BlockChangeCallback.EVENT.invoker().changeBlock(
32+
world,
33+
pos,
34+
state,
35+
state.with(LIT, !state.get(LIT)),
36+
null,
37+
null,
38+
Sources.EXTINGUISH, player);
39+
}
3840
}
3941

4042
@Inject(method = "onProjectileHit", at = @At(value = "RETURN"))

0 commit comments

Comments
 (0)