-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix chunk attachment being removed from player when it shouldn't, fix…
… usage of custom items in Trim Material/Patter
- Loading branch information
Showing
9 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/RegistryFixedCodecMixin.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,40 @@ | ||
package eu.pb4.polymer.core.mixin.other; | ||
|
||
import com.mojang.serialization.DynamicOps; | ||
import eu.pb4.polymer.core.api.utils.PolymerSyncedObject; | ||
import eu.pb4.polymer.core.api.utils.PolymerUtils; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.entry.RegistryEntry; | ||
import net.minecraft.registry.entry.RegistryFixedCodec; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
@Mixin(RegistryFixedCodec.class) | ||
public class RegistryFixedCodecMixin { | ||
@Shadow @Final private RegistryKey<Registry> registry; | ||
|
||
@ModifyVariable( | ||
method = "encode(Lnet/minecraft/registry/entry/RegistryEntry;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;", | ||
at = @At("HEAD") | ||
) | ||
private RegistryEntry<?> polymerCore$swapEntry(RegistryEntry<?> entry) { | ||
var player = PolymerUtils.getPlayerContext(); | ||
|
||
if (player != null) { | ||
try { | ||
if (entry.value() instanceof PolymerSyncedObject polymerSyncedObject) { | ||
return ((Registry<Registry>) (Object) Registries.REGISTRIES).get(this.registry).getEntry(polymerSyncedObject.getPolymerReplacement(player)); | ||
} | ||
} catch (Throwable e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
return entry; | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
polymer-core/src/testmod/resources/data/minecraft/tags/items/trim_materials.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"test:item" | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
polymer-core/src/testmod/resources/data/polymertest/trim_material/test.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"asset_name": "test", | ||
"description": { | ||
"color": "#6006ab", | ||
"translate": "TEST" | ||
}, | ||
"ingredient": "test:item", | ||
"item_model_index": 0.193702 | ||
} |
8 changes: 8 additions & 0 deletions
8
polymer-core/src/testmod/resources/data/polymertest/trim_pattern/test.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"asset_id": "test", | ||
"description": { | ||
"color": "#6006ab", | ||
"translate": "TEST" | ||
}, | ||
"template_item": "test:item" | ||
} |
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