Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermos Compat with postNeidWorldsSupport #22

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
import com.gtnewhorizons.neid.Constants;
import com.gtnewhorizons.neid.NEIDConfig;
import com.gtnewhorizons.neid.mixins.interfaces.IExtendedBlockStorageMixin;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;

@Mixin(AnvilChunkLoader.class)
public class MixinAnvilChunkLoader {

private static byte[] fakeByteArray = new byte[0];
private static NibbleArray fakeNibbleArray = new NibbleArray(0, 0);

@Redirect(
method = "writeChunkToNBT",
at = @At(
Expand Down Expand Up @@ -133,13 +138,33 @@ public class MixinAnvilChunkLoader {
return false;
}

@Redirect(
method = "readChunkFromNBT",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B",
ordinal = 2),
require = 1)
private byte[] neid$cancelByteArrayCreationForMetadata(NBTTagCompound nbttagcompound1, String s) {
return fakeByteArray;
}

@WrapOperation(
method = "readChunkFromNBT",
at = @At(value = "NEW", target = "Lnet/minecraft/world/chunk/NibbleArray;", ordinal = 1),
require = 1)
private NibbleArray neid$cancelNibbleArrayCreationForMetadata(byte[] bytes, int i,
Operation<NibbleArray> original) {
return fakeNibbleArray;
}

@Redirect(
method = "readChunkFromNBT",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockMetadataArray(Lnet/minecraft/world/chunk/NibbleArray;)V"),
require = 1)
private void neid$overrideReadMetadataArray(ExtendedBlockStorage ebs, NibbleArray oldBrokenNibbleArray,
private void neid$overrideReadMetadataArray(ExtendedBlockStorage ebs, NibbleArray oldNibble,
@Local(ordinal = 1) NBTTagCompound nbt) {
IExtendedBlockStorageMixin ebsMixin = (IExtendedBlockStorageMixin) ebs;
if (nbt.hasKey("Data16")) {
Expand Down