mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-22 11:56:21 +01:00
Cleaned source code tree
This commit is contained in:
parent
93c2abf8f1
commit
b8152d13ca
@ -21,11 +21,11 @@ package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
||||
public class ActionResultException extends RuntimeException {
|
||||
public class ActionResultException1_12_2 extends RuntimeException {
|
||||
|
||||
private final ActionResult actionResult;
|
||||
|
||||
public ActionResultException(final ActionResult actionResult) {
|
||||
public ActionResultException1_12_2(final ActionResult actionResult) {
|
||||
this.actionResult = actionResult;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import net.minecraft.registry.Registries;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ArmorUpdateListener {
|
||||
public class ArmorHudEmulation1_8 {
|
||||
|
||||
private static final UUID ARMOR_POINTS_UUID = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class BlockFixes {
|
||||
|
||||
private static final float DEFAULT_SOUL_SAND_VELOCITY_MULTIPLIER = Blocks.SOUL_SAND.getVelocityMultiplier();
|
||||
private static final float _1_14_4_SOUL_SAND_VELOCITY_MULTIPLIER = 1F;
|
||||
|
||||
public static void init() {
|
||||
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> {
|
||||
// Soul sand velocity multiplier
|
||||
if (isNewerThan(oldVersion, newVersion, VersionEnum.r1_14_4)) {
|
||||
Blocks.SOUL_SAND.velocityMultiplier = DEFAULT_SOUL_SAND_VELOCITY_MULTIPLIER;
|
||||
}
|
||||
if (isOlderThanOrEqualTo(oldVersion, newVersion, VersionEnum.r1_14_4)) {
|
||||
Blocks.SOUL_SAND.velocityMultiplier = _1_14_4_SOUL_SAND_VELOCITY_MULTIPLIER;
|
||||
}
|
||||
|
||||
// Reloads all bounding boxes
|
||||
for (Block block : Registries.BLOCK) {
|
||||
if (block instanceof AnvilBlock || block instanceof BedBlock || block instanceof BrewingStandBlock
|
||||
|| block instanceof CarpetBlock || block instanceof CauldronBlock || block instanceof ChestBlock
|
||||
|| block instanceof EnderChestBlock || block instanceof EndPortalBlock || block instanceof EndPortalFrameBlock
|
||||
|| block instanceof FarmlandBlock || block instanceof FenceBlock || block instanceof FenceGateBlock
|
||||
|| block instanceof HopperBlock || block instanceof LadderBlock || block instanceof LeavesBlock
|
||||
|| block instanceof LilyPadBlock || block instanceof PaneBlock || block instanceof PistonBlock
|
||||
|| block instanceof PistonHeadBlock || block instanceof SnowBlock || block instanceof WallBlock
|
||||
|| block instanceof CropBlock || block instanceof FlowerbedBlock
|
||||
) {
|
||||
for (BlockState state : block.getStateManager().getStates()) {
|
||||
state.initShapeCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private static boolean isOlderThanOrEqualTo(final VersionEnum oldVersion, final VersionEnum newVersion, final VersionEnum toCheck) {
|
||||
return oldVersion.isNewerThan(toCheck) && newVersion.isOlderThanOrEqualTo(toCheck);
|
||||
}
|
||||
|
||||
private static boolean isNewerThan(final VersionEnum oldVersion, final VersionEnum newVersion, final VersionEnum toCheck) {
|
||||
return newVersion.isNewerThan(toCheck) && oldVersion.isOlderThanOrEqualTo(toCheck);
|
||||
}
|
||||
|
||||
private static boolean didCrossBoundary(final VersionEnum oldVersion, final VersionEnum newVersion, final VersionEnum toCheck) {
|
||||
return isNewerThan(oldVersion, newVersion, toCheck) || isOlderThanOrEqualTo(oldVersion, newVersion, toCheck);
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ChestHandler1_13_2 {
|
||||
|
||||
public static final Consumer<PacketByteBuf> OLD_PACKET_HANDLER = data -> {
|
||||
final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
try {
|
||||
final int windowId = data.readUnsignedByte();
|
||||
final int slots = data.readUnsignedByte();
|
||||
final Text title = data.readText();
|
||||
|
||||
final GenericContainerScreenHandler screenHandler = new GenericContainerScreenHandler(null, windowId, mc.player.getInventory(), new SimpleInventory(slots), MathHelper.ceil(slots / 9F));
|
||||
mc.player.currentScreenHandler = screenHandler;
|
||||
mc.setScreen(new GenericContainerScreen(screenHandler, mc.player.getInventory(), title));
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to handle OpenWindow packet data", t);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -21,12 +21,10 @@ package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.translator.BlockStateTranslator;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
@ -34,24 +32,8 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClientPlayerInteractionManager1_18_2 {
|
||||
|
||||
public static final Consumer<PacketByteBuf> OLD_PACKET_HANDLER = data -> {
|
||||
try {
|
||||
final var pos = data.readBlockPos();
|
||||
final var blockState = BlockStateTranslator.via1_18_2toMc(data.readVarInt());
|
||||
final var action = data.readEnumConstant(PlayerActionC2SPacket.Action.class);
|
||||
final var allGood = data.readBoolean();
|
||||
|
||||
ClientPlayerInteractionManager1_18_2.handleBlockBreakAck(pos, blockState, action, allGood);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to handle BlockBreakAck packet data", t);
|
||||
}
|
||||
};
|
||||
|
||||
private static final Object2ObjectLinkedOpenHashMap<Pair<BlockPos, PlayerActionC2SPacket.Action>, PositionAndRotation> UNACKED_ACTIONS = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private static final Object2ObjectLinkedOpenHashMap<Pair<BlockPos, PlayerActionC2SPacket.Action>, Pair<Vec3d, Vec2f>> UN_ACKED_ACTIONS = new Object2ObjectLinkedOpenHashMap<>();
|
||||
|
||||
public static void trackPlayerAction(final PlayerActionC2SPacket.Action action, final BlockPos blockPos) {
|
||||
final var player = MinecraftClient.getInstance().player;
|
||||
@ -63,7 +45,7 @@ public class ClientPlayerInteractionManager1_18_2 {
|
||||
} else {
|
||||
rotation = new Vec2f(player.getYaw(), player.getPitch());
|
||||
}
|
||||
UNACKED_ACTIONS.put(Pair.of(blockPos, action), new PositionAndRotation(player.getPos(), rotation));
|
||||
UN_ACKED_ACTIONS.put(Pair.of(blockPos, action), Pair.of(player.getPos(), rotation));
|
||||
}
|
||||
|
||||
public static void handleBlockBreakAck(final BlockPos blockPos, final BlockState expectedState, final PlayerActionC2SPacket.Action action, final boolean allGood) {
|
||||
@ -71,32 +53,29 @@ public class ClientPlayerInteractionManager1_18_2 {
|
||||
if (player == null) return;
|
||||
final var world = MinecraftClient.getInstance().getNetworkHandler().getWorld();
|
||||
|
||||
final var oldPlayerState = UNACKED_ACTIONS.remove(Pair.of(blockPos, action));
|
||||
final var oldPlayerState = UN_ACKED_ACTIONS.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))) {
|
||||
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)))) {
|
||||
final Vec3d oldPlayerPosition = oldPlayerState.position;
|
||||
if (oldPlayerState.rotation != null) {
|
||||
player.updatePositionAndAngles(oldPlayerPosition.x, oldPlayerPosition.y, oldPlayerPosition.z, oldPlayerState.rotation.x, oldPlayerState.rotation.y);
|
||||
final Vec3d oldPlayerPosition = oldPlayerState.getKey();
|
||||
if (oldPlayerState.getValue() != null) {
|
||||
player.updatePositionAndAngles(oldPlayerPosition.x, oldPlayerPosition.y, oldPlayerPosition.z, oldPlayerState.getValue().x, oldPlayerState.getValue().y);
|
||||
} else {
|
||||
player.updatePosition(oldPlayerPosition.x, oldPlayerPosition.y, oldPlayerPosition.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (UNACKED_ACTIONS.size() >= 50) {
|
||||
ViaFabricPlus.global().getLogger().warn("Too many unacked block actions, dropping {}", UNACKED_ACTIONS.firstKey());
|
||||
UNACKED_ACTIONS.removeFirst();
|
||||
while (UN_ACKED_ACTIONS.size() >= 50) {
|
||||
ViaFabricPlus.global().getLogger().warn("Too many unacked block actions, dropping {}", UN_ACKED_ACTIONS.firstKey());
|
||||
UN_ACKED_ACTIONS.removeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearUnackedActions() {
|
||||
UNACKED_ACTIONS.clear();
|
||||
}
|
||||
|
||||
private record PositionAndRotation(Vec3d position, Vec2f rotation) {
|
||||
UN_ACKED_ACTIONS.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,13 +23,16 @@ import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.event.DisconnectCallback;
|
||||
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.EntityDimensionReplacements;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.CustomClassicProtocolExtensions;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.FontStorage;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
@ -60,15 +63,19 @@ public class ClientsideFixes {
|
||||
|
||||
public static void init() {
|
||||
CustomClassicProtocolExtensions.create();
|
||||
|
||||
PostGameLoadCallback.EVENT.register(() -> {
|
||||
EntityHitboxUpdateListener.init();
|
||||
ArmorUpdateListener.init();
|
||||
BlockFixes.init();
|
||||
// Handles and updates entity dimension changes in <= 1.17
|
||||
EntityDimensionReplacements.init();
|
||||
|
||||
// Ticks the armor hud manually in <= 1.8.x
|
||||
ArmorHudEmulation1_8.init();
|
||||
});
|
||||
|
||||
DisconnectCallback.EVENT.register(() -> {
|
||||
// Reset the MP-pass
|
||||
ViaFabricPlusClassicMPPassProvider.classiCubeMPPass = null;
|
||||
|
||||
// Remove all previous unacked player actions
|
||||
ClientPlayerInteractionManager1_18_2.clearUnackedActions();
|
||||
});
|
||||
@ -86,16 +93,34 @@ public class ClientsideFixes {
|
||||
currentChatLength = 256;
|
||||
}
|
||||
|
||||
// Text Renderer invisible character fix
|
||||
if (!ViaFabricPlusMixinPlugin.DASH_LOADER_PRESENT) {
|
||||
// Clear all font caches to enforce a reload of all fonts (this is needed because we change the font renderer behavior)
|
||||
for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) {
|
||||
storage.glyphRendererCache.clear();
|
||||
storage.glyphCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Reloads all bounding boxes of the blocks that we changed
|
||||
for (Block block : Registries.BLOCK) {
|
||||
if (block instanceof AnvilBlock || block instanceof BedBlock || block instanceof BrewingStandBlock
|
||||
|| block instanceof CarpetBlock || block instanceof CauldronBlock || block instanceof ChestBlock
|
||||
|| block instanceof EnderChestBlock || block instanceof EndPortalBlock || block instanceof EndPortalFrameBlock
|
||||
|| block instanceof FarmlandBlock || block instanceof FenceBlock || block instanceof FenceGateBlock
|
||||
|| block instanceof HopperBlock || block instanceof LadderBlock || block instanceof LeavesBlock
|
||||
|| block instanceof LilyPadBlock || block instanceof PaneBlock || block instanceof PistonBlock
|
||||
|| block instanceof PistonHeadBlock || block instanceof SnowBlock || block instanceof WallBlock
|
||||
|| block instanceof CropBlock || block instanceof FlowerbedBlock
|
||||
) {
|
||||
for (BlockState state : block.getStateManager().getStates()) {
|
||||
state.initShapeCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuilds the item selection screen grid
|
||||
if (newVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
ClassicItemSelectionScreen.INSTANCE.reload(newVersion, false);
|
||||
ClassicItemSelectionScreen.INSTANCE.rebuildGridOverlay();
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -17,22 +17,21 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic.screen;
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.screen.base.VFPScreen;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
public class ClassicItemSelectionScreen extends VFPScreen {
|
||||
|
||||
public static final ClassicItemSelectionScreen INSTANCE = new ClassicItemSelectionScreen();
|
||||
|
||||
private static final int MAX_ROW_DIVIDER = 9;
|
||||
@ -47,66 +46,15 @@ public class ClassicItemSelectionScreen extends VFPScreen {
|
||||
super("Classic item selection", false);
|
||||
}
|
||||
|
||||
public void reload(final VersionEnum version, final boolean hasCustomBlocksV1) {
|
||||
public void rebuildGridOverlay() {
|
||||
final List<Item> allowedItems = new ArrayList<>();
|
||||
allowedItems.add(Items.OAK_LOG);
|
||||
allowedItems.add(Items.OAK_PLANKS);
|
||||
allowedItems.add(Items.STONE);
|
||||
allowedItems.add(Items.COBBLESTONE);
|
||||
allowedItems.add(Items.MOSSY_COBBLESTONE);
|
||||
allowedItems.add(Items.BRICKS);
|
||||
allowedItems.add(Items.IRON_BLOCK);
|
||||
allowedItems.add(Items.GOLD_BLOCK);
|
||||
allowedItems.add(Items.GLASS);
|
||||
allowedItems.add(Items.DIRT);
|
||||
allowedItems.add(Items.GRAVEL);
|
||||
allowedItems.add(Items.SAND);
|
||||
allowedItems.add(Items.OBSIDIAN);
|
||||
allowedItems.add(Items.COAL_ORE);
|
||||
allowedItems.add(Items.IRON_ORE);
|
||||
allowedItems.add(Items.GOLD_ORE);
|
||||
allowedItems.add(Items.OAK_LEAVES);
|
||||
allowedItems.add(Items.OAK_SAPLING);
|
||||
allowedItems.add(Items.BOOKSHELF);
|
||||
allowedItems.add(Items.TNT);
|
||||
if (version.isNewerThan(VersionEnum.c0_0_19a_06)) {
|
||||
allowedItems.add(Items.SPONGE);
|
||||
if (version.isNewerThan(VersionEnum.c0_0_20ac0_27)) {
|
||||
allowedItems.add(Items.WHITE_WOOL);
|
||||
allowedItems.add(Items.ORANGE_WOOL);
|
||||
allowedItems.add(Items.MAGENTA_WOOL);
|
||||
allowedItems.add(Items.LIGHT_BLUE_WOOL);
|
||||
allowedItems.add(Items.YELLOW_WOOL);
|
||||
allowedItems.add(Items.LIME_WOOL);
|
||||
allowedItems.add(Items.PINK_WOOL);
|
||||
allowedItems.add(Items.CYAN_WOOL);
|
||||
allowedItems.add(Items.BLUE_WOOL);
|
||||
allowedItems.add(Items.BROWN_WOOL);
|
||||
allowedItems.add(Items.GREEN_WOOL);
|
||||
allowedItems.add(Items.BROWN_MUSHROOM);
|
||||
allowedItems.add(Items.GRAY_WOOL);
|
||||
allowedItems.add(Items.LIGHT_GRAY_WOOL);
|
||||
allowedItems.add(Items.PURPLE_WOOL);
|
||||
allowedItems.add(Items.RED_WOOL);
|
||||
allowedItems.add(Items.BLACK_WOOL);
|
||||
allowedItems.add(Items.SMOOTH_STONE_SLAB);
|
||||
allowedItems.add(Items.POPPY);
|
||||
allowedItems.add(Items.DANDELION);
|
||||
allowedItems.add(Items.RED_MUSHROOM);
|
||||
|
||||
// Calculate all visible items
|
||||
for (Item item : Registries.ITEM) {
|
||||
if (ItemRegistryDiff.keepItem(item)) {
|
||||
allowedItems.add(item);
|
||||
}
|
||||
}
|
||||
if (hasCustomBlocksV1) {
|
||||
allowedItems.add(Items.MAGMA_BLOCK);
|
||||
allowedItems.add(Items.QUARTZ_PILLAR);
|
||||
allowedItems.add(Items.SANDSTONE);
|
||||
allowedItems.add(Items.STONE_BRICKS);
|
||||
allowedItems.add(Items.COBBLESTONE_SLAB);
|
||||
allowedItems.add(Items.ICE);
|
||||
allowedItems.add(Items.SNOW);
|
||||
allowedItems.add(Items.BEDROCK);
|
||||
allowedItems.add(Items.WATER_BUCKET);
|
||||
allowedItems.add(Items.LAVA_BUCKET);
|
||||
}
|
||||
|
||||
itemGrid = new Item[MathHelper.ceil(allowedItems.size() / (double) MAX_ROW_DIVIDER)][MAX_ROW_DIVIDER];
|
||||
int x = 0;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.reference;
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
@ -20,9 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.lenni0451.reflect.Enums;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ClientboundPacketsc0_30cpe;
|
||||
@ -45,7 +43,9 @@ public class CustomClassicProtocolExtensions {
|
||||
EXT_WEATHER_TYPE = createNewPacket(ClassicProtocolExtension.ENV_WEATHER_TYPE, 31, (user, buf) -> buf.readByte());
|
||||
|
||||
LoadClassicProtocolExtensionCallback.EVENT.register(classicProtocolExtension -> {
|
||||
if (classicProtocolExtension == ClassicProtocolExtension.CUSTOM_BLOCKS) ClassicItemSelectionScreen.INSTANCE.reload(ProtocolHack.getTargetVersion(), true);
|
||||
if (classicProtocolExtension == ClassicProtocolExtension.CUSTOM_BLOCKS) {
|
||||
ClassicItemSelectionScreen.INSTANCE.rebuildGridOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command.impl;
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.ClassicViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
@ -17,11 +17,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command.impl;
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.ClassicViaSubCommand;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.diff;
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.diff;
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.diff;
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.recipe;
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.entity.BannerBlockEntity;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.recipe;
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.recipe;
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.recipe;
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Blocks;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.boat;
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.model.*;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.boat;
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
@ -28,7 +28,7 @@ import net.raphimc.vialoader.util.VersionEnum;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EntityHitboxUpdateListener {
|
||||
public class EntityDimensionReplacements {
|
||||
|
||||
private static final Map<EntityType<?>, Map<VersionEnum, EntityDimensions>> ENTITY_DIMENSIONS = linkedHashMap(
|
||||
EntityType.WITHER, linkedHashMap(
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.Entity;
|
||||
@ -36,7 +36,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class EntityHeightOffsetsPre1_20_2 {
|
||||
public class EntityRidingOffsetsPre1_20_2 {
|
||||
|
||||
public static Vector3f getMountedHeightOffset(final Entity entity, final Entity passenger) {
|
||||
float yOffset = entity.getHeight() * 0.75F;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.reference;
|
||||
package de.florianmichael.viafabricplus.fixes.replacement;
|
||||
|
||||
import net.minecraft.client.font.Glyph;
|
||||
import net.minecraft.client.font.GlyphRenderer;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.reference;
|
||||
package de.florianmichael.viafabricplus.fixes.replacement;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
package de.florianmichael.viafabricplus.fixes.replacement;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
@ -24,7 +24,7 @@ import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
|
||||
import de.florianmichael.viafabricplus.injection.reference.KeyPairResponse1_19_0;
|
||||
import de.florianmichael.viafabricplus.fixes.replacement.KeyPairResponse1_19_0;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.PendingUpdateManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.fixes.replacement.PendingUpdateManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IEntity;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.diff.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.fixes.data.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.fluid.FlowableFluid;
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.fixes.diff.RenderableGlyphDiff;
|
||||
import de.florianmichael.viafabricplus.injection.reference.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.fixes.data.RenderableGlyphDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.replacement.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import de.florianmichael.viafabricplus.fixes.diff.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMouseKeyboard;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
|
@ -22,7 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMouseKeyboard;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.util.MouseSensitivityUtil;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.MathUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.option.SimpleOption;
|
||||
@ -59,7 +59,7 @@ public abstract class MixinMouse implements IMouseKeyboard {
|
||||
@Redirect(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/SimpleOption;getValue()Ljava/lang/Object;", ordinal = 0))
|
||||
private Object adjustMouseSensitivity1_13_2(SimpleOption<Double> instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
return (double) MouseSensitivityUtil.get1_13SliderValue(instance.getValue().floatValue()).keyFloat();
|
||||
return (double) MathUtil.get1_13SliderValue(instance.getValue().floatValue()).keyFloat();
|
||||
}
|
||||
|
||||
return instance.getValue();
|
||||
|
@ -56,4 +56,12 @@ public abstract class MixinSoulSandBlock extends Block {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVelocityMultiplier() {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
return super.getVelocityMultiplier();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.EntityRidingOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -301,8 +301,8 @@ public abstract class MixinBoatEntity extends Entity {
|
||||
@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)) {
|
||||
final Vec3d newPosition = new Vec3d(EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(this, passenger)).add(this.getPos());
|
||||
positionUpdater.accept(passenger, newPosition.x, newPosition.y + EntityHeightOffsetsPre1_20_2.getHeightOffset(passenger), newPosition.z);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.EntityRidingOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IEntity;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
|
||||
@ -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)) {
|
||||
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this));
|
||||
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)) {
|
||||
return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger);
|
||||
return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger);
|
||||
}
|
||||
|
||||
return getPassengerAttachmentPos(passenger, dimensions, scaleFactor);
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import de.florianmichael.viafabricplus.fixes.boat.BoatModel1_8;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.BoatModel1_8;
|
||||
import net.minecraft.client.model.TexturedModelData;
|
||||
import net.minecraft.client.render.entity.model.EntityModelLayer;
|
||||
import net.minecraft.client.render.entity.model.EntityModels;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.boat.BoatRenderer1_8;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.BoatRenderer1_8;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.EntityRidingOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -76,14 +76,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)) {
|
||||
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset(this));
|
||||
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)) {
|
||||
return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, entity);
|
||||
return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, entity);
|
||||
}
|
||||
|
||||
return getPassengerAttachmentPos(entity, entityDimensions, v);
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import de.florianmichael.viafabricplus.fixes.diff.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.fixes.data.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.diff.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.diff.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.fixes.data.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import de.florianmichael.viafabricplus.fixes.diff.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.fixes.data.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.fabricmc.yarn.constants.MiningLevels;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import de.florianmichael.viafabricplus.fixes.recipe.RecipeInfo;
|
||||
import de.florianmichael.viafabricplus.fixes.recipe.Recipes1_11_2;
|
||||
import de.florianmichael.viafabricplus.fixes.data.recipe.RecipeInfo;
|
||||
import de.florianmichael.viafabricplus.fixes.data.recipe.Recipes1_11_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import de.florianmichael.viafabricplus.fixes.ActionResultException;
|
||||
import de.florianmichael.viafabricplus.fixes.ActionResultException1_12_2;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
|
||||
@ -202,13 +202,13 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
final ItemUsageContext itemUsageContext = new ItemUsageContext(player, hand, checkHitResult);
|
||||
final ItemPlacementContext itemPlacementContext = new ItemPlacementContext(itemUsageContext);
|
||||
if (!itemPlacementContext.canPlace() || ((BlockItem) itemPlacementContext.getStack().getItem()).getPlacementState(itemPlacementContext) == null) {
|
||||
throw new ActionResultException(ActionResult.PASS);
|
||||
throw new ActionResultException1_12_2(ActionResult.PASS);
|
||||
}
|
||||
}
|
||||
|
||||
this.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(hand, hitResult, 0));
|
||||
if (itemStack.isEmpty()) {
|
||||
throw new ActionResultException(ActionResult.PASS);
|
||||
throw new ActionResultException1_12_2(ActionResult.PASS);
|
||||
}
|
||||
final ItemUsageContext itemUsageContext = new ItemUsageContext(player, hand, checkHitResult);
|
||||
ActionResult actionResult;
|
||||
@ -222,7 +222,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
if (!actionResult.isAccepted()) {
|
||||
actionResult = ActionResult.PASS; // In <= 1.12.2 FAIL is the same as PASS
|
||||
}
|
||||
throw new ActionResultException(actionResult);
|
||||
throw new ActionResultException1_12_2(actionResult);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
try {
|
||||
mutableObject.setValue(this.interactBlockInternal(clientPlayerEntity, hand, blockHitResult));
|
||||
return new PlayerInteractBlockC2SPacket(hand, blockHitResult, sequence);
|
||||
} catch (ActionResultException e) {
|
||||
} catch (ActionResultException1_12_2 e) {
|
||||
mutableObject.setValue(e.getActionResult());
|
||||
throw e;
|
||||
}
|
||||
@ -265,7 +265,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
private void catchPacketCancelException(ClientPlayerInteractionManager instance, ClientWorld world, SequencedPacketCreator packetCreator) {
|
||||
try {
|
||||
this.sendSequencedPacket(world, packetCreator);
|
||||
} catch (ActionResultException ignored) {
|
||||
} catch (ActionResultException1_12_2 ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.util.MouseSensitivityUtil;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.MathUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.GameOptionsScreen;
|
||||
@ -48,7 +48,7 @@ public abstract class MixinMouseOptionsScreen extends GameOptionsScreen {
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
private void render1_13SliderValue(DrawContext drawContext, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2) && this.buttonList.getWidgetFor(this.gameOptions.getMouseSensitivity()).isHovered()) {
|
||||
drawContext.drawTooltip(textRenderer, Text.of("<=1.13.2 Sensitivity: " + MouseSensitivityUtil.get1_13SliderValue(this.gameOptions.getMouseSensitivity().getValue().floatValue()).valueInt() + "%"), mouseX, mouseY);
|
||||
drawContext.drawTooltip(textRenderer, Text.of("<=1.13.2 Sensitivity: " + MathUtil.get1_13SliderValue(this.gameOptions.getMouseSensitivity().getValue().floatValue()).valueInt() + "%"), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.recipe.Recipes1_11_2;
|
||||
import de.florianmichael.viafabricplus.fixes.data.recipe.Recipes1_11_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.RecipeInputInventory;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.recipe.Recipes1_11_2;
|
||||
import de.florianmichael.viafabricplus.fixes.data.recipe.Recipes1_11_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.EntityPackets;
|
||||
import de.florianmichael.viafabricplus.injection.reference.ClassicWorldHeightInjections;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.ClassicWorldHeightInjections;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -24,9 +24,14 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.InventoryPackets;
|
||||
import de.florianmichael.viafabricplus.fixes.ChestHandler1_13_2;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.protocolhack.translator.TextComponentTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -41,11 +46,26 @@ public abstract class MixinInventoryPackets {
|
||||
if ((type.equals("minecraft:container") || type.equals("minecraft:chest")) && (slots > 54 || slots <= 0)) {
|
||||
ci.cancel();
|
||||
|
||||
final String uuid = ClientsideFixes.executeSyncTask(ChestHandler1_13_2.OLD_PACKET_HANDLER);
|
||||
final String uuid = ClientsideFixes.executeSyncTask(data -> {
|
||||
final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
try {
|
||||
final int syncId = data.readUnsignedByte();
|
||||
final int size = data.readUnsignedByte();
|
||||
final Text title1_20 = data.readText();
|
||||
|
||||
final GenericContainerScreenHandler screenHandler = new GenericContainerScreenHandler(null, syncId, mc.player.getInventory(), new SimpleInventory(size), MathHelper.ceil(size / 9F));
|
||||
mc.player.currentScreenHandler = screenHandler;
|
||||
mc.setScreen(new GenericContainerScreen(screenHandler, mc.player.getInventory(), title1_20));
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to handle OpenWindow packet data", t);
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.clearPacket();
|
||||
wrapper.setPacketType(ClientboundPackets1_14.PLUGIN_MESSAGE);
|
||||
wrapper.write(Type.STRING, ClientsideFixes.PACKET_SYNC_IDENTIFIER);
|
||||
wrapper.write(Type.STRING, uuid);
|
||||
wrapper.write(Type.STRING, ClientsideFixes.PACKET_SYNC_IDENTIFIER); // sync task header
|
||||
wrapper.write(Type.STRING, uuid); // sync task id
|
||||
wrapper.write(Type.UNSIGNED_BYTE, windowId);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, slots);
|
||||
wrapper.write(Type.COMPONENT, TextComponentTranslator.via1_14toViaLatest(title));
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||
import de.florianmichael.viafabricplus.util.NoPacketSendChannel;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.NoPacketSendChannel;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.WorldPackets;
|
||||
import de.florianmichael.viafabricplus.injection.reference.ClassicWorldHeightInjections;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.ClassicWorldHeightInjections;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -27,6 +27,8 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.WorldPackets;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.protocolhack.translator.BlockStateTranslator;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@ -39,7 +41,18 @@ public abstract class MixinWorldPackets1_19 {
|
||||
instance.registerClientbound(ClientboundPackets1_18.ACKNOWLEDGE_PLAYER_DIGGING, ClientboundPackets1_19.PLUGIN_MESSAGE, wrapper -> {
|
||||
wrapper.resetReader();
|
||||
|
||||
final var uuid = ClientsideFixes.executeSyncTask(ClientPlayerInteractionManager1_18_2.OLD_PACKET_HANDLER);
|
||||
final var uuid = ClientsideFixes.executeSyncTask(data -> {
|
||||
try {
|
||||
final var pos = data.readBlockPos();
|
||||
final var blockState = BlockStateTranslator.via1_18_2toMc(data.readVarInt());
|
||||
final var action = data.readEnumConstant(PlayerActionC2SPacket.Action.class);
|
||||
final var allGood = data.readBoolean();
|
||||
|
||||
ClientPlayerInteractionManager1_18_2.handleBlockBreakAck(pos, blockState, action, allGood);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to handle BlockBreakAck packet data", t);
|
||||
}
|
||||
});
|
||||
wrapper.write(Type.STRING, ClientsideFixes.PACKET_SYNC_IDENTIFIER);
|
||||
wrapper.write(Type.STRING, uuid);
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ import de.florianmichael.viafabricplus.protocolhack.impl.ViaFabricPlusVLInjector
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.ViaFabricPlusVLLoader;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.platform.ViaFabricPlusViaLegacyPlatformImpl;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
||||
import de.florianmichael.viafabricplus.util.NoPacketSendChannel;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.NoPacketSendChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
||||
|
@ -23,8 +23,8 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.impl.ListExtensionsCommand;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.impl.SetTimeCommand;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.ListExtensionsCommand;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.SetTimeCommand;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.raphimc.vialoader.impl.viaversion.VLCommandHandler;
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.util;
|
||||
package de.florianmichael.viafabricplus.protocolhack.util;
|
||||
|
||||
import it.unimi.dsi.fastutil.floats.FloatIntPair;
|
||||
|
||||
public class MouseSensitivityUtil {
|
||||
public class MathUtil {
|
||||
|
||||
public static FloatIntPair get1_13SliderValue(final float value1_14) {
|
||||
final int oldSliderWidth = 150 - 8;
|
@ -17,10 +17,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.util;
|
||||
package de.florianmichael.viafabricplus.protocolhack.util;
|
||||
|
||||
import io.netty.channel.local.LocalChannel;
|
||||
|
||||
/**
|
||||
* This class can be used when creating dummy {@link com.viaversion.viaversion.api.connection.UserConnection} instances.
|
||||
* This class will prevent packets created by ViaVersion from being sent to the server. This is mainly used in the
|
||||
* translator system. See {@link de.florianmichael.viafabricplus.protocolhack.translator} for more information.
|
||||
*/
|
||||
public class NoPacketSendChannel extends LocalChannel {
|
||||
|
||||
public static final NoPacketSendChannel INSTANCE = new NoPacketSendChannel();
|
Loading…
Reference in New Issue
Block a user