-
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.
-Added mechanic to reverse engineer recipes
- Loading branch information
1 parent
96ffeee
commit 181482b
Showing
20 changed files
with
342 additions
and
89 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
54 changes: 54 additions & 0 deletions
54
src/client/java/cassunshine/thework/client/gui/ingame/notebook/drawables/ItemDisplay.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,54 @@ | ||
package cassunshine.thework.client.gui.ingame.notebook.drawables; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.Drawable; | ||
import net.minecraft.client.render.DiffuseLighting; | ||
import net.minecraft.client.render.OverlayTexture; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.json.ModelTransformationMode; | ||
import net.minecraft.item.ItemStack; | ||
import org.joml.Matrix4f; | ||
|
||
public class ItemDisplay implements Drawable { | ||
public int x; | ||
public int y; | ||
|
||
public ItemStack stack = ItemStack.EMPTY; | ||
|
||
@Override | ||
public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
|
||
if (stack.isEmpty()) | ||
return; | ||
|
||
var matrices = context.getMatrices(); | ||
var client = MinecraftClient.getInstance(); | ||
|
||
BakedModel bakedModel = client.getItemRenderer().getModel(stack, client.world, client.player, 0); | ||
matrices.push(); | ||
matrices.translate((float) (x), (float) (y), (float) (150)); | ||
|
||
try { | ||
matrices.multiplyPositionMatrix((new Matrix4f()).scaling(1.0F, -1.0F, 1.0F)); | ||
matrices.scale( 48 / (float) client.getWindow().getScaleFactor(), 48 / (float) client.getWindow().getScaleFactor(), 48 / (float) client.getWindow().getScaleFactor()); | ||
boolean bl = !bakedModel.isSideLit(); | ||
if (bl) { | ||
DiffuseLighting.disableGuiDepthLighting(); | ||
} | ||
|
||
client.getItemRenderer().renderItem(stack, ModelTransformationMode.GUI, false, matrices, context.getVertexConsumers(), 15728880, OverlayTexture.DEFAULT_UV, bakedModel); | ||
RenderSystem.disableDepthTest(); | ||
context.getVertexConsumers().draw(); | ||
RenderSystem.enableDepthTest(); | ||
if (bl) { | ||
DiffuseLighting.enableGuiDepthLighting(); | ||
} | ||
} catch (Throwable var12) { | ||
//Ignore. | ||
} | ||
|
||
matrices.pop(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ient/java/cassunshine/thework/client/gui/ingame/notebook/drawables/RandomItemDisplay.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,27 @@ | ||
package cassunshine.thework.client.gui.ingame.notebook.drawables; | ||
|
||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.registry.Registries; | ||
|
||
import java.util.Random; | ||
|
||
public class RandomItemDisplay extends ItemDisplay { | ||
|
||
private static final Random random = new Random(); | ||
private float changeCooldown = 0f; | ||
|
||
@Override | ||
public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
changeCooldown -= delta; | ||
|
||
if (changeCooldown <= 0) { | ||
var randomItem = Registries.ITEM.get(random.nextInt(Registries.ITEM.size())); | ||
stack = new ItemStack(randomItem); | ||
|
||
changeCooldown = 10f; | ||
} | ||
|
||
super.render(context, mouseX, mouseY, delta); | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
...nt/java/cassunshine/thework/client/gui/ingame/notebook/pages/DeconstructTutorialPage.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,43 @@ | ||
package cassunshine.thework.client.gui.ingame.notebook.pages; | ||
|
||
import cassunshine.thework.TheWorkMod; | ||
import cassunshine.thework.client.gui.ingame.notebook.AlchemistNotebookScreen; | ||
import cassunshine.thework.client.gui.ingame.notebook.drawables.ItemDisplay; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.MathHelper; | ||
|
||
public class DeconstructTutorialPage extends AlchemistNotebookPage { | ||
|
||
public static final Identifier IDENTIFIER = new Identifier(TheWorkMod.ModID, "deconstruct_tutorial"); | ||
public static final Identifier PAGE_TEXTURE = new Identifier(TheWorkMod.ModID, "textures/pages/deconstruct_tutorial.png"); | ||
|
||
public DeconstructTutorialPage(NbtCompound compound) { | ||
super(compound); | ||
} | ||
|
||
public DeconstructTutorialPage() { | ||
super(IDENTIFIER, PAGE_TEXTURE); | ||
} | ||
|
||
@Override | ||
public void init(AlchemistNotebookScreen screen, int x, int y, int width, int height) { | ||
super.init(screen, x, y, width, height); | ||
|
||
var itemDisplay = new ItemDisplay(); | ||
itemDisplay.x = x + MathHelper.floor(width * (14.5f / 96.0f)); | ||
itemDisplay.y = y + MathHelper.floor(height * (38.5f / 128.0f)); | ||
itemDisplay.stack = new ItemStack(Blocks.DIRT.asItem()); | ||
|
||
screen.addDrawable(itemDisplay); | ||
|
||
itemDisplay = new ItemDisplay(); | ||
itemDisplay.x = x + MathHelper.floor(width * (14.5f / 96.0f)); | ||
itemDisplay.y = y + MathHelper.floor(height * (54.5f / 128.0f)); | ||
itemDisplay.stack = new ItemStack(Blocks.STONE.asItem()); | ||
|
||
screen.addDrawable(itemDisplay); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/client/java/cassunshine/thework/client/gui/ingame/notebook/pages/LegendNotebookPage.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,33 @@ | ||
package cassunshine.thework.client.gui.ingame.notebook.pages; | ||
|
||
import cassunshine.thework.TheWorkMod; | ||
import cassunshine.thework.client.gui.ingame.notebook.AlchemistNotebookScreen; | ||
import cassunshine.thework.client.gui.ingame.notebook.drawables.RandomItemDisplay; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.MathHelper; | ||
|
||
public class LegendNotebookPage extends AlchemistNotebookPage { | ||
|
||
public static final Identifier IDENTIFIER = new Identifier(TheWorkMod.ModID, "legend"); | ||
public static final Identifier PAGE_TEXTURE = new Identifier(TheWorkMod.ModID, "textures/pages/legend.png"); | ||
|
||
public LegendNotebookPage(NbtCompound compound) { | ||
super(compound); | ||
} | ||
|
||
public LegendNotebookPage() { | ||
super(IDENTIFIER, PAGE_TEXTURE); | ||
} | ||
|
||
@Override | ||
public void init(AlchemistNotebookScreen screen, int x, int y, int width, int height) { | ||
super.init(screen, x, y, width, height); | ||
|
||
var randomItemDisplay = new RandomItemDisplay(); | ||
randomItemDisplay.x = x + MathHelper.floor(width * 0.61); | ||
randomItemDisplay.y = y + MathHelper.floor(height * 0.61); | ||
|
||
screen.addDrawable(randomItemDisplay); | ||
} | ||
} |
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.