Skip to content

Commit

Permalink
Add extra data to SPacketChunkData getUpdateTag crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
covers1624 committed Sep 7, 2019
1 parent 9f13930 commit 6f9a172
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public class CoreMixinCategory {
@Mapping(value = "core.network.play.server.SPacketJoinGameMixin")
@Setting(value = "world-type-length", comment = "If 'true', increases the maximum length for a WorldType name in SPacketJoinGame packet.")
private boolean worldTypeLength = false;

@Mapping(value = "core.network.play.server.SPacketChunkDataMixin")
@Setting(value = "get-update-tag-crash", comment = "If 'true', adds TileEntity data to the crash report from calls to 'getUpdateTag' that fail.")
private boolean getUpdateTagCrash = false;

public boolean isAdvancementReload() {
return advancementReload;
Expand Down Expand Up @@ -166,4 +170,8 @@ public boolean isPlayerChunkMap() {
public boolean isWorldTypeLength() {
return worldTypeLength;
}
}

public boolean isGetUpdateTagCrash() {
return getUpdateTagCrash;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.lxgaming.sledgehammer.mixin.core.network.play.server;

import net.minecraft.crash.CrashReport;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.SPacketChunkData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ReportedException;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin (value = SPacketChunkData.class, priority = 1337)
public class SPacketChunkDataMixin {

@Redirect (method = "<init>(Lnet/minecraft/world/chunk/Chunk;I)V", at = @At (value = "INVOKE", target = "Lnet/minecraft/tileentity/TileEntity;getUpdateTag()Lnet/minecraft/nbt/NBTTagCompound;"))
public NBTTagCompound onGetUpdateTag(TileEntity tile) {
try {
return tile.getUpdateTag();
} catch (Throwable t) {
CrashReport crashReport = CrashReport.makeCrashReport(t, "Getting update tag");
tile.addInfoToCrashReport(crashReport.makeCategory("Block entity being queried"));
throw new ReportedException(crashReport);
}
}

}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.sledgehammer.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"entity.EntityMixin_Teleport",
"item.ItemStackMixin_Exploit",
"item.ItemWritableBookMixin",
"network.play.server.SPacketChunkDataMixin",
"network.play.server.SPacketJoinGameMixin",
"network.NetHandlerPlayServerMixin_Book",
"network.NetHandlerPlayServerMixin_Event",
Expand All @@ -38,4 +39,4 @@
"injectors": {
"defaultRequire": 1
}
}
}

0 comments on commit 6f9a172

Please sign in to comment.