Skip to content

Commit

Permalink
1.20.2
Browse files Browse the repository at this point in the history
Still haven't fixed storage presets
  • Loading branch information
samolego committed Oct 8, 2023
1 parent 9e2be96 commit 4e4b514
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 89 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT' apply false
id 'fabric-loom' version '1.3-SNAPSHOT' apply false
id 'org.quiltmc.quilt-mappings-on-loom' version '4.2.0' apply false
id "com.modrinth.minotaur" version "2.+" apply false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public int hashCode() {

@Override
public String toString() {
return String.format("%s@%%s_%s", this.blockName, this.pos.toShortString(), BuiltInRegistries.BLOCK.getKey(this.block));
return String.format("%s@%s_%s", this.blockName, this.pos.toShortString(), BuiltInRegistries.BLOCK.getKey(this.block));
}

public String containerName() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.samo_lego.clientstorage.fabric_client.mixin.network;

import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import org.samo_lego.clientstorage.fabric_client.network.PacketLimiter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientCommonPacketListenerImpl.class)
public class MClientCommonPacketListenerImpl_BrandRecognizer {

/**
* Tries to recognize server type from server brand packet.
*
* @param packet
* @param ci
*/
@Inject(method = "handleCustomPayload",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/telemetry/WorldSessionTelemetryManager;onServerBrandReceived(Ljava/lang/String;)V",
shift = At.Shift.BEFORE))
private void onServerBrand(ClientboundCustomPayloadPacket packet, CallbackInfo ci) {
PacketLimiter.tryRecognizeServer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket;
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
import net.minecraft.world.inventory.MenuType;
import org.samo_lego.clientstorage.fabric_client.casts.ICSPlayer;
import org.samo_lego.clientstorage.fabric_client.event.ContainerDiscovery;
import org.samo_lego.clientstorage.fabric_client.network.PacketLimiter;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -24,9 +20,6 @@
@Mixin(ClientPacketListener.class)
public class MClientPacketListener {

@Shadow
@Final
private Minecraft minecraft;
@Unique
private boolean craftingScreen;
@Unique
Expand All @@ -44,7 +37,7 @@ public class MClientPacketListener {
target = "Lnet/minecraft/network/protocol/game/ClientboundContainerSetContentPacket;getContainerId()I"),
cancellable = true)
private void onInventoryPacket(ClientboundContainerSetContentPacket packet, CallbackInfo ci) {
if (((ICSPlayer) this.minecraft.player).cs_isAccessingItem()) {
if (((ICSPlayer) Minecraft.getInstance().player).cs_isAccessingItem()) {
ci.cancel();
return;
}
Expand Down Expand Up @@ -77,8 +70,9 @@ private void onOpenScreen(ClientboundOpenScreenPacket packet, CallbackInfo ci) {
this.containerId = packet.getContainerId();

if (this.craftingScreen) {
((ICSPlayer) this.minecraft.player).cs_setAccessingItem(false);
} else if (((ICSPlayer) this.minecraft.player).cs_isAccessingItem() || ContainerDiscovery.fakePacketsActive()) {
((ICSPlayer) Minecraft.getInstance().player).cs_setAccessingItem(false);
} else if (((ICSPlayer) Minecraft.getInstance().player).cs_isAccessingItem() || ContainerDiscovery.fakePacketsActive()) {

ci.cancel();
}
}
Expand All @@ -97,23 +91,9 @@ private void onOpenScreen(ClientboundOpenScreenPacket packet, CallbackInfo ci) {
cancellable = true)
private void onSoundEvent(ClientboundSoundPacket packet, CallbackInfo ci) {
// Cancel sounds if item search is active
if (packet.getSource().equals(BLOCKS) && (((ICSPlayer) this.minecraft.player).cs_isAccessingItem() || ContainerDiscovery.fakePacketsActive())) {
if (packet.getSource().equals(BLOCKS) && (((ICSPlayer) Minecraft.getInstance().player).cs_isAccessingItem() || ContainerDiscovery.fakePacketsActive())) {
ci.cancel();
}
}


/**
* Tries to recognize server type from server brand packet.
*
* @param packet
* @param ci
*/
@Inject(method = "handleCustomPayload",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/player/LocalPlayer;setServerBrand(Ljava/lang/String;)V",
shift = At.Shift.AFTER))
private void onServerBrand(ClientboundCustomPayloadPacket packet, CallbackInfo ci) {
PacketLimiter.tryRecognizeServer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.CraftingScreen;
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -33,7 +34,6 @@
import java.util.List;

import static org.samo_lego.clientstorage.fabric_client.ClientStorageFabric.config;
import static org.samo_lego.clientstorage.fabric_client.mixin.accessor.ACreativeModeInventoryScreen.CREATIVE_TABS_LOCATION;

@Environment(EnvType.CLIENT)
@Mixin(CraftingScreen.class)
Expand Down Expand Up @@ -95,7 +95,8 @@ private void addBackground(GuiGraphics graphics, float delta, int mouseX, int mo

// Scrollbar
boolean canScroll = RemoteInventory.getInstance().getRows() > 3;
graphics.blit(CREATIVE_TABS_LOCATION(), topX, topY + (int) ((float) (k - topY - 17) * RemoteInventory.getInstance().scrollOffset()), 232 + (canScroll ? 0 : 12), 0, 12, 15);
final var sprite = canScroll ? CreativeModeInventoryScreen.SCROLLER_SPRITE : CreativeModeInventoryScreen.SCROLLER_DISABLED_SPRITE;
graphics.blitSprite(sprite, topX, topY + (int) ((float) (k - topY - 17) * RemoteInventory.getInstance().scrollOffset()), 232 + (canScroll ? 0 : 12), 0);
}

@Inject(method = "<init>", at = @At("TAIL"))
Expand All @@ -104,10 +105,6 @@ private void constructor(CallbackInfo ci) {

this.titleLabelY += Y_MOVE;
this.inventoryLabelY += Y_MOVE;

if (this.searchBox != null) {
this.searchBox.tick();
}
}

@Inject(method = "init", at = @At("TAIL"))
Expand All @@ -129,12 +126,6 @@ private void init(CallbackInfo ci) {
this.addWidget(this.searchBox);
}

@Inject(method = "containerTick", at = @At("TAIL"))
private void containerTick(CallbackInfo ci) {
if (this.searchBox != null && config.enabled) {
this.searchBox.tick();
}
}

@Override
public boolean charTyped(char chr, int modifiers) {
Expand All @@ -143,7 +134,7 @@ public boolean charTyped(char chr, int modifiers) {

if (this.searchBox.charTyped(chr, modifiers)) {
if (!string.equals(this.searchBox.getValue())) {
this.refreshSearchResults();
this.clienstorage$refreshSearchResults();
}
return true;
}
Expand All @@ -158,7 +149,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
String string = this.searchBox.getValue();
if (this.searchBox.keyPressed(keyCode, scanCode, modifiers)) {
if (!string.equals(this.searchBox.getValue())) {
this.refreshSearchResults();
this.clienstorage$refreshSearchResults();
}
return true;
}
Expand All @@ -171,12 +162,13 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return super.keyPressed(keyCode, scanCode, modifiers);
}

private void refreshSearchResults() {
@Unique
private void clienstorage$refreshSearchResults() {
RemoteInventory.getInstance().refreshSearchResults(this.searchBox.getValue());
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
public boolean mouseScrolled(double mouseX, double mouseY, double amount, double _a) {
int rows = RemoteInventory.getInstance().getRows();
if (rows < 4) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.samo_lego.clientstorage.fabric_client.ClientStorageFabric.config;

@Mixin(AbstractContainerScreen.class)
public abstract class MAbstractContainerScreen {
public abstract class MAbstractContainerScreen_ArmorSlots {

private final AbstractContainerScreen<?> self = (AbstractContainerScreen<?>) (Object) this;
@Shadow
Expand All @@ -34,15 +34,15 @@ public abstract class MAbstractContainerScreen {
@Shadow
protected abstract void renderSlot(GuiGraphics guiGraphics, Slot slot);

@Inject(method = "render",
/*@Inject(method = "render",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lnet/minecraft/client/gui/GuiGraphics;FII)V",
shift = At.Shift.AFTER))
private void addArmorSlotBg(GuiGraphics graphics, int x, int y, float f, CallbackInfo ci) {
if (!config.enabled || self instanceof InventoryScreen || !config.armorAccess) return;
// Draw background
}
}*/

@Inject(method = "render",
at = @At(value = "INVOKE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ private void constructor(AbstractContainerMenu abstractContainerMenu, Inventory
cancellable = true)
private static void renderSlotHighlight(GuiGraphics graphics, int x, int y, int blitOffset, CallbackInfo ci) {
if (usingFakeSlot) {
final int color = 0x7F_FF_F7_00;
//final int color = 0x7F_FF_F7_00;
final int color = 0x7F_00_00_00;

graphics.fillGradient(x, y, x + 16, y + 16, color, color, blitOffset);
RenderSystem.colorMask(true, true, true, true);
Expand Down Expand Up @@ -133,14 +134,20 @@ private void postRenderItem(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci)
TransparencyBuffer.preInject();

// Align the matrix stack
//poseStack.pushPose();
//poseStack.translate(-this.leftPos, -this.topPos, 0.0f);
guiGraphics.pose().pushPose();
guiGraphics.pose().translate(-this.leftPos, -this.topPos, 0.0f);

// Draw the framebuffer texture
TransparencyBuffer.drawExtraFramebuffer(guiGraphics);
//poseStack.popPose();

var itemStack = slot.getItem();
guiGraphics.renderItem(itemStack, slot.x, slot.y, slot.x + slot.y * this.imageWidth);
guiGraphics.renderItemDecorations(this.font, itemStack, slot.x, slot.y, "0");


guiGraphics.pose().popPose();
TransparencyBuffer.postInject();

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void tryRecognizeServer() {
FabricConfig.limiter = getServerLimiter();

Minecraft client = Minecraft.getInstance();
var brand = client.player.getServerBrand().toLowerCase(Locale.ROOT);
var brand = client.getConnection().serverBrand().toLowerCase(Locale.ROOT);

if (FabricConfig.limiter != CUSTOM) {
if (config.informServerType && !client.hasSingleplayerServer()) {
Expand All @@ -57,7 +57,7 @@ public static PacketLimiter getServerLimiter() {
return CUSTOM;
}

var brand = player.getServerBrand().toLowerCase(Locale.ROOT);
var brand = client.getConnection().serverBrand().toLowerCase(Locale.ROOT);

// If server brand is vanilla, fabric, forge, quilt or craftbukkit, use vanilla limiter
// We use .contains as server might be behind a proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import org.samo_lego.clientstorage.fabric_client.mixin.accessor.AEntity;
import org.samo_lego.clientstorage.fabric_client.mixin.accessor.ALevelRenderer;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -31,7 +28,7 @@
*/
public class ESPRender {

private static final ModelPart.Cube CUBE = new ModelPart.Cube(0, 0, 0, 0, 0, 16, 16, 16, 0, 0, 0, false, 0, 0, new HashSet<>(List.of(Direction.values())));
private static final ModelPart.Cube CUBE = new ModelPart.Cube(0, 0, 0, 0, 0, 16, 16, 16, 0, 0, 0, false, 0, 0, Set.of(Direction.values()));
private static final RenderType RENDER_TYPE = RenderType.outline(new ResourceLocation("textures/misc/white.png"));

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ public static void preInject() {
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f);
}

public static void drawExtraFramebuffer(GuiGraphics matrices) {
public static void drawExtraFramebuffer(GuiGraphics graphics) {
// Restore the original framebuffer
GlStateManager._glBindFramebuffer(GL30.GL_FRAMEBUFFER, previousFramebuffer);

// Render the custom framebuffer's contents with transparency into the main buffer
RenderSystem.setShaderTexture(0, framebuffer.getColorTextureId());
Window window = Minecraft.getInstance().getWindow();
// Create new matrix stack to prevent the transparency from affecting the rest of the GUI
/*matrices.blit(
/*Window window = Minecraft.getInstance().getWindow();
graphics.blit(
framebuffer.getColorTextureId(),
0, // x
0, // y
Expand All @@ -55,9 +54,7 @@ public static void drawExtraFramebuffer(GuiGraphics matrices) {
0, // left-most coordinate of the texture region
framebuffer.height, // top-most coordinate of the texture region
framebuffer.width, // width of the texture region
-framebuffer.height, // height of the texture region
framebuffer.width, // width of the entire texture
framebuffer.height // height of the entire texture
-framebuffer.height // height of the texture region
);*/
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@
"tooltip.clientstorage.enable_block_search": "Omogoči preiskovanje shramb v kockah (npr. skrinjah, sodih, pečeh itd.)",
"tooltip.clientstorage.enable_entity_search": "Omogoči preiskovanje shramb bitij (npr. vozičkov ali čolnov s skrinjami) (experimentalno tudi oslov, mul in lam)",
"tooltip.clientstorage.save_preset": "Shrani trenutno postavitev stvari.",
"tooltip.clientstorage.remove_preset": "Pozabi trenutno postavitev stvari."
"tooltip.clientstorage.remove_preset": "Pozabi trenutno postavitev stvari.",
"settings.clientstorage.enable_presets": "Omogoči pomnenje shramb",
"settings.clientstorage.delete_preset": "Delete presets for this world",
"settings.clientstorage.delete_presets": "Delete all presets",
"tooltip.clientstorage.enable_presets": "Enables saving layout for containers. You won't be able to put any other items in the container via shift-clicking.",
"tooltip.clientstorage.delete_preset": "Deletes all storage presets saved for this world.",
"tooltip.clientstorage.delete_presets": "Deletes all saved presets."
}
4 changes: 3 additions & 1 deletion fabric-client/src/main/resources/clientstorage.accesswidener
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
accessWidener v1 named
extendable class net/minecraft/world/item/ItemStack
extendable class net/minecraft/world/item/ItemStack
accessible field net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen SCROLLER_SPRITE Lnet/minecraft/resources/ResourceLocation;
accessible field net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen SCROLLER_DISABLED_SPRITE Lnet/minecraft/resources/ResourceLocation;
4 changes: 2 additions & 2 deletions fabric-client/src/main/resources/clientstorage.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"MItemStack",
"MPlayer_ICSPlayer",
"accessor.ACompoundContainer",
"accessor.ACreativeModeInventoryScreen",
"accessor.AEntity",
"accessor.ALevelRenderer",
"accessor.AMultiPlayerGamemode",
"accessor.AScreen",
"accessor.AScreenHandler",
"accessor.ASlot",
"network.MClientCommonPacketListenerImpl_BrandRecognizer",
"network.MClientPacketListener",
"network.MServerboundContainerClosePacket",
"screen.MAbstractContainerScreen",
"screen.MCraftingMenu",
"screen.MCraftingScreen",
"screen.gui_armour.MAbstractContainerScreen",
"screen.gui_armour.MAbstractContainerScreen_ArmorSlots",
"screen.storage_memory.MAbstractContainerScreen",
"screen.storage_memory.MMinecraft",
"storage.MAbstractChestedHorse",
Expand Down
Loading

0 comments on commit 4e4b514

Please sign in to comment.