mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
Migrate ViaFabricPlus to ViaVersion's new ProtocolVersion API (#354)
* Updated Via API usage * Thanks for not pushing this class IntelliJ * Updated Via API usage * Updated Via API usage * Updated MixinProtocolVersion * Moved auto detect to bottom of protocol list * Use sorted version list for GUIs * Fixed compile errors and startup * Fixed config saving and loading * Updated DEVELOPER_API file --------- Co-authored-by: RaphiMC <50594595+RaphiMC@users.noreply.github.com>
This commit is contained in:
parent
9d3877a9f8
commit
da73e8ba19
@ -53,9 +53,9 @@ ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> {
|
||||
|
||||
## Get and set the current protocol version
|
||||
```java
|
||||
final VersionEnum version = ProtocolHack.getTargetVersion();
|
||||
if (version == VersionEnum.r1_8) {
|
||||
ProtocolHack.setTargetVersion(VersionEnum.r1_9);
|
||||
final ProtocolVersion version = ProtocolHack.getTargetVersion();
|
||||
if (version == ProtocolVersion.v1_8) {
|
||||
ProtocolHack.setTargetVersion(ProtocolVersion.v1_9);
|
||||
}
|
||||
```
|
||||
|
||||
@ -70,7 +70,7 @@ final ClientConnection connection = channel.attr(ProtocolHack.CLIENT_CONNECTION_
|
||||
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
|
||||
// If you need a dummy user connection for testing, you can use this method
|
||||
final UserConnection cursedDummy = ProtocolHack.createDummyUserConnection(ProtocolHack.NATIVE_VERSION, VersionEnum.r1_18_2);
|
||||
final UserConnection cursedDummy = ProtocolHack.createDummyUserConnection(ProtocolHack.NATIVE_VERSION, ProtocolVersion.v1_18_2);
|
||||
// The cursedDummy field now contains all protocols from the native version to 1.18.2
|
||||
```
|
||||
|
||||
@ -87,7 +87,7 @@ final VersionRange range = ItemRegistryDiff.ITEM_DIFF.get(Items.WRITABLE_BOOK);
|
||||
|
||||
// The Range class then contains all versions in which the item occurs.
|
||||
// https://github.com/ViaVersion/ViaLoader
|
||||
if (ItemRegistryDiff.contains(Items.STONE, VersionRange.andOlder(VersionEnum.r1_8))) {
|
||||
if (ItemRegistryDiff.contains(Items.STONE, VersionRange.andOlder(ProtocolVersion.v1_8))) {
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
@ -14,8 +14,8 @@ maven_group=de.florianmichael
|
||||
archives_base_name=viafabricplus
|
||||
|
||||
# ViaVersion Libraries
|
||||
viaversion_version=4.10.0-24w06a-SNAPSHOT
|
||||
viabackwards_version=4.10.0-24w06a-SNAPSHOT
|
||||
viaversion_version=4.10.0-24w07a-SNAPSHOT
|
||||
viabackwards_version=4.10.0-24w07a-SNAPSHOT
|
||||
vialegacy_version=2.2.22-SNAPSHOT
|
||||
viaaprilfools_version=2.0.11-SNAPSHOT
|
||||
vialoader_version=2.2.13-SNAPSHOT
|
||||
|
@ -22,7 +22,6 @@ package de.florianmichael.viafabricplus;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension;
|
||||
import de.florianmichael.viafabricplus.save.SaveManager;
|
||||
import de.florianmichael.viafabricplus.settings.SettingsManager;
|
||||
import de.florianmichael.viafabricplus.util.ClassLoaderPriorityUtil;
|
||||
@ -64,7 +63,6 @@ public class ViaFabricPlus {
|
||||
public void bootstrap() {
|
||||
directory.mkdir();
|
||||
ClassLoaderPriorityUtil.loadOverridingJars(directory); // Load overriding jars first so other code can access the new classes
|
||||
VersionEnumExtension.init(); // Register extra VersionEnum values
|
||||
|
||||
settingsManager = new SettingsManager();
|
||||
saveManager = new SaveManager(settingsManager);
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.event;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
/**
|
||||
* This event is fired when the user changes the target version in the screen, or if the user joins a server with a different version.
|
||||
@ -35,6 +35,6 @@ public interface ChangeProtocolVersionCallback {
|
||||
}
|
||||
});
|
||||
|
||||
void onChangeProtocolVersion(final VersionEnum oldVersion, final VersionEnum newVersion);
|
||||
void onChangeProtocolVersion(final ProtocolVersion oldVersion, final ProtocolVersion newVersion);
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.fixes.data.EntityDimensionDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.classic.GridItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.data.EntityDimensionDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.ArmorHudEmulation1_8;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
@ -36,9 +37,10 @@ import net.minecraft.client.font.FontStorage;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -108,7 +110,7 @@ public class ClientsideFixes {
|
||||
}
|
||||
|
||||
// Rebuilds the item selection screen grid
|
||||
if (newVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (newVersion.olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
GridItemSelectionScreen.INSTANCE.itemGrid = null;
|
||||
}
|
||||
}));
|
||||
@ -123,7 +125,7 @@ public class ClientsideFixes {
|
||||
* @return The maximum chat length
|
||||
*/
|
||||
public static int getChatLength() {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler();
|
||||
final ExtensionProtocolMetadataStorage extensionProtocol = ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection().get(ExtensionProtocolMetadataStorage.class);
|
||||
|
||||
@ -132,9 +134,9 @@ public class ClientsideFixes {
|
||||
} else {
|
||||
return 64 - (MinecraftClient.getInstance().getSession().getUsername().length() + 2);
|
||||
}
|
||||
} else if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
} else if (ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
return 512;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
|
||||
return 100;
|
||||
} else {
|
||||
return 256;
|
||||
|
@ -19,11 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@ -38,121 +39,121 @@ public class EntityDimensionDiff {
|
||||
/**
|
||||
* A map of entity types to a map of versions to dimensions.
|
||||
*/
|
||||
private static final Map<EntityType<?>, Map<VersionEnum, EntityDimensions>> ENTITY_DIMENSIONS = linkedHashMap(
|
||||
private static final Map<EntityType<?>, Map<ProtocolVersion, EntityDimensions>> ENTITY_DIMENSIONS = linkedHashMap(
|
||||
EntityType.WITHER, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.9F, 4.0F),
|
||||
VersionEnum.r1_8, EntityType.WITHER.getDimensions()
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.9F, 4.0F),
|
||||
ProtocolVersion.v1_8, EntityType.WITHER.getDimensions()
|
||||
),
|
||||
EntityType.SILVERFISH, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.3F, 0.7F),
|
||||
VersionEnum.r1_8, EntityType.SILVERFISH.getDimensions()
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.3F, 0.7F),
|
||||
ProtocolVersion.v1_8, EntityType.SILVERFISH.getDimensions()
|
||||
),
|
||||
EntityType.SNOW_GOLEM, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.4F, 1.8F),
|
||||
VersionEnum.r1_8, EntityType.SNOW_GOLEM.getDimensions()
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.4F, 1.8F),
|
||||
ProtocolVersion.v1_8, EntityType.SNOW_GOLEM.getDimensions()
|
||||
),
|
||||
EntityType.ZOMBIE, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_8, EntityDimensions.fixed(EntityType.ZOMBIE.getDimensions().width, EntityType.ZOMBIE.getDimensions().height),
|
||||
VersionEnum.r1_9, EntityType.ZOMBIE.getDimensions()
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.6F, 1.8F),
|
||||
ProtocolVersion.v1_8, EntityDimensions.fixed(EntityType.ZOMBIE.getDimensions().width, EntityType.ZOMBIE.getDimensions().height),
|
||||
ProtocolVersion.v1_9, EntityType.ZOMBIE.getDimensions()
|
||||
),
|
||||
EntityType.CHICKEN, linkedHashMap(
|
||||
VersionEnum.b1_7tob1_7_3, EntityDimensions.changing(0.3F, 0.4F),
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.3F, 0.7F),
|
||||
VersionEnum.r1_8, EntityType.CHICKEN.getDimensions()
|
||||
LegacyProtocolVersion.b1_7tob1_7_3, EntityDimensions.changing(0.3F, 0.4F),
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.3F, 0.7F),
|
||||
ProtocolVersion.v1_8, EntityType.CHICKEN.getDimensions()
|
||||
),
|
||||
EntityType.SHEEP, linkedHashMap(
|
||||
VersionEnum.c0_28toc0_30, EntityDimensions.changing(1.4F, 1.72F),
|
||||
VersionEnum.a1_0_15, EntityType.SHEEP.getDimensions()
|
||||
LegacyProtocolVersion.c0_28toc0_30, EntityDimensions.changing(1.4F, 1.72F),
|
||||
LegacyProtocolVersion.a1_0_15, EntityType.SHEEP.getDimensions()
|
||||
),
|
||||
EntityType.OCELOT, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.6F, 0.8F),
|
||||
VersionEnum.r1_8, EntityType.OCELOT.getDimensions()
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.6F, 0.8F),
|
||||
ProtocolVersion.v1_8, EntityType.OCELOT.getDimensions()
|
||||
),
|
||||
EntityType.BOAT, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(1.5F, 0.6F),
|
||||
VersionEnum.r1_9, EntityType.BOAT.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(1.5F, 0.6F),
|
||||
ProtocolVersion.v1_9, EntityType.BOAT.getDimensions()
|
||||
),
|
||||
EntityType.CREEPER, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_9, EntityType.CREEPER.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.6F, 1.8F),
|
||||
ProtocolVersion.v1_9, EntityType.CREEPER.getDimensions()
|
||||
),
|
||||
EntityType.IRON_GOLEM, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(1.4F, 2.9F),
|
||||
VersionEnum.r1_9, EntityType.IRON_GOLEM.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(1.4F, 2.9F),
|
||||
ProtocolVersion.v1_9, EntityType.IRON_GOLEM.getDimensions()
|
||||
),
|
||||
EntityType.SKELETON, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 1.95F),
|
||||
VersionEnum.r1_9, EntityType.SKELETON.getDimensions()
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.6F, 1.8F),
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.6F, 1.95F),
|
||||
ProtocolVersion.v1_9, EntityType.SKELETON.getDimensions()
|
||||
),
|
||||
EntityType.WITHER_SKELETON, linkedHashMap(
|
||||
VersionEnum.r1_4_6tor1_4_7, EntityDimensions.changing(0.72F, 2.16F),
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.72F, 2.34F),
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.72F, 2.535F),
|
||||
VersionEnum.r1_9, EntityType.WITHER_SKELETON.getDimensions()
|
||||
LegacyProtocolVersion.r1_4_6tor1_4_7, EntityDimensions.changing(0.72F, 2.16F),
|
||||
ProtocolVersion.v1_7_6, EntityDimensions.changing(0.72F, 2.34F),
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.72F, 2.535F),
|
||||
ProtocolVersion.v1_9, EntityType.WITHER_SKELETON.getDimensions()
|
||||
),
|
||||
EntityType.COW, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.9F, 1.3F),
|
||||
VersionEnum.r1_9, EntityType.COW.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.9F, 1.3F),
|
||||
ProtocolVersion.v1_9, EntityType.COW.getDimensions()
|
||||
),
|
||||
EntityType.HORSE, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(1.4F, 1.6F),
|
||||
VersionEnum.r1_9, EntityType.HORSE.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(1.4F, 1.6F),
|
||||
ProtocolVersion.v1_9, EntityType.HORSE.getDimensions()
|
||||
),
|
||||
EntityType.MOOSHROOM, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.9F, 1.3F),
|
||||
VersionEnum.r1_9, EntityType.MOOSHROOM.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.9F, 1.3F),
|
||||
ProtocolVersion.v1_9, EntityType.MOOSHROOM.getDimensions()
|
||||
),
|
||||
EntityType.RABBIT, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 0.7F),
|
||||
VersionEnum.r1_9, EntityType.RABBIT.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.6F, 0.7F),
|
||||
ProtocolVersion.v1_9, EntityType.RABBIT.getDimensions()
|
||||
),
|
||||
EntityType.SQUID, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.95F, 0.95F),
|
||||
VersionEnum.r1_9, EntityType.SQUID.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.95F, 0.95F),
|
||||
ProtocolVersion.v1_9, EntityType.SQUID.getDimensions()
|
||||
),
|
||||
EntityType.VILLAGER, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_9, EntityType.VILLAGER.getDimensions()
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.6F, 1.8F),
|
||||
ProtocolVersion.v1_9, EntityType.VILLAGER.getDimensions()
|
||||
),
|
||||
EntityType.WOLF, linkedHashMap(
|
||||
VersionEnum.r1_1, EntityDimensions.changing(0.8F, 0.8F),
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 0.8F),
|
||||
VersionEnum.r1_9, EntityType.WOLF.getDimensions()
|
||||
LegacyProtocolVersion.r1_1, EntityDimensions.changing(0.8F, 0.8F),
|
||||
ProtocolVersion.v1_8, EntityDimensions.changing(0.6F, 0.8F),
|
||||
ProtocolVersion.v1_9, EntityType.WOLF.getDimensions()
|
||||
),
|
||||
EntityType.DRAGON_FIREBALL, linkedHashMap(
|
||||
VersionEnum.r1_10, EntityDimensions.changing(0.3125F, 0.3125F),
|
||||
VersionEnum.r1_11, EntityType.DRAGON_FIREBALL.getDimensions()
|
||||
ProtocolVersion.v1_10, EntityDimensions.changing(0.3125F, 0.3125F),
|
||||
ProtocolVersion.v1_11, EntityType.DRAGON_FIREBALL.getDimensions()
|
||||
),
|
||||
EntityType.LEASH_KNOT, linkedHashMap(
|
||||
VersionEnum.r1_16_4tor1_16_5, EntityDimensions.changing(0.5F, 0.5F),
|
||||
VersionEnum.r1_17, EntityType.LEASH_KNOT.getDimensions()
|
||||
ProtocolVersion.v1_16_4, EntityDimensions.changing(0.5F, 0.5F),
|
||||
ProtocolVersion.v1_17, EntityType.LEASH_KNOT.getDimensions()
|
||||
),
|
||||
EntityType.SLIME, linkedHashMap(
|
||||
VersionEnum.r1_13_2, EntityDimensions.changing(2F, 2F),
|
||||
VersionEnum.r1_14, EntityType.SLIME.getDimensions()
|
||||
ProtocolVersion.v1_13_2, EntityDimensions.changing(2F, 2F),
|
||||
ProtocolVersion.v1_14, EntityType.SLIME.getDimensions()
|
||||
),
|
||||
EntityType.MAGMA_CUBE, linkedHashMap(
|
||||
VersionEnum.r1_13_2, EntityDimensions.changing(2F, 2F),
|
||||
VersionEnum.r1_14, EntityType.MAGMA_CUBE.getDimensions()
|
||||
ProtocolVersion.v1_13_2, EntityDimensions.changing(2F, 2F),
|
||||
ProtocolVersion.v1_14, EntityType.MAGMA_CUBE.getDimensions()
|
||||
),
|
||||
EntityType.ARROW, linkedHashMap(
|
||||
VersionEnum.c0_28toc0_30, EntityDimensions.changing(0.3F, 0.5F),
|
||||
VersionEnum.a1_0_15, EntityType.ARROW.getDimensions()
|
||||
LegacyProtocolVersion.c0_28toc0_30, EntityDimensions.changing(0.3F, 0.5F),
|
||||
LegacyProtocolVersion.a1_0_15, EntityType.ARROW.getDimensions()
|
||||
)
|
||||
);
|
||||
|
||||
static {
|
||||
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> ENTITY_DIMENSIONS.forEach((entityType, dimensionMap) -> {
|
||||
for (Map.Entry<VersionEnum, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final VersionEnum version = entry.getKey();
|
||||
for (Map.Entry<ProtocolVersion, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final ProtocolVersion version = entry.getKey();
|
||||
final EntityDimensions dimensions = entry.getValue();
|
||||
if (oldVersion.isNewerThan(version) && newVersion.isOlderThanOrEqualTo(version)) {
|
||||
if (oldVersion.newerThan(version) && newVersion.olderThanOrEqualTo(version)) {
|
||||
entityType.dimensions = dimensions;
|
||||
break;
|
||||
}
|
||||
if (newVersion.isNewerThanOrEqualTo(version) && oldVersion.isOlderThanOrEqualTo(version)) {
|
||||
if (newVersion.newerThanOrEqualTo(version) && oldVersion.olderThanOrEqualTo(version)) {
|
||||
entityType.dimensions = dimensions;
|
||||
}
|
||||
}
|
||||
@ -167,7 +168,7 @@ public class EntityDimensionDiff {
|
||||
* @param entityType The {@link EntityType} to get the dimensions for.
|
||||
* @return The dimensions for the given {@link EntityType} or null if there are none. The map is unmodifiable.
|
||||
*/
|
||||
public static Map<VersionEnum, EntityDimensions> getEntityDimensions(final EntityType<?> entityType) {
|
||||
public static Map<ProtocolVersion, EntityDimensions> getEntityDimensions(final EntityType<?> entityType) {
|
||||
if (!ENTITY_DIMENSIONS.containsKey(entityType)) {
|
||||
return null;
|
||||
}
|
||||
@ -176,19 +177,19 @@ public class EntityDimensionDiff {
|
||||
|
||||
/**
|
||||
* @param entityType The {@link EntityType} to get the dimensions for.
|
||||
* @param version The {@link VersionEnum} to get the dimensions for.
|
||||
* @return The closest dimensions for the given {@link EntityType} and {@link VersionEnum} or null if there are none.
|
||||
* @param version The {@link ProtocolVersion} to get the dimensions for.
|
||||
* @return The closest dimensions for the given {@link EntityType} and {@link ProtocolVersion} or null if there are none.
|
||||
*/
|
||||
public static EntityDimensions getEntityDimensions(final EntityType<?> entityType, final VersionEnum version) {
|
||||
final Map<VersionEnum, EntityDimensions> dimensionMap = getEntityDimensions(entityType);
|
||||
public static EntityDimensions getEntityDimensions(final EntityType<?> entityType, final ProtocolVersion version) {
|
||||
final Map<ProtocolVersion, EntityDimensions> dimensionMap = getEntityDimensions(entityType);
|
||||
if (dimensionMap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
EntityDimensions closestDimensions = null;
|
||||
VersionEnum closestVersion = null;
|
||||
ProtocolVersion closestVersion = null;
|
||||
|
||||
for (Map.Entry<VersionEnum, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
for (Map.Entry<ProtocolVersion, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final var currentVersion = entry.getKey();
|
||||
final var currentDimensions = entry.getValue();
|
||||
|
||||
@ -197,10 +198,11 @@ public class EntityDimensionDiff {
|
||||
}
|
||||
|
||||
// If the current version is closer to the version you are looking for
|
||||
if (closestVersion == null || Math.abs(version.ordinal() - currentVersion.ordinal()) < Math.abs(version.ordinal() - closestVersion.ordinal())) {
|
||||
// TODO: Fix
|
||||
/*if (closestVersion == null || Math.abs(version.ordinal() - currentVersion.ordinal()) < Math.abs(version.ordinal() - closestVersion.ordinal())) {
|
||||
closestVersion = currentVersion;
|
||||
closestDimensions = currentDimensions;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
return closestDimensions;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,12 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -1109,7 +1109,7 @@ public enum Material1_19_4 {
|
||||
* @return The material of the block for game version 1.19.4
|
||||
*/
|
||||
public static Material1_19_4 getMaterial(final Block block) {
|
||||
if (block instanceof ShulkerBoxBlock && ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_14)) {
|
||||
if (block instanceof ShulkerBoxBlock && ProtocolHack.getTargetVersion().olderThan(ProtocolVersion.v1_14)) {
|
||||
return STONE;
|
||||
} else {
|
||||
return MATERIALS.get(block);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,11 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.minecraft.SaveVersion;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -34,57 +35,58 @@ import java.util.Map;
|
||||
*/
|
||||
public class ResourcePackHeaderDiff {
|
||||
|
||||
private final static Map<VersionEnum, GameVersion> GAME_VERSION_DIFF = new HashMap<>();
|
||||
private final static Map<ProtocolVersion, GameVersion> GAME_VERSION_DIFF = new HashMap<>();
|
||||
|
||||
static {
|
||||
registerVersion(VersionEnum.r1_20_3tor1_20_4, 22, "1.20.4");
|
||||
registerVersion(VersionEnum.r1_20_2, 18, "1.20.2");
|
||||
registerVersion(VersionEnum.r1_20tor1_20_1, 15, "1.20.1");
|
||||
registerVersion(VersionEnum.r1_19_4, 13, "1.19.4");
|
||||
registerVersion(VersionEnum.r1_19_3, 12, "1.19.3");
|
||||
registerVersion(VersionEnum.r1_19_1tor1_19_2, 9, "1.19.2");
|
||||
registerVersion(VersionEnum.r1_19, 9, "1.19");
|
||||
registerVersion(VersionEnum.r1_18_2, 8, "1.18.2");
|
||||
registerVersion(VersionEnum.r1_18tor1_18_1, 8, "1.18.1");
|
||||
registerVersion(VersionEnum.r1_17_1, 7, "1.17.1");
|
||||
registerVersion(VersionEnum.r1_17, 7, "1.17");
|
||||
registerVersion(VersionEnum.r1_16_4tor1_16_5, 6, "1.16.5");
|
||||
registerVersion(VersionEnum.r1_16_3, 6, "1.16.3");
|
||||
registerVersion(VersionEnum.r1_16_2, 6, "1.16.2");
|
||||
registerVersion(VersionEnum.r1_16_1, 5, "1.16.1");
|
||||
registerVersion(VersionEnum.r1_16, 5, "1.16");
|
||||
registerVersion(VersionEnum.r1_15_2, 5, "1.15.2");
|
||||
registerVersion(VersionEnum.r1_15_1, 5, "1.15.1");
|
||||
registerVersion(VersionEnum.r1_15, 5, "1.15");
|
||||
registerVersion(VersionEnum.r1_14_4, 4, "1.14.4");
|
||||
registerVersion(VersionEnum.r1_14_3, 4, "1.14.3");
|
||||
registerVersion(VersionEnum.r1_14_2, 4, "1.14.2");
|
||||
registerVersion(VersionEnum.r1_14_1, 4, "1.14.1");
|
||||
registerVersion(VersionEnum.r1_14, 4, "1.14");
|
||||
registerVersion(VersionEnum.r1_13_2, 4, "1.13.2");
|
||||
registerVersion(VersionEnum.r1_13_1, 4, "1.13.1");
|
||||
registerVersion(VersionEnum.r1_13, 4, "1.13");
|
||||
registerVersion(VersionEnum.r1_12_2, 3, "1.12.2");
|
||||
registerVersion(VersionEnum.r1_12_1, 3, "1.12.1");
|
||||
registerVersion(VersionEnum.r1_12, 3, "1.12");
|
||||
registerVersion(VersionEnum.r1_11_1to1_11_2, 3, "1.11.2");
|
||||
registerVersion(VersionEnum.r1_11, 3, "1.11");
|
||||
registerVersion(VersionEnum.r1_10, 2, "1.10.2");
|
||||
registerVersion(VersionEnum.r1_9_3tor1_9_4, 2, "1.9.4");
|
||||
registerVersion(VersionEnum.r1_9_2, 2, "1.9.2");
|
||||
registerVersion(VersionEnum.r1_9_1, 2, "1.9.1");
|
||||
registerVersion(VersionEnum.r1_9, 2, "1.9");
|
||||
registerVersion(VersionEnum.r1_8, 1, "1.8.9");
|
||||
registerVersion(VersionEnum.r1_7_6tor1_7_10, 1, "1.7.10");
|
||||
registerVersion(VersionEnum.r1_7_2tor1_7_5, 1, "1.7.5");
|
||||
registerVersion(ProtocolVersion.v1_20_3, 22, "1.20.4");
|
||||
registerVersion(ProtocolVersion.v1_20_2, 18, "1.20.2");
|
||||
registerVersion(ProtocolVersion.v1_20, 15, "1.20.1");
|
||||
registerVersion(ProtocolVersion.v1_19_4, 13, "1.19.4");
|
||||
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.1");
|
||||
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");
|
||||
registerVersion(ProtocolVersion.v1_14_1, 4, "1.14.1");
|
||||
registerVersion(ProtocolVersion.v1_14, 4, "1.14");
|
||||
registerVersion(ProtocolVersion.v1_13_2, 4, "1.13.2");
|
||||
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_2, 1, "1.7.5");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the registry is outdated.
|
||||
*/
|
||||
public static void checkOutdated() {
|
||||
for (VersionEnum version : VersionEnum.OFFICIAL_SUPPORTED_PROTOCOLS) {
|
||||
if (version.getProtocol().isSnapshot()) continue;
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
if (version.isSnapshot()) continue;
|
||||
if (version.getVersionType() != VersionType.RELEASE) continue;
|
||||
if (!GAME_VERSION_DIFF.containsKey(version)) {
|
||||
throw new RuntimeException("The version " + version + " has no pack format registered");
|
||||
}
|
||||
@ -92,10 +94,10 @@ public class ResourcePackHeaderDiff {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version The {@link VersionEnum} to get the {@link GameVersion} for.
|
||||
* @return The {@link GameVersion} for the given {@link VersionEnum}.
|
||||
* @param version The {@link ProtocolVersion} to get the {@link GameVersion} for.
|
||||
* @return The {@link GameVersion} for the given {@link ProtocolVersion}.
|
||||
*/
|
||||
public static GameVersion get(final VersionEnum version) {
|
||||
public static GameVersion get(final ProtocolVersion version) {
|
||||
if (!GAME_VERSION_DIFF.containsKey(version)) {
|
||||
return SharedConstants.getGameVersion();
|
||||
} else {
|
||||
@ -103,11 +105,11 @@ public class ResourcePackHeaderDiff {
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerVersion(final VersionEnum version, final int packFormat, final String name) {
|
||||
private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name) {
|
||||
registerVersion(version, packFormat, name, name);
|
||||
}
|
||||
|
||||
private static void registerVersion(final VersionEnum version, final int packFormat, final String name, final String id) {
|
||||
private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name, final String id) {
|
||||
GAME_VERSION_DIFF.put(version, new GameVersion() {
|
||||
|
||||
@Override
|
||||
@ -127,7 +129,7 @@ public class ResourcePackHeaderDiff {
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return version.getProtocol().getOriginalVersion();
|
||||
return version.getOriginalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.entity.BannerBlockEntity;
|
||||
import net.minecraft.inventory.RecipeInputInventory;
|
||||
@ -35,7 +36,6 @@ import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
||||
|
||||
@ -76,7 +76,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
||||
|
||||
BannerPattern_1_13_2 pattern = getBannerPattern(inv);
|
||||
if (pattern != null) {
|
||||
DyeColor color = ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
|
||||
DyeColor color = ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
Item item = inv.getStack(i).getItem();
|
||||
if (item instanceof DyeItem dyeItem) {
|
||||
@ -138,7 +138,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!foundBaseItem || (!foundDye && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_10))) matches = false;
|
||||
if (!foundBaseItem || (!foundDye && ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_10))) matches = false;
|
||||
} else if (inv.size() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) {
|
||||
DyeColor patternColor = null;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.inventory.RecipeInputInventory;
|
||||
@ -30,7 +31,7 @@ import net.minecraft.recipe.*;
|
||||
import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -43,30 +44,30 @@ public class Recipes1_11_2 {
|
||||
/**
|
||||
* @return A list of all recipes for the given version.
|
||||
*/
|
||||
public static List<RecipeInfo> getRecipes(final VersionEnum targetVersion) {
|
||||
public static List<RecipeInfo> getRecipes(final ProtocolVersion targetVersion) {
|
||||
final List<RecipeInfo> recipes = new ArrayList<>();
|
||||
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
recipes.add(RecipeInfo.of(() -> new ArmorDyeRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new MapCloningRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new MapExtendingRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
recipes.add(RecipeInfo.of(() -> new FireworkRocketRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
|
||||
recipes.add(RecipeInfo.of(() -> new ShulkerBoxColoringRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_9)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
recipes.add(RecipeInfo.of(() -> new TippedArrowRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new ShieldDecorationRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
recipes.add(RecipeInfo.of(() -> new RepairItemRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new BannerDuplicateRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new AddBannerPatternRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_7_2tor1_7_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
|
||||
recipes.add(RecipeInfo.of(() -> new BookCloningRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
|
||||
@ -144,7 +145,7 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.BOOKSHELF, "###", "XXX", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.BOOK));
|
||||
recipes.add(RecipeInfo.shaped(4, Items.ARROW, "X", "#", "Y", '#', Items.STICK, 'X', Items.FLINT, 'Y', Items.FEATHER));
|
||||
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_12)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
|
||||
recipes.add(RecipeInfo.shapeless("concrete_powder", 8, Blocks.YELLOW_CONCRETE_POWDER, Items.YELLOW_DYE, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL));
|
||||
recipes.add(RecipeInfo.shapeless("concrete_powder", 8, Blocks.WHITE_CONCRETE_POWDER, Items.BONE_MEAL, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL));
|
||||
recipes.add(RecipeInfo.shapeless("concrete_powder", 8, Blocks.RED_CONCRETE_POWDER, Items.RED_DYE, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL));
|
||||
@ -194,26 +195,26 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped("bed", Blocks.BLACK_BED, "###", "XXX", '#', Blocks.BLACK_WOOL, 'X', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.WHITE_WOOL, Blocks.WHITE_WOOL, Items.BONE_MEAL));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped("bed", Blocks.RED_BED, "###", "XXX", '#', Blocks.YELLOW_WOOL, Blocks.BLACK_WOOL, Blocks.BLUE_WOOL, Blocks.BROWN_WOOL, Blocks.CYAN_WOOL, Blocks.GRAY_WOOL, Blocks.GREEN_WOOL, Blocks.LIGHT_BLUE_WOOL, Blocks.LIGHT_GRAY_WOOL, Blocks.WHITE_WOOL, Blocks.RED_WOOL, Blocks.PURPLE_WOOL, Blocks.PINK_WOOL, Blocks.ORANGE_WOOL, Blocks.LIME_WOOL, Blocks.MAGENTA_WOOL, 'X', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
}
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
recipes.add(RecipeInfo.shaped(9, Items.IRON_NUGGET, "#", '#', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped("iron_ingot", Items.IRON_INGOT, "###", "###", "###", '#', Items.IRON_NUGGET));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OBSERVER, "###", "RRQ", "###", 'Q', Items.QUARTZ, 'R', Blocks.REDSTONE_WIRE, '#', Blocks.COBBLESTONE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.PURPLE_SHULKER_BOX, "-", "#", "-", '#', Blocks.CHEST, '-', Items.SHULKER_SHELL));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_10)) {
|
||||
recipes.add(RecipeInfo.shapeless("bonemeal", 9, Items.BONE_MEAL, Blocks.BONE_BLOCK));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.BONE_BLOCK, "XXX", "XXX", "XXX", 'X', Items.BONE_MEAL));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.MAGMA_BLOCK, "##", "##", '#', Items.MAGMA_CREAM));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.NETHER_WART_BLOCK, "###", "###", "###", '#', Blocks.NETHER_WART));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.RED_NETHER_BRICKS, "NW", "WN", 'W', Blocks.NETHER_WART, 'N', Items.NETHER_BRICK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_9)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.TRAPPED_CHEST, Blocks.CHEST, Blocks.TRIPWIRE_HOOK));
|
||||
recipes.add(RecipeInfo.shaped(Items.SHIELD, "WoW", "WWW", " W ", 'W', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'o', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.PURPUR_BLOCK, "FF", "FF", 'F', Items.POPPED_CHORUS_FRUIT));
|
||||
@ -233,15 +234,15 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shapeless("red_dye", Items.RED_DYE, Items.BEETROOT));
|
||||
recipes.add(RecipeInfo.shaped(Items.BEETROOT_SOUP, "OOO", "OOO", " B ", 'B', Items.BOWL, 'O', Items.BEETROOT));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_5tor1_5_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_5tor1_5_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.TRAPPED_CHEST, "#-", '#', Blocks.CHEST, '-', Blocks.TRIPWIRE_HOOK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
recipes.add(RecipeInfo.shaped(Items.ENCHANTED_GOLDEN_APPLE, "###", "#X#", "###", '#', Items.GOLD_BLOCK, 'X', Items.APPLE));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped("boat", Items.OAK_BOAT, "# #", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BIRCH_PLANKS, Blocks.ACACIA_PLANKS));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE, Blocks.VINE));
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.MOSSY_STONE_BRICKS, Blocks.STONE_BRICKS, Blocks.VINE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.CHISELED_STONE_BRICKS, "#", "#", '#', Blocks.STONE_BRICK_SLAB));
|
||||
@ -305,13 +306,13 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.POLISHED_ANDESITE, "SS", "SS", 'S', Blocks.ANDESITE));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped("wooden_fence", 2, Blocks.OAK_FENCE, "###", "###", '#', Items.STICK));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.shaped("wooden_fence_gate", Blocks.OAK_FENCE_GATE, "#W#", "#W#", '#', Items.STICK, 'W', Blocks.OAK_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BIRCH_PLANKS, Blocks.ACACIA_PLANKS));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(Blocks.IRON_DOOR, "##", "##", "##", '#', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped("wooden_door", Blocks.OAK_DOOR, "##", "##", "##", '#', Blocks.OAK_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BIRCH_PLANKS, Blocks.ACACIA_PLANKS));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_7_2tor1_7_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
|
||||
recipes.add(RecipeInfo.shaped("stained_glass", 8, Blocks.YELLOW_STAINED_GLASS, "###", "#X#", "###", '#', Blocks.GLASS, 'X', Items.YELLOW_DYE));
|
||||
recipes.add(RecipeInfo.shaped("stained_glass", 8, Blocks.WHITE_STAINED_GLASS, "###", "#X#", "###", '#', Blocks.GLASS, 'X', Items.BONE_MEAL));
|
||||
recipes.add(RecipeInfo.shaped("stained_glass", 8, Blocks.RED_STAINED_GLASS, "###", "#X#", "###", '#', Blocks.GLASS, 'X', Items.RED_DYE));
|
||||
@ -368,7 +369,7 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Items.FLINT_AND_STEEL, "A ", " B", 'A', Items.IRON_INGOT, 'B', Items.FLINT));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.TNT, "X#X", "#X#", "X#X", '#', Blocks.SAND, 'X', Items.GUNPOWDER));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_6_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_6_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Items.GOLDEN_APPLE, "###", "#X#", "###", '#', Items.GOLD_INGOT, 'X', Items.APPLE));
|
||||
recipes.add(RecipeInfo.shaped(Items.GLISTERING_MELON_SLICE, "###", "#X#", "###", '#', Items.GOLD_NUGGET, 'X', Items.MELON_SLICE));
|
||||
recipes.add(RecipeInfo.shaped("carpet", 3, Blocks.YELLOW_CARPET, "##", '#', Blocks.YELLOW_WOOL));
|
||||
@ -410,11 +411,11 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(9, Items.COAL, "#", '#', Blocks.COAL_BLOCK));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped(Items.GOLDEN_APPLE, "###", "#X#", "###", '#', Items.GOLD_NUGGET, 'X', Items.APPLE));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
recipes.add(RecipeInfo.shapeless(Items.GLISTERING_MELON_SLICE, Items.GOLD_NUGGET, Items.MELON_SLICE));
|
||||
}
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_5tor1_5_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_5tor1_5_1)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.SNOW, "###", '#', Blocks.SNOW_BLOCK));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.QUARTZ_BLOCK, "##", "##", '#', Items.QUARTZ));
|
||||
recipes.add(RecipeInfo.shaped(2, Blocks.QUARTZ_PILLAR, "#", "#", '#', Blocks.QUARTZ_BLOCK));
|
||||
@ -434,10 +435,10 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.REDSTONE_BLOCK, "###", "###", "###", '#', Blocks.REDSTONE_WIRE));
|
||||
recipes.add(RecipeInfo.shaped(9, Blocks.REDSTONE_WIRE, "#", '#', Blocks.REDSTONE_BLOCK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.NETHER_BRICK_SLAB, "###", '#', Blocks.NETHER_BRICKS));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.COBBLESTONE_WALL, "###", "###", '#', Blocks.COBBLESTONE));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.MOSSY_COBBLESTONE_WALL, "###", "###", '#', Blocks.MOSSY_COBBLESTONE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.FLOWER_POT, "# #", " # ", '#', Items.BRICK));
|
||||
@ -449,7 +450,7 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.BEACON, "GGG", "GSG", "OOO", 'S', Items.NETHER_STAR, 'G', Blocks.GLASS, 'O', Blocks.OBSIDIAN));
|
||||
recipes.add(RecipeInfo.shapeless(Items.PUMPKIN_PIE, Blocks.CARVED_PUMPKIN, Items.SUGAR, Items.EGG));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
recipes.add(RecipeInfo.shapeless(Items.WRITABLE_BOOK, Items.BOOK, Items.INK_SAC, Items.FEATHER));
|
||||
recipes.add(RecipeInfo.shapeless(Items.BOOK, Items.PAPER, Items.PAPER, Items.PAPER, Items.LEATHER));
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.OAK_SIGN, "###", "###", " X ", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.STICK));
|
||||
@ -466,17 +467,17 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.EMERALD_BLOCK, "###", "###", "###", '#', Items.EMERALD));
|
||||
recipes.add(RecipeInfo.shaped(9, Items.EMERALD, "#", '#', Blocks.EMERALD_BLOCK));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_2_1tor1_2_3)) {
|
||||
recipes.add(RecipeInfo.shaped("wooden_slab", 6, Blocks.OAK_SLAB, "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped("wooden_slab", 3, Blocks.OAK_SLAB, "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
}
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(Items.BOOK, "#", "#", "#", '#', Items.PAPER));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OAK_SIGN, "###", "###", " X ", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.STICK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.BIRCH_PLANKS, "#", '#', Blocks.BIRCH_LOG));
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.SPRUCE_PLANKS, "#", '#', Blocks.SPRUCE_LOG));
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.JUNGLE_PLANKS, "#", '#', Blocks.JUNGLE_LOG));
|
||||
@ -485,7 +486,7 @@ public class Recipes1_11_2 {
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.OAK_PLANKS, "#", '#', Blocks.BIRCH_LOG, Blocks.SPRUCE_LOG, Blocks.JUNGLE_LOG));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_2_1tor1_2_3)) {
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.LADDER, "# #", "###", "# #", '#', Items.STICK));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.SMOOTH_STONE_SLAB, "###", '#', Blocks.STONE));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.SANDSTONE_SLAB, "###", '#', Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE));
|
||||
@ -495,22 +496,22 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.REDSTONE_LAMP, " R ", "RGR", " R ", 'R', Blocks.REDSTONE_WIRE, 'G', Blocks.GLOWSTONE));
|
||||
recipes.add(RecipeInfo.shapeless(3, Items.FIRE_CHARGE, new ItemConvertible[]{Items.GUNPOWDER}, new ItemConvertible[]{Items.BLAZE_POWDER}, new ItemConvertible[]{Items.COAL, Items.CHARCOAL}));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_5tob1_5_2)) {
|
||||
recipes.add(RecipeInfo.shaped(2, Blocks.LADDER, "# #", "###", "# #", '#', Items.STICK));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped(1, Blocks.LADDER, "# #", "###", "# #", '#', Items.STICK));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.SMOOTH_STONE_SLAB, "###", '#', Blocks.STONE));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.SANDSTONE_SLAB, "###", '#', Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE));
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.COBBLESTONE_SLAB, "###", '#', Blocks.COBBLESTONE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.BRICK_SLAB, "###", '#', Blocks.BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.STONE_BRICK_SLAB, "###", '#', Blocks.STONE_BRICKS, Blocks.MOSSY_STONE_BRICKS, Blocks.CRACKED_STONE_BRICKS, Blocks.CHISELED_STONE_BRICKS));
|
||||
}
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
recipes.add(RecipeInfo.shapeless(Items.MUSHROOM_STEW, Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM, Items.BOWL));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.NETHER_BRICK_STAIRS, "# ", "## ", "###", '#', Blocks.NETHER_BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.NETHER_BRICK_FENCE, "###", "###", '#', Blocks.NETHER_BRICKS));
|
||||
@ -529,7 +530,7 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Items.MUSHROOM_STEW, "Y", "X", "#", 'X', Blocks.BROWN_MUSHROOM, 'Y', Blocks.RED_MUSHROOM, '#', Items.BOWL));
|
||||
recipes.add(RecipeInfo.shaped(Items.MUSHROOM_STEW, "Y", "X", "#", 'X', Blocks.RED_MUSHROOM, 'Y', Blocks.BROWN_MUSHROOM, '#', Items.BOWL));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.BRICK_STAIRS, "# ", "## ", "###", '#', Blocks.BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.STONE_BRICK_STAIRS, "# ", "## ", "###", '#', Blocks.STONE_BRICKS, Blocks.MOSSY_STONE_BRICKS, Blocks.CRACKED_STONE_BRICKS, Blocks.CHISELED_STONE_BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.STONE_BRICKS, "##", "##", '#', Blocks.STONE));
|
||||
@ -538,30 +539,30 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.MELON, "MMM", "MMM", "MMM", 'M', Items.MELON_SLICE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.MELON_STEM, "M", 'M', Items.MELON_SLICE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.STICKY_PISTON, "S", "P", 'P', Blocks.PISTON, 'S', Items.SLIME_BALL));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.PISTON, "TTT", "#X#", "#R#", 'R', Blocks.REDSTONE_WIRE, '#', Blocks.COBBLESTONE, 'T', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped(Items.SHEARS, " #", "# ", '#', Items.IRON_INGOT));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_6tob1_6_6)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_6tob1_6_6)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.GLOWSTONE, "##", "##", '#', Items.GLOWSTONE_DUST));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.WHITE_WOOL, "##", "##", '#', Blocks.TRIPWIRE));
|
||||
recipes.add(RecipeInfo.shaped(2, Blocks.OAK_TRAPDOOR, "###", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
recipes.add(RecipeInfo.shaped(Items.MAP, "###", "#X#", "###", '#', Items.PAPER, 'X', Items.COMPASS));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_2_0toa1_2_1_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.GLOWSTONE, "###", "###", "###", '#', Items.GLOWSTONE_DUST));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(Blocks.WHITE_WOOL, "###", "###", "###", '#', Blocks.TRIPWIRE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_5tob1_5_2)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.DETECTOR_RAIL, "X X", "X#X", "XRX", 'R', Blocks.REDSTONE_WIRE, '#', Blocks.STONE_PRESSURE_PLATE, 'X', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.POWERED_RAIL, "X X", "X#X", "XRX", 'R', Blocks.REDSTONE_WIRE, '#', Items.STICK, 'X', Items.GOLD_INGOT));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_4tob1_4_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) {
|
||||
recipes.add(RecipeInfo.shaped(8, Items.COOKIE, "#X#", '#', Items.WHEAT, 'X', Blocks.COCOA));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.REPEATER, "#X#", "III", '#', Blocks.REDSTONE_TORCH, 'X', Blocks.REDSTONE_WIRE, 'I', Blocks.STONE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OAK_PRESSURE_PLATE, "##", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.STONE_PRESSURE_PLATE, "##", '#', Blocks.STONE));
|
||||
@ -569,7 +570,7 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OAK_PRESSURE_PLATE, "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.STONE_PRESSURE_PLATE, "###", '#', Blocks.STONE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_2_0tob1_2_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_2_0tob1_2_2)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.NOTE_BLOCK, "###", "#X#", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Blocks.REDSTONE_WIRE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.CAKE, "AAA", "BEB", "CCC", 'A', Items.MILK_BUCKET, 'B', Items.SUGAR, 'C', Items.WHEAT, 'E', Items.EGG));
|
||||
recipes.add(RecipeInfo.shaped(Items.SUGAR, "#", '#', Blocks.SUGAR_CANE));
|
||||
@ -611,11 +612,11 @@ public class Recipes1_11_2 {
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.TORCH, "X", "#", '#', Items.STICK, 'X', Items.COAL));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_2_0toa1_2_1_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.JACK_O_LANTERN, "A", "B", 'A', Blocks.CARVED_PUMPKIN, 'B', Blocks.TORCH));
|
||||
recipes.add(RecipeInfo.shaped(Items.CLOCK, " # ", "#X#", " # ", '#', Items.GOLD_INGOT, 'X', Blocks.REDSTONE_WIRE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_1_0toa1_1_2_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_1_0toa1_1_2_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Items.FISHING_ROD, " #", " #X", "# X", '#', Items.STICK, 'X', Blocks.TRIPWIRE));
|
||||
recipes.add(RecipeInfo.shaped(Items.COMPASS, " # ", "#X#", " # ", '#', Items.IRON_INGOT, 'X', Blocks.REDSTONE_WIRE));
|
||||
}
|
||||
@ -628,7 +629,7 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.smelting(Items.STONE, Items.COBBLESTONE, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.BRICK, Items.CLAY_BALL, 0.3F));
|
||||
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_12)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.WHITE_GLAZED_TERRACOTTA, Items.WHITE_TERRACOTTA, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.ORANGE_GLAZED_TERRACOTTA, Items.ORANGE_TERRACOTTA, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.MAGENTA_GLAZED_TERRACOTTA, Items.MAGENTA_TERRACOTTA, 0.1F));
|
||||
@ -646,47 +647,47 @@ public class Recipes1_11_2 {
|
||||
recipes.add(RecipeInfo.smelting(Items.RED_GLAZED_TERRACOTTA, Items.RED_TERRACOTTA, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.BLACK_GLAZED_TERRACOTTA, Items.BLACK_TERRACOTTA, 0.1F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.IRON_NUGGET, Ingredient.ofItems(Items.CHAINMAIL_HELMET, Items.CHAINMAIL_CHESTPLATE, Items.CHAINMAIL_LEGGINGS, Items.CHAINMAIL_BOOTS, Items.IRON_PICKAXE, Items.IRON_SHOVEL, Items.IRON_AXE, Items.IRON_HOE, Items.IRON_SWORD, Items.IRON_HELMET, Items.IRON_CHESTPLATE, Items.IRON_LEGGINGS, Items.IRON_BOOTS, Items.IRON_HORSE_ARMOR), 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.GOLD_NUGGET, Ingredient.ofItems(Items.GOLDEN_PICKAXE, Items.GOLDEN_SHOVEL, Items.GOLDEN_AXE, Items.GOLDEN_HOE, Items.GOLDEN_SWORD, Items.GOLDEN_HELMET, Items.GOLDEN_CHESTPLATE, Items.GOLDEN_LEGGINGS, Items.GOLDEN_BOOTS, Items.GOLDEN_HORSE_ARMOR), 0.1F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_9)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.POPPED_CHORUS_FRUIT, Items.CHORUS_FRUIT, 0.1F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_7_2tor1_7_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_RABBIT, Items.RABBIT, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_MUTTON, Items.MUTTON, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.CRACKED_STONE_BRICKS, Items.STONE_BRICKS, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.SPONGE, Items.WET_SPONGE, 0.15F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_6_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_6_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.TERRACOTTA, Items.CLAY, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_SALMON, Items.SALMON, 0.35F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_5tor1_5_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_5tor1_5_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.NETHER_BRICK, Items.NETHERRACK, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.QUARTZ, Items.NETHER_QUARTZ_ORE, 0.2F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.BAKED_POTATO, Items.POTATO, 0.35F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.EMERALD, Items.EMERALD_ORE, 1.0F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COAL, Items.COAL_ORE, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.REDSTONE, Items.REDSTONE_ORE, 0.7F));
|
||||
recipes.add(RecipeInfo.smelting(Items.LAPIS_LAZULI, Items.LAPIS_ORE, 0.2F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_CHICKEN, Items.CHICKEN, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_BEEF, Items.BEEF, 0.35F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_2_0tob1_2_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_2_0tob1_2_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.CHARCOAL, Ingredient.fromTag(ItemTags.LOGS), 0.15F));
|
||||
recipes.add(RecipeInfo.smelting(Items.GREEN_DYE, Items.CACTUS, 0.2F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_2_0toa1_2_1_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_COD, Items.COD, 0.35F));
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.versioned;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
@ -30,7 +31,6 @@ import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ClientPlayerInteractionManager1_18_2 {
|
||||
@ -41,7 +41,7 @@ public class ClientPlayerInteractionManager1_18_2 {
|
||||
final ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||
|
||||
final Vec2f rotation;
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_1)) {
|
||||
rotation = null;
|
||||
} else {
|
||||
rotation = new Vec2f(player.getYaw(), player.getPitch());
|
||||
@ -58,9 +58,9 @@ public class ClientPlayerInteractionManager1_18_2 {
|
||||
final var oldPlayerState = unAckedActions.remove(Pair.of(blockPos, action));
|
||||
final var actualState = world.getBlockState(blockPos);
|
||||
|
||||
if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2))) {
|
||||
if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2))) {
|
||||
world.setBlockState(blockPos, expectedState, Block.NOTIFY_ALL | Block.FORCE_STATE);
|
||||
if (oldPlayerState != null && (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_1) || (world == player.getWorld() && player.collidesWithStateAtPos(blockPos, expectedState)))) {
|
||||
if (oldPlayerState != null && (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_1) || (world == player.getWorld() && player.collidesWithStateAtPos(blockPos, expectedState)))) {
|
||||
final Vec3d oldPlayerPosition = oldPlayerState.getKey();
|
||||
if (oldPlayerState.getValue() != null) {
|
||||
player.updatePositionAndAngles(oldPlayerPosition.x, oldPlayerPosition.y, oldPlayerPosition.z, oldPlayerState.getValue().x, oldPlayerState.getValue().y);
|
||||
|
@ -31,10 +31,10 @@ 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 net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
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 net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
@ -47,7 +47,7 @@ public class WorldHeightSupport {
|
||||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
for (Tag dimension : wrapper.get(Type.NAMED_COMPOUND_TAG, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
|
||||
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class WorldHeightSupport {
|
||||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
|
||||
}
|
||||
};
|
||||
@ -72,7 +72,7 @@ public class WorldHeightSupport {
|
||||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
wrapper.resetReader();
|
||||
final Chunk chunk = wrapper.read(new ChunkType1_17(16));
|
||||
wrapper.write(new ChunkType1_17(chunk.getSections().length), chunk);
|
||||
@ -162,7 +162,7 @@ public class WorldHeightSupport {
|
||||
};
|
||||
|
||||
return wrapper -> {
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
classicLightHandler.handle(wrapper);
|
||||
} else {
|
||||
parentHandler.handle(wrapper);
|
||||
|
@ -20,12 +20,11 @@
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.command.VFPViaSubCommand;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ListExtensionsCommand extends VFPViaSubCommand {
|
||||
|
||||
@ -36,13 +35,13 @@ public class ListExtensionsCommand extends VFPViaSubCommand {
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Shows all classic extensions (only for " + VersionEnum.c0_30cpe.getName() + ")";
|
||||
return "Shows all classic extensions (only for " + LegacyProtocolVersion.c0_30cpe.getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(ViaCommandSender sender, String[] args) {
|
||||
if (!getUser().has(ExtensionProtocolMetadataStorage.class)) {
|
||||
sendMessage(sender, Formatting.RED + "Only for " + VersionEnum.c0_30cpe.getName());
|
||||
sendMessage(sender, Formatting.RED + "Only for " + LegacyProtocolVersion.c0_30cpe.getName());
|
||||
return true;
|
||||
}
|
||||
((IExtensionProtocolMetadataStorage) getUser().get(ExtensionProtocolMetadataStorage.class)).viaFabricPlus$getServerExtensions().forEach((extension, version) -> {
|
||||
|
@ -20,11 +20,10 @@
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.command.VFPViaSubCommand;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class SetTimeCommand extends VFPViaSubCommand {
|
||||
|
||||
@ -35,7 +34,7 @@ public class SetTimeCommand extends VFPViaSubCommand {
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Changes the time (Only for <= " + VersionEnum.a1_0_16toa1_0_16_2.getName() + ")";
|
||||
return "Changes the time (Only for <= " + LegacyProtocolVersion.a1_0_16toa1_0_16_2.getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,7 +45,7 @@ public class SetTimeCommand extends VFPViaSubCommand {
|
||||
@Override
|
||||
public boolean execute(ViaCommandSender sender, String[] args) {
|
||||
if (!getUser().has(TimeLockStorage.class)) {
|
||||
sendMessage(sender, Formatting.RED + "Only for <= " + VersionEnum.a1_0_16toa1_0_16_2.getName());
|
||||
sendMessage(sender, Formatting.RED + "Only for <= " + LegacyProtocolVersion.a1_0_16toa1_0_16_2.getName());
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
@ -33,7 +34,6 @@ import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.entity.vehicle.ChestBoatEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ public class EntityRidingOffsetsPre1_20_2 {
|
||||
if (entity instanceof BoatEntity boatEntity) {
|
||||
if (!boatEntity.hasPassenger(passenger)) return new Vector3f();
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
yOffset = -0.3F;
|
||||
final float xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F);
|
||||
final float zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F);
|
||||
@ -149,7 +149,7 @@ public class EntityRidingOffsetsPre1_20_2 {
|
||||
*/
|
||||
public static double getHeightOffset(final Entity entity) {
|
||||
if (entity instanceof AllayEntity || entity instanceof VexEntity) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
return 0D;
|
||||
} else {
|
||||
return 0.4D;
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
|
||||
@ -32,7 +33,6 @@ import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
|
||||
|
||||
@ -96,7 +96,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
|
||||
|
||||
@Override
|
||||
public Particle createParticle(DefaultParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) {
|
||||
throw new UnsupportedOperationException("FootStepParticle is not supported on versions newer than 1.12.2");
|
||||
}
|
||||
|
||||
|
@ -20,14 +20,14 @@
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface IClientConnection {
|
||||
|
||||
void viaFabricPlus$setupPreNettyDecryption();
|
||||
|
||||
VersionEnum viaFabricPlus$getTargetVersion();
|
||||
void viaFabricPlus$setTargetVersion(final VersionEnum serverVersion);
|
||||
ProtocolVersion viaFabricPlus$getTargetVersion();
|
||||
void viaFabricPlus$setTargetVersion(final ProtocolVersion serverVersion);
|
||||
|
||||
UserConnection viaFabricPlus$getUserConnection();
|
||||
void viaFabricPlus$setUserConnection(final UserConnection userConnection);
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface IPerformanceLog {
|
||||
|
||||
VersionEnum viaFabricPlus$getForcedVersion();
|
||||
void viaFabricPlus$setForcedVersion(final VersionEnum version);
|
||||
ProtocolVersion viaFabricPlus$getForcedVersion();
|
||||
void viaFabricPlus$setForcedVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
||||
|
@ -19,17 +19,17 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface IServerInfo {
|
||||
|
||||
VersionEnum viaFabricPlus$forcedVersion();
|
||||
void viaFabricPlus$forceVersion(final VersionEnum version);
|
||||
ProtocolVersion viaFabricPlus$forcedVersion();
|
||||
void viaFabricPlus$forceVersion(final ProtocolVersion version);
|
||||
|
||||
boolean viaFabricPlus$passedDirectConnectScreen();
|
||||
void viaFabricPlus$passDirectConnectScreen();
|
||||
|
||||
VersionEnum viaFabricPlus$translatingVersion();
|
||||
void viaFabricPlus$setTranslatingVersion(final VersionEnum version);
|
||||
ProtocolVersion viaFabricPlus$translatingVersion();
|
||||
void viaFabricPlus$setTranslatingVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ package de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension;
|
||||
import io.netty.bootstrap.AbstractBootstrap;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.*;
|
||||
@ -38,11 +38,12 @@ import net.minecraft.network.encryption.PacketDecryptor;
|
||||
import net.minecraft.network.encryption.PacketEncryptor;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
import net.raphimc.vialoader.netty.viabedrock.PingEncapsulationCodec;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -74,7 +75,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
private UserConnection viaFabricPlus$userConnection;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$serverVersion;
|
||||
private ProtocolVersion viaFabricPlus$serverVersion;
|
||||
|
||||
@Unique
|
||||
private Cipher viaFabricPlus$decryptionCipher;
|
||||
@ -87,7 +88,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
|
||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeDecryptionCipher(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
if (this.viaFabricPlus$serverVersion != null /* This happens when opening a lan server and people are joining */ && this.viaFabricPlus$serverVersion.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (this.viaFabricPlus$serverVersion != null /* This happens when opening a lan server and people are joining */ && this.viaFabricPlus$serverVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
@ -109,14 +110,14 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
super.channelRegistered(ctx);
|
||||
if (VersionEnum.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) { // Call channelActive manually when the channel is registered
|
||||
if (BedrockProtocolVersion.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) { // Call channelActive manually when the channel is registered
|
||||
this.channelActive(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "channelActive", at = @At(value = "INVOKE", target = "Lio/netty/channel/SimpleChannelInboundHandler;channelActive(Lio/netty/channel/ChannelHandlerContext;)V", remap = false))
|
||||
private boolean dontCallChannelActiveTwice(SimpleChannelInboundHandler<Packet<?>> instance, ChannelHandlerContext channelHandlerContext) {
|
||||
return !VersionEnum.bedrockLatest.equals(this.viaFabricPlus$serverVersion);
|
||||
return !BedrockProtocolVersion.bedrockLatest.equals(this.viaFabricPlus$serverVersion);
|
||||
}
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE))
|
||||
@ -135,11 +136,11 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD"))
|
||||
private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir) {
|
||||
VersionEnum targetVersion = ((IClientConnection) connection).viaFabricPlus$getTargetVersion();
|
||||
ProtocolVersion targetVersion = ((IClientConnection) connection).viaFabricPlus$getTargetVersion();
|
||||
if (targetVersion == null) { // No server specific override
|
||||
targetVersion = ProtocolHack.getTargetVersion();
|
||||
}
|
||||
if (targetVersion == VersionEnumExtension.AUTO_DETECT) { // Auto-detect enabled (when pinging always use native version). Auto-detect is resolved in ConnectScreen mixin
|
||||
if (targetVersion == ProtocolHack.AUTO_DETECT_PROTOCOL) { // Auto-detect enabled (when pinging always use native version). Auto-detect is resolved in ConnectScreen mixin
|
||||
targetVersion = ProtocolHack.NATIVE_VERSION;
|
||||
}
|
||||
|
||||
@ -148,7 +149,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private static AbstractBootstrap<?, ?> useRakNetChannelFactory(Bootstrap instance, Class<? extends Channel> channelTypeClass, @Local(argsOnly = true) ClientConnection clientConnection) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion())) {
|
||||
if (BedrockProtocolVersion.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion())) {
|
||||
return instance.channelFactory(channelTypeClass == EpollSocketChannel.class ? RakChannelFactory.client(EpollDatagramChannel.class) : RakChannelFactory.client(NioDatagramChannel.class));
|
||||
} else {
|
||||
return instance.channel(channelTypeClass);
|
||||
@ -157,7 +158,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;connect(Ljava/net/InetAddress;I)Lio/netty/channel/ChannelFuture;", remap = false))
|
||||
private static ChannelFuture useRakNetPingHandlers(Bootstrap instance, InetAddress inetHost, int inetPort, @Local(argsOnly = true) ClientConnection clientConnection, @Local(argsOnly = true) boolean isConnecting) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion()) && !isConnecting) {
|
||||
if (BedrockProtocolVersion.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion()) && !isConnecting) {
|
||||
// Bedrock edition / RakNet has different handlers for pinging a server
|
||||
return instance.register().syncUninterruptibly().channel().bind(new InetSocketAddress(0)).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f -> {
|
||||
if (f.isSuccess()) {
|
||||
@ -197,12 +198,12 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$getTargetVersion() {
|
||||
public ProtocolVersion viaFabricPlus$getTargetVersion() {
|
||||
return this.viaFabricPlus$serverVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setTargetVersion(final VersionEnum serverVersion) {
|
||||
public void viaFabricPlus$setTargetVersion(final ProtocolVersion serverVersion) {
|
||||
this.viaFabricPlus$serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -43,7 +43,7 @@ public abstract class MixinClientLoginNetworkHandler {
|
||||
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
|
||||
public void onlyVerifySessionInOnlineMode(String serverId, CallbackInfoReturnable<Text> cir) {
|
||||
final IClientConnection mixinClientConnection = (IClientConnection) connection;
|
||||
if (mixinClientConnection.viaFabricPlus$getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (mixinClientConnection.viaFabricPlus$getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
// if the server is in offline mode, due the packet changes <-> networking changes
|
||||
// Minecraft's networking code is bad for us.
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.screen.base.PerServerVersionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -62,7 +62,7 @@ public abstract class MixinAddServerScreen extends Screen {
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void addVersionSetterButton(CallbackInfo ci) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
final ProtocolVersion forcedVersion = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
|
||||
// Restore input if the user cancels the version selection screen (or if the user is editing an existing server)
|
||||
if (viaFabricPlus$nameField != null && viaFabricPlus$addressField != null) {
|
||||
|
@ -21,12 +21,12 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.ProtocolVersionDetector;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension;
|
||||
import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
|
||||
@ -34,7 +34,6 @@ import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.client.session.Session;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -62,11 +61,11 @@ public abstract class MixinConnectScreen_1 {
|
||||
private ChannelFuture setServerInfoAndHandleDisconnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, Operation<ChannelFuture> original) {
|
||||
final IServerInfo mixinServerInfo = (IServerInfo) this.field_40415;
|
||||
|
||||
VersionEnum targetVersion = ProtocolHack.getTargetVersion();
|
||||
ProtocolVersion targetVersion = ProtocolHack.getTargetVersion();
|
||||
if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) {
|
||||
targetVersion = mixinServerInfo.viaFabricPlus$forcedVersion();
|
||||
}
|
||||
if (targetVersion == VersionEnumExtension.AUTO_DETECT) {
|
||||
if (targetVersion == ProtocolHack.AUTO_DETECT_PROTOCOL) {
|
||||
this.field_2416.setStatus(Text.translatable("base.viafabricplus.detecting_server_version"));
|
||||
targetVersion = ProtocolVersionDetector.get(address, ProtocolHack.NATIVE_VERSION);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.SharedConstants;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.network.listener.ClientQueryPacketListener;
|
||||
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -57,31 +57,11 @@ public abstract class MixinMultiplayerServerListPinger_1 implements ClientQueryP
|
||||
}
|
||||
|
||||
@Inject(method = "onResponse", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V", shift = At.Shift.AFTER))
|
||||
private void setProtocolVersion(CallbackInfo ci) {
|
||||
final VersionEnum version = ((IClientConnection) this.field_3774).viaFabricPlus$getTargetVersion();
|
||||
|
||||
// ViaVersion is not translating the current connection, so we don't need to do anything
|
||||
if (version == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean isCompatible;
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Because of ViaVersion not supporting legacy minecraft versions where protocol ids are overlapping, ViaLegacy
|
||||
// has its own protocol id offset, where realVersion = -(ViaLegacyVersion >> 2). Normally ViaVersion sends the client
|
||||
// version to the client so its detection doesn't break when checking for serverVersion == clientVersion, but since
|
||||
// ViaLegacy doesn't do that, we have to do it ourselves
|
||||
isCompatible = LegacyProtocolVersion.getRealProtocolVersion(version.getVersion()) == this.field_3776.protocolVersion;
|
||||
} else if (version.equals(VersionEnum.bedrockLatest)) {
|
||||
// Bedrock edition doesn't have a protocol id like the Java edition, ViaBedrock also has its own protocol id offset
|
||||
// Which we need to remove to get the real protocol id
|
||||
isCompatible = version.getVersion() - BedrockProtocolVersion.PROTOCOL_ID_OVERLAP_PREVENTION_OFFSET == this.field_3776.protocolVersion;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
private void fixVersionComparison(CallbackInfo ci) {
|
||||
final ProtocolVersion version = ((IClientConnection) this.field_3774).viaFabricPlus$getTargetVersion();
|
||||
|
||||
// If the server is compatible with the client, we set the protocol version to the client version
|
||||
if (isCompatible) {
|
||||
if (version != null && version.getVersion() == this.field_3776.protocolVersion) {
|
||||
this.field_3776.protocolVersion = SharedConstants.getProtocolVersion();
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -47,10 +47,10 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry {
|
||||
private void drawTranslatingState(MultiplayerScreen instance, List<Text> tooltip, Operation<Void> original) {
|
||||
final List<Text> tooltipCopy = new ArrayList<>(tooltip);
|
||||
if (GeneralSettings.global().showAdvertisedServerVersion.getValue()) {
|
||||
final VersionEnum versionEnum = ((IServerInfo) server).viaFabricPlus$translatingVersion();
|
||||
final ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$translatingVersion();
|
||||
|
||||
if (versionEnum != null) {
|
||||
tooltipCopy.add(Text.translatable("base.viafabricplus.via_translates_to", versionEnum.getName() + " (" + versionEnum.getOriginalVersion() + ")"));
|
||||
if (version != null) {
|
||||
tooltipCopy.add(Text.translatable("base.viafabricplus.via_translates_to", version.getName() + " (" + version.getOriginalVersion() + ")"));
|
||||
tooltipCopy.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")"));
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,13 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.network.MultiplayerServerListPinger;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -38,7 +38,7 @@ public abstract class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;"))
|
||||
private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, @Local ServerInfo serverInfo) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) serverInfo).viaFabricPlus$forcedVersion();
|
||||
final ProtocolVersion forcedVersion = ((IServerInfo) serverInfo).viaFabricPlus$forcedVersion();
|
||||
|
||||
if (forcedVersion != null && !((IServerInfo) serverInfo).viaFabricPlus$passedDirectConnectScreen()) {
|
||||
// We use the PerformanceLog field to store the forced version since it's always null when pinging a server
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@ -29,15 +29,15 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
public abstract class MixinPerformanceLog implements IPerformanceLog {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$forcedVersion;
|
||||
private ProtocolVersion viaFabricPlus$forcedVersion;
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$getForcedVersion() {
|
||||
public ProtocolVersion viaFabricPlus$getForcedVersion() {
|
||||
return this.viaFabricPlus$forcedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setForcedVersion(VersionEnum version) {
|
||||
public void viaFabricPlus$setForcedVersion(ProtocolVersion version) {
|
||||
this.viaFabricPlus$forcedVersion = version;
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -39,28 +39,26 @@ public abstract class MixinServerInfo implements IServerInfo {
|
||||
public String name;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$forcedVersion = null;
|
||||
private ProtocolVersion viaFabricPlus$forcedVersion = null;
|
||||
|
||||
@Unique
|
||||
private boolean viaFabricPlus$passedDirectConnectScreen;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$translatingVersion;
|
||||
private ProtocolVersion viaFabricPlus$translatingVersion;
|
||||
|
||||
@Inject(method = "toNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void saveForcedVersion(CallbackInfoReturnable<NbtCompound> cir, NbtCompound nbtCompound) {
|
||||
if (viaFabricPlus$forcedVersion != null) {
|
||||
nbtCompound.putInt("viafabricplus_forcedversion", viaFabricPlus$forcedVersion.getOriginalVersion());
|
||||
nbtCompound.putString("viafabricplus_forcedversion", viaFabricPlus$forcedVersion.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "fromNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void loadForcedVersion(NbtCompound root, CallbackInfoReturnable<ServerInfo> cir, ServerInfo serverInfo) {
|
||||
if (root.contains("viafabricplus_forcedversion")) {
|
||||
final VersionEnum version = VersionEnum.fromProtocolId(root.getInt("viafabricplus_forcedversion"));
|
||||
if (VersionEnum.UNKNOWN.equals(version)) {
|
||||
((IServerInfo) serverInfo).viaFabricPlus$forceVersion(null);
|
||||
} else {
|
||||
final ProtocolVersion version = ProtocolVersion.getClosest(root.getString("viafabricplus_forcedversion"));
|
||||
if (version != null) {
|
||||
((IServerInfo) serverInfo).viaFabricPlus$forceVersion(version);
|
||||
}
|
||||
}
|
||||
@ -72,12 +70,12 @@ public abstract class MixinServerInfo implements IServerInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$forcedVersion() {
|
||||
public ProtocolVersion viaFabricPlus$forcedVersion() {
|
||||
return viaFabricPlus$forcedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$forceVersion(VersionEnum version) {
|
||||
public void viaFabricPlus$forceVersion(ProtocolVersion version) {
|
||||
viaFabricPlus$forcedVersion = version;
|
||||
}
|
||||
|
||||
@ -95,12 +93,12 @@ public abstract class MixinServerInfo implements IServerInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$translatingVersion() {
|
||||
public ProtocolVersion viaFabricPlus$translatingVersion() {
|
||||
return viaFabricPlus$translatingVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setTranslatingVersion(VersionEnum version) {
|
||||
public void viaFabricPlus$setTranslatingVersion(ProtocolVersion version) {
|
||||
viaFabricPlus$translatingVersion = version;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.ipnext;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -43,14 +43,14 @@ public abstract class MixinAutoRefillHandler_ItemSlotMonitor {
|
||||
|
||||
@Inject(method = { "checkHandle", "checkShouldHandle" }, at = @At("HEAD"), cancellable = true)
|
||||
public void dontHandleOffhandSlot(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (currentSlotId == 45) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updateCurrent", at = @At(value = "FIELD", target = "Lorg/anti_ad/mc/ipnext/event/AutoRefillHandler$ItemSlotMonitor;currentSlotId:I", shift = At.Shift.AFTER), cancellable = true)
|
||||
public void dontUpdateCurrentOffhandSlot(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (currentSlotId == 45) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.lithium;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -31,9 +31,10 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(value = Entity.class, priority = 1001 /* Lithium has to be applied first */)
|
||||
public abstract class MixinEntity {
|
||||
|
||||
@Redirect(method = "lithiumCollideMultiAxisMovement", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0))
|
||||
@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
|
||||
@Redirect(method = "lithiumCollideMultiAxisMovement", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0), remap = false)
|
||||
private static double alwaysSortYXZ(double a) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return Double.MAX_VALUE;
|
||||
} else {
|
||||
return Math.abs(a);
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.Address;
|
||||
import net.minecraft.client.network.AddressResolver;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -43,7 +44,7 @@ public abstract class MixinAllowedAddressResolver {
|
||||
|
||||
@Inject(method = "resolve", at = @At("HEAD"), cancellable = true)
|
||||
private void oldResolveBehaviour(ServerAddress address, CallbackInfoReturnable<Optional<Address>> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5) || ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4) || ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
cir.setReturnValue(this.addressResolver.resolve(address));
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -32,7 +32,7 @@ public abstract class MixinBuiltChunk {
|
||||
|
||||
@Inject(method = "shouldBuild", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyRenderCondition(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@ -89,7 +89,7 @@ public abstract class MixinChatInputSuggestor {
|
||||
|
||||
@Unique
|
||||
private boolean viaFabricPlus$cancelTabComplete() {
|
||||
return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && this.textField.getText().startsWith("/");
|
||||
return ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) && this.textField.getText().startsWith("/");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.ClientCommandSource;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +41,7 @@ public abstract class MixinClientCommandSource {
|
||||
|
||||
@Inject(method = {"getPlayerNames", "getChatSuggestions"}, at = @At("HEAD"), cancellable = true)
|
||||
private void returnChatSuggestions(CallbackInfoReturnable<Collection<String>> cir) {
|
||||
if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
cir.setReturnValue(this.chatSuggestions);
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@ -31,7 +31,7 @@ public abstract class MixinEnchantmentHelper {
|
||||
|
||||
@ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 0))
|
||||
private static int usePossibleMinLevel(int constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
return Short.MIN_VALUE;
|
||||
} else {
|
||||
return constant;
|
||||
@ -40,7 +40,7 @@ public abstract class MixinEnchantmentHelper {
|
||||
|
||||
@ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 255))
|
||||
private static int usePossibleMaxLevel(int constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
return Short.MAX_VALUE;
|
||||
} else {
|
||||
return constant;
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.data.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
@ -26,7 +27,6 @@ import net.minecraft.fluid.FlowableFluid;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -36,9 +36,9 @@ public abstract class MixinFlowableFluid {
|
||||
|
||||
@Redirect(method = "isFlowBlocked", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isSideSolidFullSquare(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;)Z"))
|
||||
private boolean modifyIsSolidBlock(BlockState instance, BlockView blockView, BlockPos blockPos, Direction direction) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
return Material1_19_4.getMaterial(instance).solid();
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
final Block block = instance.getBlock();
|
||||
if (block instanceof ShulkerBoxBlock || block instanceof LeavesBlock || block instanceof TrapdoorBlock ||
|
||||
block == Blocks.BEACON || block == Blocks.CAULDRON || block == Blocks.GLASS ||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -37,7 +37,7 @@ public abstract class MixinGameOptions {
|
||||
|
||||
@ModifyVariable(method = "setServerViewDistance", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private int changeServerViewDistance(int viewDistance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
|
||||
return 0;
|
||||
} else {
|
||||
return viewDistance;
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -44,7 +44,7 @@ public abstract class MixinGameRenderer {
|
||||
|
||||
@ModifyExpressionValue(method = "updateTargetedEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"))
|
||||
private HitResult bedrockReachAroundRaycast(HitResult hitResult) {
|
||||
if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
final Entity entity = this.client.getCameraEntity();
|
||||
if (hitResult.getType() != HitResult.Type.MISS) return hitResult;
|
||||
if (!this.viaFabricPlus$canReachAround(entity)) return hitResult;
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.input.KeyboardInput;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
@ -33,9 +33,9 @@ public abstract class MixinKeyboardInput extends Input {
|
||||
|
||||
@ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true)
|
||||
private boolean changeSneakSlowdownCondition(boolean slowDown) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return this.sneaking;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown);
|
||||
} else {
|
||||
return slowDown;
|
||||
|
@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
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;
|
||||
@ -38,7 +39,6 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -89,17 +89,17 @@ public abstract class MixinMinecraftClient {
|
||||
|
||||
@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;shouldSwingHand()Z", ordinal = 0))
|
||||
private boolean disableSwing(ActionResult instance) {
|
||||
return instance.shouldSwingHand() && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
|
||||
return instance.shouldSwingHand() && ProtocolHack.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
|
||||
}
|
||||
|
||||
@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;shouldSwingHand()Z", ordinal = 2))
|
||||
private boolean disableSwing2(ActionResult instance) {
|
||||
return instance.shouldSwingHand() && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
|
||||
return instance.shouldSwingHand() && ProtocolHack.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||
private boolean disableSwing(ClientPlayerEntity instance, Hand hand) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_14_4);
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_14_4);
|
||||
}
|
||||
|
||||
@Inject(method = "tick",
|
||||
@ -130,19 +130,19 @@ public abstract class MixinMinecraftClient {
|
||||
|
||||
@Inject(method = "doAttack", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;", shift = At.Shift.BEFORE, ordinal = 0))
|
||||
private void fixSwingPacketOrder(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
this.player.swingHand(Hand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "doAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||
private boolean fixSwingPacketOrder(ClientPlayerEntity instance, Hand hand) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8);
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_8);
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
|
||||
private int moveCooldownIncrement(MinecraftClient instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return 0;
|
||||
} else {
|
||||
return attackCooldown;
|
||||
@ -151,7 +151,7 @@ public abstract class MixinMinecraftClient {
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
|
||||
private void moveCooldownIncrement(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (this.attackCooldown > 0) {
|
||||
--this.attackCooldown;
|
||||
}
|
||||
@ -160,7 +160,7 @@ public abstract class MixinMinecraftClient {
|
||||
|
||||
@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
|
||||
private boolean allowBlockBreakAndItemUsageAtTheSameTime(boolean original) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_7_6tor1_7_10) && original;
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_7_6) && original;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMouseKeyboard;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.MathUtil;
|
||||
@ -28,7 +29,6 @@ import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.option.SimpleOption;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -62,7 +62,7 @@ public abstract class MixinMouse implements IMouseKeyboard {
|
||||
private Object adjustMouseSensitivity1_13_2(SimpleOption<Double> instance, Operation<Double> original) {
|
||||
final Double value = original.call(instance);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return (double) MathUtil.get1_13SliderValue(value.floatValue()).keyFloat();
|
||||
} else {
|
||||
return value;
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -35,7 +35,7 @@ public abstract class MixinPlayerInventory {
|
||||
|
||||
@Redirect(method = "<init>", slice = @Slice(from = @At(value = "CONSTANT", args = "intValue=1")), at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/DefaultedList;ofSize(ILjava/lang/Object;)Lnet/minecraft/util/collection/DefaultedList;", ordinal = 0))
|
||||
private <T> DefaultedList<T> redirectOffhandInventory(int size, T def) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
//noinspection MixinInnerClass
|
||||
return new DefaultedList<>(new AbstractList<T>() {
|
||||
@Override
|
||||
|
@ -21,13 +21,13 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.yggdrasil.ProfileResult;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.client.texture.PlayerSkinProvider;
|
||||
import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.util.Util;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -39,7 +39,7 @@ public abstract class MixinPlayerListEntry {
|
||||
|
||||
@Redirect(method = "texturesSupplier", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PlayerSkinProvider;fetchSkinTextures(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
private static CompletableFuture<SkinTextures> fetchGameProfileProperties(PlayerSkinProvider instance, GameProfile profile) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && !profile.getProperties().containsKey("textures")) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20) && !profile.getProperties().containsKey("textures")) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
final ProfileResult profileResult = MinecraftClient.getInstance().getSessionService().fetchProfile(profile.getId(), true);
|
||||
return profileResult == null ? profile : profileResult.profile();
|
||||
|
@ -22,7 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.RedirectResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -36,7 +36,7 @@ public interface MixinRedirectResolver {
|
||||
|
||||
@Inject(method = "method_36911", at = @At("HEAD"), cancellable = true)
|
||||
private static void disableSrvForPre1_3(DirContext context, ServerAddress address, CallbackInfoReturnable<Optional<ServerAddress>> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThan(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
cir.setReturnValue(Optional.empty());
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -39,7 +39,7 @@ public abstract class MixinServerAddress {
|
||||
|
||||
@Inject(method = "parse", at = @At("RETURN"), cancellable = true)
|
||||
private static void resolveSrv(String address, CallbackInfoReturnable<ServerAddress> cir) {
|
||||
if (!cir.getReturnValue().equals(INVALID) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
if (!cir.getReturnValue().equals(INVALID) && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(cir.getReturnValue()).orElse(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -43,9 +43,9 @@ public abstract class MixinServerResourcePackLoader_4 {
|
||||
@Inject(method = "getHeaders", at = @At("TAIL"), cancellable = true)
|
||||
private void removeHeaders(CallbackInfoReturnable<Map<String, String>> cir) {
|
||||
final LinkedHashMap<String, String> modifiableMap = new LinkedHashMap<>(cir.getReturnValue());
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_3)) {
|
||||
modifiableMap.remove("X-Minecraft-Version-ID");
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
modifiableMap.remove("X-Minecraft-Pack-Format");
|
||||
modifiableMap.remove("User-Agent");
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.text.StringVisitable;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -62,7 +62,7 @@ public abstract class MixinTextRenderer {
|
||||
|
||||
@Inject(method = "draw(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;IIZ)I", at = @At("HEAD"), cancellable = true)
|
||||
private void allowNewLines_String(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, boolean rightToLeft, CallbackInfoReturnable<Integer> cir) {
|
||||
if (ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
if (ProtocolHack.getTargetVersion() == BedrockProtocolVersion.bedrockLatest) {
|
||||
final List<OrderedText> lines = wrapLines(StringVisitable.plain(rightToLeft ? this.mirror(text) : text), Integer.MAX_VALUE);
|
||||
if (lines.size() > 1) {
|
||||
int offsetX = 0;
|
||||
@ -76,7 +76,7 @@ public abstract class MixinTextRenderer {
|
||||
|
||||
@Inject(method = "draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I", at = @At("HEAD"), cancellable = true)
|
||||
private void allowNewLines_Text(Text text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, CallbackInfoReturnable<Integer> cir) {
|
||||
if (ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
if (ProtocolHack.getTargetVersion() == BedrockProtocolVersion.bedrockLatest) {
|
||||
final List<OrderedText> lines = wrapLines(text, Integer.MAX_VALUE);
|
||||
if (lines.size() > 1) {
|
||||
int offsetX = 0;
|
||||
@ -90,7 +90,7 @@ public abstract class MixinTextRenderer {
|
||||
|
||||
@Inject(method = "getWidth(Lnet/minecraft/text/StringVisitable;)I", at = @At("HEAD"), cancellable = true)
|
||||
private void allowNewLines_getWidth(StringVisitable text, CallbackInfoReturnable<Integer> cir) {
|
||||
if (MinecraftClient.getInstance().world != null && ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
if (MinecraftClient.getInstance().world != null && ProtocolHack.getTargetVersion() == BedrockProtocolVersion.bedrockLatest) {
|
||||
int i = 0;
|
||||
for (OrderedText wrapLine : this.wrapLines(text, Integer.MAX_VALUE)) {
|
||||
if (getWidth(wrapLine) >= i) i = getWidth(wrapLine);
|
||||
|
@ -19,11 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@ -48,7 +49,7 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean isToolRequired() {
|
||||
if (this.getBlock() instanceof ShulkerBoxBlock && ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_14)) {
|
||||
if (this.getBlock() instanceof ShulkerBoxBlock && ProtocolHack.getTargetVersion().olderThan(ProtocolVersion.v1_14)) {
|
||||
return true;
|
||||
} else {
|
||||
return this.toolRequired;
|
||||
@ -60,21 +61,21 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
|
||||
final Block block = this.getBlock();
|
||||
|
||||
if (block.equals(Blocks.END_STONE_BRICKS) || block.equals(Blocks.END_STONE_BRICK_SLAB) || block.equals(Blocks.END_STONE_BRICK_STAIRS) || block.equals(Blocks.END_STONE_BRICK_WALL)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
cir.setReturnValue(0.8F);
|
||||
}
|
||||
} else if (block.equals(Blocks.PISTON) || block.equals(Blocks.STICKY_PISTON) || block.equals(Blocks.PISTON_HEAD)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(0.5F);
|
||||
}
|
||||
} else if (block instanceof InfestedBlock) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(0.75F);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(0F);
|
||||
}
|
||||
} else if (block.equals(Blocks.OBSIDIAN)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
cir.setReturnValue(10.0F);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.AbstractSignBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -32,7 +33,6 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -47,10 +47,10 @@ public abstract class MixinAbstractSignBlock {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
// <= 1.14.4 doesn't have any sign interactions.
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) {
|
||||
// Removes the isWaxed() condition and reverts the interaction changes from 1.19.4 -> 1.20 when signs
|
||||
// got a front and back side.
|
||||
final ItemStack itemStack = player.getStackInHand(hand);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
@ -27,7 +28,6 @@ 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.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -60,7 +60,7 @@ public abstract class MixinAnvilBlock extends FallingBlock {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaFabricPlusMixinPlugin.MORE_CULLING_PRESENT && viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? viaFabricPlus$x_axis_shape_r1_12_2 : viaFabricPlus$z_axis_shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.BambooBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -35,7 +35,7 @@ public abstract class MixinBambooBlock {
|
||||
|
||||
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
|
||||
private void changeBlockBoundingBox(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
@ -26,7 +27,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,14 +51,14 @@ public abstract class MixinBedBlock extends HorizontalFacingBlock {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaFabricPlusMixinPlugin.MORE_CULLING_PRESENT && viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_13_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelEntityBounce(Entity entity, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -46,7 +46,7 @@ public abstract class MixinBrewingStandBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@ -43,7 +43,7 @@ public abstract class MixinCarpetBlock extends Block {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
return viaFabricPlus$shape_r1_7_10;
|
||||
} else {
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@ -53,7 +53,7 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ViaFabricPlusMixinPlugin.MORE_CULLING_PRESENT && viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
return viaFabricPlus$shape_r1_12_2;
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
|
@ -31,7 +31,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -70,14 +70,14 @@ public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntit
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
if (state.get(ChestBlock.CHEST_TYPE) == ChestType.SINGLE) {
|
||||
return SINGLE_SHAPE;
|
||||
} else {
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.CropBlock;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -38,7 +38,7 @@ public abstract class MixinCropBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DecoratedPotBlock;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -39,7 +39,7 @@ public abstract class MixinDecoratedPotBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void alwaysPass(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) {
|
||||
cir.setReturnValue(ActionResult.PASS);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -46,9 +46,9 @@ public abstract class MixinEndPortalBlock extends BlockWithEntity {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_16_5);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -29,7 +30,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -61,14 +61,14 @@ public abstract class MixinEndPortalFrameBlock extends Block {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(FRAME_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
return state.get(EYE) ? viaFabricPlus$frame_with_eye_shape_r1_12_2 : FRAME_SHAPE;
|
||||
} else {
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -49,14 +49,14 @@ public abstract class MixinEnderChestBlock extends BlockWithEntity {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
return SHAPE;
|
||||
} else {
|
||||
return super.getCullingShape(state, view, pos);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -49,14 +49,14 @@ public abstract class MixinFarmlandBlock extends Block {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
|
||||
return SHAPE;
|
||||
} else {
|
||||
return super.getCullingShape(state, view, pos);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@ -26,7 +27,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -52,7 +53,7 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void alwaysSuccess(CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10)) {
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
@ -65,9 +66,9 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
return VoxelShapes.fullCube();
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
return this.viaFabricPlus$outline_shape_r1_4_7[this.getShapeIndex(state)];
|
||||
} else {
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
@ -76,9 +77,9 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
return viaFabricPlus$shape_b1_8_1;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
return this.viaFabricPlus$collision_shape_r1_4_7[this.getShapeIndex(state)];
|
||||
} else {
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
|
@ -25,7 +25,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -44,14 +44,14 @@ public abstract class MixinFenceGateBlock extends HorizontalFacingBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (!state.get(FenceGateBlock.IN_WALL) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (!state.get(FenceGateBlock.IN_WALL) && ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (!state.get(FenceGateBlock.OPEN) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (!state.get(FenceGateBlock.OPEN) && ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
cir.setReturnValue(viaFabricPlus$x_and_z_axis_collision_shape_b1_8_1);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FireBlock;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -38,7 +38,7 @@ public abstract class MixinFireBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(VoxelShapes.empty());
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FlowerPotBlock;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +41,7 @@ public abstract class MixinFlowerPotBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
|
||||
private void alwaysConsume(CallbackInfoReturnable<ActionResult> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10) && content != Blocks.AIR) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10) && content != Blocks.AIR) {
|
||||
ci.setReturnValue(ActionResult.CONSUME);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -42,7 +42,7 @@ public abstract class MixinFlowerbedBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_20_1);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -54,14 +54,14 @@ public abstract class MixinHopperBlock extends BlockWithEntity {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ViaFabricPlusMixinPlugin.MORE_CULLING_PRESENT && viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$hopper_shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$inside_shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -51,7 +51,7 @@ public abstract class MixinLadderBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
switch (state.get(LadderBlock.FACING)) {
|
||||
case NORTH -> ci.setReturnValue(viaFabricPlus$north_shape_r1_8_x);
|
||||
case SOUTH -> ci.setReturnValue(viaFabricPlus$south_shape_r1_8_x);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -26,7 +27,6 @@ import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -41,7 +41,7 @@ public abstract class MixinLeavesBlock extends Block {
|
||||
|
||||
@Inject(method = "getSidesShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeSidesShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14, VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().betweenInclusive(ProtocolVersion.v1_14, ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(super.getSidesShape(state, world, pos));
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -42,7 +42,7 @@ public abstract class MixinLilyPadBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.NoteBlock;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -33,7 +33,7 @@ public abstract class MixinNoteBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelMobHeadUsage(CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) {
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
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 net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -85,7 +85,7 @@ public abstract class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return this.viaFabricPlus$shape_r1_8[this.getShapeIndex(state)];
|
||||
} else {
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
@ -94,7 +94,7 @@ public abstract class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return this.viaFabricPlus$shape_r1_8[this.getShapeIndex(state)];
|
||||
} else {
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -69,14 +69,14 @@ public abstract class MixinPistonBlock extends FacingBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_1)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_1)) {
|
||||
if (state.get(PistonBlock.EXTENDED)) {
|
||||
return switch (state.get(FACING)) {
|
||||
case DOWN -> EXTENDED_DOWN_SHAPE;
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
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 net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -85,7 +85,7 @@ public abstract class MixinPistonHeadBlock extends FacingBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(switch (state.get(PistonHeadBlock.FACING)) {
|
||||
case DOWN -> DOWN_HEAD_SHAPE;
|
||||
case UP -> UP_HEAD_SHAPE;
|
||||
@ -99,7 +99,7 @@ public abstract class MixinPistonHeadBlock extends FacingBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return switch (state.get(PistonHeadBlock.FACING)) {
|
||||
case DOWN -> VoxelShapes.union(DOWN_HEAD_SHAPE, viaFabricPlus$down_arm_shape_r1_8_x);
|
||||
case UP -> VoxelShapes.union(UP_HEAD_SHAPE, viaFabricPlus$up_arm_shape_r1_8_x);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,7 +29,6 @@ import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -59,7 +59,7 @@ public abstract class MixinSnowBlock {
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$layers_to_shape_r1_12_2[state.get(LAYERS) - 1]);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -29,7 +30,6 @@ import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -44,21 +44,21 @@ public abstract class MixinSoulSandBlock extends Block {
|
||||
|
||||
@Inject(method = "getSidesShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeSidesShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_13, VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().betweenInclusive(ProtocolVersion.v1_13, ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(VoxelShapes.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
entity.setVelocity(entity.getVelocity().multiply(0.4D, 1, 0.4D));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVelocityMultiplier() {
|
||||
return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4) ? 1F : super.getVelocityMultiplier();
|
||||
return ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4) ? 1F : super.getVelocityMultiplier();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
@ -32,7 +33,6 @@ import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -72,35 +72,35 @@ public abstract class MixinWallBlock extends Block {
|
||||
|
||||
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyPlacementState(CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyBlockState(CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(this.viaFabricPlus$collision_shape_r1_12_2[this.viaFabricPlus$getShapeIndex(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(this.viaFabricPlus$outline_shape_r1_12_2[this.viaFabricPlus$getShapeIndex(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
return this.shapeMap.get(state);
|
||||
} else {
|
||||
return super.getCullingShape(state, world, pos);
|
||||
|
@ -20,12 +20,12 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -40,7 +40,7 @@ public abstract class MixinAbstractClientPlayerEntity extends PlayerEntity {
|
||||
|
||||
@Inject(method = "isCreative", at = @At("HEAD"), cancellable = true)
|
||||
private void fixCreativeCheck(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(this.getAbilities().creativeMode);
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.passive.AbstractHorseEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -37,7 +37,7 @@ public abstract class MixinAbstractHorseEntity {
|
||||
|
||||
@Redirect(method = "interactHorse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/AbstractHorseEntity;receiveFood(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;)Z"))
|
||||
private boolean decrementFoodItemClientside(AbstractHorseEntity instance, PlayerEntity player, ItemStack item) {
|
||||
return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2) || this.receiveFood(player, item);
|
||||
return ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2) || this.receiveFood(player, item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -32,7 +32,7 @@ public abstract class MixinAnimalEntity {
|
||||
|
||||
@Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z"))
|
||||
private boolean fixIsClientCheck(World instance) {
|
||||
return instance.isClient && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
|
||||
return instance.isClient && ProtocolHack.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.EntityRidingOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
@ -37,7 +38,7 @@ import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -85,7 +86,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
|
||||
@Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true)
|
||||
private void pushAwayFrom1_8(Entity entity, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ci.cancel();
|
||||
super.pushAwayFrom(entity);
|
||||
}
|
||||
@ -93,9 +94,9 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
|
||||
@Inject(method = "updateTrackedPositionAndAngles", at = @At("HEAD"), cancellable = true)
|
||||
private void updateTrackedPositionAndAngles1_8(double x, double y, double z, float yaw, float pitch, int interpolationSteps, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ci.cancel();
|
||||
if (/*interpolate &&*/ this.hasPassengers() && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
if (/*interpolate &&*/ this.hasPassengers() && ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_7_6)) {
|
||||
this.prevX = x;
|
||||
this.prevY = y;
|
||||
this.prevZ = z;
|
||||
@ -128,14 +129,14 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
public void setVelocityClient(double x, double y, double z) {
|
||||
super.setVelocityClient(x, y, z);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
this.viaFabricPlus$boatVelocity = new Vec3d(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
private void tick1_8(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ci.cancel();
|
||||
super.tick();
|
||||
|
||||
@ -161,7 +162,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
}
|
||||
|
||||
final double oldHorizontalSpeed = this.getVelocity().horizontalLength();
|
||||
if (oldHorizontalSpeed > (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10) ? 0.2625D : 0.2975D)) {
|
||||
if (oldHorizontalSpeed > (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6) ? 0.2625D : 0.2975D)) {
|
||||
final double rx = Math.cos(this.getYaw() * Math.PI / 180);
|
||||
final double rz = Math.sin(this.getYaw() * Math.PI / 180);
|
||||
for (int i = 0; i < 1 + oldHorizontalSpeed * 60; i++) {
|
||||
@ -209,11 +210,11 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
|
||||
if (this.getControllingPassenger() != null) {
|
||||
final LivingEntity passenger = this.getControllingPassenger();
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_5_2)) {
|
||||
final double xAcceleration = passenger.getVelocity().x * this.viaFabricPlus$speedMultiplier;
|
||||
final double zAcceleration = passenger.getVelocity().z * this.viaFabricPlus$speedMultiplier;
|
||||
this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration));
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
if (passenger.forwardSpeed > 0) {
|
||||
final double xAcceleration = -Math.sin(passenger.getYaw() * Math.PI / 180) * this.viaFabricPlus$speedMultiplier * 0.05D;
|
||||
final double zAcceleration = Math.cos(passenger.getYaw() * Math.PI / 180) * this.viaFabricPlus$speedMultiplier * 0.05D;
|
||||
@ -246,7 +247,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_6_4)) {
|
||||
if (ProtocolHack.getTargetVersion().newerThan(LegacyProtocolVersion.r1_6_4)) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
final int dx = MathHelper.floor(this.getX() + ((i % 2) - 0.5D) * 0.8D);
|
||||
//noinspection IntegerDivisionInFloatingPointContext
|
||||
@ -289,7 +290,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
|
||||
@Inject(method = "updatePassengerPosition", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void updatePassengerPosition1_8(Entity passenger, PositionUpdater positionUpdater, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
final Vec3d newPosition = new Vec3d(EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(this, passenger)).add(this.getPos());
|
||||
positionUpdater.accept(passenger, newPosition.x, newPosition.y + EntityRidingOffsetsPre1_20_2.getHeightOffset(passenger), newPosition.z);
|
||||
ci.cancel();
|
||||
@ -298,7 +299,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
|
||||
@Inject(method = "onPassengerLookAround", at = @At("HEAD"), cancellable = true)
|
||||
private void onPassengerLookAround1_8(Entity passenger, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ci.cancel();
|
||||
super.onPassengerLookAround(passenger);
|
||||
}
|
||||
@ -306,17 +307,17 @@ public abstract class MixinBoatEntity extends VehicleEntity {
|
||||
|
||||
@Inject(method = "fall", at = @At("HEAD"), cancellable = true)
|
||||
private void fall1_8(double heightDifference, boolean onGround, BlockState state, BlockPos landedPosition, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
ci.cancel();
|
||||
super.fall(heightDifference, onGround, state, landedPosition);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
this.location = BoatEntity.Location.ON_LAND;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "canAddPassenger", at = @At("HEAD"), cancellable = true)
|
||||
private void canAddPassenger1_8(Entity passenger, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(super.canAddPassenger(passenger));
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@ -26,7 +27,6 @@ import net.minecraft.entity.passive.AbstractHorseEntity;
|
||||
import net.minecraft.entity.passive.CamelEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@ -39,7 +39,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity {
|
||||
|
||||
@Override
|
||||
public void onPassengerLookAround(Entity passenger) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && this.getControllingPassenger() != passenger) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20) && this.getControllingPassenger() != passenger) {
|
||||
this.viaFabricPlus$clampPassengerYaw1_20_1(passenger);
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity {
|
||||
protected void updatePassengerPosition(Entity passenger, PositionUpdater positionUpdater) {
|
||||
super.updatePassengerPosition(passenger, positionUpdater);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
this.viaFabricPlus$clampPassengerYaw1_20_1(passenger);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -36,9 +37,9 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.Protocol1_6_1to1_5_2;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -73,17 +74,17 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 0))
|
||||
private boolean removeVehicleRequirement(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_20tor1_20_1) && instance.hasVehicle();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_20) && instance.hasVehicle();
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSprintingPacket()V"))
|
||||
private boolean removeSprintingPacket(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3);
|
||||
return ProtocolHack.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_19_3);
|
||||
}
|
||||
|
||||
@Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F"))
|
||||
private float useFastInverseSqrt(float x) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
|
||||
x = Float.intBitsToFloat(1597463007 - (Float.floatToIntBits(x) >> 1));
|
||||
return x * (1.5F - (0.5F * x) * x * x);
|
||||
} else {
|
||||
@ -93,22 +94,22 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
||||
private boolean removeVehicleCheck(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_19_3) && instance.hasVehicle();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.hasVehicle();
|
||||
}
|
||||
|
||||
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isFallFlying()Z"))
|
||||
private boolean removeFallFlyingCheck(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_19_3) && instance.isFallFlying();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.isFallFlying();
|
||||
}
|
||||
|
||||
@Redirect(method = "canSprint", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
||||
private boolean dontAllowSprintingAsPassenger(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_19_1tor1_19_2) && instance.hasVehicle();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_19_1) && instance.hasVehicle();
|
||||
}
|
||||
|
||||
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
|
||||
private double changeMagnitude(double n) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
|
||||
return 9.0E-4D;
|
||||
} else {
|
||||
return MathHelper.square(n);
|
||||
@ -117,7 +118,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Inject(method = "startRiding", at = @At("RETURN"))
|
||||
private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||
if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
|
||||
this.prevYaw = entity.getYaw();
|
||||
this.setYaw(entity.getYaw());
|
||||
this.setHeadYaw(entity.getYaw());
|
||||
@ -126,24 +127,24 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isClimbing()Z"))
|
||||
private boolean allowElytraWhenClimbing(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_15_1) && instance.isClimbing();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_15_1) && instance.isClimbing();
|
||||
}
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 3))
|
||||
private boolean allowElytraInVehicle(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_14_4) && instance.hasVehicle();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_14_4) && instance.hasVehicle();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "tickMovement", at = @At(value = "LOAD", ordinal = 4), ordinal = 4)
|
||||
private boolean removeBl8Boolean(boolean value) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_14_4) && value;
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_14_4) && value;
|
||||
}
|
||||
|
||||
@Inject(method = "tickMovement()V",
|
||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z")),
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/Input;sneaking:Z", ordinal = 0))
|
||||
private void injectTickMovement(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
if (this.input.sneaking) {
|
||||
this.input.movementSideways = (float) ((double) this.input.movementSideways / 0.3D);
|
||||
this.input.movementForward = (float) ((double) this.input.movementForward / 0.3D);
|
||||
@ -153,14 +154,14 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Inject(method = "isWalking", at = @At("HEAD"), cancellable = true)
|
||||
private void easierUnderwaterSprinting(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
|
||||
cir.setReturnValue(((ClientPlayerEntity) (Object) this).input.movementForward >= 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z", ordinal = 0))
|
||||
private boolean disableSprintSneak(Input input) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_1)) {
|
||||
return input.movementForward >= 0.8F;
|
||||
} else {
|
||||
return input.hasForwardMovement();
|
||||
@ -171,17 +172,17 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0))
|
||||
private boolean dontAllowSneakingWhileSwimming(ClientPlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_14_1) && instance.isSwimming();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_14_1) && instance.isSwimming();
|
||||
}
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))
|
||||
private boolean disableWaterRelatedMovement(ClientPlayerEntity self) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2) && self.isTouchingWater();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_12_2) && self.isTouchingWater();
|
||||
}
|
||||
|
||||
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 0))
|
||||
private int moveLastPosPacketIncrement(ClientPlayerEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return ticksSinceLastPositionPacketSent - 1; // Reverting original operation
|
||||
} else {
|
||||
return ticksSinceLastPositionPacketSent;
|
||||
@ -190,7 +191,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
||||
private void moveLastPosPacketIncrement(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
this.ticksSinceLastPositionPacketSent++;
|
||||
}
|
||||
}
|
||||
@ -206,7 +207,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Redirect(method = "tick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0))
|
||||
private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet<?> packet) throws Exception {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_5_2)) {
|
||||
final PacketWrapper playerPosition = PacketWrapper.create(ServerboundPackets1_5_2.PLAYER_POSITION_AND_ROTATION, ((IClientConnection) this.networkHandler.getConnection()).viaFabricPlus$getUserConnection());
|
||||
playerPosition.write(Type.DOUBLE, this.getVelocity().x); // x
|
||||
playerPosition.write(Type.DOUBLE, -999.0D); // y
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -42,7 +42,7 @@ public abstract class MixinCowEntity extends AnimalEntity {
|
||||
|
||||
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
|
||||
private void disableMilkingInCreative(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2) && player.getAbilities().creativeMode) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2) && player.getAbilities().creativeMode) {
|
||||
cir.setReturnValue(super.interactMob(player, hand));
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.mob.CreeperEntity;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -33,7 +33,7 @@ public abstract class MixinCreeperEntity {
|
||||
|
||||
@Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/sound/SoundEvents;ITEM_FIRECHARGE_USE:Lnet/minecraft/sound/SoundEvent;"))
|
||||
private SoundEvent changeSound() {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
return SoundEvents.ITEM_FLINTANDSTEEL_USE;
|
||||
} else {
|
||||
return SoundEvents.ITEM_FIRECHARGE_USE;
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.EntityRidingOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IEntity;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -38,7 +39,6 @@ import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.joml.Vector3f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -77,14 +77,14 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
|
||||
private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable<Float> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
cir.setReturnValue((float) EntityRidingOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this));
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;"))
|
||||
private Vector3f getPassengerRidingPos1_20_1(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger);
|
||||
} else {
|
||||
return getPassengerAttachmentPos(passenger, dimensions, scaleFactor);
|
||||
@ -93,9 +93,9 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@Inject(method = "getPosWithYOffset", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyPosWithYOffset(float offset, CallbackInfoReturnable<BlockPos> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) {
|
||||
int i = MathHelper.floor(this.pos.x);
|
||||
int j = MathHelper.floor(this.pos.y - (double) (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18_2) && offset == 1.0E-5F ? 0.2F : offset));
|
||||
int j = MathHelper.floor(this.pos.y - (double) (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18_2) && offset == 1.0E-5F ? 0.2F : offset));
|
||||
int k = MathHelper.floor(this.pos.z);
|
||||
BlockPos blockPos = new BlockPos(i, j, k);
|
||||
if (this.world.getBlockState(blockPos).isAir()) {
|
||||
@ -113,7 +113,7 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7))
|
||||
private double fixBlockCollisionMargin(double constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
return 1E-3;
|
||||
} else {
|
||||
return constant;
|
||||
@ -122,21 +122,21 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) {
|
||||
final VersionEnum target = ProtocolHack.getTargetVersion();
|
||||
final ProtocolVersion target = ProtocolHack.getTargetVersion();
|
||||
|
||||
if (target.isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
cir.setReturnValue(BlockPos.ofFloored(pos.x, getBoundingBox().minY - (target.isOlderThanOrEqualTo(VersionEnum.r1_14_4) ? 1 : 0.5000001), pos.z));
|
||||
if (target.olderThanOrEqualTo(ProtocolVersion.v1_19_4)) {
|
||||
cir.setReturnValue(BlockPos.ofFloored(pos.x, getBoundingBox().minY - (target.olderThanOrEqualTo(ProtocolVersion.v1_14_4) ? 1 : 0.5000001), pos.z));
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z"))
|
||||
private boolean allowInfiniteValues(float f) {
|
||||
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5));
|
||||
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4));
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
|
||||
private static double fixVelocityEpsilon(double epsilon) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return 1E-4;
|
||||
} else {
|
||||
return epsilon;
|
||||
@ -145,7 +145,7 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@Redirect(method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Ljava/util/List;)Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0))
|
||||
private static double alwaysSortYXZ(double a) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return Double.MAX_VALUE;
|
||||
} else {
|
||||
return Math.abs(a);
|
||||
@ -154,21 +154,21 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
|
||||
private void revertCalculation(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(Vec3d.fromPolar(pitch, yaw));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "setSwimming", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelSwimming(boolean swimming, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && swimming) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) && swimming) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updateMovementInFluid", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyFluidMovementBoundingBox(TagKey<Fluid> fluidTag, double d, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public abstract class MixinEntity implements IEntity {
|
||||
|
||||
@Inject(method = "getTargetingMargin", at = @At("HEAD"), cancellable = true)
|
||||
private void expandHitBox(CallbackInfoReturnable<Float> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(0.1F);
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.world.entity.EntityIndex;
|
||||
import net.minecraft.world.entity.EntityLike;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -44,12 +44,12 @@ public abstract class MixinEntityIndex<T extends EntityLike> {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Ljava/util/Map;containsKey(Ljava/lang/Object;)Z", remap = false))
|
||||
private boolean allowDuplicateUuid(Map<UUID, T> instance, Object o) {
|
||||
return instance.containsKey(o) && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_16_4tor1_16_5);
|
||||
return instance.containsKey(o) && ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_16_4);
|
||||
}
|
||||
|
||||
@Inject(method = "size", at = @At("HEAD"), cancellable = true)
|
||||
private void returnRealSize(CallbackInfoReturnable<Integer> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(this.idToEntity.size());
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.BoatRenderer1_8;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
@ -27,7 +28,6 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -50,7 +50,7 @@ public abstract class MixinEntityRenderDispatcher {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true)
|
||||
private <T extends Entity> void useBoatRenderer1_8(T entity, CallbackInfoReturnable<EntityRenderer<? super T>> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && entity instanceof BoatEntity) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8) && entity instanceof BoatEntity) {
|
||||
ci.setReturnValue((EntityRenderer<? super T>) viaFabricPlus$boatRenderer);
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -32,7 +32,7 @@ public abstract class MixinItemEntity {
|
||||
|
||||
@Inject(method = "applyWaterBuoyancy", at = @At("HEAD"), cancellable = true)
|
||||
private void dontApplyWaterBuoyancy(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.EntityRidingOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
@ -38,7 +39,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.joml.Vector3f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -75,14 +77,14 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
|
||||
private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable<Float> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
cir.setReturnValue((float) EntityRidingOffsetsPre1_20_2.getHeightOffset(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;"))
|
||||
private Vector3f getPassengerRidingPos1_20_1(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, entity);
|
||||
} else {
|
||||
return getPassengerAttachmentPos(entity, entityDimensions, v);
|
||||
@ -91,7 +93,7 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isLogicalSideForUpdatingMovement()Z"))
|
||||
private boolean allowPlayerToBeMovedByEntityPackets(LivingEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3) || ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3) || ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
return instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient;
|
||||
} else {
|
||||
return instance.isLogicalSideForUpdatingMovement();
|
||||
@ -107,7 +109,7 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D", remap = false))
|
||||
private double fixCosTable(double a) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
|
||||
return MathHelper.cos((float) a);
|
||||
} else {
|
||||
return Math.cos(a);
|
||||
@ -116,7 +118,7 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D"))
|
||||
private double dontApplyLavaMovement(LivingEntity instance, TagKey<Fluid> tagKey) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
return Double.MAX_VALUE;
|
||||
} else {
|
||||
return instance.getFluidHeight(tagKey);
|
||||
@ -125,7 +127,7 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isChunkLoaded(Lnet/minecraft/util/math/BlockPos;)Z"))
|
||||
private boolean modify1_13LoadedCheck(World instance, BlockPos blockPos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return this.getWorld().isChunkLoaded(blockPos) && instance.getChunkManager().isChunkLoaded(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
} else {
|
||||
return this.getWorld().isChunkLoaded(blockPos);
|
||||
@ -134,36 +136,36 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Redirect(method = "applyMovementInput", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;jumping:Z"))
|
||||
private boolean disableJumpOnLadder(LivingEntity self) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_13_2) && jumping;
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && jumping;
|
||||
}
|
||||
|
||||
@Redirect(method = "travel",
|
||||
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;DOLPHINS_GRACE:Lnet/minecraft/entity/effect/StatusEffect;")),
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;horizontalCollision:Z", ordinal = 0))
|
||||
private boolean disableClimbing(LivingEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_13_2) && instance.horizontalCollision;
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && instance.horizontalCollision;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "applyFluidMovingSpeed", ordinal = 0, at = @At("HEAD"), argsOnly = true)
|
||||
private boolean modifyMovingDown(boolean movingDown) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_13_2) && movingDown;
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && movingDown;
|
||||
}
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V"))
|
||||
private void dontResetLevitationFallDistance(LivingEntity instance) {
|
||||
if (this.hasStatusEffect(StatusEffects.SLOW_FALLING) || ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) {
|
||||
if (this.hasStatusEffect(StatusEffects.SLOW_FALLING) || ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) {
|
||||
instance.onLanding();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0))
|
||||
private boolean modifySwimSprintSpeed(LivingEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2) && instance.isSprinting();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_12_2) && instance.isSprinting();
|
||||
}
|
||||
|
||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D"))
|
||||
private double redirectFluidHeight(LivingEntity instance, TagKey<Fluid> tagKey) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && tagKey == FluidTags.WATER) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) && tagKey == FluidTags.WATER) {
|
||||
if (instance.getFluidHeight(tagKey) > 0) return 1;
|
||||
}
|
||||
return instance.getFluidHeight(tagKey);
|
||||
@ -171,14 +173,14 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Inject(method = "applyFluidMovingSpeed", at = @At("HEAD"), cancellable = true)
|
||||
private void modifySwimSprintFallSpeed(double gravity, boolean movingDown, Vec3d velocity, CallbackInfoReturnable<Vec3d> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && !this.hasNoGravity()) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) && !this.hasNoGravity()) {
|
||||
ci.setReturnValue(new Vec3d(velocity.x, velocity.y - 0.02, velocity.z));
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.9F))
|
||||
private float modifySwimFriction(float constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
return this.getBaseMovementSpeedMultiplier();
|
||||
} else {
|
||||
return constant;
|
||||
@ -187,14 +189,14 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true)
|
||||
private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable<EquipmentSlot> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3) && stack.isOf(Items.SHIELD)) {
|
||||
cir.setReturnValue(EquipmentSlot.MAINHAND);
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "tickMovement", constant = @Constant(doubleValue = 0.003D))
|
||||
private double modifyVelocityZero(final double constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return 0.005D;
|
||||
} else {
|
||||
return constant;
|
||||
@ -203,28 +205,28 @@ public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Inject(method = "canEnterTrapdoor", at = @At("HEAD"), cancellable = true)
|
||||
private void disableCrawling(CallbackInfoReturnable<Boolean> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void modify1_7StepHeight(EntityType<? extends LivingEntity> type, World world, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
this.setStepHeight(0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickMovement", at = @At("HEAD"))
|
||||
private void removeJumpDelay1_0(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
this.jumpingCooldown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "isClimbing", at = @At("RETURN"), cancellable = true)
|
||||
private void allowGappedLadderClimb(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.b1_5tob1_5_2) && !cir.getReturnValueZ() && !this.isSpectator()) {
|
||||
if (ProtocolHack.getTargetVersion().olderThan(LegacyProtocolVersion.b1_5tob1_5_2) && !cir.getReturnValueZ() && !this.isSpectator()) {
|
||||
final BlockPos blockPos = this.getBlockPos().up();
|
||||
final BlockState blockState = this.getWorld().getBlockState(blockPos);
|
||||
if (blockState.isIn(BlockTags.CLIMBABLE)) {
|
||||
|
@ -20,11 +20,11 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.network.OtherClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -39,7 +39,7 @@ public abstract class MixinOtherClientPlayerEntity extends AbstractClientPlayerE
|
||||
|
||||
@Inject(method = "updatePose", at = @At("HEAD"))
|
||||
private void onUpdatePose(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
super.updatePose();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalFloatRef;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -40,7 +41,7 @@ import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -79,7 +80,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Redirect(method = "getMaxRelativeHeadRotation", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isBlocking()Z"))
|
||||
private boolean dontModifyHeadRotationWhenBlocking(PlayerEntity instance) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_20_2) && instance.isBlocking();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_20_2) && instance.isBlocking();
|
||||
}
|
||||
|
||||
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setMovementSpeed(F)V"))
|
||||
@ -89,7 +90,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Redirect(method = "getOffGroundSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z"))
|
||||
private boolean useLastSprintingState(PlayerEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
|
||||
return viaFabricPlus$isSprinting;
|
||||
} else {
|
||||
return instance.isSprinting();
|
||||
@ -98,17 +99,17 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@WrapWithCondition(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||
private boolean dontSwingHand(PlayerEntity instance, Hand hand) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_15_2);
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_15_2);
|
||||
}
|
||||
|
||||
@Redirect(method = "checkFallFlying", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"))
|
||||
private boolean allowElytraWhenLevitating(PlayerEntity instance, StatusEffect statusEffect) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_15_2) && instance.hasStatusEffect(statusEffect);
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_15_2) && instance.hasStatusEffect(statusEffect);
|
||||
}
|
||||
|
||||
@Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true)
|
||||
private void replaceFallFlyingCondition(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
if (!this.isOnGround() && this.getVelocity().y < 0D && !this.isFallFlying()) {
|
||||
final ItemStack itemStack = this.getEquippedStack(EquipmentSlot.CHEST);
|
||||
if (itemStack.isOf(Items.ELYTRA) && ElytraItem.isUsable(itemStack)) {
|
||||
@ -122,7 +123,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@ModifyConstant(method = "getActiveEyeHeight", constant = @Constant(floatValue = 1.27f))
|
||||
private float modifySneakEyeHeight(float prevEyeHeight) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return 1.54F;
|
||||
} else {
|
||||
return prevEyeHeight;
|
||||
@ -131,7 +132,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Inject(method = "updatePose", at = @At("HEAD"), cancellable = true)
|
||||
private void onUpdatePose(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
final EntityPose pose;
|
||||
if (this.isFallFlying()) {
|
||||
pose = EntityPose.FALL_FLYING;
|
||||
@ -154,9 +155,9 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
@Inject(method = "getDimensions", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> cir) {
|
||||
if (pose == EntityPose.CROUCHING) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(PlayerEntity.STANDING_DIMENSIONS);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$sneaking_dimensions_v1_13_2);
|
||||
}
|
||||
}
|
||||
@ -164,7 +165,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Redirect(method = "adjustMovementForSneaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getStepHeight()F"))
|
||||
private float modifyStepHeight1_10(PlayerEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10)) {
|
||||
return 1.0F;
|
||||
} else {
|
||||
return instance.getStepHeight();
|
||||
@ -173,7 +174,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Inject(method = "getAttackCooldownProgress", at = @At("HEAD"), cancellable = true)
|
||||
private void removeAttackCooldown(CallbackInfoReturnable<Float> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
ci.setReturnValue(1F);
|
||||
}
|
||||
}
|
||||
@ -192,11 +193,11 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
final float speed = this.inventory.getBlockBreakingSpeed(block);
|
||||
final int effLevel = efficiency * efficiency + 1;
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_4tor1_4_5) && this.canHarvest(block)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_4tor1_4_5) && this.canHarvest(block)) {
|
||||
f.set(speed + effLevel);
|
||||
} else if (speed > 1F || ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
} else if (speed > 1F || ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
if (!this.getMainHandStack().isEmpty()) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
if (speed <= 1.0 && !this.canHarvest(block)) {
|
||||
f.set(speed + effLevel * 0.08F);
|
||||
} else {
|
||||
@ -210,7 +211,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
@Redirect(method = "getBlockBreakingSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"))
|
||||
private boolean changeSpeedCalculation(PlayerEntity instance, StatusEffect statusEffect, @Local LocalFloatRef f) {
|
||||
final boolean hasMiningFatigue = instance.hasStatusEffect(statusEffect);
|
||||
if (hasMiningFatigue && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
if (hasMiningFatigue && ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
f.set(f.get() * (1.0F - (this.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier() + 1) * 0.2F));
|
||||
if (f.get() < 0) f.set(0);
|
||||
return false; // disable original code
|
||||
@ -220,7 +221,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Inject(method = "getReachDistance", at = @At("RETURN"), cancellable = true)
|
||||
private static void modifyReachDistance(boolean creative, CallbackInfoReturnable<Float> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_0_0tor1_0_1) && !creative) {
|
||||
if (ProtocolHack.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1) && !creative) {
|
||||
cir.setReturnValue(4F);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.entity.PlayerEntityRenderer;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -40,13 +41,13 @@ public abstract class MixinPlayerEntityRenderer {
|
||||
if (player.getPose() == EntityPose.SLEEPING) {
|
||||
final Direction sleepingDir = player.getSleepingDirection();
|
||||
if (sleepingDir != null) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
cir.setReturnValue(cir.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.4, 0, sleepingDir.getOffsetZ() * 0.4));
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_5tob1_5_2)) {
|
||||
cir.setReturnValue(cir.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.1, 0, sleepingDir.getOffsetZ() * 0.1));
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.b1_6tob1_6_6, VersionEnum.r1_7_6tor1_7_10)) {
|
||||
if (ProtocolHack.getTargetVersion().betweenInclusive(LegacyProtocolVersion.b1_6tob1_6_6, ProtocolVersion.v1_7_6)) {
|
||||
cir.setReturnValue(cir.getReturnValue().subtract(0, 0.3F, 0));
|
||||
}
|
||||
}
|
||||
@ -56,7 +57,7 @@ public abstract class MixinPlayerEntityRenderer {
|
||||
@Redirect(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isInSneakingPose()Z"))
|
||||
private boolean disableSneakPositionOffset(AbstractClientPlayerEntity player) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2) && player.isInSneakingPose();
|
||||
return ProtocolHack.getTargetVersion().newerThan(ProtocolVersion.v1_11_1) && player.isInSneakingPose();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.mob.SkeletonHorseEntity;
|
||||
import net.minecraft.entity.passive.AbstractHorseEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -39,7 +39,7 @@ public abstract class MixinSkeletonHorseEntity extends AbstractHorseEntity {
|
||||
|
||||
@Inject(method = "getBaseMovementSpeedMultiplier", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyBaseMovementSpeedMultiplier(CallbackInfoReturnable<Float> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
cir.setReturnValue(super.getBaseMovementSpeedMultiplier());
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.passive.SquidEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -33,7 +33,7 @@ public abstract class MixinSquidEntity {
|
||||
|
||||
@Inject(method = "canBeLeashedBy", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelLeashing(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.tracker.WolfHealthTracker;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@ -34,7 +35,6 @@ import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -58,7 +58,7 @@ public abstract class MixinWolfEntity extends TameableEntity implements Angerabl
|
||||
|
||||
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
|
||||
private void fixWolfInteract(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
final ItemStack itemStack = player.getStackInHand(hand);
|
||||
final Item item = itemStack.getItem();
|
||||
if (this.isTamed()) {
|
||||
@ -90,7 +90,7 @@ public abstract class MixinWolfEntity extends TameableEntity implements Angerabl
|
||||
|
||||
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;getHealth()F"))
|
||||
private float fixWolfHealth(WolfEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
return this.viaFabricPlus$getWolfHealth();
|
||||
} else {
|
||||
return instance.getHealth();
|
||||
|
@ -27,7 +27,7 @@ import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -38,7 +38,7 @@ public abstract class MixinArmorItem {
|
||||
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
private void disableRightClick(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
cir.setReturnValue(new TypedActionResult<>(ActionResult.FAIL, user.getStackInHand(hand)));
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user