-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i forgot to commit yesterday (omw to lose my daily commit or something)
- Loading branch information
Showing
11 changed files
with
218 additions
and
36 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
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
71 changes: 71 additions & 0 deletions
71
src/main/java/dev/dfonline/codeclient/dev/menu/customchest/FakeSlot.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,71 @@ | ||
package dev.dfonline.codeclient.dev.menu.customchest; | ||
|
||
import dev.dfonline.codeclient.CodeClient; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreens; | ||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; | ||
import net.minecraft.client.gui.tooltip.Tooltip; | ||
import net.minecraft.client.gui.widget.ClickableWidget; | ||
import net.minecraft.client.item.TooltipContext; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.screen.ScreenHandler; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class FakeSlot extends ClickableWidget { | ||
public static final Identifier TEXTURE = new Identifier("minecraft","textures/gui/sprites/container/slot.png"); | ||
private final ScreenHandler handler; | ||
public boolean disabled = false; | ||
@NotNull | ||
public ItemStack item = ItemStack.EMPTY; | ||
|
||
public FakeSlot(int x, int y, Text message, ScreenHandler handler) { | ||
super(x, y, 18, 18, message); | ||
this.handler = handler; | ||
this.item = Items.STRING.getDefaultStack(); | ||
} | ||
|
||
@Override | ||
protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) { | ||
context.drawTexture(TEXTURE,this.getX(),this.getY(),0,0,this.width,this.height,18,18); | ||
context.drawItem(item,this.getX() + 1,this.getY() + 1); | ||
if(this.isMouseOver(mouseX,mouseY)) { | ||
HandledScreen.drawSlotHighlight(context,this.getX() + 1,this.getY() + 1,-1000); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean mouseClicked(double mouseX, double mouseY, int button) { | ||
if(this.isMouseOver(mouseX,mouseY) && ((!this.item.isEmpty()) || (!this.handler.getCursorStack().isEmpty()))) { | ||
var swap = this.item.copy(); | ||
this.item = this.handler.getCursorStack().copyWithCount(1); | ||
this.handler.setCursorStack(swap); | ||
return true; | ||
} | ||
return super.mouseClicked(mouseX, mouseY, button); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Tooltip getTooltip() { | ||
var data = Screen.getTooltipFromItem(CodeClient.MC, item); | ||
var text = Text.empty(); | ||
boolean first = true; | ||
for (var line: data) { | ||
if(first) first = false; | ||
else text.append(Text.literal("\n")); | ||
text.append(line); | ||
} | ||
return Tooltip.of(text); | ||
} | ||
|
||
@Override | ||
protected void appendClickableNarrations(NarrationMessageBuilder builder) { | ||
|
||
} | ||
} |
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
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
Oops, something went wrong.