-
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.
- Loading branch information
1 parent
5712caa
commit 1982377
Showing
45 changed files
with
791 additions
and
230 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
18 changes: 18 additions & 0 deletions
18
...ient/java/cassunshine/thework/client/gui/ingame/notebook/AlchemistNotebookNodeScreen.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,18 @@ | ||
package cassunshine.thework.client.gui.ingame.notebook; | ||
|
||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.text.Text; | ||
|
||
public class AlchemistNotebookNodeScreen extends AlchemistNotebookScreen { | ||
public AlchemistNotebookNodeScreen() { | ||
super(Text.translatable("ui.alchemist_notebook.page.node.title"), "nodes"); | ||
|
||
|
||
} | ||
|
||
|
||
@Override | ||
public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
super.render(context, mouseX, mouseY, delta); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/client/java/cassunshine/thework/client/gui/ingame/notebook/AlchemistNotebookScreen.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,47 @@ | ||
package cassunshine.thework.client.gui.ingame.notebook; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Hand; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public abstract class AlchemistNotebookScreen extends Screen { | ||
private static final String DEFAULT_PAGE = "nodes"; | ||
|
||
private static final ImmutableMap<String, Supplier<AlchemistNotebookScreen>> SCREEN_GENERATORS = new ImmutableMap.Builder<String, Supplier<AlchemistNotebookScreen>>().put("node", AlchemistNotebookNodeScreen::new).build(); | ||
|
||
public NbtCompound itemNbt; | ||
public NbtCompound pageNbt; | ||
|
||
public AlchemistNotebookScreen(Text title, String pageName) { | ||
super(title); | ||
|
||
itemNbt = MinecraftClient.getInstance().player.getStackInHand(Hand.MAIN_HAND).getOrCreateNbt(); | ||
this.client = MinecraftClient.getInstance(); | ||
|
||
pageNbt = itemNbt.getCompound(pageName); | ||
itemNbt.put(pageName, pageNbt); | ||
} | ||
|
||
public void openPage(String pageName) { | ||
if (pageName.isEmpty()) | ||
pageName = DEFAULT_PAGE; | ||
|
||
itemNbt.putString("opened_page", pageName); | ||
|
||
String finalPageName = pageName; | ||
|
||
this.client.execute(() -> { | ||
client.setScreen(SCREEN_GENERATORS.get(finalPageName).get()); | ||
}); | ||
} | ||
|
||
@Override | ||
public boolean shouldPause() { | ||
return false; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/client/java/cassunshine/thework/client/networking/TheWorkClientNetworking.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 |
---|---|---|
@@ -1,10 +1,32 @@ | ||
package cassunshine.thework.client.networking; | ||
|
||
import cassunshine.thework.client.events.TheWorkClientNetworkEvents; | ||
import cassunshine.thework.client.gui.ingame.notebook.AlchemistNotebookNodeScreen; | ||
import cassunshine.thework.items.TheWorkItems; | ||
import cassunshine.thework.network.TheWorkNetworking; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.fabricmc.fabric.api.networking.v1.PacketSender; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.util.Hand; | ||
|
||
public class TheWorkClientNetworking { | ||
|
||
public static void initialize() { | ||
TheWorkClientNetworkEvents.initialize(); | ||
|
||
ClientPlayNetworking.registerGlobalReceiver(TheWorkNetworking.OPEN_ALCHEMIST_BOOK, TheWorkClientNetworking::onOpenBook); | ||
} | ||
|
||
private static void onOpenBook(MinecraftClient minecraftClient, ClientPlayNetworkHandler clientPlayNetworkHandler, PacketByteBuf packetByteBuf, PacketSender packetSender) { | ||
var stack = MinecraftClient.getInstance().player.getStackInHand(Hand.MAIN_HAND); | ||
|
||
if (!stack.isOf(TheWorkItems.ALCHEMIST_NOTEBOOK_ITEM)) | ||
return; | ||
|
||
minecraftClient.execute(() -> { | ||
minecraftClient.setScreen(new AlchemistNotebookNodeScreen()); | ||
}); | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
src/client/java/cassunshine/thework/rendering/particles/PathParticle.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,55 @@ | ||
package cassunshine.thework.rendering.particles; | ||
|
||
import cassunshine.thework.alchemy.circle.path.AlchemyPath; | ||
import cassunshine.thework.particles.TheWorkParticles; | ||
import net.minecraft.client.particle.ParticleTextureSheet; | ||
import net.minecraft.client.particle.SpriteBillboardParticle; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.util.math.ColorHelper; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
public class PathParticle extends SpriteBillboardParticle { | ||
|
||
private final Vec3d startPos; | ||
private final Vec3d endPos; | ||
|
||
private final double travelDistance; | ||
|
||
private float progress = 0; | ||
|
||
protected PathParticle(ClientWorld clientWorld, double x, double y, double z, double dstX, double dstY, double dstZ) { | ||
super(clientWorld, x, y, z); | ||
this.maxAge = Integer.MAX_VALUE; | ||
this.setColor(ColorHelper.Argb.getRed(TheWorkParticles.particleColor) / 255.0f, ColorHelper.Argb.getGreen(TheWorkParticles.particleColor) / 255.0f, ColorHelper.Argb.getBlue(TheWorkParticles.particleColor) / 255.0f); | ||
this.scale = 0.05f; | ||
|
||
this.startPos = new Vec3d(x, y, z); | ||
this.endPos = new Vec3d(dstX, dstY, dstZ); | ||
|
||
this.travelDistance = startPos.distanceTo(endPos); | ||
|
||
} | ||
|
||
@Override | ||
public ParticleTextureSheet getType() { | ||
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
super.tick(); | ||
|
||
if (progress >= travelDistance) | ||
markDead(); | ||
|
||
//Move along path... | ||
progress += AlchemyPath.TRAVEL_SPEED; | ||
|
||
var progressFrac = progress / travelDistance; | ||
Vec3d newPos = startPos.lerp(endPos, progressFrac); | ||
|
||
x = newPos.x; | ||
y = newPos.y; | ||
z = newPos.z; | ||
} | ||
} |
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.