mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 03:49:15 +00:00
fix visual issues
This commit is contained in:
@@ -594,21 +594,15 @@ public class RecipeEventListener implements Listener {
|
||||
|
||||
int finalCost = repairCost + repairPenalty;
|
||||
|
||||
if (VersionHelper.isVersionNewerThan1_21()) {
|
||||
AnvilView anvilView = event.getView();
|
||||
anvilView.setRepairCost(finalCost <= 1 ? 2 : finalCost - 1);
|
||||
} else {
|
||||
LegacyInventoryUtils.setRepairCost(inventory, finalCost <= 1 ? 2 : finalCost - 1);
|
||||
}
|
||||
|
||||
// To fix some client side visual issues
|
||||
try {
|
||||
Object anvilMenu;
|
||||
if (VersionHelper.isVersionNewerThan1_21()) {
|
||||
Object anvilMenu = Reflections.field$CraftInventoryView$container.get(event.getView());
|
||||
Reflections.method$AbstractContainerMenu$broadcastChanges.invoke(anvilMenu);
|
||||
anvilMenu = Reflections.field$CraftInventoryView$container.get(event.getView());
|
||||
} else {
|
||||
Object anvilMenu = Reflections.field$CraftInventoryAnvil$menu.get(inventory);
|
||||
Reflections.method$AbstractContainerMenu$broadcastChanges.invoke(anvilMenu);
|
||||
anvilMenu = Reflections.field$CraftInventoryAnvil$menu.get(inventory);
|
||||
}
|
||||
Reflections.method$AbstractContainerMenu$broadcastFullState.invoke(anvilMenu);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
this.plugin.logger().warn("Failed to broadcast changes", e);
|
||||
}
|
||||
|
||||
@@ -4734,6 +4734,12 @@ public class Reflections {
|
||||
)
|
||||
);
|
||||
|
||||
public static final Method method$AbstractContainerMenu$broadcastFullState = requireNonNull(
|
||||
ReflectionUtils.getMethod(
|
||||
clazz$AbstractContainerMenu, void.class, new String[]{ "broadcastFullState", "e" }
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$CraftContainer = requireNonNull(
|
||||
ReflectionUtils.getClazz(
|
||||
BukkitReflectionUtils.assembleCBClass("inventory.CraftContainer")
|
||||
|
||||
Reference in New Issue
Block a user