Skip to content

Commit

Permalink
fix: Use spell grid component on tutorial as well as fixing
Browse files Browse the repository at this point in the history
Fixes #742 #787
Introduces parchment as well, in order to have better name parameters
  • Loading branch information
Kamefrede committed Nov 7, 2023
1 parent 4440374 commit 449f01d
Show file tree
Hide file tree
Showing 78 changed files with 62 additions and 1,936 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ buildscript {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/maven' }
mavenCentral()
maven { url = 'https://maven.parchmentmc.org' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1+', changing: true
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
classpath 'org.parchmentmc:librarian:1.+'
}
}

Expand All @@ -15,6 +17,7 @@ plugins {
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
Expand Down
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#Sun Apr 09 14:41:44 WEST 2023
mapping_channel=official
mapping_channel=parchment
mod_id=psi
forge_version=43.3.0
jei_version=11.6.0.1013
build_number=99
patchy_version=1.19.2-77
dir_output=../Build Output/Psi/
version=1.19
mapping_version=1.19.2
mapping_version=2022.11.27-1.19.2
mod_name=Psi
mc_version=1.19.2
32 changes: 22 additions & 10 deletions src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
*/
package vazkii.psi.client.patchouli;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.brigadier.exceptions.CommandSyntaxException;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.TagParser;
import net.minecraft.util.StringUtil;
Expand All @@ -26,13 +28,13 @@

import java.util.function.UnaryOperator;

import static vazkii.psi.client.gui.GuiProgrammer.texture;

public class SpellGridComponent implements ICustomComponent {
private transient int x, y;
private transient boolean isDownscaled;
private transient SpellGrid grid;
private transient String spellName;

public IVariable spell;
public IVariable halfsize;

@Override
public void build(int componentX, int componentY, int pageNum) {
Expand All @@ -47,20 +49,31 @@ public void build(int componentX, int componentY, int pageNum) {
throw new IllegalArgumentException("Invalid spell string: " + spell);
}
grid = fromNBT.grid;
spellName = fromNBT.name;
} catch (CommandSyntaxException e) {
throw new IllegalArgumentException("Invalid spell string: " + spell, e);
}
isDownscaled = halfsize.asBoolean(false);
}

@Override
public void render(PoseStack ms, IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
float scale = isDownscaled ? 0.5f : 1.0f;
float scale = 0.65f;

MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
ms.pushPose();
ms.translate(x, y, 0);
ms.scale(scale, scale, scale);
ms.scale(scale, scale, 0f);

// Draw the Programmer BG
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
RenderSystem.setShaderTexture(0, texture);
context.getGui().blit(ms, 0, 0, 0, 0, 174, 184);

// Draw the name label and spell name
context.getGui().getMinecraft().font.drawShadow(ms, I18n.get("psimisc.name"), 7, 171, 0xFFFFFF);
context.getGui().getMinecraft().font.drawShadow(ms, spellName, 44, 170, 0xFFFFFF);

// Pad the spell pieces and draw them
ms.translate(7f, 7f, 0f);
MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
grid.draw(ms, buffer, 0xF000F0);
buffer.endBatch();

Expand All @@ -72,7 +85,7 @@ public void render(PoseStack ms, IComponentRenderContext context, float pticks,
SpellPiece[] data = gridData[i];
for(int j = 0; j < data.length; j++) {
SpellPiece piece = data[j];
if(piece != null && context.isAreaHovered(mouseX, mouseY, (int) (x + i * scaledSize), (int) (y + j * scaledSize), scaledHoverSize, scaledHoverSize)) {
if(piece != null && context.isAreaHovered(mouseX, mouseY, (int) (4 + i * scaledSize), (int) (4 + j * scaledSize), scaledHoverSize, scaledHoverSize)) {
PatchouliUtils.setPieceTooltip(context, piece);
}
}
Expand All @@ -83,6 +96,5 @@ public void render(PoseStack ms, IComponentRenderContext context, float pticks,
@Override
public void onVariablesAvailable(UnaryOperator<IVariable> lookup) {
spell = lookup.apply(spell);
halfsize = lookup.apply(halfsize);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/psi/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@
"psi.datatype.entity": "Entity",
"psi.datatype.living_entity": "Entity (Living)",
"psi.datatype.living_entity_base": "Entity (Living)",
"psi.datatype.player_entity": "Entity (Player, Living)",
"psi.datatype.player": "Entity (Player, Living)",
"psi.datatype.entity_list_wrapper": "Entity List",
"psi.spellerror.nospell": "No Spell to compile",
"psi.spellerror.invalid_base": "ERROR: Cannot interpret bases below 2",
Expand Down Expand Up @@ -829,7 +829,7 @@
"psi.book.page.tutorial4.7": "Copy the $(thing)Spell$(0) into your $(thing)CAD$(0), look straight ahead, and cast. If you get thrown forward, then congratulations! You've just finished writing your first real $(thing)Spell$(0)!$(p)$(o)Note: Casting your new $(thing)Spell$(0) too many times in a row might be bad for your health. More on this in $(l:basics/tutorial_5)the next tutorial$(/l).$()",
"psi.book.entry.tutorial5": "Tutorial (5): Limits",
"psi.book.page.tutorial5.0": "Open your $(l:basics/spell_programmer)$(o)$(item)Spell Programmer$(0)$(/l) again, and review the $(thing)Spell$(0) you wrote in $(l:basics/tutorial_4)the last tutorial$(/l).$(p)When it compiled correctly, you should have seen five icons appear to the right of the grid, each with two numbers. These numerical stats define the practical limits on exactly what $(thing)Spells$(0) you're able to cast.",
"psi.book.page.tutorial5.1": "The stats for your Add Motion $(thing)Spell$(0) (assuming your constant was 3)",
"psi.book.page.tutorial5.1": "The stats for your Add Motion $(thing)Spell$(0) (assuming your constant was 2)",
"psi.book.subsec.tutorial5.2": "Complexity",
"psi.book.page.tutorial5.2": "The first stat is $(thing)Complexity$(0), the total number of $(thing)Operators$(0), $(thing)Selectors$(0), and non-debug $(thing)Tricks$(0) in the $(thing)Spell$(0).$(p)Its maximum value is determined by the $(l:components/core)$(o)$(item)CAD Core$(0)$(/l) you have installed; if a $(thing)Spell$(0)'s $(thing)Complexity$(0) exceeds your $(thing)CAD$(0)'s capacity, it won't be castable.",
"psi.book.subsec.tutorial5.3": "Potency",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,27 @@
"text": "psi.book.page.evalOrder.2"
},
{
"type": "image",
"text": "psi.book.page.evalOrder.3",
"images": [
"psi:textures/gui/entries/eval_order_1.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:trick_debug\",params:{_number:0,_target:4}},x:1,y:2},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:4}},x:1,y:6},{data:{constantValue:\"1\",key:\"psi:constant_number\"},x:2,y:2},{data:{constantValue:\"3\",key:\"psi:constant_number\"},x:2,y:6},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:4}},x:6,y:2},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:4}},x:6,y:6},{data:{constantValue:\"2\",key:\"psi:constant_number\"},x:7,y:2},{data:{constantValue:\"4\",key:\"psi:constant_number\"},x:7,y:6}],spellName:\"Rule 1\",uuidLeast:-8740135302326498868L,uuidMost:4572508895319312811L,validSpell:1b}",
"text": "psi.book.page.evalOrder.3"
},
{
"type": "text",
"text": "psi.book.page.evalOrder.4"
},
{
"type": "image",
"text": "psi.book.page.evalOrder.5",
"images": [
"psi:textures/gui/entries/eval_order_2.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{constantValue:\"1\",key:\"psi:constant_number\"},x:1,y:5},{data:{key:\"psi:operator_entity_look\",params:{_target:1}},x:1,y:6},{data:{constantValue:\"0\",key:\"psi:constant_number\"},x:2,y:2},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:1}},x:2,y:3},{data:{key:\"psi:operator_absolute\",params:{_target:2}},x:2,y:5},{data:{key:\"psi:selector_caster\"},x:2,y:6},{data:{key:\"psi:operator_vector_negate\",params:{_target:2}},x:6,y:2},{data:{key:\"psi:connector\",params:{_target:4}},x:6,y:3},{data:{key:\"psi:selector_caster\"},x:6,y:5},{data:{key:\"psi:operator_divide\",params:{_number1:1,_number2:4,_number3:0}},x:6,y:6},{data:{key:\"psi:connector\",params:{_target:3}},x:7,y:2},{data:{key:\"psi:connector\",params:{_target:1}},x:7,y:3},{data:{key:\"psi:selector_focal_point\"},x:7,y:6}],spellName:\"Undefined Behaviour\",uuidLeast:-8740135302326498868L,uuidMost:4572508895319312811L,validSpell:1b}",
"text": "psi.book.page.evalOrder.5"
},
{
"type": "text",
"text": "psi.book.page.evalOrder.6"
},
{
"type": "image",
"text": "psi.book.page.evalOrder.7",
"images": [
"psi:textures/gui/entries/eval_order_3.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:trick_debug\",params:{_number:0,_target:2}},x:3,y:3},{data:{key:\"psi:connector\",params:{_target:4}},x:3,y:4},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:1}},x:3,y:5},{data:{constantValue:\"1\",key:\"psi:constant_number\"},x:4,y:3},{data:{key:\"psi:operator_random\",params:{_max:1,_min:0}},x:4,y:4},{data:{key:\"psi:trick_debug_spamless\",params:{_number:0,_target:2}},x:5,y:3},{data:{key:\"psi:connector\",params:{_target:3}},x:5,y:4},{data:{key:\"psi:trick_debug_spamless\",params:{_number:0,_target:1}},x:5,y:5}],spellName:\"Rule 3\",uuidLeast:-4674464373897948180L,uuidMost:-1782855518829395229L,validSpell:1b}",
"text": "psi.book.page.evalOrder.7"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@
"text": "psi.book.page.tutorial1.12"
},
{
"type": "image",
"text": "psi.book.page.tutorial1.13",
"images": [
"psi:textures/gui/entries/tutorial_1_spell.png"
],
"border": true
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:selector_caster\"},x:4,y:4},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:3}},x:5,y:4}],spellName:\"Debug\",uuidLeast:-8344502881889052755L,uuidMost:8904817452787319960L,validSpell:1b}"
},
{
"type": "text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
"text": "psi.book.page.tutorial3.2"
},
{
"type": "image",
"text": "psi.book.page.tutorial3.3",
"images": [
"psi:textures/gui/entries/tutorial_3_tooltip.png"
],
"border": false
"type": "psi:spellpiece_spotlight",
"spellpiece": "psi:selector_caster",
"text": "psi.book.page.tutorial3.3"
},
{
"type": "text",
Expand Down Expand Up @@ -54,24 +51,16 @@
"text": "psi.book.page.tutorial3.10"
},
{
"type": "image",
"text": "psi.book.page.tutorial3.11",
"images": [
"psi:textures/gui/entries/tutorial_3_connector.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:trick_debug\",params:{_number:0,_target:4}},x:3,y:4},{data:{key:\"psi:connector\",params:{_target:4}},x:4,y:4},{data:{key:\"psi:selector_caster\"},x:5,y:4}],spellName:\"Bridge to Terabithia\",uuidLeast:-8344502881889052755L,uuidMost:8904817452787319960L,validSpell:1b}"
},
{
"type": "text",
"text": "psi.book.page.tutorial3.12"
},
{
"type": "image",
"text": "psi.book.page.tutorial3.13",
"images": [
"psi:textures/gui/entries/tutorial_3_chain.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:connector\",params:{_target:2}},x:2,y:3},{data:{constantValue:\"42\",key:\"psi:constant_number\"},x:2,y:4},{data:{key:\"psi:connector\",params:{_target:1}},x:2,y:5},{data:{key:\"psi:connector\",params:{_target:3}},x:3,y:3},{data:{key:\"psi:selector_caster\"},x:3,y:4},{data:{key:\"psi:connector\",params:{_target:3}},x:3,y:5},{data:{key:\"psi:connector\",params:{_target:3}},x:4,y:3},{data:{key:\"psi:connector\",params:{_target:3}},x:4,y:4},{data:{key:\"psi:connector\",params:{_target:3}},x:4,y:5},{data:{key:\"psi:connector\",params:{_target:3}},x:5,y:3},{data:{key:\"psi:trick_debug\",params:{_number:0,_target:3}},x:5,y:4},{data:{key:\"psi:connector\",params:{_target:3}},x:5,y:5},{data:{key:\"psi:connector\",params:{_target:3}},x:6,y:3},{data:{key:\"psi:trick_debug\",params:{_number:1,_target:2}},x:6,y:4},{data:{key:\"psi:connector\",params:{_target:3}},x:6,y:5}],spellName:\"The long way around\",uuidLeast:-8344502881889052755L,uuidMost:8904817452787319960L,validSpell:1b}"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@
"text": "psi.book.page.tutorial4.5"
},
{
"type": "image",
"text": "psi.book.page.tutorial4.6",
"images": [
"psi:textures/gui/entries/tutorial_4_spell.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{constantValue:\"2\",key:\"psi:constant_number\"},x:3,y:4},{data:{key:\"psi:selector_caster\"},x:4,y:3},{data:{key:\"psi:trick_add_motion\",params:{_direction:4,_speed:3,_target:1}},x:4,y:4},{data:{key:\"psi:connector\",params:{_target:3}},x:5,y:3},{data:{key:\"psi:operator_entity_look\",params:{_target:1}},x:5,y:4}],spellName:\"Add motion\",uuidLeast:-8344502881889052755L,uuidMost:8904817452787319960L,validSpell:1b}",
"text": "psi.book.page.tutorial4.6"
},
{
"type": "text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@
"text": "psi.book.page.tutorial6.9"
},
{
"type": "image",
"text": "psi.book.page.tutorial6.10",
"images": [
"psi:textures/gui/entries/tutorial_6_spell.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:selector_caster\"},x:3,y:3},{data:{key:\"psi:operator_entity_position\",params:{_target:1}},x:3,y:4},{data:{key:\"psi:operator_entity_look\",params:{_target:3}},x:4,y:3},{data:{key:\"psi:operator_vector_raycast\",params:{_max:0,_position:3,_ray:1}},x:4,y:4},{data:{key:\"psi:trick_explode\",params:{_position:1,_power:4}},x:4,y:5},{data:{constantValue:\"1.4\",key:\"psi:constant_number\"},x:5,y:5}],spellName:\"Explode\",uuidLeast:-8344502881889052755L,uuidMost:8904817452787319960L,validSpell:1b}",
"text": "psi.book.page.tutorial6.10"
},
{
"type": "text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@
"anchor": "circlesync"
},
{
"type": "image",
"text": "psi.book.page.circleBullet.7",
"images": [
"psi:textures/gui/entries/circle_bullet_circlesync.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:trick_delay\",params:{_time:2}},x:3,y:3},{data:{key:\"psi:constant_wrapper\",params:{_constant:2,_target:4}},x:3,y:4},{data:{constantValue:\"95\",key:\"psi:constant_number\"},x:3,y:5},{data:{key:\"psi:operator_subtract\",params:{_number1:2,_number2:4,_number3:0}},x:4,y:4},{data:{key:\"psi:connector\",params:{_target:3}},x:4,y:5},{data:{key:\"psi:selector_loopcast_index\"},x:5,y:3},{data:{key:\"psi:operator_multiply\",params:{_number1:1,_number2:2,_number3:0}},x:5,y:4},{data:{constantValue:\"5\",key:\"psi:constant_number\"},x:5,y:5}],spellName:\"Circlesync\",uuidLeast:-5666065845008046135L,uuidMost:-8982799496831941618L,validSpell:1b}",
"text": "psi.book.page.circleBullet.7"
},
{
"type": "text",
Expand All @@ -53,12 +50,9 @@
"text": "psi.book.page.circleBullet.9"
},
{
"type": "image",
"text": "psi.book.page.circleBullet.10",
"images": [
"psi:textures/gui/entries/circle_bullet_20b_tower.png"
],
"border": false
"type": "psi:spell_grid",
"spell": "{modsRequired:[{modName:\"psi\",modVersion:\"2.0.0\"}],spellList:[{data:{key:\"psi:trick_die\",params:{_target:4}},x:3,y:3},{data:{key:\"psi:selector_ruler_vector\"},x:3,y:4},{data:{key:\"psi:selector_block_presence\",params:{_position:2}},x:4,y:3},{data:{key:\"psi:operator_vector_sum\",params:{_vector1:4,_vector2:3,_vector3:0}},x:4,y:4},{data:{key:\"psi:selector_loopcast_index\"},x:5,y:3},{data:{key:\"psi:operator_vector_construct\",params:{_x:0,_y:1,_z:0}},x:5,y:4}],spellName:\"20-Bit Tower\",uuidLeast:-6418013341378361091L,uuidMost:8665330167676028379L,validSpell:1b}",
"text": "psi.book.page.circleBullet.10"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
{
"components": [
{
"type": "header",
"text": "#title",
"x": -1,
"y": -1
},
{
"type": "custom",
"type": "patchouli:custom",
"class": "vazkii.psi.client.patchouli.SpellGridComponent",
"x": 5,
"y": 5,
"spell": "#spell",
"halfsize": "#halfsize"
},
{
"type": "text",
"text": "#text",
"y": 100
"spell": "#spell"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"texture_height": 128
},
{
"type": "custom",
"type": "patchouli:custom",
"class": "vazkii.psi.client.patchouli.SpellPieceComponent",
"x": 50,
"y": 15,
Expand Down
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 449f01d

Please sign in to comment.