Skip to content

Commit

Permalink
fix(patch): use locals to avoid repeating work
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-kirby committed Dec 20, 2023
1 parent 0af6372 commit 3d12fe5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version_base = 1.11.0
version_base = 1.11.1

# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import tv.darkosto.sevpatches.SevPatches;

@Mixin(value = Chunk.class, priority = 1500)
Expand All @@ -20,11 +21,9 @@ public abstract class ChunkTEMixin {
@Shadow
public abstract IBlockState getBlockState(BlockPos pos);

@Inject(method = "createNewTileEntity", at = @At(value = "HEAD"), cancellable = true, require = 1)
private void skipTileEntityIfLoading(BlockPos blockPos, CallbackInfoReturnable<TileEntity> cir) {
IBlockState blockState = this.getBlockState(blockPos);
Block block = blockState.getBlock();
if (this.loadingTileEntities && block.hasTileEntity(blockState)) {
@Inject(method = "createNewTileEntity", at = @At(value = "RETURN"), cancellable = true, require = 1, locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void skipTileEntityIfLoading(BlockPos blockPos, CallbackInfoReturnable<TileEntity> cir, IBlockState iblockstate, Block block) {
if (this.loadingTileEntities && block.hasTileEntity(iblockstate)) {
SevPatches.LOGGER.warn("#########################################################################");
SevPatches.LOGGER.warn("A mod has attempted to add a TileEntity to a chunk during chunk loading; this may result in iterator invalidation");
SevPatches.LOGGER.warn("This attempt has been blocked, which may lead to some weirdness, e.g. pipes not connecting");
Expand Down

0 comments on commit 3d12fe5

Please sign in to comment.