generated from Turnip-Labs/bta-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df11eb0
commit c40bb1e
Showing
10 changed files
with
155 additions
and
71 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
52 changes: 52 additions & 0 deletions
52
src/main/java/rootenginear/sortchest/gui/GuiSortChestButton.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,52 @@ | ||
package rootenginear.sortchest.gui; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.render.FontRenderer; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
public class GuiSortChestButton extends GuiButton { | ||
private final int leftPadding; | ||
private final String tooltipText; | ||
|
||
public GuiSortChestButton(int id, int xPosition, int yPosition, int width, int height, String text, int leftPadding, String tooltipText) { | ||
super(id, xPosition, yPosition, width, height, text); | ||
this.leftPadding = leftPadding; | ||
this.tooltipText = tooltipText; | ||
} | ||
|
||
@Override | ||
public void drawButton(Minecraft minecraft, int i, int j) { | ||
if (!this.visible) { | ||
return; | ||
} | ||
FontRenderer fontrenderer = minecraft.fontRenderer; | ||
GL11.glBindTexture(3553, minecraft.renderEngine.getTexture("/gui/gui.png")); | ||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | ||
boolean flag = i >= this.xPosition && j >= this.yPosition && i < this.xPosition + this.width && j < this.yPosition + this.height; | ||
int k = this.getButtonState(flag); | ||
|
||
// Edited — Draw from 4 corners | ||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height / 2); | ||
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height / 2); | ||
this.drawTexturedModalRect(this.xPosition, this.yPosition + this.height / 2, 0, (46 + (k + 1) * 20) - this.height / 2, this.width / 2, this.height / 2); | ||
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition + this.height / 2, 200 - this.width / 2, (46 + (k + 1) * 20) - this.height / 2, this.width / 2, this.height / 2); | ||
// End | ||
|
||
this.mouseDragged(minecraft, i, j); | ||
|
||
// Edited — Using `leftPadding` on x position | ||
if (!this.enabled) { | ||
this.drawStringCentered(fontrenderer, this.displayString, this.xPosition + this.leftPadding, this.yPosition + (this.height - 8) / 2, -6250336); | ||
} else if (flag) { | ||
this.drawStringCentered(fontrenderer, this.displayString, this.xPosition + this.leftPadding, this.yPosition + (this.height - 8) / 2, 0xFFFFA0); | ||
} else { | ||
this.drawStringCentered(fontrenderer, this.displayString, this.xPosition + this.leftPadding, this.yPosition + (this.height - 8) / 2, 0xE0E0E0); | ||
} | ||
// End | ||
} | ||
|
||
public String getTooltipText() { | ||
return this.tooltipText; | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
src/main/java/rootenginear/sortchest/mixin/GuiChestMixin.java
This file was deleted.
Oops, something went wrong.
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
37 changes: 37 additions & 0 deletions
37
src/main/java/rootenginear/sortchest/mixin/GuiScreenMixin.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,37 @@ | ||
package rootenginear.sortchest.mixin; | ||
|
||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.gui.GuiScreen; | ||
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 rootenginear.sortchest.utils.Utils; | ||
|
||
@Mixin(value = {GuiScreen.class}, remap = false) | ||
public class GuiScreenMixin { | ||
@Inject(method = "buttonPressed", at = @At(value = "HEAD"), cancellable = true) | ||
private void chestButtonsAction(GuiButton guibutton, CallbackInfo ci) { | ||
if (Utils.isNotChest(this)) return; | ||
|
||
if (!guibutton.enabled) { | ||
ci.cancel(); | ||
return; | ||
} | ||
|
||
GuiScreen screenThis = (GuiScreen) (Object) this; | ||
switch (guibutton.id) { | ||
case 0: | ||
screenThis.keyTyped('s', 0, 0, 0); | ||
ci.cancel(); | ||
return; | ||
case 1: | ||
screenThis.keyTyped('f', 0, 0, 0); | ||
ci.cancel(); | ||
return; | ||
case 2: | ||
screenThis.keyTyped('d', 0, 0, 0); | ||
ci.cancel(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/rootenginear/sortchest/mixin/accessor/GuiContainerAccessor.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,12 @@ | ||
package rootenginear.sortchest.mixin.accessor; | ||
|
||
import net.minecraft.client.gui.GuiContainer; | ||
import net.minecraft.client.gui.GuiTooltip; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(value = {GuiContainer.class}, remap = false) | ||
public interface GuiContainerAccessor { | ||
@Accessor | ||
GuiTooltip getGuiTooltip(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package rootenginear.sortchest.utils; | ||
|
||
import net.minecraft.client.gui.GuiChest; | ||
|
||
public class Utils { | ||
public static boolean isNotChest(Object object) { | ||
return !(object instanceof GuiChest); | ||
} | ||
} |
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