-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate conditional mining speed modifier and mob disguise to modules
Need to consider if I should let modifier modules suggest a priority, as the setting of priorities feels a little arbitrary right now to anyone without a high understanding of the code, and most of the time its a single module that wants it
- Loading branch information
1 parent
c00a81a
commit ae40120
Showing
23 changed files
with
384 additions
and
85 deletions.
There are no files selected for viewing
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/blaze_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:blaze" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:blaze" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/cave_spider_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:cave_spider" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:cave_spider" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/creeper_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:creeper" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:creeper" | ||
} | ||
] | ||
} |
22 changes: 15 additions & 7 deletions
22
src/generated/resources/data/tconstruct/tinkering/modifiers/crumbling.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
{ | ||
"type": "tconstruct:conditional_mining_speed", | ||
"blocks": { | ||
"type": "tconstruct:inverted", | ||
"predicate": "tconstruct:requires_tool" | ||
}, | ||
"require_effective": false, | ||
"bonus": 0.5 | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 125, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:conditional_mining_speed", | ||
"blocks": { | ||
"type": "mantle:inverted", | ||
"predicate": "mantle:requires_tool" | ||
}, | ||
"require_effective": false, | ||
"bonus": 0.5 | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/drowned_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:drowned" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:drowned" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/enderman_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:enderman" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:enderman" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/husk_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:husk" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:husk" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/piglin_brute_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:piglin_brute" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:piglin_brute" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/piglin_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:piglin" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:piglin" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/skeleton_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:skeleton" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:skeleton" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/spider_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:spider" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:spider" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/stray_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:stray" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:stray" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/wither_skeleton_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:wither_skeleton" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:wither_skeleton" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/zombie_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:zombie" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:zombie" | ||
} | ||
] | ||
} |
12 changes: 10 additions & 2 deletions
12
src/generated/resources/data/tconstruct/tinkering/modifiers/zombified_piglin_disguise.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:zombified_piglin" | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:default", | ||
"tooltip_display": "always", | ||
"priority": 100, | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:mob_disguise", | ||
"entity": "minecraft:zombified_piglin" | ||
} | ||
] | ||
} |
45 changes: 45 additions & 0 deletions
45
.../java/slimeknights/tconstruct/library/json/serializer/GenericRegistryEntrySerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package slimeknights.tconstruct.library.json.serializer; | ||
|
||
import com.google.gson.JsonObject; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraftforge.registries.IForgeRegistry; | ||
import net.minecraftforge.registries.IForgeRegistryEntry; | ||
import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; | ||
import slimeknights.mantle.data.GenericLoaderRegistry.IHaveLoader; | ||
import slimeknights.mantle.util.JsonHelper; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Serializer for an object with a registry entry parameter | ||
* @param <O> Object type | ||
* @param <V> Registry entry type | ||
*/ | ||
public record GenericRegistryEntrySerializer<O extends IHaveLoader<?>,V extends IForgeRegistryEntry<V>>( | ||
String key, | ||
IForgeRegistry<V> registry, | ||
Function<V,O> constructor, | ||
Function<O,V> getter | ||
) implements IGenericLoader<O> { | ||
|
||
@Override | ||
public O deserialize(JsonObject json) { | ||
return constructor.apply(JsonHelper.getAsEntry(registry, json, key)); | ||
} | ||
|
||
@Override | ||
public void serialize(O object, JsonObject json) { | ||
json.addProperty(key, Objects.requireNonNull(getter.apply(object).getRegistryName()).toString()); | ||
} | ||
|
||
@Override | ||
public O fromNetwork(FriendlyByteBuf buffer) { | ||
return constructor.apply(buffer.readRegistryIdUnsafe(registry)); | ||
} | ||
|
||
@Override | ||
public void toNetwork(O object, FriendlyByteBuf buffer) { | ||
buffer.writeRegistryIdUnsafe(registry, getter.apply(object)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.