-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open custom GUI instead of vanilla GUI
- Loading branch information
Showing
10 changed files
with
1,815 additions
and
38 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
src/client/java/works/nuty/calcite/mixin/client/AbstractCommandBlockScreenMixin.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/client/java/works/nuty/calcite/mixin/client/ClientPlayNetworkHandlerMixin.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,32 @@ | ||
package works.nuty.calcite.mixin.client; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.block.entity.CommandBlockBlockEntity; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientCommonNetworkHandler; | ||
import net.minecraft.client.network.ClientConnectionState; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; | ||
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; | ||
import works.nuty.calcite.screen.CalciteCommandScreen; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(ClientPlayNetworkHandler.class) | ||
public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkHandler { | ||
protected ClientPlayNetworkHandlerMixin(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) { | ||
super(client, connection, connectionState); | ||
} | ||
|
||
@Inject(at = @At("TAIL"), method = "method_38542") | ||
public void onBlockEntityUpdate(BlockEntityUpdateS2CPacket blockEntityUpdateS2CPacket, BlockEntity blockEntity, CallbackInfo ci) { | ||
if (blockEntity instanceof CommandBlockBlockEntity && this.client.currentScreen instanceof CalciteCommandScreen calciteCommandScreen) { | ||
calciteCommandScreen.updateAll(); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/client/java/works/nuty/calcite/mixin/client/ClientPlayerEntityMixin.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,28 @@ | ||
package works.nuty.calcite.mixin.client; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.block.entity.CommandBlockBlockEntity; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import works.nuty.calcite.screen.CalciteCommandScreen; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(ClientPlayerEntity.class) | ||
public class ClientPlayerEntityMixin { | ||
@Shadow | ||
@Final | ||
protected MinecraftClient client; | ||
|
||
@Inject(at = @At("HEAD"), method = "openCommandBlockScreen", cancellable = true) | ||
public void openCommandBlockScreenMixin(CommandBlockBlockEntity commandBlock, CallbackInfo ci) { | ||
this.client.setScreen(new CalciteCommandScreen(commandBlock)); | ||
ci.cancel(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/client/java/works/nuty/calcite/mixin/client/DataQueryHandlerMixin.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,34 @@ | ||
package works.nuty.calcite.mixin.client; | ||
|
||
import net.minecraft.client.network.DataQueryHandler; | ||
import net.minecraft.nbt.NbtCompound; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.function.Consumer; | ||
|
||
@Mixin(DataQueryHandler.class) | ||
public class DataQueryHandlerMixin { | ||
@Shadow | ||
private @Nullable Consumer<NbtCompound> callback; | ||
@Shadow | ||
private int expectedTransactionId; | ||
|
||
@Inject(at = @At("HEAD"), method = "handleQueryResponse", cancellable = true) | ||
public void queryBlockNbt(int transactionId, @Nullable NbtCompound nbt, CallbackInfoReturnable<Boolean> cir) { | ||
@Nullable Consumer<NbtCompound> previousCallback = this.callback; | ||
if (this.expectedTransactionId == transactionId && this.callback != null) { | ||
this.callback.accept(nbt); | ||
if (this.callback.equals(previousCallback)) { | ||
this.callback = null; | ||
} | ||
cir.setReturnValue(true); | ||
} | ||
cir.setReturnValue(false); | ||
cir.cancel(); | ||
} | ||
} |
Oops, something went wrong.