added Block Spam fix

This commit is contained in:
FlorianMichael 2023-03-06 21:19:54 +01:00
parent dce621a30b
commit d4b196dffe
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_13to1_12_2;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.List;
// Copyright RaphiMC/RK_01 - LICENSE file
@Mixin(value = ConnectionData.NeighbourUpdater.class, remap = false)
public class MixinConnectionData_NeighbourUpdater {
@Inject(method = "updateBlock", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
public void preventBlockSpam(int x, int y, int z, List<BlockChangeRecord1_8> records, CallbackInfo ci, int blockState, int newBlockState) {
if (!DebugSettings.getClassWrapper().preventBlockSpam.getValue()) return;
if (blockState == newBlockState) ci.cancel();
}
}

View File

@ -18,6 +18,7 @@ public class DebugSettings extends SettingGroup {
// 1.13 -> 1.12.2
public final ProtocolSyncBooleanSetting executeInputsInSync = new ProtocolSyncBooleanSetting(this, "Execute inputs in sync", ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
public final ProtocolSyncBooleanSetting sneakInstant = new ProtocolSyncBooleanSetting(this, "Sneak instant", new ProtocolRange(ProtocolVersion.v1_12_2, ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting preventBlockSpam = new ProtocolSyncBooleanSetting(this, "Prevent block spam", ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
// 1.12 -> 1.11.1-1.11.2
public final ProtocolSyncBooleanSetting sendOpenInventoryPacket = new ProtocolSyncBooleanSetting(this, "Send open inventory packet", ProtocolRange.andOlder(ProtocolVersion.v1_11_1));

View File

@ -105,6 +105,7 @@
"fixes.viaversion.protocol1_11to1_10.MixinProtocol1_11To1_10",
"fixes.viaversion.protocol1_12to1_11_1.MixinChatItemRewriter",
"fixes.viaversion.protocol1_13to1_12_2.MixinAbstractFenceConnectionHandler",
"fixes.viaversion.protocol1_13to1_12_2.MixinConnectionData_NeighbourUpdater",
"fixes.viaversion.protocol1_13to1_12_2.MixinGlassConnectionHandler",
"fixes.viaversion.protocol1_13to1_12_2.MixinWorldPackets1_13",
"fixes.viaversion.protocol1_14to1_13_2.MixinInventoryPackets_2",