Skip to content

Commit

Permalink
Use identifier path composition methods (#3820)
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored Jun 8, 2024
1 parent 18dd60f commit d132107
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class EntityModelLayersMixin {
private static void createSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = Identifier.of(type.name());
cir.setReturnValue(new EntityModelLayer(Identifier.of(identifier.getNamespace(), "sign/" + identifier.getPath()), "main"));
cir.setReturnValue(new EntityModelLayer(identifier.withPrefixedPath("sign/"), "main"));
}
}

@Inject(method = "createHangingSign", at = @At("HEAD"), cancellable = true)
private static void createHangingSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = Identifier.of(type.name());
cir.setReturnValue(new EntityModelLayer(Identifier.of(identifier.getNamespace(), "hanging_sign/" + identifier.getPath()), "main"));
cir.setReturnValue(new EntityModelLayer(identifier.withPrefixedPath("hanging_sign/"), "main"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private HangingSignEditScreenMixin(SignBlockEntity blockEntity, boolean filtered
private Identifier init(String id, Operation<Identifier> original) {
if (signType.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = Identifier.of(signType.name());
return Identifier.of(identifier.getNamespace(), "textures/gui/hanging_signs/" + identifier.getPath() + ".png");
return identifier.withPath(path -> "textures/gui/hanging_signs/" + path + ".png");
}

return original.call(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public FabricShaderProgram(ResourceFactory factory, Identifier name, VertexForma
*/
public static Identifier rewriteAsId(String input, String containedId) {
Identifier contained = Identifier.of(containedId);
return Identifier.of(contained.getNamespace(), input.replace(containedId, contained.getPath()));
return contained.withPath(path -> input.replace(containedId, path));
}
}

0 comments on commit d132107

Please sign in to comment.