Skip to content

Commit

Permalink
1.6.X mixin src
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardZHY authored Dec 28, 2022
1 parent 747e7af commit cb06616
Show file tree
Hide file tree
Showing 54 changed files with 264 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/net/minecraft/src/TMIFabricContainer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.minecraft.src;
import net.fabricmc.api.ModInitializer;

public class TMIFabricContainer implements ModInitializer {
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.

System.out.println("TMI's Access Transformer is loading on Legacy Fabric.");
}
}
14 changes: 14 additions & 0 deletions src/main/java/net/minecraft/src/mixin/ExampleMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.minecraft.src.mixin;
import net.minecraft.client.gui.screen.TitleScreen;
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(TitleScreen.class)
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
System.out.println("This is a TMI mixin build.");
}
}
120 changes: 120 additions & 0 deletions src/main/java/net/minecraft/src/mixin/HandledScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package net.minecraft.src.mixin;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.inventory.slot.Slot;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.src.*;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(HandledScreen.class)
public abstract class HandledScreenMixin extends Screen {

// field_1347 -> backgroundWidth
@Shadow protected int backgroundWidth;
// field_1348 -> backgroundHeight
@Shadow protected int backgroundHeight;
// field_1349 -> screenHandler
@Shadow public ScreenHandler screenHandler;

// field_1350 -> x
@Shadow
protected int x;
// field_1351 -> y
@Shadow
protected int y;

@Shadow
private Slot getSlotAt(int x, int y){
return null;
}

@Inject( method = "<init>", at = @At( "TAIL" ) )
public void onInit( ScreenHandler screenHandler, CallbackInfo ci ) {
TMI.instance.controller.onCreate(handledScreen());
}

private HandledScreen handledScreen() {
return (HandledScreen) (Object) (this);
}

public void handleMouse() {
super.handleMouse();
int i = Mouse.getEventX() * this.width / (MinecraftClient.getInstance()).width;
int j = this.height - Mouse.getEventY() * this.height / (MinecraftClient.getInstance()).height - 1;
TMI.instance.controller.handleScrollWheel(i, j);
}

@Inject( method = "render", at = @At( "HEAD" ) )
public void onRenderStart( int mouseX, int mouseY, float tickDelta, CallbackInfo ci ) {
this.x = ( this.width - this.backgroundWidth ) / 2;
this.y = ( this.height - this.backgroundHeight ) / 2;
if (handledScreen() instanceof net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen)
try {
TextFieldWidget textFieldWidget = (TextFieldWidget)TMIPrivateFields.creativeSearchBox.get(this);
TMIPrivateFields.textFieldX.setInt(textFieldWidget, this.x + 82);
} catch (Exception exception) {
exception.printStackTrace();
}
}

@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawForeground(II)V"
)
)
public void onRenderEnd( int mouseX, int mouseY, float tickDelta, CallbackInfo ci ) {
GL11.glTranslatef(-this.x, -this.y, 0.0F);
TMI.instance.controller.onEnterFrame(mouseX, mouseY, this.backgroundWidth, this.backgroundHeight );
GL11.glTranslatef(this.x, this.y, 0.0F);
GL11.glEnable(2896);
GL11.glEnable(2929);
}

@Inject(
method = "mouseClicked",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/MinecraftClient;getTime()J"
),
cancellable = true,
locals = LocalCapture.CAPTURE_FAILHARD)
public void onMouseClicked(int mouseX, int mouseY, int button, CallbackInfo ci) {
Slot var5 = this.getSlotAt( mouseX, mouseY );
boolean bool1 = (mouseX >= this.x && mouseY >= this.y && mouseX <= this.x + this.backgroundWidth && mouseY <= this.y + this.backgroundHeight);
if (! TMI.instance.controller.onMouseEvent(mouseX, mouseY, button, bool1, var5, this.screenHandler)) {
ci.cancel();
}
}

@Inject( method = "keyPressed", at = @At("HEAD"), cancellable = true )
public void onKeyPressed( char character, int code, CallbackInfo ci ) {
if ( TMI.instance.controller.onKeypress( character, code ) )
ci.cancel();
}

@Inject( method = "removed", at = @At("HEAD") )
public void removed( CallbackInfo ci ) {
TMI.instance.controller.onClose();
}

@Inject( method = "shouldPauseGame", at = @At("HEAD"))
public void shouldPauseGame( CallbackInfoReturnable<Boolean> cir ) {
TMI.instance.controller.shouldPauseGame();
}

// field_1230 -> width
// field_1231 -> height
}
2 changes: 2 additions & 0 deletions src/main/resources/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
All rights reserved.
Copyright 2011-2014 Marglyph. Free for personal or educational use only. Do not redistribute TooManyItems, including in mod packs, and do not use TooManyItems' source code or graphics in your own mods.
10 changes: 10 additions & 0 deletions src/main/resources/TMI.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
accessWidener v1 named
accessible class net/minecraft/client/class_417
accessible field net/minecraft/world/World levelProperties Lnet/minecraft/world/level/LevelProperties;
accessible field net/minecraft/client/gui/screen/Screen field_1234 Lnet/minecraft/client/font/TextRenderer;
accessible field net/minecraft/entity/player/PlayerEntity field_3973 Lnet/minecraft/entity/player/HungerManager;
accessible field net/minecraft/class_988 field_3982 Ljava/lang/String;
accessible method net/minecraft/client/gui/DrawableHelper fillGradient (IIIIII)V
accessible method net/minecraft/client/gui/screen/ingame/HandledScreen method_1131 (Lnet/minecraft/inventory/slot/Slot;IIZ)V
accessible method net/minecraft/nbt/NbtList method_1649 (Ljava/io/DataInput;)V
accessible method net/minecraft/nbt/NbtList method_1650 (Ljava/io/DataOutput;)V
13 changes: 13 additions & 0 deletions src/main/resources/TMI.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8",
"package": "net.minecraft.src.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"ExampleMixin",
"HandledScreenMixin"
],
"injectors": {
"defaultRequire": 1
}
}
32 changes: 32 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"schemaVersion": 1,
"id": "tmi",
"version": "1.6.4-Mixin",
"name": "TMI",
"description": "Too Many Items For LegacyFabric using Mixin; Create items, save states, cheats, etc.",
"authors": [
"Marglyph",
"Wotblitz",
"HowardZHY",
"Arminias"
],
"contact": {
"sources": "https://github.com/HowardZHY/TooManyItems-LegacyFabric"
},
"license": "ARR+CUSTOM",
"environment": "client",
"entrypoints": {
"main": [
"net.minecraft.src.TMIFabricContainer"
]
},
"mixins": [
"TMI.mixins.json"
],
"accessWidener": "TMI.accesswidener",
"depends": {
},
"custom": {
"modmenu:clientsideOnly": true
}
}
Binary file added src/main/resources/net/minecraft/src/TMI.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/main/resources/net/minecraft/src/tmi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/tmi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions src/main/resources/tmi.tiny
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
v1 official intermediary
CLASS * net/minecraft/src/*
CLASS . net/minecraft/src/.
CLASS _ net/minecraft/src/_
CLASS _tmi_MgButton net/minecraft/src/_tmi_MgButton
CLASS _tmi_MgButtonHandler net/minecraft/src/_tmi_MgButtonHandler
CLASS _tmi_MgCanvas net/minecraft/src/_tmi_MgCanvas
CLASS _tmi_MgFocusHandler net/minecraft/src/_tmi_MgFocusHandler
CLASS _tmi_MgImage net/minecraft/src/_tmi_MgImage
CLASS _tmi_MgItemButton net/minecraft/src/_tmi_MgItemButton
CLASS _tmi_MgItemHandler net/minecraft/src/_tmi_MgItemHandler
CLASS _tmi_MgTabView net/minecraft/src/_tmi_MgTabView
CLASS _tmi_MgTextField net/minecraft/src/_tmi_MgTextField
CLASS _tmi_MgTooltipHandler net/minecraft/src/_tmi_MgTooltipHandler
CLASS _tmi_MgWidget net/minecraft/src/_tmi_MgWidget
CLASS _tmi_MgZOrder net/minecraft/src/_tmi_MgZOrder
CLASS mod_TooManyItems net/minecraft/src/mod_TooManyItems
CLASS TMI net/minecraft/src/TMI
CLASS TMICompatibility net/minecraft/src/TMICompatibility
CLASS TMIConfig net/minecraft/src/TMIConfig
CLASS TMIConfigPanel net/minecraft/src/TMIConfigPanel
CLASS TMIController net/minecraft/src/TMIController
CLASS TMIEnchantControl net/minecraft/src/TMIEnchantControl
CLASS TMIEnchanting net/minecraft/src/TMIEnchanting
CLASS TMIEnchantItemPicker net/minecraft/src/TMIEnchantItemPicker
CLASS TMIEnchantPanel net/minecraft/src/TMIEnchantPanel
CLASS TMIFavoritesPanel net/minecraft/src/TMIFavoritesPanel
CLASS TMIFireworkPanel net/minecraft/src/TMIFireworkPanel
CLASS TMIImages net/minecraft/src/TMIImages
CLASS TMIItemCrop net/minecraft/src/TMIItemCrop
CLASS TMIItemInfo net/minecraft/src/TMIItemInfo
CLASS TMIItemMushroomCap net/minecraft/src/TMIItemMushroomCap
CLASS TMIItemPanel net/minecraft/src/TMIItemPanel
CLASS TMIItemSnow net/minecraft/src/TMIItemSnow
CLASS TMIItemSpawner net/minecraft/src/TMIItemSpawner
CLASS TMIPotionEffectControl net/minecraft/src/TMIPotionEffectControl
CLASS TMIPotionEffectPicker net/minecraft/src/TMIPotionEffectPicker
CLASS TMIPotionPanel net/minecraft/src/TMIPotionPanel
CLASS TMIPrivateFields net/minecraft/src/TMIPrivateFields
CLASS TMIPrivateFields$1 net/minecraft/src/TMIPrivateFields$1
CLASS TMIStateButtonData net/minecraft/src/TMIStateButtonData
CLASS TMIUtils net/minecraft/src/TMIUtils
CLASS TMIUtils$1 net/minecraft/src/TMIUtils$1
CLASS TMIView net/minecraft/src/TMIView
CLASS BaseMod modloader/BaseMod
CLASS EntityRendererProxy modloader/EntityRendererProxy
CLASS EntityTrackerNonliving modloader/EntityTrackerNonliving
CLASS MLProp modloader/MLProp
CLASS ModLoader modloader/ModLoader
CLASS ModTextureAnimation modloader/ModTextureAnimation
CLASS ModTextureStatic modloader/ModTextureStatic
CLASS TradeEntry modloader/TradeEntry
CLASS TMIBlockUtils net/minecraft/src/TMIBlockUtils
CLASS TMICustomItems net/minecraft/src/TMICustomItems
CLASS TMIPotionColorPicker net/minecraft/src/TMIPotionColorPicker
CLASS TMIReplaceItems net/minecraft/src/TMIReplaceItems
CLASS TMIReplaceItems$MetadataBlock net/minecraft/src/TMIReplaceItems$MetadataBlock
CLASS TMIReplaceItems$SpawnerBlock net/minecraft/src/TMIReplaceItems$SpawnerBlock
CLASS _tmi_MgColorButton net/minecraft/src/_tmi_MgColorButton
CLASS _tmi_MgTabPolicy net/minecraft/src/_tmi_MgTabPolicy

0 comments on commit cb06616

Please sign in to comment.