renamed setting, improved Fix

This commit is contained in:
FlorianMichael 2023-03-06 21:58:49 +01:00
parent d4b196dffe
commit 6579902e13
5 changed files with 56 additions and 3 deletions

View File

@ -8,7 +8,7 @@ yarn_mappings=1.19.3+build.5
loader_version=0.14.14
# viafabricplus
mod_version=1.7.3
mod_version=1.7.4
maven_group=de.florianmichael
archives_base_name=viafabricplus

View File

@ -0,0 +1,52 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_13to1_12_2;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.BlockFace;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = ConnectionData.class, remap = false)
public class MixinConnectionData {
@Shadow private static Int2ObjectMap<ConnectionHandler> connectionHandlerMap;
@Shadow public static BlockConnectionProvider blockConnectionProvider;
/**
* @author FlorianMichael
* @reason prevent block spam
*/
@Overwrite
public static void update(UserConnection user, Position position) {
for (BlockFace face : BlockFace.values()) {
Position pos = position.getRelative(face);
int blockState = blockConnectionProvider.getBlockData(user, pos.x(), pos.y(), pos.z());
ConnectionHandler handler = connectionHandlerMap.get(blockState);
if (handler == null) continue;
final int newBlockState = handler.connect(user, pos, blockState);
if (DebugSettings.getClassWrapper().cancelEqualBlockChangeUpdates.getValue()) {
if (blockState == newBlockState) continue;
}
PacketWrapper blockUpdatePacket = PacketWrapper.create(ClientboundPackets1_13.BLOCK_CHANGE, null, user);
blockUpdatePacket.write(Type.POSITION, pos);
blockUpdatePacket.write(Type.VAR_INT, newBlockState);
try {
blockUpdatePacket.send(Protocol1_13To1_12_2.class);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

View File

@ -17,7 +17,7 @@ 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 (!DebugSettings.getClassWrapper().cancelEqualBlockChangeUpdates.getValue()) return;
if (blockState == newBlockState) ci.cancel();
}
}

View File

@ -18,7 +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));
public final ProtocolSyncBooleanSetting cancelEqualBlockChangeUpdates = new ProtocolSyncBooleanSetting(this, "Cancel equal block change updates", 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",
"fixes.viaversion.protocol1_13to1_12_2.MixinConnectionData_NeighbourUpdater",
"fixes.viaversion.protocol1_13to1_12_2.MixinGlassConnectionHandler",
"fixes.viaversion.protocol1_13to1_12_2.MixinWorldPackets1_13",