mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-08 19:38:57 +01:00
started with adding codebase from Clamp/tarasande
This commit is contained in:
parent
c541bbc5e9
commit
16c92741e0
18
LICENSE
Normal file
18
LICENSE
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
--FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
|
||||
This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
"Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
that have arisen, are arising or will arise from this project / file.
|
||||
|
||||
Changelog:
|
||||
v1.0:
|
||||
Added License
|
||||
v1.1:
|
||||
Ownership withdrawn
|
||||
v1.2:
|
||||
Version-independent validity and automatic renewal
|
@ -1,2 +1,5 @@
|
||||
# ViaFabricPlus
|
||||
Clientside ViaVersion, ViaLegacy and ViaAprilFools implementation with clientside fixes for Fabric
|
||||
|
||||
TODO:
|
||||
[ ] ViaFabricPlus-Visual
|
||||
|
@ -21,6 +21,10 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/viafabricplus.accesswidener")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
@ -34,6 +38,8 @@ dependencies {
|
||||
|
||||
implementation "com.github.RaphiMC:ViaLegacy:${project.vialegacy_version}"
|
||||
implementation "com.github.RaphiMC:ViaAprilFools:${project.viaaprilfools_version}"
|
||||
|
||||
implementation "net.lenni0451.mcstructs:text:${project.mcstructs_text_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -10,7 +10,8 @@ maven_group=de.florianmichael
|
||||
archives_base_name=every-protocol
|
||||
|
||||
vialoadingbase_version=ad5fd83ad1
|
||||
viaversion_version=4.6.0-23w06a-SNAPSHOT
|
||||
viabackwards_version=4.6.0-23w06a-SNAPSHOT
|
||||
viaversion_version=4.6.0-23w07a-SNAPSHOT
|
||||
viabackwards_version=4.6.0-23w07a-SNAPSHOT
|
||||
vialegacy_version=f451a8ffb2
|
||||
viaaprilfools_version=e98bfb8aa5
|
||||
mcstructs_text_version=2.2.0
|
||||
|
@ -1,52 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.everyprotocol.platform.PreNettyConstants;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.event.PipelineReorderEvent;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.encryption.PacketDecryptor;
|
||||
import net.minecraft.network.encryption.PacketEncryptor;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public class MixinClientConnection {
|
||||
|
||||
@Shadow private Channel channel;
|
||||
|
||||
@Shadow private boolean encrypted;
|
||||
@Unique
|
||||
private Cipher vialegacy_decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private Cipher vialegacy_encryptionCipher;
|
||||
|
||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
|
||||
channel.pipeline().fireUserEventTriggered(new PipelineReorderEvent());
|
||||
}
|
||||
|
||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.r1_6_4)) {
|
||||
ci.cancel();
|
||||
this.vialegacy_decryptionCipher = decryptionCipher;
|
||||
this.vialegacy_encryptionCipher = encryptionCipher;
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void vialegacy_setupPreNettyEncryption() {
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(PreNettyConstants.DECODER, "decrypt", new PacketDecryptor(this.vialegacy_decryptionCipher));
|
||||
this.channel.pipeline().addBefore(PreNettyConstants.ENCODER, "encrypt", new PacketEncryptor(this.vialegacy_encryptionCipher));
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.everyprotocol.EveryProtocol;
|
||||
import net.minecraft.client.main.Main;
|
||||
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;
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class MixinMain {
|
||||
|
||||
@Inject(method = "main([Ljava/lang/String;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;initCrashReport()V"))
|
||||
private static void loadViaLoadingBase(CallbackInfo ci) {
|
||||
EveryProtocol.getClassWrapper().create();
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.platform;
|
||||
|
||||
public class PreNettyConstants {
|
||||
|
||||
public static final String DECODER = "via-legacy-decoder";
|
||||
public static final String ENCODER = "via-legacy-encoder";
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import de.florianmichael.vialoadingbase.util.JLoggerToLog4j;
|
||||
import net.raphimc.vialegacy.platform.ViaLegacyPlatform;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaAprilFoolsPlatformImpl implements ViaLegacyPlatform {
|
||||
private static final Logger LOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaAprilFools"));
|
||||
|
||||
public ViaAprilFoolsPlatformImpl() {
|
||||
this.init(this.getDataFolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import de.florianmichael.vialoadingbase.util.JLoggerToLog4j;
|
||||
import net.raphimc.vialegacy.platform.ViaLegacyPlatform;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaLegacyPlatformImpl implements ViaLegacyPlatform {
|
||||
private static final Logger LOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaLegacy"));
|
||||
|
||||
public ViaLegacyPlatformImpl() {
|
||||
this.init(this.getDataFolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||
import de.florianmichael.everyprotocol.translator.ItemTranslator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class EveryProtocolHandItemProvider extends HandItemProvider {
|
||||
public static ItemStack lastUsedItem = null;
|
||||
|
||||
@Override
|
||||
public Item getHandItem(UserConnection info) {
|
||||
if (lastUsedItem == null) {
|
||||
return null;
|
||||
}
|
||||
return ItemTranslator.minecraftToViaVersion(info, lastUsedItem, ProtocolVersion.v1_8.getVersion());
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package de.florianmichael.everyprotocol.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
|
||||
public class EveryProtocolMovementTransmitterProvider extends MovementTransmitterProvider {
|
||||
|
||||
@Override
|
||||
public Object getFlyingPacket() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroundPacket() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayer(UserConnection userConnection) {}
|
||||
}
|
@ -1,33 +1,66 @@
|
||||
package de.florianmichael.everyprotocol;
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import de.florianmichael.everyprotocol.platform.ViaAprilFoolsPlatformImpl;
|
||||
import de.florianmichael.everyprotocol.platform.ViaLegacyPlatformImpl;
|
||||
import de.florianmichael.everyprotocol.provider.EveryProtocolHandItemProvider;
|
||||
import de.florianmichael.everyprotocol.provider.EveryProtocolMovementTransmitterProvider;
|
||||
import de.florianmichael.viafabricplus.definition.ItemReleaseVersionDefinition;
|
||||
import de.florianmichael.viafabricplus.definition.PackFormatsDefinition;
|
||||
import de.florianmichael.viafabricplus.platform.ViaAprilFoolsPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.platform.ViaLegacyPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.provider.EveryProtocolHandItemProvider;
|
||||
import de.florianmichael.viafabricplus.provider.EveryProtocolMovementTransmitterProvider;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.api.SubPlatform;
|
||||
import io.netty.channel.DefaultEventLoop;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.metadata.Person;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EveryProtocol {
|
||||
private final static EveryProtocol self = new EveryProtocol();
|
||||
public class ViaFabricPlus {
|
||||
public static final AttributeKey<UserConnection> LOCAL_USER_CONNECTION = AttributeKey.newInstance("via-version-user-connection");
|
||||
|
||||
private final static ViaFabricPlus self = new ViaFabricPlus();
|
||||
|
||||
private final SubPlatform SUB_PLATFORM_VIA_LEGACY = new SubPlatform("ViaLegacy", () -> true, ViaLegacyPlatformImpl::new, protocolVersions -> protocolVersions.addAll(LegacyProtocolVersions.PROTOCOLS));
|
||||
private final SubPlatform SUB_PLATFORM_VIA_APRIL_FOOLS = new SubPlatform("ViaAprilFools", () -> true, ViaAprilFoolsPlatformImpl::new, this::invokeAprilFoolsProtocols);
|
||||
|
||||
private final List<Item> availableItemsInTargetVersion = new ArrayList<>();
|
||||
|
||||
protected void invokeAprilFoolsProtocols(List<ProtocolVersion> origin) {
|
||||
final int v1_14Index = origin.indexOf(ProtocolVersion.v1_14);
|
||||
final int v1_16Index = origin.indexOf(ProtocolVersion.v1_16);
|
||||
@ -81,11 +114,24 @@ public class EveryProtocol {
|
||||
providers.use(MovementTransmitterProvider.class, new EveryProtocolMovementTransmitterProvider());
|
||||
providers.use(HandItemProvider.class, new EveryProtocolHandItemProvider());
|
||||
});
|
||||
builder = builder.protocolReloader(protocolVersion -> {
|
||||
availableItemsInTargetVersion.clear();
|
||||
availableItemsInTargetVersion.addAll(Registries.ITEM.stream().filter(item -> ItemReleaseVersionDefinition.contains(item, protocolVersion)).toList());
|
||||
});
|
||||
|
||||
ValueHolder.setup();
|
||||
|
||||
PackFormatsDefinition.load();
|
||||
ItemReleaseVersionDefinition.load();
|
||||
|
||||
builder.build();
|
||||
}
|
||||
|
||||
public static EveryProtocol getClassWrapper() {
|
||||
return EveryProtocol.self;
|
||||
public List<Item> getAvailableItemsInTargetVersion() {
|
||||
return availableItemsInTargetVersion;
|
||||
}
|
||||
|
||||
public static ViaFabricPlus getClassWrapper() {
|
||||
return ViaFabricPlus.self;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,118 @@
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
|
||||
import com.mojang.bridge.game.PackType;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.minecraft.SaveVersion;
|
||||
import net.minecraft.SharedConstants;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PackFormatsDefinition {
|
||||
private final static Map<Integer, GameVersion> protocolMap = new HashMap<>();
|
||||
|
||||
public static void load() {
|
||||
registerVersion(ProtocolVersion.v1_19_3, 12, "1.19.3");
|
||||
registerVersion(ProtocolVersion.v1_19_1, 9, "1.19.2");
|
||||
registerVersion(ProtocolVersion.v1_19, 9, "1.19");
|
||||
registerVersion(ProtocolVersion.v1_18_2, 8, "1.18.2");
|
||||
registerVersion(ProtocolVersion.v1_18, 8, "1.18");
|
||||
registerVersion(ProtocolVersion.v1_17_1, 7, "1.17.1");
|
||||
registerVersion(ProtocolVersion.v1_17, 7, "1.17");
|
||||
registerVersion(ProtocolVersion.v1_16_4, 6, "1.16.5");
|
||||
registerVersion(ProtocolVersion.v1_16_3, 6, "1.16.3");
|
||||
registerVersion(ProtocolVersion.v1_16_2, 6, "1.16.2");
|
||||
registerVersion(ProtocolVersion.v1_16_1, 5, "1.16.1");
|
||||
registerVersion(ProtocolVersion.v1_16, 5, "1.16");
|
||||
registerVersion(ProtocolVersion.v1_15_2, 5, "1.15.2");
|
||||
registerVersion(ProtocolVersion.v1_15_1, 5, "1.15.1");
|
||||
registerVersion(ProtocolVersion.v1_15, 5, "1.15");
|
||||
registerVersion(ProtocolVersion.v1_14_4, 4, "1.14.4");
|
||||
registerVersion(ProtocolVersion.v1_14_3, 4, "1.14.3");
|
||||
registerVersion(ProtocolVersion.v1_14_2, 4, "1.14.2", "1.14.2 / f647ba8dc371474797bee24b2b312ff4");
|
||||
registerVersion(ProtocolVersion.v1_14_1, 4, "1.14.1", "1.14.1 / a8f78b0d43c74598a199d6d80cda413f");
|
||||
registerVersion(ProtocolVersion.v1_14, 4, "1.14", "1.14 / 5dac5567e13e46bdb0c1d90aa8d8b3f7");
|
||||
registerVersion(ProtocolVersion.v1_13_2, 4, "1.13.2"); // ids weren't sent over the http headers back then, why care...
|
||||
registerVersion(ProtocolVersion.v1_13_1, 4, "1.13.1");
|
||||
registerVersion(ProtocolVersion.v1_13, 4, "1.13");
|
||||
registerVersion(ProtocolVersion.v1_12_2, 3, "1.12.2");
|
||||
registerVersion(ProtocolVersion.v1_12_1, 3, "1.12.1");
|
||||
registerVersion(ProtocolVersion.v1_12, 3, "1.12");
|
||||
registerVersion(ProtocolVersion.v1_11_1, 3, "1.11.2");
|
||||
registerVersion(ProtocolVersion.v1_11, 3, "1.11");
|
||||
registerVersion(ProtocolVersion.v1_10, 2, "1.10.2");
|
||||
registerVersion(ProtocolVersion.v1_9_3, 2, "1.9.4");
|
||||
registerVersion(ProtocolVersion.v1_9_2, 2, "1.9.2");
|
||||
registerVersion(ProtocolVersion.v1_9_1, 2, "1.9.1");
|
||||
registerVersion(ProtocolVersion.v1_9, 2, "1.9");
|
||||
registerVersion(ProtocolVersion.v1_8, 1, "1.8.9");
|
||||
registerVersion(ProtocolVersion.v1_7_6, 1, "1.7.10");
|
||||
registerVersion(ProtocolVersion.v1_7_1, 1, "1.7.5");
|
||||
}
|
||||
|
||||
public static void checkOutdated(final int nativeVersion) {
|
||||
if (!protocolMap.containsKey(nativeVersion))
|
||||
throw new RuntimeException("The current version has no pack format registered");
|
||||
|
||||
final GameVersion gameVersion = protocolMap.get(nativeVersion);
|
||||
if (!gameVersion.getName().equals(SharedConstants.getGameVersion().getName()) ||
|
||||
!gameVersion.getId().equals(SharedConstants.getGameVersion().getId()) ||
|
||||
gameVersion.getPackVersion(PackType.RESOURCE) != SharedConstants.getGameVersion().getPackVersion(PackType.RESOURCE))
|
||||
throw new RuntimeException("The current version has no pack format registered");
|
||||
}
|
||||
|
||||
public static GameVersion current() {
|
||||
final int targetVersion = ViaLoadingBase.getTargetVersion().getOriginalVersion();
|
||||
if (!protocolMap.containsKey(targetVersion)) return SharedConstants.getGameVersion();
|
||||
return protocolMap.get(targetVersion);
|
||||
}
|
||||
|
||||
private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name) {
|
||||
registerVersion(version, packFormat, name, name);
|
||||
}
|
||||
|
||||
private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name, final String id) {
|
||||
protocolMap.put(version.getVersion(), new GameVersion() {
|
||||
@Override
|
||||
public SaveVersion getSaveVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return version.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPackVersion(PackType packType) {
|
||||
if (packType == PackType.RESOURCE) {
|
||||
return packFormat;
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getBuildTime() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStable() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package de.florianmichael.viafabricplus.definition.c0_30;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersions;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicLevelStorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
public class ClassicWorldHeightInjection {
|
||||
|
||||
public static PacketHandler handleJoinGame(final PacketHandler parentRemapper) {
|
||||
return new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
parentRemapper.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) {
|
||||
for (Tag dimension : wrapper.get(Type.NBT, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
|
||||
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
|
||||
}
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static PacketHandler handleRespawn(final PacketHandler parentRemapper) {
|
||||
return new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
parentRemapper.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) {
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static PacketHandler handleChunkData(final PacketHandler parentRemapper) {
|
||||
return new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
parentRemapper.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) {
|
||||
wrapper.resetReader();
|
||||
final Chunk chunk = wrapper.read(new Chunk1_17Type(16));
|
||||
wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk);
|
||||
|
||||
final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class);
|
||||
if (chunk.getSections().length < heightProvider.getMaxChunkSectionCount(wrapper.user())) { // Increase available sections to match new world height
|
||||
final ChunkSection[] newArray = new ChunkSection[heightProvider.getMaxChunkSectionCount(wrapper.user())];
|
||||
System.arraycopy(chunk.getSections(), 0, newArray, 0, chunk.getSections().length);
|
||||
chunk.setSections(newArray);
|
||||
}
|
||||
|
||||
final BitSet chunkMask = new BitSet();
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
if (chunk.getSections()[i] != null) chunkMask.set(i);
|
||||
}
|
||||
chunk.setChunkMask(chunkMask);
|
||||
|
||||
final int[] newBiomeData = new int[chunk.getSections().length * 4 * 4 * 4];
|
||||
System.arraycopy(chunk.getBiomeData(), 0, newBiomeData, 0, chunk.getBiomeData().length);
|
||||
for (int i = 64; i < chunk.getSections().length * 4; i++) { // copy top layer of old biome data all the way to max world height
|
||||
System.arraycopy(chunk.getBiomeData(), chunk.getBiomeData().length - 16, newBiomeData, i * 16, 16);
|
||||
}
|
||||
chunk.setBiomeData(newBiomeData);
|
||||
|
||||
chunk.setHeightMap(new CompoundTag()); // rip heightmap :(
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static PacketHandler handleUpdateLight(final PacketHandler parentRemapper) {
|
||||
final PacketHandler classicLightHandler = new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // x
|
||||
map(Type.VAR_INT); // y
|
||||
map(Type.BOOLEAN); // trust edges
|
||||
handler(wrapper -> {
|
||||
wrapper.read(Type.VAR_INT); // sky light mask
|
||||
wrapper.read(Type.VAR_INT); // block light mask
|
||||
final int emptySkyLightMask = wrapper.read(Type.VAR_INT); // empty sky light mask
|
||||
final int emptyBlockLightMask = wrapper.read(Type.VAR_INT); // empty block light mask
|
||||
|
||||
final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel();
|
||||
final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class);
|
||||
|
||||
int sectionYCount = level.getSizeY() >> 4;
|
||||
if (level.getSizeY() % 16 != 0) sectionYCount++;
|
||||
if (sectionYCount > heightProvider.getMaxChunkSectionCount(wrapper.user())) {
|
||||
sectionYCount = heightProvider.getMaxChunkSectionCount(wrapper.user());
|
||||
}
|
||||
|
||||
final List<byte[]> lightArrays = new ArrayList<>();
|
||||
while (wrapper.isReadable(Type.BYTE_ARRAY_PRIMITIVE, 0)) {
|
||||
lightArrays.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
|
||||
}
|
||||
|
||||
int skyLightCount = 16;
|
||||
int blockLightCount = sectionYCount;
|
||||
if (lightArrays.size() == 18) {
|
||||
blockLightCount = 0;
|
||||
} else if (lightArrays.size() == sectionYCount + sectionYCount + 2) {
|
||||
skyLightCount = sectionYCount;
|
||||
}
|
||||
skyLightCount += 2; // Chunk below 0 and above 255
|
||||
|
||||
final BitSet skyLightMask = new BitSet();
|
||||
final BitSet blockLightMask = new BitSet();
|
||||
skyLightMask.set(0, skyLightCount);
|
||||
blockLightMask.set(0, blockLightCount);
|
||||
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, skyLightMask.toLongArray());
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, blockLightMask.toLongArray());
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptySkyLightMask]);
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptyBlockLightMask]);
|
||||
|
||||
wrapper.write(Type.VAR_INT, skyLightCount);
|
||||
for (int i = 0; i < skyLightCount; i++) {
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, blockLightCount);
|
||||
for (int i = 0; i < blockLightCount; i++) {
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.c0_28toc0_30)) {
|
||||
classicLightHandler.handle(wrapper);
|
||||
} else {
|
||||
parentRemapper.handle(wrapper);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void changeDimensionTagHeight(final UserConnection user, final CompoundTag tag) {
|
||||
tag.put("height", new IntTag(Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(user) << 4));
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.*;
|
||||
|
||||
public class JsonHelper {
|
||||
|
||||
public static String toSortedString(JsonElement json) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JsonWriter jsonWriter = new JsonWriter(stringWriter);
|
||||
|
||||
try {
|
||||
writeSorted(jsonWriter, json, Comparator.naturalOrder());
|
||||
} catch (IOException var4) {
|
||||
throw new AssertionError(var4);
|
||||
}
|
||||
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
public static void writeSorted(JsonWriter writer, @Nullable JsonElement json, @Nullable Comparator<String> comparator) throws IOException {
|
||||
if (json != null && !json.isJsonNull()) {
|
||||
if (json.isJsonPrimitive()) {
|
||||
JsonPrimitive jsonPrimitive = json.getAsJsonPrimitive();
|
||||
if (jsonPrimitive.isNumber()) {
|
||||
writer.value(jsonPrimitive.getAsNumber());
|
||||
} else if (jsonPrimitive.isBoolean()) {
|
||||
writer.value(jsonPrimitive.getAsBoolean());
|
||||
} else {
|
||||
writer.value(jsonPrimitive.getAsString());
|
||||
}
|
||||
} else {
|
||||
Iterator var5;
|
||||
if (json.isJsonArray()) {
|
||||
writer.beginArray();
|
||||
var5 = json.getAsJsonArray().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
JsonElement jsonElement = (JsonElement)var5.next();
|
||||
writeSorted(writer, jsonElement, comparator);
|
||||
}
|
||||
|
||||
writer.endArray();
|
||||
} else {
|
||||
if (!json.isJsonObject()) {
|
||||
throw new IllegalArgumentException("Couldn't write " + json.getClass());
|
||||
}
|
||||
|
||||
writer.beginObject();
|
||||
var5 = sort(json.getAsJsonObject().entrySet(), comparator).iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<String, JsonElement> entry = (Map.Entry)var5.next();
|
||||
writer.name((String)entry.getKey());
|
||||
writeSorted(writer, (JsonElement)entry.getValue(), comparator);
|
||||
}
|
||||
|
||||
writer.endObject();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
writer.nullValue();
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<Map.Entry<String, JsonElement>> sort(Collection<Map.Entry<String, JsonElement>> entries, @Nullable Comparator<String> comparator) {
|
||||
if (comparator == null) {
|
||||
return entries;
|
||||
} else {
|
||||
List<Map.Entry<String, JsonElement>> list = new ArrayList(entries);
|
||||
list.sort(Map.Entry.comparingByKey(comparator));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0;
|
||||
|
||||
public record MessageMetadataModel(String plain, long timestamp, long salt) {
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.model.SignatureUpdatableModel;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
public interface MessageSigner {
|
||||
|
||||
byte[] sign(final SignatureUpdatableModel signer);
|
||||
|
||||
static MessageSigner create(final PrivateKey privateKey, final String algorithm) {
|
||||
return signer -> {
|
||||
try {
|
||||
final Signature signature = Signature.getInstance(algorithm);
|
||||
signature.initSign(privateKey);
|
||||
|
||||
signer.update(data -> {
|
||||
try {
|
||||
signature.update(data);
|
||||
} catch (SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
return signature.sign();
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
|
||||
throw new IllegalStateException("Failed to sign message", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0.model;
|
||||
|
||||
public interface SignatureUpdatableModel {
|
||||
|
||||
void update(final SignatureUpdaterModel updater);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0.model;
|
||||
|
||||
public interface SignatureUpdaterModel {
|
||||
|
||||
void update(final byte[] data);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandArgumentsProvider implements Provider {
|
||||
|
||||
public List<Pair<String, String>> getSignedArguments(final String command) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.MessageSigner;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
|
||||
public abstract class AbstractChatSession extends StoredObject {
|
||||
private final ProfileKey profileKey;
|
||||
private final PrivateKey privateKey;
|
||||
|
||||
private final MessageSigner signer;
|
||||
|
||||
public AbstractChatSession(UserConnection user, final ProfileKey profileKey, final PrivateKey privateKey) {
|
||||
super(user);
|
||||
this.profileKey = profileKey;
|
||||
this.privateKey = privateKey;
|
||||
|
||||
this.signer = MessageSigner.create(privateKey, "SHA256withRSA");
|
||||
}
|
||||
|
||||
public ProfileKey getProfileKey() {
|
||||
return profileKey;
|
||||
}
|
||||
|
||||
public PrivateKey getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public MessageSigner getSigner() {
|
||||
return signer;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_0.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.JsonHelper;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.MessageMetadataModel;
|
||||
import net.lenni0451.mcstructs.text.components.StringComponent;
|
||||
import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.PrivateKey;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatSession1_19_0 extends AbstractChatSession {
|
||||
|
||||
private final byte[] legacyKey;
|
||||
|
||||
public ChatSession1_19_0(UserConnection user, ProfileKey profileKey, PrivateKey privateKey, byte[] legacyKey) {
|
||||
super(user, profileKey, privateKey);
|
||||
this.legacyKey = legacyKey;
|
||||
}
|
||||
|
||||
public byte[] sign(final UUID sender, final MessageMetadataModel messageMetadata) {
|
||||
return getSigner().sign(updater -> {
|
||||
final byte[] data = new byte[32];
|
||||
final ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN);
|
||||
|
||||
buffer.putLong(messageMetadata.salt());
|
||||
buffer.putLong(sender.getMostSignificantBits()).putLong(sender.getLeastSignificantBits());
|
||||
buffer.putLong(Instant.ofEpochMilli(messageMetadata.timestamp()).getEpochSecond());
|
||||
|
||||
updater.update(data);
|
||||
updater.update(JsonHelper.toSortedString(TextComponentSerializer.V1_18.serializeJson(new StringComponent(messageMetadata.plain()))).getBytes(StandardCharsets.UTF_8));
|
||||
});
|
||||
}
|
||||
|
||||
public byte[] getLegacyKey() {
|
||||
return legacyKey;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_2;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.hash.HashingOutputStream;
|
||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.MessageMetadataModel;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class MessageBodyModel {
|
||||
private final MessageMetadataModel messageMetadata;
|
||||
private final PlayerMessageSignature[] lastSeenMessages;
|
||||
|
||||
public MessageBodyModel(MessageMetadataModel messageMetadata, PlayerMessageSignature[] lastSeenMessages) {
|
||||
this.messageMetadata = messageMetadata;
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
}
|
||||
|
||||
public void writeLastSeenMessage(final DataOutput dataOutput) {
|
||||
for (PlayerMessageSignature seenMessage : lastSeenMessages) {
|
||||
try {
|
||||
dataOutput.writeByte(70);
|
||||
dataOutput.writeLong(seenMessage.uuid().getMostSignificantBits());
|
||||
dataOutput.writeLong(seenMessage.uuid().getLeastSignificantBits());
|
||||
dataOutput.write(seenMessage.signatureBytes());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] digestBytes() {
|
||||
final HashingOutputStream hashingOutputStream = new HashingOutputStream(Hashing.sha256(), OutputStream.nullOutputStream());
|
||||
final DataOutputStream dataOutputStream = new DataOutputStream(hashingOutputStream);
|
||||
|
||||
try {
|
||||
dataOutputStream.writeLong(messageMetadata.salt());
|
||||
dataOutputStream.writeLong(Instant.ofEpochMilli(messageMetadata.timestamp()).getEpochSecond());
|
||||
|
||||
final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(dataOutputStream, StandardCharsets.UTF_8);
|
||||
outputStreamWriter.write(messageMetadata.plain());
|
||||
outputStreamWriter.flush();
|
||||
|
||||
dataOutputStream.write(70);
|
||||
writeLastSeenMessage(dataOutputStream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return hashingOutputStream.hash().asBytes();
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_2;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.model.SignatureUpdaterModel;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MessageHeaderModel {
|
||||
private final UUID sender;
|
||||
private final byte[] precedingSignature;
|
||||
|
||||
public MessageHeaderModel(UUID sender, byte[] precedingSignature) {
|
||||
this.sender = sender;
|
||||
this.precedingSignature = precedingSignature;
|
||||
}
|
||||
|
||||
public byte[] toByteArray(final UUID uuid) {
|
||||
final byte[] data = new byte[16];
|
||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN);
|
||||
|
||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||
byteBuffer.putLong(uuid.getLeastSignificantBits());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void updater(final byte[] bodyDigest, final SignatureUpdaterModel updater) {
|
||||
if (precedingSignature != null) {
|
||||
updater.update(precedingSignature);
|
||||
}
|
||||
|
||||
updater.update(toByteArray(getSender()));
|
||||
updater.update(bodyDigest);
|
||||
}
|
||||
|
||||
public UUID getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public byte[] getPrecedingSignature() {
|
||||
return precedingSignature;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package de.florianmichael.viafabricplus.definition.v1_19_2.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.MessageMetadataModel;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.storage.AbstractChatSession;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_2.MessageBodyModel;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_2.MessageHeaderModel;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatSession1_19_2 extends AbstractChatSession {
|
||||
public final static SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||
|
||||
private byte[] precedingSignature = null;
|
||||
|
||||
public ChatSession1_19_2(UserConnection user, ProfileKey profileKey, PrivateKey privateKey) {
|
||||
super(user, profileKey, privateKey);
|
||||
}
|
||||
|
||||
public byte[] sign(final UUID sender, final MessageMetadataModel messageMetadata, final PlayerMessageSignature[] lastSeenMessages) {
|
||||
final MessageHeaderModel header = new MessageHeaderModel(sender, precedingSignature);
|
||||
final MessageBodyModel body = new MessageBodyModel(messageMetadata, lastSeenMessages);
|
||||
|
||||
precedingSignature = getSigner().sign(updater -> header.updater(body.digestBytes(), updater));
|
||||
|
||||
return precedingSignature;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
public interface IClientConnection {
|
||||
|
||||
void viafabricplus_setupPreNettyEncryption();
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
public interface IMinecraftClient {
|
||||
|
||||
void protocolhack_trackKeyboardInteraction(final Runnable interaction);
|
||||
void protocolhack_trackMouseInteraction(final Runnable interaction);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.florianmichael.everyprotocol.injection.access;
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.util.Pair;
|
@ -0,0 +1,10 @@
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface IPublicKeyData {
|
||||
|
||||
ByteBuffer protocolhack_get1_19_0Key();
|
||||
|
||||
void protocolhack_set1_19_0Key(final ByteBuffer oldKey);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
public interface IScreenHandler {
|
||||
|
||||
short protocolhack_getAndIncrementLastActionId();
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.platform.PreNettyConstants;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.event.PipelineReorderEvent;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.encryption.PacketDecryptor;
|
||||
import net.minecraft.network.encryption.PacketEncryptor;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public class MixinClientConnection implements IClientConnection {
|
||||
|
||||
@Shadow private Channel channel;
|
||||
|
||||
@Shadow private boolean encrypted;
|
||||
@Unique
|
||||
private Cipher viafabricplus_decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private Cipher viafabricplus_encryptionCipher;
|
||||
|
||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
|
||||
channel.pipeline().fireUserEventTriggered(new PipelineReorderEvent());
|
||||
}
|
||||
|
||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.r1_6_4)) {
|
||||
ci.cancel();
|
||||
this.viafabricplus_decryptionCipher = decryptionCipher;
|
||||
this.viafabricplus_encryptionCipher = encryptionCipher;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setupPreNettyEncryption() {
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(PreNettyConstants.DECODER, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
|
||||
this.channel.pipeline().addBefore(PreNettyConstants.ENCODER, "encrypt", new PacketEncryptor(this.viafabricplus_encryptionCipher));
|
||||
}
|
||||
}
|
@ -1,4 +1,25 @@
|
||||
package de.florianmichael.everyprotocol.injection.mixin.base;
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import net.minecraft.client.main.Main;
|
||||
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;
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class MixinMain {
|
||||
|
||||
@Inject(method = "main([Ljava/lang/String;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;initCrashReport()V"))
|
||||
private static void loadViaLoadingBase(CallbackInfo ci) {
|
||||
ViaFabricPlus.getClassWrapper().create();
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MixinMinecraftClient implements IMinecraftClient {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
public ClientPlayerEntity player;
|
||||
|
||||
@Shadow @Final public Mouse mouse;
|
||||
|
||||
@Shadow protected int attackCooldown;
|
||||
|
||||
@Shadow @Nullable public abstract ClientPlayNetworkHandler getNetworkHandler();
|
||||
|
||||
@Redirect(method = "doItemUse",
|
||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0))
|
||||
private void redirectDoItemUse(HeldItemRenderer heldItemRenderer, Hand hand) {
|
||||
if (ViaLoadingBase.getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem)) {
|
||||
heldItemRenderer.resetEquipProgress(hand);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "doItemUse",
|
||||
slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;isAccepted()Z", ordinal = 0))
|
||||
private boolean preventGenericInteract(ActionResult instance) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return instance.isAccepted();
|
||||
}
|
||||
|
||||
/**
|
||||
* This code removes the cooldown if
|
||||
*/
|
||||
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
|
||||
public int unwrapOperation(MinecraftClient instance) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return 0;
|
||||
}
|
||||
return attackCooldown;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
|
||||
public void updateCooldown(CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (this.attackCooldown > 0) {
|
||||
--this.attackCooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final ConcurrentLinkedDeque<Runnable> protocolhack_keyboardInteractions = new ConcurrentLinkedDeque<>();
|
||||
|
||||
@Unique
|
||||
private final ConcurrentLinkedDeque<Runnable> protocolhack_mouseInteractions = new ConcurrentLinkedDeque<>();
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||
ordinal = 4, shift = At.Shift.BEFORE))
|
||||
public void injectTick(CallbackInfo ci) {
|
||||
if (!ValueHolder.executeInputsInSync.getValue()) return;
|
||||
|
||||
while (!protocolhack_mouseInteractions.isEmpty()) {
|
||||
protocolhack_mouseInteractions.poll().run();
|
||||
}
|
||||
while (!protocolhack_keyboardInteractions.isEmpty()) {
|
||||
protocolhack_keyboardInteractions.poll().run();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;hasRidingInventory()Z"))
|
||||
private void onInventoryKeyPressed(CallbackInfo ci) throws Exception {
|
||||
final UserConnection viaConnection = getNetworkHandler().getConnection().channel.attr(ViaFabricPlus.LOCAL_USER_CONNECTION).get();
|
||||
|
||||
if (viaConnection != null && ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
final PacketWrapper clientStatus = PacketWrapper.create(ServerboundPackets1_9_3.CLIENT_STATUS, viaConnection);
|
||||
clientStatus.write(Type.VAR_INT, 2); // Open Inventory Achievement
|
||||
|
||||
clientStatus.sendToServer(Protocol1_12To1_11_1.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protocolhack_trackKeyboardInteraction(Runnable interaction) {
|
||||
this.protocolhack_keyboardInteractions.add(interaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protocolhack_trackMouseInteraction(Runnable interaction) {
|
||||
this.protocolhack_mouseInteractions.add(interaction);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@Mixin(PlayerPublicKey.PublicKeyData.class)
|
||||
public class MixinPlayerPublicKey_PublicKeyData implements IPublicKeyData {
|
||||
|
||||
@Unique
|
||||
private ByteBuffer protocolhack_1_19_0Key;
|
||||
|
||||
@Override
|
||||
public ByteBuffer protocolhack_get1_19_0Key() {
|
||||
return protocolhack_1_19_0Key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protocolhack_set1_19_0Key(ByteBuffer byteBuffer) {
|
||||
this.protocolhack_1_19_0Key = byteBuffer;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||
import net.minecraft.client.util.ProfileKeysImpl;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ProfileKeysImpl.class)
|
||||
public class MixinProfileKeysImpl {
|
||||
|
||||
@Inject(method = "decodeKeyPairResponse", at = @At("RETURN"))
|
||||
private static void trackLegacyKey(KeyPairResponse keyPairResponse, CallbackInfoReturnable<PlayerPublicKey.PublicKeyData> cir) {
|
||||
((IPublicKeyData) (Object) cir.getReturnValue()).protocolhack_set1_19_0Key(keyPairResponse.getLegacyPublicKeySignature());
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerAddress.class)
|
||||
public class MixinServerAddress {
|
||||
|
||||
@Shadow @Final private static ServerAddress INVALID;
|
||||
|
||||
@Inject(method = "parse", at = @At("RETURN"), cancellable = true)
|
||||
private static void fixAddress(String address, CallbackInfoReturnable<ServerAddress> cir) {
|
||||
if (!cir.getReturnValue().equals(INVALID) && ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(cir.getReturnValue()).orElse(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes;
|
||||
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.Files;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.definition.PackFormatsDefinition;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.minecraft.client.resource.ServerResourcePackProvider;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ServerResourcePackProvider.class)
|
||||
public class MixinServerResourcePackProvider {
|
||||
|
||||
@Unique
|
||||
private File protocolhack_trackedFile;
|
||||
|
||||
@Redirect(method = "getDownloadHeaders", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;getGameVersion()Lnet/minecraft/GameVersion;"))
|
||||
private static GameVersion editHeaders() {
|
||||
return PackFormatsDefinition.current();
|
||||
}
|
||||
|
||||
@Inject(method = "getDownloadHeaders", at = @At("TAIL"), cancellable = true)
|
||||
private static void removeHeaders(CallbackInfoReturnable<Map<String, String>> cir) {
|
||||
final LinkedHashMap<String, String> modifiableMap = new LinkedHashMap<>(cir.getReturnValue());
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_14)) {
|
||||
modifiableMap.remove("X-Minecraft-Version-ID");
|
||||
}
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_13)) {
|
||||
modifiableMap.remove("X-Minecraft-Pack-Format");
|
||||
modifiableMap.remove("User-Agent");
|
||||
}
|
||||
|
||||
cir.setReturnValue(modifiableMap);
|
||||
}
|
||||
|
||||
@Inject(method = "verifyFile", at = @At("HEAD"))
|
||||
public void keepFile(String expectedSha1, File file, CallbackInfoReturnable<Boolean> cir) {
|
||||
protocolhack_trackedFile = file;
|
||||
}
|
||||
|
||||
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Lcom/google/common/hash/HashCode;toString()Ljava/lang/String;", remap = false))
|
||||
public String revertHashAlgorithm(HashCode instance) {
|
||||
try {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
//noinspection deprecation
|
||||
return Hashing.sha1().hashBytes(Files.toByteArray(protocolhack_trackedFile)).toString();
|
||||
} else if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_18)) {
|
||||
return DigestUtils.sha1Hex(new FileInputStream(protocolhack_trackedFile));
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
return instance.toString();
|
||||
}
|
||||
|
||||
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Ljava/lang/String;toLowerCase(Ljava/util/Locale;)Ljava/lang/String;"))
|
||||
public String disableIgnoreCase(String instance, Locale locale) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
return instance.toLowerCase(locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.InfestedBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AbstractBlock.AbstractBlockState.class)
|
||||
public abstract class MixinAbstractBlock_AbstractBlockState {
|
||||
|
||||
@Shadow
|
||||
protected abstract BlockState asBlockState();
|
||||
|
||||
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
|
||||
public void injectGetHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
final BlockState state = this.asBlockState();
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
if (state.getBlock() instanceof InfestedBlock) {
|
||||
cir.setReturnValue(0.75F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
if (state.getBlock() == Blocks.END_STONE_BRICKS || state.getBlock() == Blocks.END_STONE_BRICK_SLAB || state.getBlock() == Blocks.END_STONE_BRICK_STAIRS || state.getBlock() == Blocks.END_STONE_BRICK_WALL) {
|
||||
cir.setReturnValue(0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
if (state.getBlock() == Blocks.PISTON || state.getBlock() == Blocks.STICKY_PISTON || state.getBlock() == Blocks.PISTON_HEAD) {
|
||||
cir.setReturnValue(0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
if (state.getBlock() instanceof InfestedBlock) {
|
||||
cir.setReturnValue(0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.AnvilBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AnvilBlock.class)
|
||||
public class MixinAnvilBlock {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_X_AXIS_SHAPE_1_12_2 = Block.createCuboidShape(0, 0, 2, 16, 16, 14);
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_Z_AXIS_SHAPE_1_12_2 = Block.createCuboidShape(2, 0, 0, 14, 16, 16);
|
||||
@Shadow
|
||||
@Final
|
||||
public static DirectionProperty FACING;
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? protocolhack_X_AXIS_SHAPE_1_12_2 : protocolhack_Z_AXIS_SHAPE_1_12_2);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.BambooBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BambooBlock.class)
|
||||
public class MixinBambooBlock {
|
||||
|
||||
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
|
||||
public void changeFullCube(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.BedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BedBlock.class)
|
||||
public class MixinBedBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape protocolhack_BED_SHAPE_1_13_2 = Block.createCuboidShape(0, 0, 0, 16, 9, 16);
|
||||
|
||||
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
|
||||
public void injectBounceEntity(Entity entity, CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getClassWrapper() != null) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
cir.setReturnValue(protocolhack_BED_SHAPE_1_13_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.InfestedBlock;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Block.class)
|
||||
public class MixinBlock {
|
||||
|
||||
@Inject(method = "getBlastResistance", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyBlastResistance(CallbackInfoReturnable<Float> ci) {
|
||||
final Block block = ((Block) (Object) this);
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
if (block == Blocks.END_STONE_BRICKS || block == Blocks.END_STONE_BRICK_SLAB || block == Blocks.END_STONE_BRICK_STAIRS || block == Blocks.END_STONE_BRICK_WALL) {
|
||||
ci.setReturnValue(0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
if (block == Blocks.PISTON || block == Blocks.STICKY_PISTON || block == Blocks.PISTON_HEAD) {
|
||||
ci.setReturnValue(0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
if (block instanceof InfestedBlock) {
|
||||
ci.setReturnValue(0.75F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(BlockView.class)
|
||||
public interface MixinBlockView {
|
||||
|
||||
@Redirect(method = "raycastBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getRaycastShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;"))
|
||||
default VoxelShape hookedGetRaycastShape(BlockState instance, BlockView blockView, BlockPos blockPos) {
|
||||
VoxelShape shape = instance.getRaycastShape(blockView, blockPos);
|
||||
// It appears, that certain game states react unstable to the shape changes we are producing.
|
||||
if (shape == null)
|
||||
shape = VoxelShapes.empty();
|
||||
return shape;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BrewingStandBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BrewingStandBlock.class)
|
||||
public class MixinBrewingStandBlock {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_BASE_SHAPE_1_12_2 = VoxelShapes.union(
|
||||
Block.createCuboidShape(0, 0, 0, 16, 2, 16) /* Base */,
|
||||
Block.createCuboidShape(7, 0, 7, 9, 14, 9) /* Stick */
|
||||
);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(protocolhack_BASE_SHAPE_1_12_2);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.cauldron.CauldronBehavior;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.function.BooleanBiFunction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(CauldronBlock.class)
|
||||
public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape protocolhack_CAULDRON_SHAPE_1_12_2 = VoxelShapes.combineAndSimplify(
|
||||
VoxelShapes.fullCube(),
|
||||
Block.createCuboidShape(2.0D, 5.0D, 2.0D, 14.0D, 16.0D, 14.0D),
|
||||
BooleanBiFunction.ONLY_FIRST
|
||||
);
|
||||
|
||||
public MixinCauldronBlock(Settings settings, Map<Item, CauldronBehavior> behaviorMap) {
|
||||
super(settings, behaviorMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
return protocolhack_CAULDRON_SHAPE_1_12_2;
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EndPortalBlock.class)
|
||||
public abstract class MixinEndPortalBlock extends BlockWithEntity {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape SHAPE;
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_SHAPE_1_8 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_SHAPE_1_16_5 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
|
||||
|
||||
protected MixinEndPortalBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().world == null) return;
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(protocolhack_SHAPE_1_8);
|
||||
}
|
||||
else if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(protocolhack_SHAPE_1_16_5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.EndPortalFrameBlock;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(EndPortalFrameBlock.class)
|
||||
public class MixinEndPortalFrameBlock {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape FRAME_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape FRAME_WITH_EYE_SHAPE;
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_EYE_SHAPE_1_12_2 = Block.createCuboidShape(5.0, 13.0, 5.0, 11.0, 16.0, 11.0);
|
||||
|
||||
@Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/EndPortalFrameBlock;FRAME_WITH_EYE_SHAPE:Lnet/minecraft/util/shape/VoxelShape;"))
|
||||
public VoxelShape redirectGetOutlineShape() {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
return VoxelShapes.union(FRAME_SHAPE, protocolhack_EYE_SHAPE_1_12_2);
|
||||
}
|
||||
return FRAME_WITH_EYE_SHAPE;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FarmlandBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FarmlandBlock.class)
|
||||
public class MixinFarmlandBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_SHAPE_1_9_4 = VoxelShapes.fullCube();
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape SHAPE;
|
||||
|
||||
public MixinFarmlandBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
|
||||
cir.setReturnValue(protocolhack_SHAPE_1_9_4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
return SHAPE;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.util.ActionResult;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FenceBlock.class)
|
||||
public class MixinFenceBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10)) {
|
||||
ci.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FireBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FireBlock.class)
|
||||
public class MixinFireBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(VoxelShapes.empty());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FlowerPotBlock;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FlowerPotBlock.class)
|
||||
public class MixinFlowerPotBlock {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Block content;
|
||||
|
||||
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
|
||||
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_10) && content != Blocks.AIR) {
|
||||
ci.setReturnValue(ActionResult.CONSUME);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HopperBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.function.BooleanBiFunction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(HopperBlock.class)
|
||||
public class MixinHopperBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape protocolhack_INSIDE_SHAPE_1_12_2 = Block.createCuboidShape(2, 10, 2, 14, 16, 14);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape protocolhack_HOPPER_SHAPE_1_12_2 = VoxelShapes.combineAndSimplify(
|
||||
VoxelShapes.fullCube(),
|
||||
protocolhack_INSIDE_SHAPE_1_12_2,
|
||||
BooleanBiFunction.ONLY_FIRST);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(protocolhack_HOPPER_SHAPE_1_12_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(protocolhack_INSIDE_SHAPE_1_12_2);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LadderBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LadderBlock.class)
|
||||
public class MixinLadderBlock {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_EAST_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 2, 16, 16);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_WEST_SHAPE_1_8 = Block.createCuboidShape(14, 0, 0, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_SOUTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 16, 16, 2);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_NORTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 14, 16, 16, 16);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
switch (state.get(LadderBlock.FACING)) {
|
||||
case NORTH -> ci.setReturnValue(protocolhack_NORTH_SHAPE_1_8);
|
||||
case SOUTH -> ci.setReturnValue(protocolhack_SOUTH_SHAPE_1_8);
|
||||
case WEST -> ci.setReturnValue(protocolhack_WEST_SHAPE_1_8);
|
||||
default -> ci.setReturnValue(protocolhack_EAST_SHAPE_1_8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.LightBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(LightBlock.class)
|
||||
public class MixinLightBlock {
|
||||
|
||||
// Not relevant for GamePlay
|
||||
@Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isCreativeLevelTwoOp()Z"))
|
||||
public boolean removeIf(PlayerEntity instance) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
return true;
|
||||
}
|
||||
return instance.isCreativeLevelTwoOp();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LilyPadBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LilyPadBlock.class)
|
||||
public class MixinLilyPadBlock {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape protocolhack_SHAPE_1_8 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 0.015625D /* 1 / 64 */ * 16, 16.0D);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void changeBoundingBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(protocolhack_SHAPE_1_8);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(PaneBlock.class)
|
||||
public class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
|
||||
public MixinPaneBlock(float radius1, float radius2, float boundingHeight1, float boundingHeight2, float collisionHeight, Settings settings) {
|
||||
super(radius1, radius2, boundingHeight1, boundingHeight2, collisionHeight, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return protocolhack_get1_8Shape(state);
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return protocolhack_get1_8Shape(state);
|
||||
}
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_WEST_SHAPE_1_8 = Block.createCuboidShape(0, 0, 7, 8, 16, 9);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_EAST_SHAPE_1_8 = Block.createCuboidShape(8, 0, 7, 16, 16, 9);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_WEST_EAST_COMBINED_SHAPE_1_8 = Block.createCuboidShape(0, 0, 7, 16, 16, 9);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_NORTH_SHAPE_1_8 = Block.createCuboidShape(7, 0, 0, 9, 16, 8);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_SOUTH_SHAPE_1_8 = Block.createCuboidShape(7, 0, 8, 9, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_NORTH_SOUTH_COMBINED_SHAPE_1_8 = Block.createCuboidShape(7, 0, 0, 9, 16, 16);
|
||||
|
||||
@Unique
|
||||
public VoxelShape protocolhack_get1_8Shape(BlockState state) {
|
||||
VoxelShape finalShape = VoxelShapes.empty();
|
||||
|
||||
final boolean isNorthFacing = state.get(NORTH);
|
||||
final boolean isSouthFacing = state.get(SOUTH);
|
||||
final boolean isWestFacing = state.get(WEST);
|
||||
final boolean isEastFacing = state.get(EAST);
|
||||
|
||||
if ((!isWestFacing || !isEastFacing) && (isWestFacing || isEastFacing || isNorthFacing || isSouthFacing)) {
|
||||
if (isWestFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, protocolhack_WEST_SHAPE_1_8);
|
||||
else if (isEastFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, protocolhack_EAST_SHAPE_1_8);
|
||||
} else
|
||||
finalShape = VoxelShapes.union(finalShape, protocolhack_WEST_EAST_COMBINED_SHAPE_1_8);
|
||||
|
||||
if ((!isNorthFacing || !isSouthFacing) && (isWestFacing || isEastFacing || isNorthFacing || isSouthFacing)) {
|
||||
if (isNorthFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, protocolhack_NORTH_SHAPE_1_8);
|
||||
else if (isSouthFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, protocolhack_SOUTH_SHAPE_1_8);
|
||||
} else
|
||||
finalShape = VoxelShapes.union(finalShape, protocolhack_NORTH_SOUTH_COMBINED_SHAPE_1_8);
|
||||
|
||||
return finalShape;
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PistonHeadBlock.class)
|
||||
public class MixinPistonHeadBlock extends FacingBlock {
|
||||
|
||||
public MixinPistonHeadBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2))
|
||||
cir.setReturnValue(getCoreShape_1_8(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
|
||||
return VoxelShapes.union(getHeadShape_1_8(state), getCoreShape_1_8(state));
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_CORE_DOWN_SHAPE_1_8 = Block.createCuboidShape(6, 4, 6, 10, 16, 10);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_CORE_UP_SHAPE_1_8 = Block.createCuboidShape(6, 0, 6, 10, 12, 10);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_CORE_NORTH_SHAPE_1_8 = Block.createCuboidShape(4, 6, 4, 12, 10, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_CORE_SOUTH_SHAPE_1_8 = Block.createCuboidShape(4, 6, 0, 12, 10, 12);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_CORE_WEST_SHAPE_1_8 = Block.createCuboidShape(6, 4, 4, 10, 12, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_CORE_EAST_SHAPE_1_8 = Block.createCuboidShape(0, 6, 4, 12, 10, 12);
|
||||
|
||||
@Unique
|
||||
private VoxelShape getCoreShape_1_8(BlockState state) {
|
||||
final Direction direction = state.get(FACING);
|
||||
|
||||
return switch (direction) {
|
||||
case DOWN -> protocolhack_CORE_DOWN_SHAPE_1_8;
|
||||
case UP -> protocolhack_CORE_UP_SHAPE_1_8;
|
||||
case NORTH -> protocolhack_CORE_NORTH_SHAPE_1_8;
|
||||
case SOUTH -> protocolhack_CORE_SOUTH_SHAPE_1_8;
|
||||
case WEST -> protocolhack_CORE_WEST_SHAPE_1_8;
|
||||
case EAST -> protocolhack_CORE_EAST_SHAPE_1_8;
|
||||
};
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_HEAD_DOWN_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 16, 4, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_HEAD_UP_SHAPE_1_8 = Block.createCuboidShape(0, 12, 0, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_HEAD_NORTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 16, 16, 4);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_HEAD_SOUTH_SHAPE_1_8 = Block.createCuboidShape(0, 0, 12, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_HEAD_WEST_SHAPE_1_8 = Block.createCuboidShape(0, 0, 0, 4, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape protocolhack_HEAD_EAST_SHAPE_1_8 = Block.createCuboidShape(12, 0, 0, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private VoxelShape getHeadShape_1_8(BlockState state) {
|
||||
final Direction direction = state.get(FACING);
|
||||
|
||||
return switch (direction) {
|
||||
case DOWN -> protocolhack_HEAD_DOWN_SHAPE_1_8;
|
||||
case UP -> protocolhack_HEAD_UP_SHAPE_1_8;
|
||||
case NORTH -> protocolhack_HEAD_NORTH_SHAPE_1_8;
|
||||
case SOUTH -> protocolhack_HEAD_SOUTH_SHAPE_1_8;
|
||||
case WEST -> protocolhack_HEAD_WEST_SHAPE_1_8;
|
||||
case EAST -> protocolhack_HEAD_EAST_SHAPE_1_8;
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.SnowBlock;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(SnowBlock.class)
|
||||
public class MixinSnowBlock {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape[] protocolhack_LAYERS_TO_SHAPE_1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(0, -0.00001 /* Bypass for Minecraft-Fixes */, 0, 16, 0, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 2, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 4, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 6, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 8, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 10, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 12, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 14, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 16, 16)
|
||||
};
|
||||
@Shadow
|
||||
@Final
|
||||
public static IntProperty LAYERS;
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(protocolhack_LAYERS_TO_SHAPE_1_12_2[state.get(LAYERS) - 1]);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoulSandBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(SoulSandBlock.class)
|
||||
public class MixinSoulSandBlock extends Block {
|
||||
|
||||
public MixinSoulSandBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(state, world, pos, entity);
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
final Vec3d velocity = entity.getVelocity();
|
||||
|
||||
double multiplier = 0.4D;
|
||||
entity.setVelocity(velocity.getX() * multiplier, velocity.getY(), velocity.getZ() * multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVelocityMultiplier() {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4))
|
||||
return 1.0F;
|
||||
return super.getVelocityMultiplier();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.SugarCaneBlock;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(SugarCaneBlock.class)
|
||||
public class MixinSugarCaneBlock {
|
||||
|
||||
@Redirect(method = "canPlaceAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/registry/tag/TagKey;)Z"))
|
||||
public boolean changePlaceTarget(BlockState instance, TagKey<Block> tagKey) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
return instance.isOf(Blocks.GRASS_BLOCK) || instance.isOf(Blocks.DIRT) || instance.isOf(Blocks.COARSE_DIRT) || instance.isOf(Blocks.PODZOL);
|
||||
}
|
||||
return instance.isIn(tagKey);
|
||||
}
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.enums.WallShape;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(WallBlock.class)
|
||||
public class MixinWallBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape[] protocolhack_SHAPE_BY_INDEX_1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(4, 0, 4, 12, 16, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 12, 16, 16),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 16, 12),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 16, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 12, 16, 12),
|
||||
|
||||
Block.createCuboidShape(5, 0, 0, 11, 14, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 0, 12, 16, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 12, 16, 16),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 16, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 16, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 5, 16, 14, 11),
|
||||
|
||||
Block.createCuboidShape(0, 0, 4, 16, 16, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 16, 12),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 16, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 16, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 16, 16)
|
||||
};
|
||||
@Unique
|
||||
private static final VoxelShape[] protocolhack_CLIP_SHAPE_BY_INDEX_1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(4, 0, 4, 12, 24, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 12, 24, 16),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 24, 12),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 24, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 12, 24, 12),
|
||||
|
||||
Block.createCuboidShape(5, 0, 0, 11, 24, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 0, 12, 24, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 12, 24, 16),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 24, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 24, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 5, 16, 24, 11),
|
||||
|
||||
Block.createCuboidShape(0, 0, 4, 16, 24, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 24, 12),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 24, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 24, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 24, 16)
|
||||
};
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> EAST_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> NORTH_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> WEST_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> SOUTH_SHAPE;
|
||||
public MixinWallBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static BlockState protocolhack_oldWallPlacementLogic(BlockState state) {
|
||||
boolean addUp = false;
|
||||
if (state.get(WallBlock.NORTH_SHAPE) == WallShape.TALL) {
|
||||
state = state.with(WallBlock.NORTH_SHAPE, WallShape.LOW);
|
||||
addUp = true;
|
||||
}
|
||||
if (state.get(WallBlock.EAST_SHAPE) == WallShape.TALL) {
|
||||
state = state.with(WallBlock.EAST_SHAPE, WallShape.LOW);
|
||||
addUp = true;
|
||||
}
|
||||
if (state.get(WallBlock.SOUTH_SHAPE) == WallShape.TALL) {
|
||||
state = state.with(WallBlock.SOUTH_SHAPE, WallShape.LOW);
|
||||
addUp = true;
|
||||
}
|
||||
if (state.get(WallBlock.WEST_SHAPE) == WallShape.TALL) {
|
||||
state = state.with(WallBlock.WEST_SHAPE, WallShape.LOW);
|
||||
addUp = true;
|
||||
}
|
||||
if (addUp) {
|
||||
state = state.with(WallBlock.UP, true);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static int protocolhack_getShapeIndex_1122(BlockState state) {
|
||||
int i = 0;
|
||||
|
||||
if (state.get(NORTH_SHAPE) != WallShape.NONE) i |= 1 << Direction.NORTH.getHorizontal();
|
||||
if (state.get(EAST_SHAPE) != WallShape.NONE) i |= 1 << Direction.EAST.getHorizontal();
|
||||
if (state.get(SOUTH_SHAPE) != WallShape.NONE) i |= 1 << Direction.SOUTH.getHorizontal();
|
||||
if (state.get(WEST_SHAPE) != WallShape.NONE) i |= 1 << Direction.WEST.getHorizontal();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
|
||||
public void injectGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(protocolhack_oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true)
|
||||
public void injectGetStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos, CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(protocolhack_oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(protocolhack_CLIP_SHAPE_BY_INDEX_1_12_2[protocolhack_getShapeIndex_1122(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(protocolhack_SHAPE_BY_INDEX_1_12_2[protocolhack_getShapeIndex_1122(state)]);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.input;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public class MixinKeyboard {
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
|
||||
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
public void redirectSync(MinecraftClient instance, Runnable runnable) {
|
||||
if (ValueHolder.executeInputsInSync.getValue()) {
|
||||
((IMinecraftClient) client).protocolhack_trackKeyboardInteraction(runnable);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.execute(runnable);
|
||||
}
|
||||
|
||||
@Redirect(method = "processF3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendCommand(Ljava/lang/String;)Z", ordinal = 0))
|
||||
public boolean replaceSpectatorCommand(ClientPlayNetworkHandler instance, String command) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
|
||||
return false;
|
||||
}
|
||||
return instance.sendCommand(command);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.input;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.input.KeyboardInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(KeyboardInput.class)
|
||||
public class MixinKeyboardInput extends Input {
|
||||
|
||||
@ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true)
|
||||
private boolean injectTick(boolean slowDown) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return this.sneaking;
|
||||
} else if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown);
|
||||
}
|
||||
return slowDown;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.input;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(value = Mouse.class, priority = 1001)
|
||||
public class MixinMouse {
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
|
||||
@Redirect(method = { "method_29615", "method_22685", "method_22684" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
public void redirectSync(MinecraftClient instance, Runnable runnable) {
|
||||
if (ValueHolder.executeInputsInSync.getValue()) {
|
||||
((IMinecraftClient) client).protocolhack_trackMouseInteraction(runnable);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.execute(runnable);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AxeItem.class)
|
||||
public class MixinAxeItem {
|
||||
|
||||
@Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true)
|
||||
public void injectUseOnBlock(ItemUsageContext context, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(ActionResult.PASS);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.enums.ChestType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BlockItem.class)
|
||||
public class MixinBlockItem {
|
||||
|
||||
@Inject(method = "canPlace", at = @At("HEAD"), cancellable = true)
|
||||
private void injectCanPlace(ItemPlacementContext context, BlockState state, CallbackInfoReturnable<Boolean> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) {
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
boolean foundAdjChest = false;
|
||||
for (Direction dir : Direction.Type.HORIZONTAL) {
|
||||
BlockState otherState = world.getBlockState(pos.offset(dir));
|
||||
if (otherState.getBlock() == block) {
|
||||
if (foundAdjChest) {
|
||||
ci.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
foundAdjChest = true;
|
||||
if (otherState.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE) {
|
||||
ci.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.EnderPearlItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EnderPearlItem.class)
|
||||
public class MixinEnderPearlItem {
|
||||
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
private void injectUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && user.getAbilities().creativeMode) {
|
||||
ci.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand)));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.FireworkRocketItem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(FireworkRocketItem.class)
|
||||
public class MixinFireworkRocketItem {
|
||||
|
||||
@Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isFallFlying()Z", ordinal = 0))
|
||||
private boolean disableFireworkElytraBoost(PlayerEntity player) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_11)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return player.isFallFlying();
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(HeldItemRenderer.class)
|
||||
public class MixinHeldItemRenderer {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@Inject(method = "renderFirstPersonItem",
|
||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/util/UseAction;")),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
|
||||
private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
||||
//noinspection DataFlowIssue
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && client.player.isBlocking()) {
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25f));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(13.365f));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(78.05f));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.HoeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(HoeItem.class)
|
||||
public abstract class MixinHoeItem extends MiningToolItem {
|
||||
|
||||
@Unique
|
||||
private static final Set<Block> protocolhack_EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(
|
||||
Blocks.NETHER_WART_BLOCK,
|
||||
Blocks.WARPED_WART_BLOCK,
|
||||
Blocks.HAY_BLOCK,
|
||||
Blocks.DRIED_KELP_BLOCK,
|
||||
Blocks.TARGET,
|
||||
Blocks.SHROOMLIGHT,
|
||||
Blocks.SPONGE,
|
||||
Blocks.WET_SPONGE,
|
||||
Blocks.JUNGLE_LEAVES,
|
||||
Blocks.OAK_LEAVES,
|
||||
Blocks.SPRUCE_LEAVES,
|
||||
Blocks.DARK_OAK_LEAVES,
|
||||
Blocks.ACACIA_LEAVES,
|
||||
Blocks.BIRCH_LEAVES
|
||||
);
|
||||
|
||||
protected MixinHoeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings) {
|
||||
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuitableFor(BlockState state) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.isSuitableFor(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
return 1.0F;
|
||||
}
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
return protocolhack_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||
}
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import net.minecraft.entity.player.ItemCooldownManager;
|
||||
import net.minecraft.item.Item;
|
||||
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;
|
||||
|
||||
@Mixin(value = ItemCooldownManager.class)
|
||||
public class MixinItemCooldownManager {
|
||||
|
||||
@Inject(method = "set", at = @At("HEAD"), cancellable = true)
|
||||
public void injectSet(Item item, int duration, CallbackInfo ci) {
|
||||
if (ValueHolder.removeCooldowns.getValue()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(targets = "net.minecraft.item.ItemGroup$EntriesImpl")
|
||||
public class MixinItemGroup_EntriesImpl {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z"))
|
||||
public boolean removeUnknownItems(Item instance, FeatureSet featureSet) {
|
||||
if ((ViaFabricPlus.getClassWrapper().getAvailableItemsInTargetVersion().contains(instance) && ValueHolder.removeNotAvailableItemsFromCreativeTab.getValue()) || MinecraftClient.getInstance().isInSingleplayer()) {
|
||||
return instance.isEnabled(featureSet);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.api.version.ComparableProtocolVersion;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ItemGroups.class)
|
||||
public class MixinItemGroups {
|
||||
|
||||
@Unique
|
||||
private static ComparableProtocolVersion protocolhack_version;
|
||||
|
||||
@Redirect(method = "displayParametersMatch", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/featuretoggle/FeatureSet;equals(Ljava/lang/Object;)Z"))
|
||||
private static boolean adjustLastVersionMatchCheck(FeatureSet instance, Object o) {
|
||||
return instance.equals(o) && protocolhack_version == ViaLoadingBase.getTargetVersion();
|
||||
}
|
||||
|
||||
@Inject(method = "updateDisplayParameters", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemGroups;updateEntries(Lnet/minecraft/resource/featuretoggle/FeatureSet;Z)V", shift = At.Shift.BEFORE))
|
||||
private static void trackLastVersion(FeatureSet enabledFeatures, boolean operatorEnabled, CallbackInfoReturnable<Boolean> cir) {
|
||||
protocolhack_version = ViaLoadingBase.getTargetVersion();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ItemPlacementContext.class)
|
||||
public class MixinItemPlacementContext {
|
||||
|
||||
@Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true)
|
||||
private void injectGetPlayerLookDirection(CallbackInfoReturnable<Direction> ci) {
|
||||
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
|
||||
final PlayerEntity player = self.getPlayer();
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2) && player != null) {
|
||||
final BlockPos placementPos = self.getBlockPos();
|
||||
final double blockPosCenterFactor = ViaLoadingBase.getTargetVersion().isNewerThan(ProtocolVersion.v1_10) ? 0.5 : 0;
|
||||
|
||||
if (Math.abs(player.getX() - (placementPos.getX() + blockPosCenterFactor)) < 2 && Math.abs(player.getZ() - (placementPos.getZ() + blockPosCenterFactor)) < 2) {
|
||||
final double eyeY = player.getY() + player.getEyeHeight(player.getPose());
|
||||
|
||||
if (eyeY - placementPos.getY() > 2) {
|
||||
ci.setReturnValue(Direction.DOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (placementPos.getY() - eyeY > 0) {
|
||||
ci.setReturnValue(Direction.UP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ci.setReturnValue(player.getHorizontalFacing());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:21 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.*;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
|
||||
@Mixin(ItemStack.class)
|
||||
public abstract class MixinItemStack {
|
||||
|
||||
@Shadow
|
||||
public abstract Item getItem();
|
||||
|
||||
@Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyMiningSpeedMultiplier(BlockState state, CallbackInfoReturnable<Float> ci) {
|
||||
final Item toolItem = ((ItemStack) (Object) this).getItem();
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && toolItem instanceof HoeItem) {
|
||||
ci.setReturnValue(1F);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "getTooltip",
|
||||
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/attribute/EntityAttributes;GENERIC_ATTACK_DAMAGE:Lnet/minecraft/entity/attribute/EntityAttribute;", ordinal = 0)),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getAttributeBaseValue(Lnet/minecraft/entity/attribute/EntityAttribute;)D", ordinal = 0))
|
||||
private double redirectGetTooltip(PlayerEntity player, EntityAttribute attribute) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return 0;
|
||||
} else {
|
||||
return player.getAttributeBaseValue(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"InvalidInjectorMethodSignature", "MixinAnnotationTarget"})
|
||||
@ModifyVariable(method = "getAttributeModifiers", ordinal = 0, at = @At(value = "STORE", ordinal = 1))
|
||||
private Multimap<EntityAttribute, EntityAttributeModifier> modifyVariableGetAttributeModifiers(Multimap<EntityAttribute, EntityAttributeModifier> modifiers) {
|
||||
if (modifiers.isEmpty()) {
|
||||
return modifiers;
|
||||
}
|
||||
modifiers = HashMultimap.create(modifiers);
|
||||
modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE);
|
||||
OptionalDouble defaultAttackDamage = protocolhack_getDefaultAttackDamage(getItem());
|
||||
if (defaultAttackDamage.isPresent()) {
|
||||
modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Weapon Modifier", defaultAttackDamage.getAsDouble(), EntityAttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_SPEED);
|
||||
modifiers.removeAll(EntityAttributes.GENERIC_ARMOR);
|
||||
modifiers.removeAll(EntityAttributes.GENERIC_ARMOR_TOUGHNESS);
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private OptionalDouble protocolhack_getDefaultAttackDamage(Item item) {
|
||||
if (item instanceof ToolItem) {
|
||||
ToolMaterial material = ((ToolItem) item).getMaterial();
|
||||
int materialBonus;
|
||||
if (material == ToolMaterials.STONE) {
|
||||
materialBonus = 1;
|
||||
} else if (material == ToolMaterials.IRON) {
|
||||
materialBonus = 2;
|
||||
} else if (material == ToolMaterials.DIAMOND) {
|
||||
materialBonus = 3;
|
||||
} else {
|
||||
materialBonus = 0;
|
||||
}
|
||||
if (item instanceof SwordItem) {
|
||||
return OptionalDouble.of(4 + materialBonus);
|
||||
} else if (item instanceof PickaxeItem) {
|
||||
return OptionalDouble.of(2 + materialBonus);
|
||||
} else if (item instanceof ShovelItem) {
|
||||
return OptionalDouble.of(1 + materialBonus);
|
||||
} else if (item instanceof AxeItem) {
|
||||
return OptionalDouble.of(3 + materialBonus);
|
||||
}
|
||||
}
|
||||
|
||||
return OptionalDouble.empty();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 7/9/22, 10:40 AM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.HoeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MiningToolItem.class)
|
||||
public class MixinMiningToolItem {
|
||||
|
||||
@Inject(method = "getMiningSpeedMultiplier", at = @At("RETURN"), cancellable = true)
|
||||
public void changeHoeEffectiveBlocks(ItemStack stack, BlockState state, CallbackInfoReturnable<Float> cir) {
|
||||
//noinspection ConstantValue
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2) && (Object) this instanceof HoeItem) {
|
||||
cir.setReturnValue(1.0F);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:22 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(PickaxeItem.class)
|
||||
public abstract class MixinPickaxeItem extends MiningToolItem {
|
||||
|
||||
@Unique
|
||||
private static final Set<Block> protocolhack_EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.PISTON_HEAD);
|
||||
|
||||
@Unique
|
||||
private static final Set<Material> protocolhack_EFFECTIVE_MATERIALS = ImmutableSet.of(Material.METAL, Material.REPAIR_STATION, Material.STONE);
|
||||
|
||||
@Unique
|
||||
private static final Set<Block> protocolhack_EFFECTIVE_BLOCKS_1152 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX);
|
||||
|
||||
protected MixinPickaxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings) {
|
||||
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuitableFor(BlockState state) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
Block block = state.getBlock();
|
||||
int i = this.getMaterial().getMiningLevel();
|
||||
if (block == Blocks.OBSIDIAN) {
|
||||
return i == 3;
|
||||
} else if (block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE && block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK && block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE && block != Blocks.REDSTONE_ORE) {
|
||||
if (block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE && block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE) {
|
||||
return protocolhack_EFFECTIVE_MATERIALS.contains(state.getMaterial());
|
||||
} else
|
||||
return i >= 1;
|
||||
} else
|
||||
return i >= 2;
|
||||
}
|
||||
return super.isSuitableFor(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
return protocolhack_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || protocolhack_EFFECTIVE_BLOCKS_1152.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||
} else if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
return protocolhack_EFFECTIVE_MATERIALS.contains(state.getMaterial()) || protocolhack_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||
}
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:27 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ShovelItem.class)
|
||||
public class MixinShovelItem {
|
||||
|
||||
@Redirect(method = "useOnBlock",
|
||||
at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0),
|
||||
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;")))
|
||||
private Object redirectUseOnBlock(Map<Object, Object> map, Object grassBlock) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return null;
|
||||
} else {
|
||||
return map.get(grassBlock);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:28 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.item;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.item.ToolItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(SwordItem.class)
|
||||
public class MixinSwordItem extends ToolItem {
|
||||
|
||||
public MixinSwordItem(ToolMaterial material, Settings settings) {
|
||||
super(material, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ItemStack itemStack = user.getStackInHand(hand);
|
||||
user.setCurrentHand(hand);
|
||||
return TypedActionResult.consume(itemStack);
|
||||
}
|
||||
return super.use(world, user, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAction getUseAction(ItemStack stack) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return UseAction.BLOCK;
|
||||
}
|
||||
return super.getUseAction(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxUseTime(ItemStack stack) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return 72000;
|
||||
}
|
||||
return super.getMaxUseTime(stack);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.packet;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.text.Text;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = PacketByteBuf.class)
|
||||
public class MixinPacketByteBuf {
|
||||
|
||||
@Inject(method = "readText", at = @At(value = "INVOKE", target = "Lio/netty/handler/codec/DecoderException;<init>(Ljava/lang/String;)V", shift = At.Shift.BEFORE, remap = false), cancellable = true)
|
||||
public void injectReadText(CallbackInfoReturnable<Text> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18)) {
|
||||
cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.packet;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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;
|
||||
|
||||
@Mixin(UpdatePlayerAbilitiesC2SPacket.class)
|
||||
public class MixinUpdatePlayerAbilitiesC2SPacket {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private boolean flying;
|
||||
|
||||
@Inject(method = "write", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeByte(I)Lio/netty/buffer/ByteBuf;", shift = At.Shift.BEFORE), cancellable = true)
|
||||
public void injectWrite(PacketByteBuf buf, CallbackInfo ci) {
|
||||
final PlayerAbilities abilities = MinecraftClient.getInstance().player.getAbilities();
|
||||
|
||||
byte b = 0;
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
if (this.flying) b = (byte) (b | 2); // Minecraft
|
||||
|
||||
if (abilities.invulnerable) b |= 1;
|
||||
if (abilities.allowFlying) b |= 4;
|
||||
if (abilities.creativeMode) b |= 8; // Protocol Hack Fixes
|
||||
|
||||
buf.writeByte(b);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:47 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.client.gui.screen.ingame.CommandBlockScreen;
|
||||
import net.minecraft.client.gui.widget.CyclingButtonWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(CommandBlockScreen.class)
|
||||
public abstract class MixinCommandBlockScreen {
|
||||
|
||||
@Shadow
|
||||
private CyclingButtonWidget<CommandBlockBlockEntity.Type> modeButton;
|
||||
|
||||
@Shadow
|
||||
private CyclingButtonWidget<Boolean> conditionalModeButton;
|
||||
@Shadow
|
||||
private CyclingButtonWidget<Boolean> redstoneTriggerButton;
|
||||
|
||||
@Shadow
|
||||
public abstract void updateCommandBlock();
|
||||
|
||||
@Inject(method = "init", at = @At("TAIL"))
|
||||
private void injectInit(CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
modeButton.visible = false;
|
||||
conditionalModeButton.visible = false;
|
||||
redstoneTriggerButton.visible = false;
|
||||
|
||||
updateCommandBlock();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_0.storage.ChatSession1_19_0;
|
||||
import de.florianmichael.viafabricplus.definition.v1_19_2.storage.ChatSession1_19_2;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ConnectScreen;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.network.encryption.PlayerKeyPair;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreen_1 {
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
ServerAddress field_33737;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
ConnectScreen field_2416;
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getHostName()Ljava/lang/String;", ordinal = 1))
|
||||
public String replaceAddress(InetSocketAddress instance) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) return field_33737.getAddress();
|
||||
|
||||
return instance.getHostString();
|
||||
}
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getPort()I"))
|
||||
public int replacePort(InetSocketAddress instance) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_17)) return field_33737.getPort();
|
||||
|
||||
return instance.getPort();
|
||||
}
|
||||
|
||||
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/Packet;)V", ordinal = 1, shift = At.Shift.BEFORE))
|
||||
public void setupConnectionSessions(CallbackInfo ci) {
|
||||
final UserConnection userConnection = field_2416.connection.channel.attr(ViaFabricPlus.LOCAL_USER_CONNECTION).get();
|
||||
|
||||
if (userConnection == null) {
|
||||
ViaLoadingBase.LOGGER.log(Level.WARNING, "ViaVersion userConnection is null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_19)) {
|
||||
return; // This disables the chat session emulation for all versions <= 1.18.2
|
||||
}
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
try {
|
||||
final PlayerKeyPair playerKeyPair = MinecraftClient.getInstance().getProfileKeys().fetchKeyPair().get().orElse(null);
|
||||
if (playerKeyPair != null) {
|
||||
final PlayerPublicKey.PublicKeyData publicKeyData = playerKeyPair.publicKey().data();
|
||||
final ProfileKey profileKey = new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), publicKeyData.keySignature());
|
||||
|
||||
userConnection.put(new ChatSession1_19_2(userConnection, profileKey, playerKeyPair.privateKey()));
|
||||
|
||||
if (ViaLoadingBase.getTargetVersion() == ProtocolVersion.v1_19) {
|
||||
final byte[] legacyKey = ((IPublicKeyData) (Object) publicKeyData).protocolhack_get1_19_0Key().array();
|
||||
if (legacyKey != null) {
|
||||
userConnection.put(new ChatSession1_19_0(userConnection, profileKey, playerKeyPair.privateKey(), legacyKey));
|
||||
} else {
|
||||
ViaLoadingBase.LOGGER.log(Level.WARNING, "Mojang removed the legacy key");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ViaLoadingBase.LOGGER.log(Level.WARNING, "Failed to fetch the key pair");
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
ViaLoadingBase.LOGGER.log(Level.WARNING, "Failed to fetch the key pair");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:47 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.network.packet.c2s.play.KeepAliveC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(DownloadingTerrainScreen.class)
|
||||
public class MixinDownloadingTerrainScreen extends Screen {
|
||||
|
||||
@Shadow @Final private long loadStartTime;
|
||||
@Shadow private boolean closeOnNextTick;
|
||||
@Shadow private boolean ready;
|
||||
@Unique
|
||||
private int protocolhack_tickCounter;
|
||||
|
||||
public MixinDownloadingTerrainScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void injectTick(CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
|
||||
protocolhack_tickCounter++;
|
||||
|
||||
if (protocolhack_tickCounter % 20 == 0) {
|
||||
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new KeepAliveC2SPacket(0));
|
||||
}
|
||||
}
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
final boolean isTimeOver = this.closeOnNextTick || System.currentTimeMillis() > this.loadStartTime + 2000L;
|
||||
|
||||
if (isTimeOver && this.client != null && this.client.player != null) {
|
||||
final BlockPos blockPos = this.client.player.getBlockPos();
|
||||
final boolean isWorldLoaded = this.client.world != null && this.client.world.isOutOfHeightLimit(blockPos.getY());
|
||||
|
||||
if (isWorldLoaded || this.client.worldRenderer.isRenderingReady(blockPos)) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
if (this.ready) {
|
||||
this.closeOnNextTick = true;
|
||||
}
|
||||
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersions;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GameModeSelectionScreen.class)
|
||||
public class MixinGameModeSelectionScreen {
|
||||
|
||||
@Mutable
|
||||
@Shadow @Final private static int UI_WIDTH;
|
||||
|
||||
@Unique
|
||||
private GameModeSelectionScreen.GameModeSelection[] protocolhack_unwrappedGameModes;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void fixUIWidth(CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
|
||||
final List<GameModeSelectionScreen.GameModeSelection> gameModeSelections = Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList();
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(LegacyProtocolVersions.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
|
||||
|
||||
protocolhack_unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
|
||||
UI_WIDTH = protocolhack_unwrappedGameModes.length * 31 - 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
|
||||
public GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
|
||||
return protocolhack_unwrappedGameModes;
|
||||
}
|
||||
return GameModeSelectionScreen.GameModeSelection.values();
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersions;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Mixin(GameModeSelectionScreen.GameModeSelection.class)
|
||||
public class MixinGameModeSelectionScreen_GameModeSelection {
|
||||
|
||||
@Shadow @Final public static GameModeSelectionScreen.GameModeSelection SURVIVAL;
|
||||
|
||||
@Shadow @Final public static GameModeSelectionScreen.GameModeSelection CREATIVE;
|
||||
|
||||
@Inject(method = "getCommand", at = @At("HEAD"), cancellable = true)
|
||||
private void oldCommand(CallbackInfoReturnable<String> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersions.r1_2_4tor1_2_5)) {
|
||||
cir.setReturnValue(
|
||||
"gamemode " + MinecraftClient.getInstance().getSession().getUsername() + ' ' + switch (((Enum<?>)(Object)this).ordinal()) {
|
||||
case 0, 3 -> 1;
|
||||
case 1, 2 -> 0;
|
||||
default -> throw new AssertionError();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
|
||||
public void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(ProtocolVersion.v1_8)) {
|
||||
switch ((GameModeSelectionScreen.GameModeSelection)(Object)this) {
|
||||
case CREATIVE -> cir.setReturnValue(Optional.of(SURVIVAL));
|
||||
case SURVIVAL -> {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThan(LegacyProtocolVersions.r1_2_4tor1_2_5)) {
|
||||
cir.setReturnValue(Optional.of(CREATIVE));
|
||||
} else {
|
||||
cir.setReturnValue(Optional.of(GameModeSelectionScreen.GameModeSelection.ADVENTURE));
|
||||
}
|
||||
}
|
||||
case ADVENTURE -> {
|
||||
cir.setReturnValue(Optional.of(CREATIVE));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:49 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.block.entity.JigsawBlockEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.JigsawBlockScreen;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.CyclingButtonWidget;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(JigsawBlockScreen.class)
|
||||
public class MixinJigsawBlockScreen extends Screen {
|
||||
|
||||
@Shadow
|
||||
private TextFieldWidget nameField;
|
||||
|
||||
@Shadow
|
||||
private CyclingButtonWidget<JigsawBlockEntity.Joint> jointRotationButton;
|
||||
|
||||
@Shadow
|
||||
private TextFieldWidget targetField;
|
||||
|
||||
public MixinJigsawBlockScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void injectInit(CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
nameField.active = false;
|
||||
jointRotationButton.active = false;
|
||||
int index = children().indexOf(jointRotationButton);
|
||||
((ClickableWidget) children().get(index + 1)).active = false; // levels slider
|
||||
((ClickableWidget) children().get(index + 2)).active = false; // keep jigsaws toggle
|
||||
((ClickableWidget) children().get(index + 3)).active = false; // generate button
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
public void injectRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
nameField.setText(targetField.getText());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 6/24/22, 8:50 PM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.Text;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ingame.StructureBlockScreen$1")
|
||||
public class MixinStructureBlockScreen_1 extends TextFieldWidget {
|
||||
|
||||
public MixinStructureBlockScreen_1(TextRenderer textRenderer, int x, int y, int width, int height, TextFieldWidget copyFrom, Text text) {
|
||||
super(textRenderer, x, y, width, height, copyFrom, text);
|
||||
}
|
||||
|
||||
@Inject(method = "charTyped(CI)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void onCharTyped(char chr, int keyCode, CallbackInfoReturnable<Boolean> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2))
|
||||
ci.setReturnValue(super.charTyped(chr, keyCode));
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.hud;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.client.gui.hud.ClientBossBar;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.hud.BossBarHud$1")
|
||||
public class MixinBossBarHud_1 {
|
||||
|
||||
@Redirect(method = "updateProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ClientBossBar;setPercent(F)V"))
|
||||
public void nullSafety(ClientBossBar instance, float percent) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (instance != null) instance.setPercent(percent);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.merchant;
|
||||
|
||||
import de.florianmichael.viafabricplus.value.ValueHolder;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket;
|
||||
import net.minecraft.screen.MerchantScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MerchantScreen.class)
|
||||
public abstract class MixinMerchantScreen extends HandledScreen<MerchantScreenHandler> {
|
||||
|
||||
@Shadow
|
||||
private int selectedIndex;
|
||||
|
||||
@Unique
|
||||
private int protocolhack_previousRecipeIndex;
|
||||
|
||||
public MixinMerchantScreen(MerchantScreenHandler handler, PlayerInventory inventory, Text title) {
|
||||
super(handler, inventory, title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("HEAD"))
|
||||
public void reset(CallbackInfo ci) {
|
||||
protocolhack_previousRecipeIndex = 0;
|
||||
}
|
||||
|
||||
@Inject(method = "syncRecipeIndex", at = @At("HEAD"))
|
||||
public void smoothOutRecipeIndex(CallbackInfo ci) {
|
||||
if (ValueHolder.smoothOutMerchantScreens.getValue()) {
|
||||
if (protocolhack_previousRecipeIndex != selectedIndex) {
|
||||
int direction = protocolhack_previousRecipeIndex < selectedIndex ? 1 : -1;
|
||||
for (int smooth = protocolhack_previousRecipeIndex + direction /* don't send the page we already are on */; smooth != selectedIndex; smooth += direction) {
|
||||
client.getNetworkHandler().sendPacket(new SelectMerchantTradeC2SPacket(smooth));
|
||||
}
|
||||
protocolhack_previousRecipeIndex = selectedIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 7/9/22, 10:26 AM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.merchant;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.screen.MerchantScreenHandler;
|
||||
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;
|
||||
|
||||
@Mixin(MerchantScreenHandler.class)
|
||||
public class MixinMerchantScreenHandler {
|
||||
|
||||
@Inject(method = "switchTo", at = @At("HEAD"), cancellable = true)
|
||||
private void injectSwitchTo(int recipeId, CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
ci.cancel(); // no lmao?
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.screenhandler;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(targets = "net.minecraft.screen.BrewingStandScreenHandler$FuelSlot")
|
||||
public class MixinBrewingStandScreenHandler_FuelSlot extends Slot {
|
||||
|
||||
public MixinBrewingStandScreenHandler_FuelSlot(Inventory inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
}
|
||||
|
||||
@Inject(method = "matches(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private static void removeFuelSlot(CallbackInfoReturnable<Boolean> ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return ViaLoadingBase.getTargetVersion().isNewerThan(ProtocolVersion.v1_8);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 7/9/22, 10:28 AM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.screenhandler;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.screen.AbstractRecipeScreenHandler;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
|
||||
@Mixin(PlayerScreenHandler.class)
|
||||
public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandler<CraftingInventory> {
|
||||
|
||||
public MixinPlayerScreenHandler(ScreenHandlerType<?> screenHandlerType, int i) {
|
||||
super(screenHandlerType, i);
|
||||
}
|
||||
|
||||
@Redirect(method = "<init>",
|
||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler$2;<init>(Lnet/minecraft/screen/PlayerScreenHandler;Lnet/minecraft/inventory/Inventory;III)V")),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler;addSlot(Lnet/minecraft/screen/slot/Slot;)Lnet/minecraft/screen/slot/Slot;", ordinal = 0))
|
||||
private Slot redirectAddOffhandSlot(PlayerScreenHandler screenHandler, Slot slot) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8))
|
||||
return null;
|
||||
return addSlot(slot);
|
||||
}
|
||||
|
||||
@SuppressWarnings("InvalidInjectorMethodSignature")
|
||||
@ModifyVariable(method = "quickMove", ordinal = 0, at = @At(value = "STORE", ordinal = 0))
|
||||
private EquipmentSlot injectTransferSlot(EquipmentSlot slot) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && slot == EquipmentSlot.OFFHAND)
|
||||
return EquipmentSlot.MAINHAND;
|
||||
else
|
||||
return slot;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) FlorianMichael as EnZaXD 2022
|
||||
* Created on 7/9/22, 1:46 AM
|
||||
*
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.0--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license.
|
||||
*/
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.screen.screenhandler;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ScreenHandler.class)
|
||||
public class MixinScreenHandler implements IScreenHandler {
|
||||
|
||||
@Unique
|
||||
private short protocolhack_lastActionId = 0;
|
||||
|
||||
@Inject(method = "internalOnSlotClick", at = @At("HEAD"), cancellable = true)
|
||||
private void injectInternalOnSlotClick(int slot, int clickData, SlotActionType actionType, PlayerEntity player, CallbackInfo ci) {
|
||||
if (ViaLoadingBase.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8) && actionType == SlotActionType.SWAP && clickData == 40) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public short protocolhack_getAndIncrementLastActionId() {
|
||||
return ++protocolhack_lastActionId;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.florianmichael.everyprotocol.injection.mixin.vialoadingbase;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.vialoadingbase;
|
||||
|
||||
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||
import de.florianmichael.vialoadingbase.internal.viaversion.CustomViaConfig;
|
@ -1,9 +1,9 @@
|
||||
package de.florianmichael.everyprotocol.injection.mixin.viaversion;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.everyprotocol.injection.access.IPacketWrapperImpl;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPacketWrapperImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* --FLORIAN MICHAEL PRIVATE LICENCE v1.2--
|
||||
*
|
||||
* This file / project is protected and is the intellectual property of Florian Michael (aka. EnZaXD),
|
||||
* any use (be it private or public, be it copying or using for own use, be it publishing or modifying) of this
|
||||
* file / project is prohibited. It requires in that use a written permission with official signature of the owner
|
||||
* "Florian Michael". "Florian Michael" receives the right to control and manage this file / project. This right is not
|
||||
* cancelled by copying or removing the license and in case of violation a criminal consequence is to be expected.
|
||||
* The owner "Florian Michael" is free to change this license. The creator assumes no responsibility for any infringements
|
||||
* that have arisen, are arising or will arise from this project / file. If this licence is used anywhere,
|
||||
* the latest version published by the author Florian Michael (aka EnZaXD) always applies automatically.
|
||||
*
|
||||
* Changelog:
|
||||
* v1.0:
|
||||
* Added License
|
||||
* v1.1:
|
||||
* Ownership withdrawn
|
||||
* v1.2:
|
||||
* Version-independent validity and automatic renewal
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.platform;
|
||||
|
||||
public class PreNettyConstants {
|
||||
|
||||
public static final String DECODER = "via-legacy-decoder";
|
||||
public static final String ENCODER = "via-legacy-encoder";
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package de.florianmichael.viafabricplus.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.api.version.ComparableProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.api.version.InternalProtocolList;
|
||||
|
||||
public class ProtocolRange {
|
||||
private final ComparableProtocolVersion lowerBound;
|
||||
private final ComparableProtocolVersion upperBound;
|
||||
|
||||
public ProtocolRange(ProtocolVersion lowerBound, ProtocolVersion upperBound) {
|
||||
if (lowerBound == null && upperBound == null) {
|
||||
throw new RuntimeException("Invalid protocol range");
|
||||
}
|
||||
this.lowerBound = InternalProtocolList.fromProtocolVersion(lowerBound);
|
||||
this.upperBound = InternalProtocolList.fromProtocolVersion(upperBound);
|
||||
}
|
||||
|
||||
public static ProtocolRange andNewer(final ProtocolVersion version) {
|
||||
return new ProtocolRange(null, version);
|
||||
}
|
||||
|
||||
public static ProtocolRange singleton(final ProtocolVersion version) {
|
||||
return new ProtocolRange(version, version);
|
||||
}
|
||||
|
||||
public static ProtocolRange andOlder(final ProtocolVersion version) {
|
||||
return new ProtocolRange(version, null);
|
||||
}
|
||||
|
||||
public boolean contains(final ComparableProtocolVersion protocolVersion) {
|
||||
if (this.lowerBound != null && this.lowerBound.getIndex() < protocolVersion.getIndex()) return false;
|
||||
|
||||
return this.upperBound == null || this.upperBound.getIndex() <= protocolVersion.getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (lowerBound == null) return upperBound.getName() + "+";
|
||||
if (upperBound == null) return lowerBound.getName() + "-";
|
||||
if (lowerBound == upperBound) return lowerBound.getName();
|
||||
|
||||
return lowerBound.getName() + " - " + upperBound.getName();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user