Skip to content

Commit

Permalink
Fix mixin crashes & bump version to 1.2.3 (#155)
Browse files Browse the repository at this point in the history
Co-authored-by: yitzy299 <yitzy299@users.noreply.github.com>
  • Loading branch information
Genau6502 and yitzy299 authored Feb 24, 2022
1 parent 5e5b929 commit 950e8a9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ These are the currently logged action types:

- block-break
- block-place
- block-change
- item-insert
- item-remove
- entity-killed
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.2
modVersion = 1.2.3
mavenGroup = com.github.quiltservertools
modId = ledger
modName = Ledger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ public abstract class FallingBlockEntityMixin {
@Shadow
private BlockState block;

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

@ModifyArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public void logCampfireAddItem(BlockState blockState, World world, BlockPos pos,

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public abstract class CandleBlockMixin {
public static BooleanProperty LIT;

@Inject(method = "extinguish", at = @At(value = "RETURN"))
private static void ledgerLogCandleExtinguish(PlayerEntity player, BlockState state, WorldAccess world, BlockPos pos, CallbackInfo ci) {
BlockChangeCallback.EVENT.invoker().changeBlock(
(World) world,
pos,
state,
state.with(LIT, !state.get(LIT)),
null,
null,
Sources.EXTINGUISH, player);
private static void ledgerLogCandleExtinguish(PlayerEntity player, BlockState state, WorldAccess worldAccess, BlockPos pos, CallbackInfo ci) {
if (worldAccess instanceof World world) {
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
pos,
state,
state.with(LIT, !state.get(LIT)),
null,
null,
Sources.EXTINGUISH, player);
}
}

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

0 comments on commit 950e8a9

Please sign in to comment.