-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added and fixed tons of clientside fixes
- Loading branch information
Showing
129 changed files
with
7,135 additions
and
1,488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/de/florianmichael/viafabricplus/fixes/ActionResultException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.util.ActionResult; | ||
|
||
public class ActionResultException extends RuntimeException { | ||
|
||
private final ActionResult actionResult; | ||
|
||
public ActionResultException(final ActionResult actionResult) { | ||
this.actionResult = actionResult; | ||
} | ||
|
||
public ActionResult getActionResult() { | ||
return this.actionResult; | ||
} | ||
|
||
@Override | ||
public synchronized Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/de/florianmichael/viafabricplus/fixes/ArmorUpdateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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 com.viaversion.viaversion.api.protocol.packet.PacketWrapper; | ||
import com.viaversion.viaversion.api.type.Type; | ||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType; | ||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; | ||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; | ||
import de.florianmichael.viafabricplus.ViaFabricPlus; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.registry.Registries; | ||
|
||
public class ArmorUpdateListener { | ||
|
||
public static void init() { | ||
ClientTickEvents.START_WORLD_TICK.register(world -> { | ||
if (MinecraftClient.getInstance().player != null) { | ||
try { | ||
sendArmorUpdate(); | ||
} catch (Throwable t) { | ||
ViaFabricPlus.global().getLogger().error("Error sending armor update", t); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public static void sendArmorUpdate() throws Exception { | ||
int armor = 0; | ||
for (final ItemStack stack : MinecraftClient.getInstance().player.getInventory().armor) { | ||
armor += ArmorType.findByType(Registries.ITEM.getId(stack.getItem()).toString()).getArmorPoints(); | ||
} | ||
if (armor == this.oldArmor) return; | ||
|
||
this.oldArmor = armor; | ||
final PacketWrapper properties = PacketWrapper.create(ClientboundPackets1_9.ENTITY_PROPERTIES, MinecraftClient.getInstance().getNetworkHandler().getConnection().getUserConnection()); | ||
properties.write(Type.VAR_INT, MinecraftClient.getInstance().player.getId()); | ||
properties.write(Type.INT, 1); | ||
properties.write(Type.STRING, "generic.armor"); | ||
properties.write(Type.DOUBLE, 0D); | ||
properties.write(Type.VAR_INT, 1); | ||
properties.write(Type.UUID, ARMOR_POINTS_UUID); | ||
properties.write(Type.DOUBLE, (double) armor); | ||
properties.write(Type.BYTE, (byte) 0); | ||
properties.scheduleSend(Protocol1_9To1_8.class); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/de/florianmichael/viafabricplus/fixes/ChestHandler1_13_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.