Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
5381263113 | |||
263466eed3 | |||
10bfbdb53d | |||
162df5c962 | |||
3f06723a1f | |||
700b970a04 | |||
3bfe235d97 | |||
48fef73096 | |||
504a52597d | |||
55808ca049 | |||
e5aa71f751 | |||
0664de5de5 | |||
4d0e4b6411 | |||
114c3a03d2 | |||
6b3445e1f6 | |||
14f254af3d | |||
8a23afeed0 | |||
8ca4986714 | |||
fb3ba1411f | |||
3b91e3daf8 | |||
acf08c7fa6 | |||
5552fe5cd8 | |||
d381beff16 | |||
ff50bd3851 | |||
76f316f7bd | |||
df3c1dcffd | |||
d2d33c6159 | |||
f40e44e366 | |||
4ebae792ac | |||
3fe89d2d95 | |||
b44ca31175 | |||
9d1cad6223 | |||
373f0ad8d3 | |||
1c033d5a0d | |||
1dbbd55376 | |||
019c588add | |||
5e24602ca8 | |||
ee78088250 | |||
c592b9e9af | |||
db54bdf2ad | |||
a3be3712d4 | |||
998e514cd9 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,3 +23,5 @@ bin/
|
|||||||
# fabric
|
# fabric
|
||||||
|
|
||||||
run/
|
run/
|
||||||
|
|
||||||
|
remappedSrc/
|
59
API.md
59
API.md
@ -4,17 +4,18 @@
|
|||||||
1. Add Dependency to Gradle
|
1. Add Dependency to Gradle
|
||||||
```gradle
|
```gradle
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://maven.thebrokenrail.com' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation 'com.thebrokenrail:sorcerycraft:VERSION'
|
modImplementation 'com.thebrokenrail:sorcerycraft:VERSION'
|
||||||
|
// VERSION = "<Mod Version>+<MC Version>", for example "1.2.4+20w12a"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
2. Add Dependency to ```fabric.mod.json```
|
2. Add Dependency to ```fabric.mod.json```
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"depends": {
|
"depends": {
|
||||||
"sorcerycraft": "1.1.x"
|
"sorcerycraft": "1.2.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -27,40 +28,72 @@
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Entity target, Entity source, Entity attacker) {
|
public void execute(Entity target, Entity source, Entity attacker) {
|
||||||
|
// OPTIONAL
|
||||||
// Called when ExampleSpell hits an entity
|
// Called when ExampleSpell hits an entity
|
||||||
// Not required to override
|
// Override this if you want the spell to affect entities
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(World world, BlockHitResult hitResult) {
|
public void execute(World world, BlockHitResult hitResult) {
|
||||||
|
// OPTIONAL
|
||||||
// Called when ExampleSpell hits a block
|
// Called when ExampleSpell hits a block
|
||||||
// Not required to override
|
// Override this if you want the spell to affect blocks
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getXPCost() {
|
public int getXPCost() {
|
||||||
|
// REQUIRED
|
||||||
// Return the amount of levels required to make ExampleSpell in a Casting Table
|
// Return the amount of levels required to make ExampleSpell in a Casting Table
|
||||||
|
switch (getLevel()) {
|
||||||
|
case 0: {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemCost() {
|
public ItemStack getItemCost() {
|
||||||
|
// REQUIRED
|
||||||
// Return the item(s) required to make ExampleSpell in a Casting Table
|
// Return the item(s) required to make ExampleSpell in a Casting Table
|
||||||
// Return ItemStack.EMPTY if an item is not required
|
// Return ItemStack.EMPTY if an item is not required
|
||||||
|
switch (getLevel()) {
|
||||||
|
case 0: {
|
||||||
|
return new ItemStack(Items.SUGAR_CANE);
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
return new ItemStack(Items.BOOK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxLevel() {
|
public int getMaxLevel() {
|
||||||
|
// REQUIRED
|
||||||
// Return ExampleSpell's maximum level
|
// Return ExampleSpell's maximum level
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Text getTranslation() {
|
||||||
|
// OPTIONAL
|
||||||
|
// Return a custom display name for ExampleSpell
|
||||||
|
// Override this only if you want a custom display name
|
||||||
|
return new LiteralText("Example " + (getLevel() + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
4. Register the Spell in your ModInitializer
|
4. Register the spell in your ModInitializer
|
||||||
```java
|
```java
|
||||||
public class ExampleMod implements ModInitializer {
|
public class ExampleMod implements ModInitializer {
|
||||||
public static final Identifier EXAMPLE_SPELL = SpellRegistry.register(new Identifier("modid", "example_spell"), ExampleSpell.class);
|
public static final Identifier EXAMPLE_SPELL = SpellRegistry.register(new Identifier("modid", "example_spell"), ExampleSpell.class);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
5. Add Spell Translation
|
5. Add Spell Translation (skip this if you have overridden ```Spell.getTranslation()``)
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"spell.modid.example_spell": "Example"
|
"spell.modid.example_spell": "Example"
|
||||||
@ -68,5 +101,15 @@
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Useful Methods
|
## Useful Methods
|
||||||
- ```Spell.getLevel()```
|
- ```(non-static) Spell.getLevel()```
|
||||||
- ```Spell.getID()```
|
- ```(non-static) Spell.getID()```
|
||||||
|
- ```(static) SpellRegistry.register()```
|
||||||
|
|
||||||
|
## API Stability
|
||||||
|
APIs are only guaranteed to be stable in the ```com.thebrokenrail.sorcerycraft.api``` package, it is unrecommended to rely on any SorceryCraft classes outside of this package.
|
||||||
|
|
||||||
|
## Spell Levels
|
||||||
|
Spell levels are 0-indexed, if you have a level 1 Example Spell, ```Spell.getLevel()``` wil return 0, and if it is level 2 ```Spell.getLevel()``` wil return 1, ```Spell.getMaxSpell()``` should be the maximum-acceptable value of ```Spell.getLevel() + 1```, so if Example Spell has levels 1-2, ```Spell.getMaxLevel()``` should return 2.
|
||||||
|
|
||||||
|
## JavaDoc
|
||||||
|
[View JavaDoc](https://jenkins.thebrokenrail.com/job/SorceryCraft/job/master/JavaDoc/)
|
73
CHANGELOG.md
73
CHANGELOG.md
@ -1,4 +1,75 @@
|
|||||||
### Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.2.9**
|
||||||
|
* Fix Dedicated Server Crash
|
||||||
|
|
||||||
|
**1.2.8**
|
||||||
|
* Register Loot Table Function
|
||||||
|
|
||||||
|
**1.2.7**
|
||||||
|
* Fix Cooling Spell Bug
|
||||||
|
|
||||||
|
**1.2.6**
|
||||||
|
* Fix Potential Client-Server De-sync Bug
|
||||||
|
|
||||||
|
**1.2.5**
|
||||||
|
* Fix Casting Table Bug
|
||||||
|
|
||||||
|
**1.2.4**
|
||||||
|
* Optimize Packets
|
||||||
|
* Allow Command Blocks to use ```/spell``` Command
|
||||||
|
* Namespace Statistics
|
||||||
|
|
||||||
|
**1.2.3**
|
||||||
|
* Tweak Cooling Spell
|
||||||
|
* Tweak Versioning
|
||||||
|
|
||||||
|
**1.2.2**
|
||||||
|
* Allow ```/spell``` command to work with multiple players
|
||||||
|
|
||||||
|
**1.2.1**
|
||||||
|
* Fix Launching Without ModMenu
|
||||||
|
|
||||||
|
**1.2**
|
||||||
|
* Update Mappings
|
||||||
|
* Update API (More Consistent Package Names)
|
||||||
|
* Fix Bug When Casting Spell
|
||||||
|
|
||||||
|
**1.1.21**
|
||||||
|
* Update Mappings
|
||||||
|
* Tweak Teleport and Flame Spells
|
||||||
|
|
||||||
|
**1.1.20**
|
||||||
|
* Update to 20w12a
|
||||||
|
|
||||||
|
**1.1.19**
|
||||||
|
* Update API Docs
|
||||||
|
* Allow Setting Custom Display name for Spell
|
||||||
|
|
||||||
|
**1.1.18**
|
||||||
|
* Fix Crash When Using Dedicated Server
|
||||||
|
|
||||||
|
**1.1.17**
|
||||||
|
* Update Mappings
|
||||||
|
* Add Spell-related Advancements
|
||||||
|
|
||||||
|
**1.1.16**
|
||||||
|
* Consistent Gradle Project Name
|
||||||
|
|
||||||
|
**1.1.15**
|
||||||
|
* Build JavaDoc Jar
|
||||||
|
|
||||||
|
**1.1.14**
|
||||||
|
* Update Config Lang
|
||||||
|
|
||||||
|
**1.1.13**
|
||||||
|
* Update Mappings
|
||||||
|
* Improve ```/spell``` command
|
||||||
|
|
||||||
|
**1.1.12**
|
||||||
|
* Update Mappings
|
||||||
|
* Add Config Screen
|
||||||
|
* Clarify Terms
|
||||||
|
|
||||||
**1.1.11**
|
**1.1.11**
|
||||||
* Update Mappings
|
* Update Mappings
|
||||||
|
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -7,11 +7,32 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
sh './gradlew build'
|
sh './gradlew build javadoc'
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
archiveArtifacts artifacts: 'build/libs/*', fingerprint: true
|
archiveArtifacts artifacts: 'build/libs/*', fingerprint: true
|
||||||
|
|
||||||
|
publishHTML target: [
|
||||||
|
allowMissing: false,
|
||||||
|
alwaysLinkToLastBuild: false,
|
||||||
|
keepAll: false,
|
||||||
|
reportDir: 'build/docs/javadoc',
|
||||||
|
reportFiles: 'index.html',
|
||||||
|
reportName: 'JavaDoc'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Publish') {
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
return sh(returnStdout: true, script: 'git tag --contains').trim().length() > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
withCredentials([string(credentialsId: 'curseforge_key', variable: 'CURSEFORGE_KEY')]) {
|
||||||
|
sh './gradlew -Pcurseforge.api_key="${CURSEFORGE_KEY}" curseforge publish'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
README.md
30
README.md
@ -1,13 +1,13 @@
|
|||||||
# SorceryCraft
|
# SorceryCraft
|
||||||
Cast Spells in Minecraft!
|
Cast Spells in Minecraft!
|
||||||
|
|
||||||
This mod supports the Minecraft 1.16 snapshots.
|
This mod currently supports the Minecraft 1.16 snapshots.
|
||||||
|
|
||||||
## What are Spells?
|
## What are Spells?
|
||||||
Spells are found throughout the world in chests. When you pick up a Spell you will learn it, one you learn a Spell you can apply it to a blank or existing Spell in the Casting Table. You can cast Spells by right-clicking. There is also a 30% chance the spell will rebound and hit you instead, unless the "Steadfast" Spell is applied.
|
Spells are found throughout the world in chests. When you pick up a Spell you will "discover" it, once you "discover" a spell you can apply it to a blank or existing spell in the Casting Table. You can cast spells by right-clicking. There is also a 30% chance (by default) that the spell will rebound and hit you instead, unless the "Steadfast" spell is applied.
|
||||||
|
|
||||||
## What's a Casting Table?
|
## What's a Casting Table?
|
||||||
You can apply Spells to blank or existing Spells in the Casting Table. Doing so will require a certain amount of levels, and sometimes may require an item.
|
You can apply Spells to blank or existing spells in the Casting Table. Doing so will require a certain amount of levels, and may require an item.
|
||||||
|
|
||||||
## Crafting
|
## Crafting
|
||||||
#### Blank Spell
|
#### Blank Spell
|
||||||
@ -56,29 +56,35 @@ You can apply Spells to blank or existing Spells in the Casting Table. Doing so
|
|||||||
| Heal | 2 | Heals target. |
|
| Heal | 2 | Heals target. |
|
||||||
| Dissolve | 1 | Removes target's status effects. |
|
| Dissolve | 1 | Removes target's status effects. |
|
||||||
| Levitate | 2 | Gives target the Levitation effect. |
|
| Levitate | 2 | Gives target the Levitation effect. |
|
||||||
| Steadfast | 1 | Prevents Spell from failing. This does nothing on its own. |
|
| Steadfast | 1 | Prevents the spell from failing. This spell does nothing on its own. |
|
||||||
| Teleport | 2 | Teleports target to random location. |
|
| Teleport | 3 | Teleports the target to a random location. |
|
||||||
| Inward | 1 | Causes the Spell to target the caster. If the Spell fails instead of rebounding, it will just do nothing. This does nothing on its own. |
|
| Inward | 1 | Causes the spell to target the caster. If the spell fails instead of rebounding, it will just do nothing. This spell does nothing on its own. |
|
||||||
| Cooling | 1 | Extinguish the target if they are on fire. |
|
| Cooling | 1 | Extinguish the target if they are on fire. |
|
||||||
| Lightning | 1 | Strikes the target with lightning. |
|
| Lightning | 1 | Strikes the target with lightning. |
|
||||||
|
|
||||||
## ```/spell``` Command
|
## ```/spell``` Command
|
||||||
This command requires OP permissions.
|
This command requires OP permissions.
|
||||||
|
|
||||||
#### ```/spell clear <player>```
|
#### ```/spell forget <player>```
|
||||||
This command clears all known spells from the given player.
|
This command clears all known spells from the given player.
|
||||||
|
|
||||||
|
#### ```/spell forget <player> <spell-id>```
|
||||||
|
This command clears the specified spell from the given player.
|
||||||
|
|
||||||
#### ```/spell list <player>```
|
#### ```/spell list <player>```
|
||||||
This lists all the spells the given player knows.
|
This lists all the spells the given player knows.
|
||||||
|
|
||||||
#### ```/spell learn <player> <spell-id> <level>```
|
#### ```/spell discover <player>```
|
||||||
This teaches the specified spell to the specified player.
|
This adds all spells to the specified player's discovered spells list.
|
||||||
|
|
||||||
#### ```/spell add <player> <spell-id> <level>```
|
#### ```/spell discover <player> <spell-id> <level>```
|
||||||
This adds the specified spell to the item in the player's main hand.
|
This adds the specified spell to the specified player's discovered spells list.
|
||||||
|
|
||||||
|
#### ```/spell apply <player> <spell-id> <level>```
|
||||||
|
This adds the specified spell to the item in the specified player's main hand.
|
||||||
|
|
||||||
#### ```/spell remove <player> <spell-id>```
|
#### ```/spell remove <player> <spell-id>```
|
||||||
This removes the specified spell from the item in the player's main hand.
|
This removes the specified spell from the item in the specified player's main hand.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
[View API](API.md)
|
[View API](API.md)
|
||||||
|
59
build.gradle
59
build.gradle
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
id 'fabric-loom' version '0.4-SNAPSHOT'
|
||||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||||
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
@ -9,25 +10,40 @@ compileJava {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name
|
archivesBaseName = project.archives_base_name
|
||||||
version = project.mod_version as Object
|
def mod_version = project.mod_version as Object
|
||||||
|
version = "${mod_version}+${project.minecraft_version}"
|
||||||
group = project.maven_group as Object
|
group = project.maven_group as Object
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://dl.bintray.com/shedaniel/autoconfig1u/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||||
|
|
||||||
|
modImplementation "me.shedaniel.cloth:config-2:${project.cloth_config_version}"
|
||||||
|
include "me.shedaniel.cloth:config-2:${project.cloth_config_version}"
|
||||||
|
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
|
||||||
|
include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
|
||||||
|
modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property 'version', version
|
inputs.property 'version', project.version
|
||||||
|
inputs.property 'name', rootProject.name
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include 'fabric.mod.json'
|
include 'fabric.mod.json'
|
||||||
expand 'version': version
|
expand 'version': project.version, 'name': rootProject.name
|
||||||
}
|
}
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
@ -50,10 +66,37 @@ task sourcesJar(type: Jar, dependsOn: classes) {
|
|||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
classifier 'javadoc'
|
||||||
|
from javadoc.destinationDir
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
archives javadocJar
|
||||||
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from "LICENSE"
|
from "LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
artifactId archivesBaseName
|
||||||
|
|
||||||
|
artifact(remapJar) {
|
||||||
|
builtBy remapJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url '/data/maven'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (project.hasProperty('curseforge.api_key')) {
|
if (project.hasProperty('curseforge.api_key')) {
|
||||||
curseforge {
|
curseforge {
|
||||||
apiKey = project.getProperty('curseforge.api_key')
|
apiKey = project.getProperty('curseforge.api_key')
|
||||||
@ -64,7 +107,7 @@ if (project.hasProperty('curseforge.api_key')) {
|
|||||||
addGameVersion project.simple_minecraft_version
|
addGameVersion project.simple_minecraft_version
|
||||||
addGameVersion 'Fabric'
|
addGameVersion 'Fabric'
|
||||||
mainArtifact(remapJar) {
|
mainArtifact(remapJar) {
|
||||||
displayName = "SorceryCraft v${version} for ${project.minecraft_version}"
|
displayName = "SorceryCraft v${mod_version} for ${project.minecraft_version}"
|
||||||
}
|
}
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
uploadTask.dependsOn('remapJar')
|
uploadTask.dependsOn('remapJar')
|
||||||
|
@ -3,17 +3,20 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version = 20w11a
|
minecraft_version = 1.16.4
|
||||||
curseforge_id = 365308
|
curseforge_id = 365308
|
||||||
simple_minecraft_version = 1.16-Snapshot
|
simple_minecraft_version = 1.16.4
|
||||||
yarn_mappings = 20w11a+build.6
|
yarn_build = 7
|
||||||
loader_version = 0.7.8+build.187
|
fabric_loader_version = 0.10.8
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.1.11
|
mod_version = 1.2.9
|
||||||
maven_group = com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
archives_base_name = sorcerycraft
|
archives_base_name = sorcerycraft
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_version = 0.5.3+build.308-1.16
|
fabric_api_version = 0.28.1+1.16
|
||||||
|
cloth_config_version = 4.8.3
|
||||||
|
auto_config_version = 3.3.1
|
||||||
|
mod_menu_version = 1.14.13+build.19
|
||||||
|
@ -8,3 +8,5 @@ pluginManagement {
|
|||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootProject.name = 'SorceryCraft'
|
||||||
|
32
src/main/java/com/thebrokenrail/sorcerycraft/ModConfig.java
Normal file
32
src/main/java/com/thebrokenrail/sorcerycraft/ModConfig.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft;
|
||||||
|
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Config(name = SorceryCraft.NAMESPACE)
|
||||||
|
public class ModConfig implements ConfigData {
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
public @interface UsePercentage {
|
||||||
|
double min();
|
||||||
|
|
||||||
|
double max();
|
||||||
|
}
|
||||||
|
|
||||||
|
@UsePercentage(min = 0, max = 1)
|
||||||
|
public double failureChance = 0.3;
|
||||||
|
|
||||||
|
@ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
|
||||||
|
public LimitCastingTable limitCastingTable = new LimitCastingTable();
|
||||||
|
|
||||||
|
public static class LimitCastingTable {
|
||||||
|
public boolean creative = false;
|
||||||
|
public boolean survival = true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,36 +1,32 @@
|
|||||||
package com.thebrokenrail.sorcerycraft;
|
package com.thebrokenrail.sorcerycraft;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.advancement.CreateSpellCriterion;
|
||||||
|
import com.thebrokenrail.sorcerycraft.advancement.DiscoverAllSpellsCriterion;
|
||||||
import com.thebrokenrail.sorcerycraft.block.CastingTableBlock;
|
import com.thebrokenrail.sorcerycraft.block.CastingTableBlock;
|
||||||
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
|
||||||
import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen;
|
|
||||||
import com.thebrokenrail.sorcerycraft.client.entity.SpellEntityRenderer;
|
|
||||||
import com.thebrokenrail.sorcerycraft.command.SpellCommand;
|
import com.thebrokenrail.sorcerycraft.command.SpellCommand;
|
||||||
import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
|
import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.item.SpellItem;
|
import com.thebrokenrail.sorcerycraft.item.SpellItem;
|
||||||
|
import com.thebrokenrail.sorcerycraft.mixin.CriteriaRegistryHook;
|
||||||
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
|
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
|
||||||
import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
|
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.RandomSpellLootTableFunction;
|
import com.thebrokenrail.sorcerycraft.spell.util.RandomSpellLootTableFunction;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.Spells;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.Spells;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
|
|
||||||
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
|
|
||||||
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
||||||
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
||||||
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
|
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
|
||||||
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
||||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||||
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
|
|
||||||
import net.fabricmc.fabric.impl.networking.ServerSidePacketRegistryImpl;
|
import net.fabricmc.fabric.impl.networking.ServerSidePacketRegistryImpl;
|
||||||
import net.minecraft.block.DispenserBlock;
|
import net.minecraft.block.DispenserBlock;
|
||||||
import net.minecraft.block.dispenser.ProjectileDispenserBehavior;
|
import net.minecraft.block.dispenser.ProjectileDispenserBehavior;
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.entity.EntityCategory;
|
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.SpawnGroup;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.Projectile;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
@ -38,12 +34,12 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.loot.BinomialLootTableRange;
|
import net.minecraft.loot.BinomialLootTableRange;
|
||||||
import net.minecraft.loot.LootTables;
|
import net.minecraft.loot.LootTables;
|
||||||
import net.minecraft.loot.entry.ItemEntry;
|
import net.minecraft.loot.entry.ItemEntry;
|
||||||
|
import net.minecraft.loot.function.LootFunctionType;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.stat.StatFormatter;
|
import net.minecraft.stat.StatFormatter;
|
||||||
import net.minecraft.stat.Stats;
|
import net.minecraft.stat.Stats;
|
||||||
import net.minecraft.text.TranslatableText;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPointer;
|
import net.minecraft.util.math.BlockPointer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -53,13 +49,18 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
public class SorceryCraft implements ModInitializer {
|
||||||
public static final String NAMESPACE = "sorcerycraft";
|
public static final String NAMESPACE = "sorcerycraft";
|
||||||
|
|
||||||
public static SpellItem SPELL_ITEM;
|
public static SpellItem SPELL_ITEM;
|
||||||
|
|
||||||
public static CastingTableBlock CASTING_TABLE_BLOCK;
|
public static CastingTableBlock CASTING_TABLE_BLOCK;
|
||||||
public static BlockItem CASTING_TABLE_BLOCK_ITEM;
|
public static BlockItem CASTING_TABLE_BLOCK_ITEM;
|
||||||
|
|
||||||
public static ItemGroup ITEM_GROUP;
|
public static ItemGroup ITEM_GROUP;
|
||||||
|
|
||||||
public static EntityType<SpellEntity> SPELL_ENTITY;
|
public static EntityType<SpellEntity> SPELL_ENTITY;
|
||||||
|
|
||||||
public static final Identifier[] LOOT_TABLES = new Identifier[]{
|
public static final Identifier[] LOOT_TABLES = new Identifier[]{
|
||||||
LootTables.SIMPLE_DUNGEON_CHEST,
|
LootTables.SIMPLE_DUNGEON_CHEST,
|
||||||
LootTables.END_CITY_TREASURE_CHEST,
|
LootTables.END_CITY_TREASURE_CHEST,
|
||||||
@ -70,11 +71,20 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
LootTables.JUNGLE_TEMPLE_CHEST,
|
LootTables.JUNGLE_TEMPLE_CHEST,
|
||||||
LootTables.STRONGHOLD_LIBRARY_CHEST,
|
LootTables.STRONGHOLD_LIBRARY_CHEST,
|
||||||
LootTables.PILLAGER_OUTPOST_CHEST,
|
LootTables.PILLAGER_OUTPOST_CHEST,
|
||||||
LootTables.WOODLAND_MANSION_CHEST
|
LootTables.WOODLAND_MANSION_CHEST,
|
||||||
|
LootTables.BURIED_TREASURE_CHEST,
|
||||||
|
LootTables.FISHING_TREASURE_GAMEPLAY
|
||||||
};
|
};
|
||||||
public static final double SPELL_FAILURE_CHANCE = 0.3d;
|
|
||||||
public static Identifier STAT_INTERACT_WITH_CASTING_TABLE;
|
public static Identifier INTERACT_WITH_CASTING_TABLE_STAT;
|
||||||
public static Identifier STAT_CAST_SPELL;
|
public static Identifier CAST_SPELL_STAT;
|
||||||
|
|
||||||
|
public static DiscoverAllSpellsCriterion DISCOVER_ALL_SPELLS_CRITERION;
|
||||||
|
public static CreateSpellCriterion CREATE_SPELL_CRITERION;
|
||||||
|
|
||||||
|
public static ModConfig getConfig() {
|
||||||
|
return AutoConfig.getConfigHolder(ModConfig.class).getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isSelectedLootTable(Identifier lootTable) {
|
private boolean isSelectedLootTable(Identifier lootTable) {
|
||||||
for (Identifier id : LOOT_TABLES) {
|
for (Identifier id : LOOT_TABLES) {
|
||||||
@ -87,8 +97,11 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
//noinspection InstantiationOfUtilityClass
|
||||||
new Spells();
|
new Spells();
|
||||||
|
|
||||||
|
AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
|
||||||
|
|
||||||
ITEM_GROUP = FabricItemGroupBuilder.create(
|
ITEM_GROUP = FabricItemGroupBuilder.create(
|
||||||
new Identifier(NAMESPACE, "spells"))
|
new Identifier(NAMESPACE, "spells"))
|
||||||
.icon(() -> new ItemStack(SPELL_ITEM))
|
.icon(() -> new ItemStack(SPELL_ITEM))
|
||||||
@ -98,7 +111,7 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
CASTING_TABLE_BLOCK_ITEM = new BlockItem(CASTING_TABLE_BLOCK, new Item.Settings().group(ITEM_GROUP));
|
CASTING_TABLE_BLOCK_ITEM = new BlockItem(CASTING_TABLE_BLOCK, new Item.Settings().group(ITEM_GROUP));
|
||||||
SPELL_ITEM = new SpellItem();
|
SPELL_ITEM = new SpellItem();
|
||||||
|
|
||||||
SPELL_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<SpellEntity>) SpellEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
|
SPELL_ENTITY = FabricEntityTypeBuilder.create(SpawnGroup.MISC, (EntityType.EntityFactory<SpellEntity>) SpellEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
|
||||||
|
|
||||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "spell"), SPELL_ITEM);
|
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "spell"), SPELL_ITEM);
|
||||||
Registry.register(Registry.BLOCK, new Identifier(NAMESPACE, "casting_table"), CASTING_TABLE_BLOCK);
|
Registry.register(Registry.BLOCK, new Identifier(NAMESPACE, "casting_table"), CASTING_TABLE_BLOCK);
|
||||||
@ -114,22 +127,22 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
CommandRegistry.INSTANCE.register(false, SpellCommand::register);
|
CommandRegistry.INSTANCE.register(false, SpellCommand::register);
|
||||||
|
|
||||||
ServerSidePacketRegistryImpl.INSTANCE.register(new Identifier(NAMESPACE, "select_spell"), SelectSpellC2SPacket::handle);
|
ServerSidePacketRegistryImpl.INSTANCE.register(new Identifier(NAMESPACE, "select_spell"), SelectSpellC2SPacket::handle);
|
||||||
ClientSidePacketRegistryImpl.INSTANCE.register(new Identifier(NAMESPACE, "update_known_spells"), UpdateKnownSpellsS2CPacket::handle);
|
|
||||||
|
|
||||||
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
|
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
|
||||||
if (isSelectedLootTable(id)) {
|
if (isSelectedLootTable(id)) {
|
||||||
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
|
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
|
||||||
.withRolls(new BinomialLootTableRange(2, 0.5f))
|
.rolls(new BinomialLootTableRange(2, 0.5f))
|
||||||
.withEntry(ItemEntry.builder(SPELL_ITEM))
|
.withEntry(ItemEntry.builder(SPELL_ITEM).build())
|
||||||
.withFunction(new RandomSpellLootTableFunction.Builder());
|
.withFunction(new RandomSpellLootTableFunction.Builder().build());
|
||||||
|
|
||||||
supplier.withPool(poolBuilder);
|
supplier.withPool(poolBuilder.build());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Registry.register(Registry.LOOT_FUNCTION_TYPE, new Identifier(NAMESPACE, "random_spell"), new LootFunctionType(new RandomSpellLootTableFunction.Factory()));
|
||||||
|
|
||||||
DispenserBlock.registerBehavior(SorceryCraft.SPELL_ITEM, new ProjectileDispenserBehavior() {
|
DispenserBlock.registerBehavior(SorceryCraft.SPELL_ITEM, new ProjectileDispenserBehavior() {
|
||||||
@Override
|
@Override
|
||||||
protected Projectile createProjectile(World position, Position stack, ItemStack itemStack) {
|
protected ProjectileEntity createProjectile(World position, Position stack, ItemStack itemStack) {
|
||||||
SpellEntity entity = new SpellEntity(position, stack.getX(), stack.getY(), stack.getZ());
|
SpellEntity entity = new SpellEntity(position, stack.getX(), stack.getY(), stack.getZ());
|
||||||
entity.setItem(itemStack);
|
entity.setItem(itemStack);
|
||||||
return entity;
|
return entity;
|
||||||
@ -141,13 +154,16 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
STAT_INTERACT_WITH_CASTING_TABLE = registerStat("interact_with_casting_table");
|
INTERACT_WITH_CASTING_TABLE_STAT = registerStat("interact_with_casting_table");
|
||||||
STAT_CAST_SPELL = registerStat("cast_spell");
|
CAST_SPELL_STAT = registerStat("cast_spell");
|
||||||
|
|
||||||
|
DISCOVER_ALL_SPELLS_CRITERION = CriteriaRegistryHook.callRegister(new DiscoverAllSpellsCriterion());
|
||||||
|
CREATE_SPELL_CRITERION = CriteriaRegistryHook.callRegister(new CreateSpellCriterion());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Identifier registerStat(String name) {
|
private Identifier registerStat(String name) {
|
||||||
Identifier statID = new Identifier(NAMESPACE, name);
|
Identifier statID = new Identifier(NAMESPACE, name);
|
||||||
Registry.register(Registry.CUSTOM_STAT, name, statID);
|
Registry.register(Registry.CUSTOM_STAT, statID, statID);
|
||||||
Stats.CUSTOM.getOrCreateStat(statID, StatFormatter.DEFAULT);
|
Stats.CUSTOM.getOrCreateStat(statID, StatFormatter.DEFAULT);
|
||||||
return statID;
|
return statID;
|
||||||
}
|
}
|
||||||
@ -165,13 +181,4 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
public static void playSpellSound(PlayerEntity player) {
|
public static void playSpellSound(PlayerEntity player) {
|
||||||
player.playSound(SPELL_SOUND_EFFECT, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
player.playSound(SPELL_SOUND_EFFECT, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient() {
|
|
||||||
EntityRendererRegistry.INSTANCE.register(SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher));
|
|
||||||
ScreenProviderRegistry.INSTANCE.<CastingTableScreenHandler>registerFactory(new Identifier(NAMESPACE, "casting_table"), (container) -> {
|
|
||||||
assert MinecraftClient.getInstance().player != null;
|
|
||||||
return new CastingTableScreen(container, MinecraftClient.getInstance().player.inventory, new TranslatableText("block." + SorceryCraft.NAMESPACE + ".casting_table"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.advancement;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
|
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||||
|
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||||
|
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||||
|
import net.minecraft.predicate.entity.EntityPredicate;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class CreateSpellCriterion extends AbstractCriterion<CreateSpellCriterion.Conditions> {
|
||||||
|
private static final Identifier ID = new Identifier(SorceryCraft.NAMESPACE, "create_spell");
|
||||||
|
|
||||||
|
public CreateSpellCriterion() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||||
|
return new CreateSpellCriterion.Conditions(playerPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trigger(ServerPlayerEntity player) {
|
||||||
|
test(player, (conditions) -> true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Conditions extends AbstractCriterionConditions {
|
||||||
|
public Conditions(EntityPredicate.Extended player) {
|
||||||
|
super(ID, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.advancement;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
|
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||||
|
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||||
|
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||||
|
import net.minecraft.predicate.entity.EntityPredicate;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DiscoverAllSpellsCriterion extends AbstractCriterion<DiscoverAllSpellsCriterion.Conditions> {
|
||||||
|
private static final Identifier ID = new Identifier(SorceryCraft.NAMESPACE, "discover_all_spells");
|
||||||
|
|
||||||
|
public DiscoverAllSpellsCriterion() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DiscoverAllSpellsCriterion.Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||||
|
return new DiscoverAllSpellsCriterion.Conditions(playerPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trigger(ServerPlayerEntity player) {
|
||||||
|
test(player, (conditions) -> {
|
||||||
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
|
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
|
||||||
|
Spell[] maxSpells = SpellRegistry.getMaxSpells();
|
||||||
|
boolean match = true;
|
||||||
|
for (Spell spell : maxSpells) {
|
||||||
|
if (!spells.containsKey(spell.getID()) || spells.get(spell.getID()) < (spell.getLevel() - 1)) {
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Conditions extends AbstractCriterionConditions {
|
||||||
|
public Conditions(EntityPredicate.Extended player) {
|
||||||
|
super(ID, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.thebrokenrail.sorcerycraft.block;
|
|||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellServerPlayerEntity;
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@ -29,13 +30,18 @@ public class CastingTableBlock extends Block {
|
|||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
if (!world.isClient()) {
|
if (!world.isClient()) {
|
||||||
ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos));
|
ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos));
|
||||||
player.incrementStat(SorceryCraft.STAT_INTERACT_WITH_CASTING_TABLE);
|
player.incrementStat(SorceryCraft.INTERACT_WITH_CASTING_TABLE_STAT);
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
|
public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
|
||||||
return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> new CastingTableScreenHandler(i, playerInventory, ScreenHandlerContext.create(world, pos)), new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> {
|
||||||
|
if (!playerEntity.getEntityWorld().isClient()) {
|
||||||
|
((SpellServerPlayerEntity) playerEntity).sync();
|
||||||
|
}
|
||||||
|
return new CastingTableScreenHandler(i, playerInventory, ScreenHandlerContext.create(world, pos));
|
||||||
|
}, new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.client;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.ModConfig;
|
||||||
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
|
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||||
|
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class ModMenu implements ModMenuApi {
|
||||||
|
@Override
|
||||||
|
public String getModId() {
|
||||||
|
return SorceryCraft.NAMESPACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
|
return (ConfigScreenFactory<Screen>) screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.client;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.ModConfig;
|
||||||
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
|
import com.thebrokenrail.sorcerycraft.client.entity.SpellEntityRenderer;
|
||||||
|
import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen;
|
||||||
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
|
import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.gui.registry.GuiRegistry;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.util.Utils;
|
||||||
|
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
|
||||||
|
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
|
||||||
|
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class SorceryCraftClient implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
GuiRegistry guiRegistry = AutoConfig.getGuiRegistry(ModConfig.class);
|
||||||
|
guiRegistry.registerAnnotationProvider((s, field, config, defaults, guiRegistryAccess) -> {
|
||||||
|
ModConfig.UsePercentage bounds = field.getAnnotation(ModConfig.UsePercentage.class);
|
||||||
|
return Collections.singletonList(ConfigEntryBuilder.create().startIntSlider(new TranslatableText(s), MathHelper.ceil(Utils.getUnsafely(field, config, 0.0) * 100), MathHelper.ceil(bounds.min() * 100), MathHelper.ceil(bounds.max() * 100)).setDefaultValue(() -> MathHelper.ceil((double) Utils.getUnsafely(field, defaults) * 100)).setSaveConsumer((newValue) -> Utils.setUnsafely(field, config, newValue / 100d)).setTextGetter(integer -> new LiteralText(String.format("%d%%", integer))).build());
|
||||||
|
}, field -> field.getType() == Double.TYPE || field.getType() == Double.class, ModConfig.UsePercentage.class);
|
||||||
|
|
||||||
|
EntityRendererRegistry.INSTANCE.register(SorceryCraft.SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher));
|
||||||
|
ScreenProviderRegistry.INSTANCE.<CastingTableScreenHandler>registerFactory(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), (container) -> {
|
||||||
|
assert MinecraftClient.getInstance().player != null;
|
||||||
|
return new CastingTableScreen(container, MinecraftClient.getInstance().player.inventory, new TranslatableText("block." + SorceryCraft.NAMESPACE + ".casting_table"));
|
||||||
|
});
|
||||||
|
|
||||||
|
ClientSidePacketRegistryImpl.INSTANCE.register(new Identifier(SorceryCraft.NAMESPACE, "update_known_spells"), UpdateKnownSpellsS2CPacket::handle);
|
||||||
|
}
|
||||||
|
}
|
@ -5,14 +5,15 @@ import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
|||||||
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
|
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
|
||||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@ -21,9 +22,9 @@ import net.minecraft.util.math.MathHelper;
|
|||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler> {
|
public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler> {
|
||||||
private static final Identifier TEXTURE = new Identifier("textures/gui/container/villager2.png");
|
private static final Identifier TEXTURE = new Identifier("textures/gui/container/villager2.png");
|
||||||
private int selectedIndex;
|
private int selectedIndex = 0;
|
||||||
private int indexStartOffset;
|
private int indexStartOffset = 0;
|
||||||
private boolean scrolling;
|
private boolean scrolling = false;
|
||||||
|
|
||||||
public CastingTableScreen(CastingTableScreenHandler container, PlayerInventory inventory, Text title) {
|
public CastingTableScreen(CastingTableScreenHandler container, PlayerInventory inventory, Text title) {
|
||||||
super(container, inventory, title);
|
super(container, inventory, title);
|
||||||
@ -31,47 +32,52 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawForeground(int mouseX, int mouseY) {
|
protected void drawForeground(MatrixStack matrixStack, int i, int j) {
|
||||||
int titleY = backgroundHeight - 94;
|
int titleY = backgroundHeight - 94;
|
||||||
textRenderer.draw(title.asFormattedString(), (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752);
|
textRenderer.draw(matrixStack, title, (float) (49 + this.backgroundWidth / 2 - textRenderer.getWidth(title) / 2), 6.0F, 4210752);
|
||||||
textRenderer.draw(playerInventory.getDisplayName().asFormattedString(), 107.0F, (float) titleY, 4210752);
|
textRenderer.draw(matrixStack, playerInventory.getDisplayName(), 107.0F, (float) titleY, 4210752);
|
||||||
String spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells").getString();
|
Text spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells");
|
||||||
textRenderer.draw(spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752);
|
textRenderer.draw(matrixStack, spells, (float) (5 - textRenderer.getWidth(spells) / 2 + 48), 6.0F, 4210752);
|
||||||
renderXPCost();
|
renderXPCost(matrixStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetIndex() {
|
||||||
|
selectedIndex = 0;
|
||||||
|
indexStartOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackground(float delta, int mouseX, int mouseY) {
|
protected void drawBackground(MatrixStack matrixStack, float delta, int mouseX, int mouseY) {
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
assert client != null;
|
assert client != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
client.getTextureManager().bindTexture(TEXTURE);
|
||||||
int i = (width - backgroundWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 2;
|
int j = (height - backgroundHeight) / 2;
|
||||||
blit(i, j, getZOffset(), 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 512);
|
drawTexture(matrixStack, i, j, getZOffset(), 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int mouseX, int mouseY, float delta) {
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
|
||||||
renderBackground();
|
renderBackground(matrixStack);
|
||||||
super.render(mouseX, mouseY, delta);
|
super.render(matrixStack, mouseX, mouseY, delta);
|
||||||
drawMouseoverTooltip(mouseX, mouseY);
|
drawMouseoverTooltip(matrixStack, mouseX, mouseY);
|
||||||
|
|
||||||
renderScrollbar();
|
renderScrollbar(matrixStack);
|
||||||
renderItems();
|
renderItems();
|
||||||
|
|
||||||
for (WidgetButtonPage button : buttons) {
|
for (WidgetButtonPage button : buttons) {
|
||||||
if (button.isHovered()) {
|
if (button.isHovered()) {
|
||||||
button.renderToolTip(mouseX, mouseY);
|
button.renderToolTip(matrixStack, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
button.visible = button.index < handler.getRecipes().length;
|
button.visible = button.index < handler.getRecipes().length;
|
||||||
if (button.visible) {
|
if (button.visible) {
|
||||||
Spell spell = handler.getRecipes()[button.getIndex() + indexStartOffset];
|
Spell spell = handler.getRecipes()[button.getIndex() + indexStartOffset];
|
||||||
button.setMessage(SpellTag.getTranslatedSpell(spell.getID(), spell.getLevel(), true).getString());
|
button.setMessage(SpellHelper.getTranslatedSpell(spell.getID(), spell.getLevel()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderScrollbar() {
|
private void renderScrollbar(MatrixStack matrixStack) {
|
||||||
Spell[] spells = handler.getRecipes();
|
Spell[] spells = handler.getRecipes();
|
||||||
assert client != null;
|
assert client != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
client.getTextureManager().bindTexture(TEXTURE);
|
||||||
@ -81,9 +87,9 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
|
|
||||||
if (k > 0) {
|
if (k > 0) {
|
||||||
int modifier = (int) (((float) indexStartOffset / k) * (1 + 139 - 27));
|
int modifier = (int) (((float) indexStartOffset / k) * (1 + 139 - 27));
|
||||||
blit(i + 94, j + 18 + modifier, getZOffset(), 0.0F, 199.0F, 6, 27, 256, 512);
|
drawTexture(matrixStack, i + 94, j + 18 + modifier, getZOffset(), 0.0F, 199.0F, 6, 27, 256, 512);
|
||||||
} else {
|
} else {
|
||||||
blit(i + 94, j + 18, getZOffset(), 6.0F, 199.0F, 6, 27, 256, 512);
|
drawTexture(matrixStack, i + 94, j + 18, getZOffset(), 6.0F, 199.0F, 6, 27, 256, 512);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +105,7 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
itemRenderer.zOffset = 100.0F;
|
itemRenderer.zOffset = 100.0F;
|
||||||
int y = k + 2;
|
int y = k + 2;
|
||||||
|
|
||||||
itemRenderer.renderGuiItem(itemStack, i + 5 + 68, y);
|
itemRenderer.renderInGuiWithOverrides(itemStack, i + 5 + 68, y);
|
||||||
itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, i + 5 + 68, y);
|
itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, i + 5 + 68, y);
|
||||||
itemRenderer.zOffset = 0.0F;
|
itemRenderer.zOffset = 0.0F;
|
||||||
k += 20;
|
k += 20;
|
||||||
@ -107,21 +113,21 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderXPCost() {
|
private void renderXPCost(MatrixStack matrixStack) {
|
||||||
if (handler.getRecipes().length > 0) {
|
if (handler.getRecipes().length > 0) {
|
||||||
int cost = handler.getRecipes()[selectedIndex].getXPCost();
|
int cost = handler.getRecipes()[selectedIndex].getXPCost();
|
||||||
int color = 8453920;
|
int color = 8453920;
|
||||||
assert client != null;
|
assert client != null;
|
||||||
assert client.player != null;
|
assert client.player != null;
|
||||||
String string = new TranslatableText("container.repair.cost", cost).getString();
|
Text string = new TranslatableText("container.repair.cost", cost);
|
||||||
if (!handler.canTakeResult(playerInventory.player)) {
|
if (!handler.canTakeResult(playerInventory.player)) {
|
||||||
color = 16736352;
|
color = 16736352;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x2 = backgroundWidth - 8;
|
int x2 = backgroundWidth - 8;
|
||||||
int x1 = x2 - textRenderer.getStringWidth(string);
|
int x1 = x2 - textRenderer.getWidth(string);
|
||||||
fill(x1, 65, x2, 77, 1325400064);
|
fill(matrixStack, x1, 65, x2, 77, 1325400064);
|
||||||
textRenderer.drawWithShadow(string, (float) x1, 67.0F, color);
|
textRenderer.drawWithShadow(matrixStack, string, (float) x1, 67.0F, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,37 +200,32 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
private class WidgetButtonPage extends ButtonWidget {
|
public class WidgetButtonPage extends ButtonWidget {
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
public WidgetButtonPage(int i, int j, int k, PressAction pressAction) {
|
public WidgetButtonPage(int i, int j, int k, PressAction pressAction) {
|
||||||
super(i, j, 89, 20, "", pressAction);
|
super(i, j, 89, 20, new LiteralText(""), pressAction);
|
||||||
index = k;
|
index = k;
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int mouseX, int mouseY, float delta) {
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
|
||||||
active = (index + CastingTableScreen.this.indexStartOffset) != CastingTableScreen.this.selectedIndex;
|
active = (index + CastingTableScreen.this.indexStartOffset) != CastingTableScreen.this.selectedIndex;
|
||||||
super.render(mouseX, mouseY, delta);
|
super.render(matrixStack, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return this.index;
|
return this.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderToolTip(int mouseX, int mouseY) {
|
public void renderToolTip(MatrixStack matrixStack, int mouseX, int mouseY) {
|
||||||
if (hovered && handler.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
if (hovered && handler.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
||||||
ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost();
|
ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost();
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
renderTooltip(itemStack, mouseX, mouseY);
|
renderTooltip(matrixStack, itemStack, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawCenteredString(TextRenderer textRenderer, String str, int centerX, int y, int color) {
|
|
||||||
drawString(textRenderer, str, x + 5, y, color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
|||||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import net.minecraft.server.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -4,17 +4,21 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import net.minecraft.command.argument.EntityArgumentType;
|
||||||
import net.minecraft.command.arguments.EntityArgumentType;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Texts;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -23,55 +27,101 @@ public class SpellCommand {
|
|||||||
|
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
dispatcher.register(CommandManager.literal("spell")
|
dispatcher.register(CommandManager.literal("spell")
|
||||||
.requires(source -> source.hasPermissionLevel(4))
|
.requires(source -> source.hasPermissionLevel(2))
|
||||||
.then(CommandManager.literal("list")
|
.then(CommandManager.literal("list")
|
||||||
.then(CommandManager.argument("player", EntityArgumentType.player())
|
.then(CommandManager.argument("player", EntityArgumentType.players())
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
int i = 0;
|
||||||
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.listing_spells", player.getDisplayName()), false);
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
Map<Identifier, Integer> spells = spellPlayer.getSorceryCraftSpells();
|
Map<Identifier, Integer> spellMap = spellPlayer.getDiscoveredSpells();
|
||||||
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
|
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.listing_spells", player.getDisplayName(), Texts.join(spellMap.entrySet(), spell -> SpellHelper.getTranslatedSpell(spell.getKey(), spell.getValue()))), false);
|
||||||
ctx.getSource().sendFeedback(SpellTag.getTranslatedSpell(entry.getKey(), entry.getValue(), true).formatted(Formatting.YELLOW), false);
|
i++;
|
||||||
}
|
}
|
||||||
return 0;
|
return i;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(CommandManager.literal("clear")
|
.then(CommandManager.literal("forget")
|
||||||
.then(CommandManager.argument("player", EntityArgumentType.player())
|
.then(CommandManager.argument("player", EntityArgumentType.players())
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
int i = 0;
|
||||||
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
spellPlayer.setSorceryCraftSpells(new HashMap<>());
|
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
|
||||||
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.cleared_spells", player.getDisplayName()), true);
|
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
|
||||||
return 1;
|
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.forgotten_spell", player.getDisplayName(), SpellHelper.getTranslatedSpellChat(entry.getKey(), entry.getValue())), true);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
spellPlayer.setDiscoveredSpells(new HashMap<>());
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
})
|
||||||
|
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
||||||
|
.executes(ctx -> {
|
||||||
|
int i = 0;
|
||||||
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
|
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
||||||
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
|
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
|
||||||
|
if (spells.containsKey(spell)) {
|
||||||
|
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.forgotten_spell", player.getDisplayName(), SpellHelper.getTranslatedSpellChat(spell, spells.get(spell))), true);
|
||||||
|
spells.remove(spell);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
spellPlayer.setDiscoveredSpells(spells);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(CommandManager.literal("learn")
|
)
|
||||||
.then(CommandManager.argument("player", EntityArgumentType.player())
|
.then(CommandManager.literal("discover")
|
||||||
|
.then(CommandManager.argument("player", EntityArgumentType.players())
|
||||||
|
.executes(ctx -> {
|
||||||
|
int i = 0;
|
||||||
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
|
Map<Identifier, Integer> spellMap = new HashMap<>();
|
||||||
|
Spell[] maxSpells = SpellRegistry.getMaxSpells();
|
||||||
|
for (Spell spell : maxSpells) {
|
||||||
|
spellMap.put(spell.getID(), spell.getLevel());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
SpellHelper.learnSpells(player, spellMap);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
})
|
||||||
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
||||||
.then(CommandManager.argument("level", IntegerArgumentType.integer())
|
.then(CommandManager.argument("level", IntegerArgumentType.integer())
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
int i = 0;
|
||||||
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
||||||
int level = IntegerArgumentType.getInteger(ctx, "level") - 1;
|
int level = IntegerArgumentType.getInteger(ctx, "level") - 1;
|
||||||
Map<Identifier, Integer> spellMap = new HashMap<>();
|
Map<Identifier, Integer> spellMap = new HashMap<>();
|
||||||
spellMap.put(spell, level);
|
spellMap.put(spell, level);
|
||||||
SpellTag.learnSpells(player, spellMap);
|
i++;
|
||||||
return 1;
|
SpellHelper.learnSpells(player, spellMap);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(CommandManager.literal("add")
|
.then(CommandManager.literal("apply")
|
||||||
.then(CommandManager.argument("player", EntityArgumentType.player())
|
.then(CommandManager.argument("player", EntityArgumentType.players())
|
||||||
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
||||||
.then(CommandManager.argument("level", IntegerArgumentType.integer())
|
.then(CommandManager.argument("level", IntegerArgumentType.integer())
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
int i = 0;
|
||||||
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
||||||
int level = IntegerArgumentType.getInteger(ctx, "level") - 1;
|
int level = IntegerArgumentType.getInteger(ctx, "level") - 1;
|
||||||
|
|
||||||
@ -81,22 +131,26 @@ public class SpellCommand {
|
|||||||
throw NOT_HOLDING_SPELL_EXCEPTION.create(player);
|
throw NOT_HOLDING_SPELL_EXCEPTION.create(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Identifier, Integer> spellMap = SpellTag.getSpells(stack);
|
Map<Identifier, Integer> spellMap = SpellHelper.getSpells(stack);
|
||||||
spellMap.put(spell, level);
|
spellMap.put(spell, level);
|
||||||
SpellTag.setSpells(stack, spellMap);
|
i++;
|
||||||
|
SpellHelper.setSpells(stack, spellMap);
|
||||||
|
|
||||||
ctx.getSource().sendFeedback(new TranslatableText("command.sorcerycraft.spell.applied_spell", SpellTag.getTranslatedSpell(spell, level, true)), true);
|
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.applied_spell", SpellHelper.getTranslatedSpell(spell, level)), true);
|
||||||
return 1;
|
}
|
||||||
|
return i;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(CommandManager.literal("remove")
|
.then(CommandManager.literal("remove")
|
||||||
.then(CommandManager.argument("player", EntityArgumentType.player())
|
.then(CommandManager.argument("player", EntityArgumentType.players())
|
||||||
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
.then(CommandManager.argument("spell", SpellArgumentType.spell())
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
int i = 0;
|
||||||
|
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(ctx, "player");
|
||||||
|
for (PlayerEntity player : players) {
|
||||||
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
Identifier spell = SpellArgumentType.getSpell(ctx, "spell");
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandStack();
|
ItemStack stack = player.getMainHandStack();
|
||||||
@ -105,12 +159,15 @@ public class SpellCommand {
|
|||||||
throw NOT_HOLDING_SPELL_EXCEPTION.create(player);
|
throw NOT_HOLDING_SPELL_EXCEPTION.create(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Identifier, Integer> spellMap = SpellTag.getSpells(stack);
|
Map<Identifier, Integer> spellMap = SpellHelper.getSpells(stack);
|
||||||
|
if (spellMap.containsKey(spell)) {
|
||||||
|
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.removed_spell", SpellHelper.getTranslatedSpell(spell, spellMap.get(spell))), true);
|
||||||
spellMap.remove(spell);
|
spellMap.remove(spell);
|
||||||
SpellTag.setSpells(stack, spellMap);
|
i++;
|
||||||
|
}
|
||||||
ctx.getSource().sendFeedback(new TranslatableText("command.sorcerycraft.spell.removed_spell", SpellTag.getTranslatedSpell(spell, 0, false)), true);
|
SpellHelper.setSpells(stack, spellMap);
|
||||||
return 1;
|
}
|
||||||
|
return i;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -2,14 +2,14 @@ package com.thebrokenrail.sorcerycraft.entity;
|
|||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.Spells;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.Spells;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.thrown.ThrownItemEntity;
|
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||||
@ -28,6 +28,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class SpellEntity extends ThrownItemEntity {
|
public class SpellEntity extends ThrownItemEntity {
|
||||||
public SpellEntity(EntityType<SpellEntity> entityType, World world) {
|
public SpellEntity(EntityType<SpellEntity> entityType, World world) {
|
||||||
super(entityType, world);
|
super(entityType, world);
|
||||||
@ -41,14 +42,19 @@ public class SpellEntity extends ThrownItemEntity {
|
|||||||
super(SorceryCraft.SPELL_ENTITY, x, y, z, world);
|
super(SorceryCraft.SPELL_ENTITY, x, y, z, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpellEntity(World world) {
|
||||||
|
super(SorceryCraft.SPELL_ENTITY, world);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean didSpellSucceed(Map<Identifier, Integer> spells) {
|
private boolean didSpellSucceed(Map<Identifier, Integer> spells) {
|
||||||
return Math.random() > SorceryCraft.SPELL_FAILURE_CHANCE || spells.containsKey(Spells.STEADFAST_SPELL);
|
return Math.random() > SorceryCraft.getConfig().failureChance || spells.containsKey(Spells.STEADFAST_SPELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCollision(HitResult hitResult) {
|
protected void onCollision(HitResult hitResult) {
|
||||||
|
super.onCollision(hitResult);
|
||||||
if (!getEntityWorld().isClient()) {
|
if (!getEntityWorld().isClient()) {
|
||||||
Map<Identifier, Integer> spells = SpellTag.getSpells(getItem());
|
Map<Identifier, Integer> spells = SpellHelper.getSpells(getItem());
|
||||||
if (!spells.containsKey(Spells.INWARD_SPELL)) {
|
if (!spells.containsKey(Spells.INWARD_SPELL)) {
|
||||||
boolean success = didSpellSucceed(spells);
|
boolean success = didSpellSucceed(spells);
|
||||||
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
|
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
|
||||||
@ -80,7 +86,7 @@ public class SpellEntity extends ThrownItemEntity {
|
|||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (!getEntityWorld().isClient()) {
|
if (!getEntityWorld().isClient()) {
|
||||||
Map<Identifier, Integer> spells = SpellTag.getSpells(getItem());
|
Map<Identifier, Integer> spells = SpellHelper.getSpells(getItem());
|
||||||
if (spells.containsKey(Spells.INWARD_SPELL)) {
|
if (spells.containsKey(Spells.INWARD_SPELL)) {
|
||||||
if (getOwner() != null) {
|
if (getOwner() != null) {
|
||||||
boolean success = didSpellSucceed(spells);
|
boolean success = didSpellSucceed(spells);
|
||||||
|
@ -3,18 +3,19 @@ package com.thebrokenrail.sorcerycraft.gui;
|
|||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.BasicInventory;
|
|
||||||
import net.minecraft.inventory.CraftingResultInventory;
|
import net.minecraft.inventory.CraftingResultInventory;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.inventory.SimpleInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.screen.ScreenHandlerContext;
|
import net.minecraft.screen.ScreenHandlerContext;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.screen.slot.Slot;
|
import net.minecraft.screen.slot.Slot;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@ -27,14 +28,14 @@ import java.util.function.BiConsumer;
|
|||||||
public class CastingTableScreenHandler extends ScreenHandler {
|
public class CastingTableScreenHandler extends ScreenHandler {
|
||||||
private final Inventory inventory;
|
private final Inventory inventory;
|
||||||
private final Inventory result;
|
private final Inventory result;
|
||||||
private final Spell[] spells;
|
private Spell[] spells = new Spell[0];
|
||||||
private final ScreenHandlerContext context;
|
private final ScreenHandlerContext context;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, ScreenHandlerContext blockContext) {
|
public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, ScreenHandlerContext blockContext) {
|
||||||
super(ScreenHandlerType.STONECUTTER, syncId);
|
super(ScreenHandlerType.STONECUTTER, syncId);
|
||||||
|
|
||||||
inventory = new BasicInventory(2) {
|
inventory = new SimpleInventory(2) {
|
||||||
public void markDirty() {
|
public void markDirty() {
|
||||||
super.markDirty();
|
super.markDirty();
|
||||||
CastingTableScreenHandler.this.onContentChanged(this);
|
CastingTableScreenHandler.this.onContentChanged(this);
|
||||||
@ -43,21 +44,7 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
context = blockContext;
|
context = blockContext;
|
||||||
result = new CraftingResultInventory();
|
result = new CraftingResultInventory();
|
||||||
|
|
||||||
if (playerInventory.player.isCreative()) {
|
setSpells(playerInventory.player);
|
||||||
spells = SpellRegistry.getSpells();
|
|
||||||
} else {
|
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) playerInventory.player;
|
|
||||||
Map<Identifier, Integer> spellsMap = spellPlayer.getSorceryCraftSpells();
|
|
||||||
List<Spell> spellsArray = new ArrayList<>();
|
|
||||||
|
|
||||||
Spell[] allSpells = SpellRegistry.getSpells();
|
|
||||||
for (Spell spell : allSpells) {
|
|
||||||
if (spellsMap.containsKey(spell.getID()) && spellsMap.get(spell.getID()) >= spell.getLevel()) {
|
|
||||||
spellsArray.add(spell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spells = spellsArray.toArray(new Spell[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
addSlot(new Slot(inventory, 0, 136, 37) {
|
addSlot(new Slot(inventory, 0, 136, 37) {
|
||||||
@Override
|
@Override
|
||||||
@ -66,7 +53,7 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxStackAmount() {
|
public int getMaxItemCount() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,10 +84,15 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
player.addExperienceLevels(-spells[index].getXPCost());
|
player.addExperienceLevels(-spells[index].getXPCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
context.run((BiConsumer<World, BlockPos>) SorceryCraft::playSpellSound);
|
context.run((world, blockPos) -> {
|
||||||
|
SorceryCraft.playSpellSound(world, blockPos);
|
||||||
|
if (!world.isClient()) {
|
||||||
|
SorceryCraft.CREATE_SPELL_CRITERION.trigger((ServerPlayerEntity) player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
CastingTableScreenHandler.this.inventory.setInvStack(0, ItemStack.EMPTY);
|
CastingTableScreenHandler.this.inventory.setStack(0, ItemStack.EMPTY);
|
||||||
CastingTableScreenHandler.this.inventory.takeInvStack(1, spells[index].getItemCost().getCount());
|
CastingTableScreenHandler.this.inventory.removeStack(1, spells[index].getItemCost().getCount());
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -117,6 +109,30 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetIndex() {
|
||||||
|
index = 0;
|
||||||
|
onContentChanged(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpells(PlayerEntity player) {
|
||||||
|
if (player.isCreative() ? SorceryCraft.getConfig().limitCastingTable.creative : SorceryCraft.getConfig().limitCastingTable.survival) {
|
||||||
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
|
Map<Identifier, Integer> spellsMap = spellPlayer.getDiscoveredSpells();
|
||||||
|
List<Spell> spellsArray = new ArrayList<>();
|
||||||
|
|
||||||
|
Spell[] allSpells = SpellRegistry.getSpells();
|
||||||
|
for (Spell spell : allSpells) {
|
||||||
|
if (spellsMap.containsKey(spell.getID()) && spellsMap.get(spell.getID()) >= spell.getLevel()) {
|
||||||
|
spellsArray.add(spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spells = spellsArray.toArray(new Spell[0]);
|
||||||
|
} else {
|
||||||
|
spells = SpellRegistry.getSpells();
|
||||||
|
}
|
||||||
|
resetIndex();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canTakeResult(PlayerEntity playerEntity) {
|
public boolean canTakeResult(PlayerEntity playerEntity) {
|
||||||
return playerEntity.isCreative() || playerEntity.experienceLevel >= spells[index].getXPCost();
|
return playerEntity.isCreative() || playerEntity.experienceLevel >= spells[index].getXPCost();
|
||||||
}
|
}
|
||||||
@ -125,7 +141,7 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
onContentChanged(inventory);
|
onContentChanged(inventory);
|
||||||
|
|
||||||
if (inventory.getInvStack(0).isEmpty() && inventory.getInvStack(1).isEmpty()) {
|
if (inventory.getStack(0).isEmpty() && inventory.getStack(1).isEmpty()) {
|
||||||
ItemStack spellItem = new ItemStack(SorceryCraft.SPELL_ITEM);
|
ItemStack spellItem = new ItemStack(SorceryCraft.SPELL_ITEM);
|
||||||
autoFill(0, spellItem, true);
|
autoFill(0, spellItem, true);
|
||||||
ItemStack paymentItem = getRecipes()[index].getItemCost();
|
ItemStack paymentItem = getRecipes()[index].getItemCost();
|
||||||
@ -182,22 +198,22 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void onContentChanged(Inventory inventory) {
|
public void onContentChanged(Inventory inventory) {
|
||||||
super.onContentChanged(inventory);
|
super.onContentChanged(inventory);
|
||||||
ItemStack item = inventory.getInvStack(0);
|
ItemStack item = inventory.getStack(0);
|
||||||
ItemStack cost = inventory.getInvStack(1);
|
ItemStack cost = inventory.getStack(1);
|
||||||
if (inventory == this.inventory) {
|
if (inventory == this.inventory) {
|
||||||
if (spells.length > 0 &&
|
if (spells.length > 0 &&
|
||||||
!item.isEmpty() &&
|
!item.isEmpty() &&
|
||||||
cost.getItem() == spells[index].getItemCost().getItem() &&
|
cost.getItem() == spells[index].getItemCost().getItem() &&
|
||||||
cost.getCount() >= spells[index].getItemCost().getCount()) {
|
cost.getCount() >= spells[index].getItemCost().getCount()) {
|
||||||
ItemStack resultItem = item.copy();
|
ItemStack resultItem = item.copy();
|
||||||
Map<Identifier, Integer> resultSpells = SpellTag.getSpells(resultItem);
|
Map<Identifier, Integer> resultSpells = SpellHelper.getSpells(resultItem);
|
||||||
if (!resultSpells.containsKey(spells[index].getID()) || resultSpells.get(spells[index].getID()) <= spells[index].getLevel()) {
|
if (!resultSpells.containsKey(spells[index].getID()) || resultSpells.get(spells[index].getID()) <= spells[index].getLevel()) {
|
||||||
resultSpells.put(spells[index].getID(), spells[index].getLevel());
|
resultSpells.put(spells[index].getID(), spells[index].getLevel());
|
||||||
}
|
}
|
||||||
SpellTag.setSpells(resultItem, resultSpells);
|
SpellHelper.setSpells(resultItem, resultSpells);
|
||||||
result.setInvStack(2, resultItem);
|
result.setStack(2, resultItem);
|
||||||
} else {
|
} else {
|
||||||
result.setInvStack(2, ItemStack.EMPTY);
|
result.setStack(2, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,14 +223,14 @@ public class CastingTableScreenHandler extends ScreenHandler {
|
|||||||
for (int i = 3; i < 39; ++i) {
|
for (int i = 3; i < 39; ++i) {
|
||||||
ItemStack itemStack = slots.get(i).getStack();
|
ItemStack itemStack = slots.get(i).getStack();
|
||||||
if (!itemStack.isEmpty() && itemCompatible(stack, itemStack)) {
|
if (!itemStack.isEmpty() && itemCompatible(stack, itemStack)) {
|
||||||
ItemStack invSlot = inventory.getInvStack(slot);
|
ItemStack invSlot = inventory.getStack(slot);
|
||||||
int count = invSlot.isEmpty() ? 0 : invSlot.getCount();
|
int count = invSlot.isEmpty() ? 0 : invSlot.getCount();
|
||||||
int requiredCount = Math.min((onlyOne ? 1 : stack.getMaxCount()) - count, itemStack.getCount());
|
int requiredCount = Math.min((onlyOne ? 1 : stack.getMaxCount()) - count, itemStack.getCount());
|
||||||
ItemStack modifiedItem = itemStack.copy();
|
ItemStack modifiedItem = itemStack.copy();
|
||||||
int totalCount = count + requiredCount;
|
int totalCount = count + requiredCount;
|
||||||
itemStack.decrement(requiredCount);
|
itemStack.decrement(requiredCount);
|
||||||
modifiedItem.setCount(totalCount);
|
modifiedItem.setCount(totalCount);
|
||||||
inventory.setInvStack(slot, modifiedItem);
|
inventory.setStack(slot, modifiedItem);
|
||||||
if (totalCount >= stack.getMaxCount() || onlyOne) {
|
if (totalCount >= stack.getMaxCount() || onlyOne) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,22 @@ package com.thebrokenrail.sorcerycraft.item;
|
|||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
|
import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import net.minecraft.client.item.TooltipContext;
|
import net.minecraft.client.item.TooltipContext;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.DefaultedList;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Rarity;
|
import net.minecraft.util.Rarity;
|
||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -36,7 +37,7 @@ public class SpellItem extends Item {
|
|||||||
if (!world.isClient()) {
|
if (!world.isClient()) {
|
||||||
SorceryCraft.playSpellSound(playerEntity);
|
SorceryCraft.playSpellSound(playerEntity);
|
||||||
|
|
||||||
playerEntity.incrementStat(SorceryCraft.STAT_CAST_SPELL);
|
playerEntity.incrementStat(SorceryCraft.CAST_SPELL_STAT);
|
||||||
|
|
||||||
SpellEntity entity = new SpellEntity(world, playerEntity);
|
SpellEntity entity = new SpellEntity(world, playerEntity);
|
||||||
entity.setItem(itemStack);
|
entity.setItem(itemStack);
|
||||||
@ -52,16 +53,22 @@ public class SpellItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasEnchantmentGlint(ItemStack stack) {
|
public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) {
|
||||||
Map<Identifier, Integer> spells = SpellTag.getSpells(stack);
|
use(user.getEntityWorld(), user, hand);
|
||||||
return spells.size() > 0 || super.hasEnchantmentGlint(stack);
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasGlint(ItemStack stack) {
|
||||||
|
Map<Identifier, Integer> spells = SpellHelper.getSpells(stack);
|
||||||
|
return spells.size() > 0 || super.hasGlint(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) {
|
public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) {
|
||||||
Map<Identifier, Integer> spells = SpellTag.getSpells(itemStack);
|
Map<Identifier, Integer> spells = SpellHelper.getSpells(itemStack);
|
||||||
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
|
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
|
||||||
tooltip.add(SpellTag.getTranslatedSpell(entry.getKey(), entry.getValue(), true));
|
tooltip.add(SpellHelper.getTranslatedSpell(entry.getKey(), entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +81,7 @@ public class SpellItem extends Item {
|
|||||||
ItemStack item = new ItemStack(this);
|
ItemStack item = new ItemStack(this);
|
||||||
Map<Identifier, Integer> spell = new HashMap<>();
|
Map<Identifier, Integer> spell = new HashMap<>();
|
||||||
spell.put(value.getID(), value.getLevel());
|
spell.put(value.getID(), value.getLevel());
|
||||||
SpellTag.setSpells(item, spell);
|
SpellHelper.setSpells(item, spell);
|
||||||
stacks.add(item);
|
stacks.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,9 +97,9 @@ public class SpellItem extends Item {
|
|||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
if (!world.isClient() && entity instanceof PlayerEntity) {
|
if (!world.isClient() && entity instanceof PlayerEntity) {
|
||||||
PlayerEntity player = (PlayerEntity) entity;
|
PlayerEntity player = (PlayerEntity) entity;
|
||||||
Map<Identifier, Integer> itemSpells = SpellTag.getSpells(player.inventory.getInvStack(slot));
|
Map<Identifier, Integer> itemSpells = SpellHelper.getSpells(player.inventory.getStack(slot));
|
||||||
|
|
||||||
SpellTag.learnSpells(player, itemSpells);
|
SpellHelper.learnSpells(player, itemSpells);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.advancement.criterion.Criteria;
|
||||||
|
import net.minecraft.advancement.criterion.Criterion;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
|
@Mixin(Criteria.class)
|
||||||
|
public interface CriteriaRegistryHook {
|
||||||
|
@Invoker("register")
|
||||||
|
static <T extends Criterion<?>> T callRegister(T criterion) {
|
||||||
|
return criterion;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.mixin;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen;
|
||||||
|
import net.minecraft.client.font.TextRenderer;
|
||||||
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
|
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Mixin(AbstractButtonWidget.class)
|
||||||
|
public class MixinAbstractButtonWidget {
|
||||||
|
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/AbstractButtonWidget;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V"), method = "renderButton")
|
||||||
|
public void drawCenteredText(MatrixStack matrices, TextRenderer textRenderer, Text text, int centerX, int y, int color) {
|
||||||
|
if ((Object) this instanceof CastingTableScreen.WidgetButtonPage) {
|
||||||
|
DrawableHelper.drawStringWithShadow(matrices, textRenderer, text.getString(), ((CastingTableScreen.WidgetButtonPage) (Object) this).x + 5, y, color);
|
||||||
|
} else {
|
||||||
|
DrawableHelper.drawCenteredText(matrices, textRenderer, text, centerX, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,8 @@ package com.thebrokenrail.sorcerycraft.mixin;
|
|||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
|
import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -14,13 +16,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
@Mixin(ClientPlayNetworkHandler.class)
|
@Mixin(ClientPlayNetworkHandler.class)
|
||||||
public class MixinClientPlayNetworkHandler {
|
public class MixinClientPlayNetworkHandler {
|
||||||
@Shadow
|
@Shadow
|
||||||
private ClientWorld world;
|
private ClientWorld world;
|
||||||
|
|
||||||
@Inject(method = "onEntitySpawn", at = @At(value = "TAIL"))
|
@Inject(method = "onEntitySpawn", at = @At(value = "TAIL"))
|
||||||
public void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo callbackInfo) {
|
public void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo info) {
|
||||||
EntityType<?> entityType = packet.getEntityTypeId();
|
EntityType<?> entityType = packet.getEntityTypeId();
|
||||||
Entity entity = null;
|
Entity entity = null;
|
||||||
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.mixin;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Mixin(ClientPlayerEntity.class)
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class MixinClientPlayerEntity extends MixinPlayerEntity {
|
||||||
|
@Shadow
|
||||||
|
@Final
|
||||||
|
protected MinecraftClient client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
||||||
|
super.setDiscoveredSpells(spells);
|
||||||
|
if (client.currentScreen instanceof CastingTableScreen) {
|
||||||
|
((CastingTableScreen) client.currentScreen).resetIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,15 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.mixin;
|
package com.thebrokenrail.sorcerycraft.mixin;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@ -16,25 +20,32 @@ import java.util.Map;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(PlayerEntity.class)
|
@Mixin(PlayerEntity.class)
|
||||||
public class MixinPlayerEntity implements SpellPlayerEntity {
|
public class MixinPlayerEntity implements SpellPlayerEntity {
|
||||||
private Map<Identifier, Integer> sorceryCraftSpells = new HashMap<>();
|
@Shadow
|
||||||
|
public ScreenHandler currentScreenHandler;
|
||||||
|
@Unique
|
||||||
|
private Map<Identifier, Integer> discoveredSpells = new HashMap<>();
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
||||||
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
|
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
|
||||||
sorceryCraftSpells = SpellTag.getSpells(tag);
|
discoveredSpells = SpellHelper.getSpells(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "writeCustomDataToTag")
|
@Inject(at = @At("HEAD"), method = "writeCustomDataToTag")
|
||||||
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
|
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
|
||||||
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(sorceryCraftSpells));
|
tag.put(SpellHelper.SPELL_TAG, SpellHelper.createSpellsTag(discoveredSpells));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSorceryCraftSpells(Map<Identifier, Integer> spells) {
|
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
||||||
this.sorceryCraftSpells = spells;
|
discoveredSpells = spells;
|
||||||
|
if (currentScreenHandler instanceof CastingTableScreenHandler) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
((CastingTableScreenHandler) currentScreenHandler).setSpells((PlayerEntity) (Object) this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Identifier, Integer> getSorceryCraftSpells() {
|
public Map<Identifier, Integer> getDiscoveredSpells() {
|
||||||
return sorceryCraftSpells;
|
return discoveredSpells;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,45 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.mixin;
|
package com.thebrokenrail.sorcerycraft.mixin;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
|
import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellServerPlayerEntity;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(ServerPlayerEntity.class)
|
@Mixin(ServerPlayerEntity.class)
|
||||||
public abstract class MixinServerPlayerEntity implements SpellPlayerEntity {
|
public abstract class MixinServerPlayerEntity extends MixinPlayerEntity implements SpellServerPlayerEntity {
|
||||||
@Inject(at = @At("HEAD"), method = "copyFrom")
|
@Inject(at = @At("HEAD"), method = "copyFrom")
|
||||||
public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo ci) {
|
public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo info) {
|
||||||
SpellPlayerEntity oldSpellPlayer = (SpellPlayerEntity) oldPlayer;
|
SpellPlayerEntity oldSpellPlayer = (SpellPlayerEntity) oldPlayer;
|
||||||
SpellPlayerEntity newSpellPlayer = this;
|
SpellPlayerEntity newSpellPlayer = this;
|
||||||
|
|
||||||
newSpellPlayer.setSorceryCraftSpells(oldSpellPlayer.getSorceryCraftSpells());
|
newSpellPlayer.setDiscoveredSpells(oldSpellPlayer.getDiscoveredSpells());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "playerTick")
|
@Override
|
||||||
public void playerTick(CallbackInfo ignored) {
|
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
||||||
|
super.setDiscoveredSpells(spells);
|
||||||
|
if (currentScreenHandler instanceof CastingTableScreenHandler) {
|
||||||
|
sync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sync() {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(getSorceryCraftSpells()));
|
tag.put(SpellHelper.SPELL_TAG, SpellHelper.createSpellsTag(getDiscoveredSpells()));
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
UpdateKnownSpellsS2CPacket.send((ServerPlayerEntity) (Object) this, tag);
|
UpdateKnownSpellsS2CPacket.send((ServerPlayerEntity) (Object) this, tag);
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,14 @@ package com.thebrokenrail.sorcerycraft.packet;
|
|||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.network.PacketContext;
|
import net.fabricmc.fabric.api.network.PacketContext;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.PacketByteBuf;
|
|
||||||
|
|
||||||
public class SelectSpellC2SPacket {
|
public class SelectSpellC2SPacket {
|
||||||
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
||||||
@ -20,6 +22,7 @@ public class SelectSpellC2SPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
public static void send(MinecraftClient minecraft, int index) {
|
public static void send(MinecraftClient minecraft, int index) {
|
||||||
PacketByteBuf bytes = new PacketByteBuf(Unpooled.buffer());
|
PacketByteBuf bytes = new PacketByteBuf(Unpooled.buffer());
|
||||||
bytes.writeInt(index);
|
bytes.writeInt(index);
|
||||||
|
@ -2,21 +2,24 @@ package com.thebrokenrail.sorcerycraft.packet;
|
|||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.network.PacketContext;
|
import net.fabricmc.fabric.api.network.PacketContext;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.PacketByteBuf;
|
|
||||||
|
|
||||||
public class UpdateKnownSpellsS2CPacket {
|
public class UpdateKnownSpellsS2CPacket {
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
||||||
CompoundTag tag = bytes.readCompoundTag();
|
CompoundTag tag = bytes.readCompoundTag();
|
||||||
if (context.getPlayer() != null) {
|
if (context.getPlayer() != null) {
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) context.getPlayer();
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) context.getPlayer();
|
||||||
spellPlayer.setSorceryCraftSpells(SpellTag.getSpells(tag));
|
spellPlayer.setDiscoveredSpells(SpellHelper.getSpells(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
@ -23,12 +24,15 @@ public class CoolingSpell extends Spell {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
||||||
BlockPos blockPos = hitResult.getBlockPos();
|
BlockPos blockPos = hitResult.getBlockPos();
|
||||||
if (world.getBlockState(blockPos).matches(BlockTags.FIRE)) {
|
if (world.getBlockState(blockPos).isIn(BlockTags.FIRE)) {
|
||||||
world.removeBlock(blockPos, false);
|
world.removeBlock(blockPos, false);
|
||||||
}
|
}
|
||||||
|
if (world.getBlockState(blockPos).contains(Properties.LIT) && world.getBlockState(blockPos).get(Properties.LIT)) {
|
||||||
|
world.setBlockState(blockPos, world.getBlockState(blockPos).with(Properties.LIT, false));
|
||||||
|
}
|
||||||
|
|
||||||
BlockPos sideBlockPos = blockPos.offset(hitResult.getSide());
|
BlockPos sideBlockPos = blockPos.offset(hitResult.getSide());
|
||||||
if (world.getBlockState(sideBlockPos).matches(BlockTags.FIRE)) {
|
if (world.getBlockState(sideBlockPos).isIn(BlockTags.FIRE)) {
|
||||||
world.removeBlock(sideBlockPos, false);
|
world.removeBlock(sideBlockPos, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell;
|
package com.thebrokenrail.sorcerycraft.spell;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import net.minecraft.block.AbstractFireBlock;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.TntBlock;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.FlintAndSteelItem;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.AutomaticItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.state.property.Properties;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class FlameSpell extends Spell {
|
public class FlameSpell extends Spell {
|
||||||
@ -21,25 +17,15 @@ public class FlameSpell extends Spell {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(World world, Entity source, Entity attacker, Entity target) {
|
public void execute(World world, Entity source, Entity attacker, Entity target) {
|
||||||
target.setFireTicks(400 + (getLevel() * 200));
|
if (attacker instanceof LivingEntity) {
|
||||||
|
((LivingEntity) attacker).onAttacking(target);
|
||||||
|
}
|
||||||
|
target.setOnFireFor(8 + (getLevel() * 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
||||||
BlockPos blockPos = hitResult.getBlockPos();
|
Items.FLINT_AND_STEEL.useOnBlock(new AutomaticItemPlacementContext(world, hitResult.getBlockPos(), hitResult.getSide().getOpposite(), new ItemStack(Items.FLINT_AND_STEEL), hitResult.getSide()));
|
||||||
BlockState blockState = world.getBlockState(blockPos);
|
|
||||||
|
|
||||||
BlockPos sideBlockPos = hitResult.getBlockPos().offset(hitResult.getSide());
|
|
||||||
BlockState sideBlockState = world.getBlockState(sideBlockPos);
|
|
||||||
|
|
||||||
if (blockState.getBlock() instanceof TntBlock) {
|
|
||||||
TntBlock.primeTnt(world, blockPos);
|
|
||||||
world.removeBlock(blockPos, false);
|
|
||||||
} else if (FlintAndSteelItem.canIgnite(sideBlockState, world, sideBlockPos)) {
|
|
||||||
world.setBlockState(sideBlockPos, AbstractFireBlock.getState(world, sideBlockPos));
|
|
||||||
} else if (FlintAndSteelItem.isIgnitable(blockState)) {
|
|
||||||
world.setBlockState(blockPos, blockState.with(Properties.LIT, true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,7 @@ package com.thebrokenrail.sorcerycraft.spell;
|
|||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LightningEntity;
|
import net.minecraft.entity.LightningEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
@ -29,11 +30,13 @@ public class LightningSpell extends Spell {
|
|||||||
|
|
||||||
private void strike(World world, Vec3d pos, Entity attacker) {
|
private void strike(World world, Vec3d pos, Entity attacker) {
|
||||||
ServerWorld serverWorld = (ServerWorld) world;
|
ServerWorld serverWorld = (ServerWorld) world;
|
||||||
LightningEntity lightningEntity = new LightningEntity(world, pos.getX(), pos.getY(), pos.getZ(), false);
|
LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(world);
|
||||||
|
assert lightningEntity != null;
|
||||||
|
lightningEntity.updatePosition(pos.x, pos.y, pos.z);
|
||||||
if (attacker instanceof ServerPlayerEntity) {
|
if (attacker instanceof ServerPlayerEntity) {
|
||||||
lightningEntity.setChanneller((ServerPlayerEntity) attacker);
|
lightningEntity.setChanneler((ServerPlayerEntity) attacker);
|
||||||
}
|
}
|
||||||
serverWorld.addLightning(lightningEntity);
|
serverWorld.spawnEntity(lightningEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,7 @@ public class TeleportSpell extends Spell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getMaxTeleport(World world) {
|
private int getMaxTeleport(World world) {
|
||||||
return world.getDimension().isNether() ? 128 : 256;
|
return world.getRegistryKey() != World.OVERWORLD ? 128 : 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,6 +57,9 @@ public class TeleportSpell extends Spell {
|
|||||||
case 1: {
|
case 1: {
|
||||||
return 18;
|
return 18;
|
||||||
}
|
}
|
||||||
|
case 2: {
|
||||||
|
return 24;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -70,12 +73,15 @@ public class TeleportSpell extends Spell {
|
|||||||
case 1: {
|
case 1: {
|
||||||
return new ItemStack(Items.CHORUS_FRUIT);
|
return new ItemStack(Items.CHORUS_FRUIT);
|
||||||
}
|
}
|
||||||
|
case 2: {
|
||||||
|
return new ItemStack(Items.CHORUS_FLOWER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxLevel() {
|
public int getMaxLevel() {
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell.api;
|
package com.thebrokenrail.sorcerycraft.spell.api;
|
||||||
|
|
||||||
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spell Implementation Base Class
|
||||||
|
*/
|
||||||
public abstract class Spell {
|
public abstract class Spell {
|
||||||
private final Identifier id;
|
private final Identifier id;
|
||||||
private final int level;
|
private final int level;
|
||||||
@ -16,7 +22,7 @@ public abstract class Spell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ID of this Spell
|
* Get the ID of this spell
|
||||||
* @return The Spell ID
|
* @return The Spell ID
|
||||||
*/
|
*/
|
||||||
public Identifier getID() {
|
public Identifier getID() {
|
||||||
@ -24,18 +30,18 @@ public abstract class Spell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the level of this Spell
|
* Get the level of this spell
|
||||||
* @return The Spell Level
|
* @return The Spell's Level
|
||||||
*/
|
*/
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute this Spell on an Entity
|
* Execute this spell on an Entity
|
||||||
* @param world World
|
* @param world World
|
||||||
* @param source A SpellEntity
|
* @param source A SpellEntity
|
||||||
* @param attacker The Entity that cast this Spell
|
* @param attacker The Entity that cast this spell
|
||||||
* @param target The Target
|
* @param target The Target
|
||||||
*/
|
*/
|
||||||
public void execute(World world, Entity source, Entity attacker, Entity target) {
|
public void execute(World world, Entity source, Entity attacker, Entity target) {
|
||||||
@ -43,10 +49,10 @@ public abstract class Spell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast this Spell on a block
|
* Execute this spell on a block
|
||||||
* @param world World
|
* @param world World
|
||||||
* @param source A SpellEntity
|
* @param source A SpellEntity
|
||||||
* @param attacker The Entity that cast this Spell
|
* @param attacker The Entity that cast this spell
|
||||||
* @param hitResult The block's HitResult
|
* @param hitResult The block's HitResult
|
||||||
*/
|
*/
|
||||||
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
||||||
@ -54,20 +60,42 @@ public abstract class Spell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of levels required to make this Spell in a Casting Table
|
* Get the amount of levels required to make this spell in a Casting Table
|
||||||
* @return The XP cost
|
* @return The XP cost
|
||||||
*/
|
*/
|
||||||
public abstract int getXPCost();
|
public abstract int getXPCost();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the item(s) required to make ExampleSpell in a Casting Table, or ItemStack.EMPTY if an item is not required
|
* Get the item(s) required to make this spell in a Casting Table, or ItemStack.EMPTY if an item is not required
|
||||||
* @return The item cost
|
* @return The item cost
|
||||||
*/
|
*/
|
||||||
public abstract ItemStack getItemCost();
|
public abstract ItemStack getItemCost();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum level of this Spell
|
* Get the maximum level of this spell
|
||||||
* @return The Max Level
|
* @return The Spell's Max Level
|
||||||
*/
|
*/
|
||||||
public abstract int getMaxLevel();
|
public abstract int getMaxLevel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Implementation for Spell.getTranslation()
|
||||||
|
* @param id Spell ID
|
||||||
|
* @param level Spell Level
|
||||||
|
* @return Translated Display Name
|
||||||
|
*/
|
||||||
|
public static MutableText getDefaultTranslation(Identifier id, int level) {
|
||||||
|
MutableText text = new TranslatableText("spell." + id.getNamespace() + '.' + id.getPath());
|
||||||
|
if (level != 0 || SpellRegistry.getMaxLevel(id) != 1) {
|
||||||
|
text.append(" ").append(new TranslatableText("enchantment.level." + (level + 1)));
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Translated Display Name
|
||||||
|
* @return Translated Display Name
|
||||||
|
*/
|
||||||
|
public MutableText getTranslation() {
|
||||||
|
return getDefaultTranslation(getID(), getLevel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell.registry;
|
package com.thebrokenrail.sorcerycraft.spell.api.registry;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@ -9,13 +9,28 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spell Implementation Registry
|
||||||
|
*/
|
||||||
public class SpellRegistry {
|
public class SpellRegistry {
|
||||||
private static final Map<Identifier, Class<?>> spells = new HashMap<>();
|
private static final Map<Identifier, Class<?>> spells = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Spell Implementation
|
||||||
|
* @param entry Map Entry
|
||||||
|
* @return Spell Implementation
|
||||||
|
*/
|
||||||
public static Spell getSpell(Map.Entry<Identifier, Integer> entry) {
|
public static Spell getSpell(Map.Entry<Identifier, Integer> entry) {
|
||||||
return getSpell(entry.getKey(), entry.getValue());
|
return getSpell(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Spell Implementation
|
||||||
|
* @param id Spell ID
|
||||||
|
* @param level Spell Level
|
||||||
|
* @return Spell Implementation
|
||||||
|
*/
|
||||||
public static Spell getSpell(Identifier id, int level) {
|
public static Spell getSpell(Identifier id, int level) {
|
||||||
if (!spells.containsKey(id)) {
|
if (!spells.containsKey(id)) {
|
||||||
return null;
|
return null;
|
||||||
@ -28,6 +43,11 @@ public class SpellRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Max Level of a Spell
|
||||||
|
* @param id Spell ID
|
||||||
|
* @return Max Level
|
||||||
|
*/
|
||||||
public static int getMaxLevel(Identifier id) {
|
public static int getMaxLevel(Identifier id) {
|
||||||
Spell tempSpell = getSpell(id, 0);
|
Spell tempSpell = getSpell(id, 0);
|
||||||
if (tempSpell == null) {
|
if (tempSpell == null) {
|
||||||
@ -36,6 +56,10 @@ public class SpellRegistry {
|
|||||||
return tempSpell.getMaxLevel();
|
return tempSpell.getMaxLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get All Spell Implementations
|
||||||
|
* @return List of Spell Implementations
|
||||||
|
*/
|
||||||
public static Spell[] getSpells() {
|
public static Spell[] getSpells() {
|
||||||
List<Spell> out = new ArrayList<>();
|
List<Spell> out = new ArrayList<>();
|
||||||
for (Map.Entry<Identifier, Class<?>> entry : spells.entrySet()) {
|
for (Map.Entry<Identifier, Class<?>> entry : spells.entrySet()) {
|
||||||
@ -53,6 +77,22 @@ public class SpellRegistry {
|
|||||||
return out.toArray(new Spell[0]);
|
return out.toArray(new Spell[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get All Max Level Spell Implementations
|
||||||
|
* @return List of Spell Implementations
|
||||||
|
*/
|
||||||
|
public static Spell[] getMaxSpells() {
|
||||||
|
List<Spell> out = new ArrayList<>();
|
||||||
|
for (Map.Entry<Identifier, Class<?>> entry : spells.entrySet()) {
|
||||||
|
int maxLevel = getMaxLevel(entry.getKey());
|
||||||
|
if (maxLevel == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.add(getSpell(entry.getKey(), maxLevel - 1));
|
||||||
|
}
|
||||||
|
return out.toArray(new Spell[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a Spell
|
* Register a Spell
|
||||||
* @param id The Spell ID
|
* @param id The Spell ID
|
||||||
@ -64,6 +104,10 @@ public class SpellRegistry {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gat All Spell IDs
|
||||||
|
* @return List of Spell IDs
|
||||||
|
*/
|
||||||
public static Identifier[] getSpellsID() {
|
public static Identifier[] getSpellsID() {
|
||||||
return spells.keySet().toArray(new Identifier[0]);
|
return spells.keySet().toArray(new Identifier[0]);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell.registry;
|
package com.thebrokenrail.sorcerycraft.spell.api.registry;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.CoolingSpell;
|
import com.thebrokenrail.sorcerycraft.spell.CoolingSpell;
|
||||||
@ -13,6 +13,9 @@ import com.thebrokenrail.sorcerycraft.spell.SteadfastSpell;
|
|||||||
import com.thebrokenrail.sorcerycraft.spell.TeleportSpell;
|
import com.thebrokenrail.sorcerycraft.spell.TeleportSpell;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All Builtin Spells
|
||||||
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class Spells {
|
public class Spells {
|
||||||
public static final Identifier HEAL_SPELL;
|
public static final Identifier HEAL_SPELL;
|
@ -1,13 +1,18 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell.util;
|
package com.thebrokenrail.sorcerycraft.spell.util;
|
||||||
|
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.loot.condition.LootCondition;
|
import net.minecraft.loot.condition.LootCondition;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.loot.context.LootContext;
|
||||||
import net.minecraft.loot.function.ConditionalLootFunction;
|
import net.minecraft.loot.function.ConditionalLootFunction;
|
||||||
import net.minecraft.loot.function.LootFunction;
|
import net.minecraft.loot.function.LootFunction;
|
||||||
|
import net.minecraft.loot.function.LootFunctionType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -21,14 +26,30 @@ public class RandomSpellLootTableFunction extends ConditionalLootFunction {
|
|||||||
while (!(context.getRandom().nextDouble() > chance)) {
|
while (!(context.getRandom().nextDouble() > chance)) {
|
||||||
Spell[] spells = SpellRegistry.getSpells();
|
Spell[] spells = SpellRegistry.getSpells();
|
||||||
int index = context.getRandom().nextInt(spells.length);
|
int index = context.getRandom().nextInt(spells.length);
|
||||||
Map<Identifier, Integer> spell = SpellTag.getSpells(stack);
|
Map<Identifier, Integer> spell = SpellHelper.getSpells(stack);
|
||||||
spell.put(spells[index].getID(), spells[index].getLevel());
|
spell.put(spells[index].getID(), spells[index].getLevel());
|
||||||
SpellTag.setSpells(stack, spell);
|
SpellHelper.setSpells(stack, spell);
|
||||||
chance = chance * 0.25d;
|
chance = chance * 0.25d;
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LootFunctionType getType() {
|
||||||
|
return Registry.LOOT_FUNCTION_TYPE.get(new Identifier(SorceryCraft.NAMESPACE, "random_spell"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory extends ConditionalLootFunction.Serializer<RandomSpellLootTableFunction> {
|
||||||
|
public Factory() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RandomSpellLootTableFunction fromJson(JsonObject json, JsonDeserializationContext context, LootCondition[] conditions) {
|
||||||
|
return (RandomSpellLootTableFunction) new com.thebrokenrail.sorcerycraft.spell.util.RandomSpellLootTableFunction.Builder().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder extends ConditionalLootFunction.Builder<RandomSpellLootTableFunction.Builder> {
|
public static class Builder extends ConditionalLootFunction.Builder<RandomSpellLootTableFunction.Builder> {
|
||||||
@Override
|
@Override
|
||||||
protected RandomSpellLootTableFunction.Builder getThisBuilder() {
|
protected RandomSpellLootTableFunction.Builder getThisBuilder() {
|
||||||
|
@ -2,23 +2,28 @@ package com.thebrokenrail.sorcerycraft.spell.util;
|
|||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.network.MessageType;
|
||||||
|
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SpellTag {
|
public class SpellHelper {
|
||||||
public static final String SPELL_TAG = "Spells";
|
public static final String SPELL_TAG = "Spells";
|
||||||
|
|
||||||
public static void setSpells(ItemStack itemStack, Map<Identifier, Integer> map) {
|
public static void setSpells(ItemStack itemStack, Map<Identifier, Integer> map) {
|
||||||
@ -82,20 +87,27 @@ public class SpellTag {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Text getTranslatedSpell(Identifier id, int level, boolean allowNumber) {
|
public static Text getTranslatedSpell(Identifier id, int level) {
|
||||||
Text text = new TranslatableText("spell." + id.getNamespace() + '.' + id.getPath());
|
Spell spell = SpellRegistry.getSpell(id, level);
|
||||||
text.formatted(Formatting.GRAY);
|
MutableText text;
|
||||||
if ((level != 0 || SpellRegistry.getMaxLevel(id) != 1) && allowNumber) {
|
if (spell != null) {
|
||||||
text.append(" ").append(new TranslatableText("enchantment.level." + (level + 1)));
|
text = spell.getTranslation();
|
||||||
|
} else {
|
||||||
|
text = Spell.getDefaultTranslation(id, level);
|
||||||
}
|
}
|
||||||
|
text.formatted(Formatting.GRAY);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Text getTranslatedSpellChat(Identifier id, int level) {
|
||||||
|
return new LiteralText("[").append(SpellHelper.getTranslatedSpell(id, level).getString()).append("]").formatted(Formatting.GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
public static void learnSpells(PlayerEntity player, Map<Identifier, Integer> itemSpells) {
|
public static void learnSpells(PlayerEntity player, Map<Identifier, Integer> itemSpells) {
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
World world = player.getEntityWorld();
|
World world = player.getEntityWorld();
|
||||||
|
|
||||||
Map<Identifier, Integer> playerSpells = spellPlayer.getSorceryCraftSpells();
|
Map<Identifier, Integer> playerSpells = spellPlayer.getDiscoveredSpells();
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
@ -111,15 +123,16 @@ public class SpellTag {
|
|||||||
|
|
||||||
playerSpells.put(spell.getID(), spell.getLevel());
|
playerSpells.put(spell.getID(), spell.getLevel());
|
||||||
assert world.getServer() != null;
|
assert world.getServer() != null;
|
||||||
Text text = new LiteralText("[").append(SpellTag.getTranslatedSpell(spell.getID(), spell.getLevel(), true).getString()).append("]").formatted(Formatting.GREEN);
|
Text text = getTranslatedSpellChat(spell.getID(), spell.getLevel());
|
||||||
world.getServer().getPlayerManager().sendToAll(new TranslatableText("chat." + SorceryCraft.NAMESPACE + ".new_spell", player.getDisplayName(), text));
|
world.getServer().getPlayerManager().sendToAll(new GameMessageS2CPacket(new TranslatableText("chat." + SorceryCraft.NAMESPACE + ".discovered_spell", player.getDisplayName(), text), MessageType.CHAT, Util.NIL_UUID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
SorceryCraft.playSpellSound(player);
|
SorceryCraft.playSpellSound(player);
|
||||||
spellPlayer.setSorceryCraftSpells(playerSpells);
|
spellPlayer.setDiscoveredSpells(playerSpells);
|
||||||
|
SorceryCraft.DISCOVER_ALL_SPELLS_CRITERION.trigger((ServerPlayerEntity) player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import net.minecraft.util.Identifier;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface SpellPlayerEntity {
|
public interface SpellPlayerEntity {
|
||||||
void setSorceryCraftSpells(Map<Identifier, Integer> spells);
|
void setDiscoveredSpells(Map<Identifier, Integer> spells);
|
||||||
|
|
||||||
Map<Identifier, Integer> getSorceryCraftSpells();
|
Map<Identifier, Integer> getDiscoveredSpells();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.thebrokenrail.sorcerycraft.spell.util;
|
||||||
|
|
||||||
|
public interface SpellServerPlayerEntity extends SpellPlayerEntity {
|
||||||
|
void sync();
|
||||||
|
}
|
@ -4,16 +4,27 @@
|
|||||||
"itemGroup.sorcerycraft.spells": "SorceryCraft",
|
"itemGroup.sorcerycraft.spells": "SorceryCraft",
|
||||||
"container.sorcerycraft.casting_table": "Casting Table",
|
"container.sorcerycraft.casting_table": "Casting Table",
|
||||||
"container.sorcerycraft.spells": "Spells",
|
"container.sorcerycraft.spells": "Spells",
|
||||||
"chat.sorcerycraft.new_spell": "%s has learned the spell %s",
|
"chat.sorcerycraft.discovered_spell": "%s has discovered the spell %s",
|
||||||
"entity.sorcerycraft.spell": "Spell",
|
"entity.sorcerycraft.spell": "Spell",
|
||||||
"command.sorcerycraft.spell.cleared_spells": "All spells cleared from %s",
|
"command.sorcerycraft.spell.forgotten_spell": "%s has forgotten the spell %s",
|
||||||
"command.sorcerycraft.spell.listing_spells": "%s knows the following spells:",
|
"command.sorcerycraft.spell.listing_spells": "%s has discovered the following spells: %s",
|
||||||
"command.sorcerycraft.spell.unknown_spell": "Unknown spell: %s",
|
"command.sorcerycraft.spell.unknown_spell": "Unknown spell: %s",
|
||||||
"command.sorcerycraft.spell.not_holding_spell": "%s is not holding a Spell",
|
"command.sorcerycraft.spell.not_holding_spell": "%s is not holding a spell",
|
||||||
"command.sorcerycraft.spell.applied_spell": "Applied Spell %s",
|
"command.sorcerycraft.spell.applied_spell": "Applied Spell %s",
|
||||||
"command.sorcerycraft.spell.removed_spell": "Removed Spell %s",
|
"command.sorcerycraft.spell.removed_spell": "Removed Spell %s",
|
||||||
"stat.sorcerycraft.interact_with_casting_table": "Interactions with Casting Table",
|
"stat.sorcerycraft.interact_with_casting_table": "Interactions with Casting Table",
|
||||||
"stat.sorcerycraft.cast_spell": "Spells Cast",
|
"stat.sorcerycraft.cast_spell": "Spells Cast",
|
||||||
|
"text.autoconfig.sorcerycraft.title": "SorceryCraft Config",
|
||||||
|
"text.autoconfig.sorcerycraft.option.failureChance": "Spell Failure Chance",
|
||||||
|
"text.autoconfig.sorcerycraft.option.limitCastingTable": "Limit Casting Table To Discovered Spells",
|
||||||
|
"text.autoconfig.sorcerycraft.option.limitCastingTable.creative": "Creative Mode",
|
||||||
|
"text.autoconfig.sorcerycraft.option.limitCastingTable.survival": "Survival Mode",
|
||||||
|
"advancements.sorcerycraft.adventure.discover_spell.title": "Witchcraft!",
|
||||||
|
"advancements.sorcerycraft.adventure.discover_spell.description": "Discover a spell",
|
||||||
|
"advancements.sorcerycraft.adventure.create_spell.title": "Spellbinding!",
|
||||||
|
"advancements.sorcerycraft.adventure.create_spell.description": "Cast a spell using a Casting Table",
|
||||||
|
"advancements.sorcerycraft.adventure.discover_all_spells.title": "Master of Magic!",
|
||||||
|
"advancements.sorcerycraft.adventure.discover_all_spells.description": "Discover all spells",
|
||||||
"spell.sorcerycraft.damage_spell": "Damage",
|
"spell.sorcerycraft.damage_spell": "Damage",
|
||||||
"spell.sorcerycraft.heal_spell": "Heal",
|
"spell.sorcerycraft.heal_spell": "Heal",
|
||||||
"spell.sorcerycraft.dissolve_spell": "Dissolve",
|
"spell.sorcerycraft.dissolve_spell": "Dissolve",
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"parent": "sorcerycraft:adventure/discover_spell",
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "sorcerycraft:casting_table"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"translate": "advancements.sorcerycraft.adventure.create_spell.title"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"translate": "advancements.sorcerycraft.adventure.create_spell.description"
|
||||||
|
},
|
||||||
|
"frame": "task",
|
||||||
|
"show_toast": true,
|
||||||
|
"announce_to_chat": true,
|
||||||
|
"hidden": false
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"sorcerycraft:casting_table": {
|
||||||
|
"trigger": "sorcerycraft:create_spell"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"parent": "sorcerycraft:adventure/create_spell",
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "sorcerycraft:spell",
|
||||||
|
"nbt": "{Spells: [{id: \"sorcerycraft:damage_spell\", level: 0}]}"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"translate": "advancements.sorcerycraft.adventure.discover_all_spells.title"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"translate": "advancements.sorcerycraft.adventure.discover_all_spells.description"
|
||||||
|
},
|
||||||
|
"frame": "challenge",
|
||||||
|
"show_toast": true,
|
||||||
|
"announce_to_chat": true,
|
||||||
|
"hidden": false
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"sorcerycraft:spell": {
|
||||||
|
"trigger": "sorcerycraft:discover_all_spells"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rewards": {
|
||||||
|
"experience": 100
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:adventure/root",
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "sorcerycraft:spell"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"translate": "advancements.sorcerycraft.adventure.discover_spell.title"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"translate": "advancements.sorcerycraft.adventure.discover_spell.description"
|
||||||
|
},
|
||||||
|
"frame": "task",
|
||||||
|
"show_toast": true,
|
||||||
|
"announce_to_chat": true,
|
||||||
|
"hidden": false
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"sorcerycraft:spell": {
|
||||||
|
"trigger": "minecraft:inventory_changed",
|
||||||
|
"conditions": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"item": "sorcerycraft:spell"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rewards": {
|
||||||
|
"recipes": [
|
||||||
|
"sorcerycraft:spell",
|
||||||
|
"sorcerycraft:casting_table"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "sorcerycraft",
|
"id": "sorcerycraft",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "SorceryCraft",
|
"name": "${name}",
|
||||||
"description": "Cast Spells in Minecraft!",
|
"description": "Cast Spells in Minecraft!",
|
||||||
"authors": [
|
"authors": [
|
||||||
"TheBrokenRail"
|
"TheBrokenRail"
|
||||||
@ -20,7 +20,10 @@
|
|||||||
"com.thebrokenrail.sorcerycraft.SorceryCraft"
|
"com.thebrokenrail.sorcerycraft.SorceryCraft"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"com.thebrokenrail.sorcerycraft.SorceryCraft"
|
"com.thebrokenrail.sorcerycraft.client.SorceryCraftClient"
|
||||||
|
],
|
||||||
|
"modmenu": [
|
||||||
|
"com.thebrokenrail.sorcerycraft.client.ModMenu"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
@ -30,5 +33,11 @@
|
|||||||
"fabricloader": ">=0.7.4",
|
"fabricloader": ">=0.7.4",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "1.16.x"
|
"minecraft": "1.16.x"
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"modupdater": {
|
||||||
|
"strategy": "curseforge",
|
||||||
|
"projectID": 365308
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,12 @@
|
|||||||
"package": "com.thebrokenrail.sorcerycraft.mixin",
|
"package": "com.thebrokenrail.sorcerycraft.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"client": [
|
"client": [
|
||||||
"MixinClientPlayNetworkHandler"
|
"MixinClientPlayerEntity",
|
||||||
|
"MixinClientPlayNetworkHandler",
|
||||||
|
"MixinAbstractButtonWidget"
|
||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"CriteriaRegistryHook",
|
||||||
"MixinPlayerEntity",
|
"MixinPlayerEntity",
|
||||||
"MixinServerPlayerEntity"
|
"MixinServerPlayerEntity"
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user