Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit b05b46d

Browse files
committed
Be aware of methods which may have overrides
1 parent 14dbd37 commit b05b46d

7 files changed

Lines changed: 22 additions & 22 deletions

File tree

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/BlockEntityMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@ public CapabilityProvider<BlockEntity> getCapabilityProvider() {
4646

4747
@Inject(method = "<init>", at = @At("RETURN"))
4848
private void initializeCapabilities(CallbackInfo callbackInfo) {
49-
provider.gatherCapabilities();
49+
gatherCapabilities();
5050
}
5151

5252
@Inject(method = "writeIdentifyingData", at = @At("RETURN"))
5353
private void serializeCapabilities(CompoundTag compoundTag, CallbackInfoReturnable<CompoundTag> callbackInfoReturnable) {
54-
if (provider.getCapabilities() != null) {
55-
compoundTag.put("ForgeCaps", provider.serializeCaps());
54+
if (getCapabilities() != null) {
55+
compoundTag.put("ForgeCaps", serializeCaps());
5656
}
5757
}
5858

5959
@Inject(method = "fromTag", at = @At("RETURN"))
6060
private void deserializeCapabilities(CompoundTag compoundTag, CallbackInfo callbackInfo) {
61-
if (provider.getCapabilities() != null && compoundTag.containsKey("ForgeCaps")) {
62-
provider.deserializeCaps(compoundTag.getCompound("ForgeCaps"));
61+
if (getCapabilities() != null && compoundTag.containsKey("ForgeCaps")) {
62+
deserializeCaps(compoundTag.getCompound("ForgeCaps"));
6363
}
6464
}
6565

6666
@Inject(method = "invalidate", at = @At("RETURN"))
6767
private void invalidate(CallbackInfo callbackInfo) {
68-
provider.invalidateCaps();
68+
invalidateCaps();
6969
}
7070
}

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/ChunkSerializerMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ private static WorldChunk newWorldChunk(
6060
CompoundTag level = compoundTag.getCompound("Level");
6161

6262
if (level.containsKey("ForgeCaps")) {
63-
((CapabilityProviderHolder) chunk).getCapabilityProvider().deserializeCaps(level.getCompound("ForgeCaps"));
63+
((CapabilityProviderHolder) chunk).deserializeCaps(level.getCompound("ForgeCaps"));
6464
}
6565

6666
return chunk;
6767
}
6868

6969
@Inject(method = "serialize", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;saveToTag(Lnet/minecraft/nbt/CompoundTag;)Z"), to = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/ProtoChunk;getEntities()Ljava/util/List;")), at = @At(value = "JUMP", opcode = Opcodes.GOTO, ordinal = 2), locals = LocalCapture.CAPTURE_FAILHARD)
7070
private static void serializeCapabilities(ServerWorld serverWorld, Chunk chunk, CallbackInfoReturnable<CompoundTag> callbackInfoReturnable, ChunkPos chunkPos, CompoundTag compoundTag, CompoundTag level) {
71-
CompoundTag tag = ((CapabilityProviderHolder) chunk).getCapabilityProvider().serializeCaps();
71+
CompoundTag tag = ((CapabilityProviderHolder) chunk).serializeCaps();
7272

7373
if (tag != null) {
7474
level.put("ForgeCaps", tag);

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/ClientWorldMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public abstract class ClientWorldMixin implements CapabilityProviderHolder {
3434
@Inject(method = "<init>", at = @At("TAIL"))
3535
private void initializeCapabilities(CallbackInfo callbackInfo) {
3636
// TODO: Requires Dimension API (IForgeDimension)
37-
getCapabilityProvider().gatherCapabilities(null);
37+
gatherCapabilities(null);
3838
}
3939
}

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/EntityMixin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public CapabilityProvider<Entity> getCapabilityProvider() {
5050

5151
@Inject(method = "<init>", at = @At("RETURN"))
5252
private void initializeCapabilities(CallbackInfo callbackInfo) {
53-
provider.gatherCapabilities();
53+
gatherCapabilities();
5454
}
5555

5656
@Inject(method = "toTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;writeCustomDataToTag(Lnet/minecraft/nbt/CompoundTag;)V"))
5757
private void serializeCapabilities(CompoundTag tag, CallbackInfoReturnable<CompoundTag> callbackInfoReturnable) {
58-
CompoundTag compoundTag = provider.serializeCaps();
58+
CompoundTag compoundTag = serializeCaps();
5959

6060
if (compoundTag != null) {
6161
tag.put("ForgeCaps", compoundTag);
@@ -65,13 +65,13 @@ private void serializeCapabilities(CompoundTag tag, CallbackInfoReturnable<Compo
6565
@Inject(method = "fromTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;readCustomDataFromTag(Lnet/minecraft/nbt/CompoundTag;)V"))
6666
private void deserializeCapabilities(CompoundTag tag, CallbackInfo callbackInfo) {
6767
if (tag.containsKey("ForgeCaps")) {
68-
provider.deserializeCaps(tag.getCompound("ForgeCaps"));
68+
deserializeCaps(tag.getCompound("ForgeCaps"));
6969
}
7070
}
7171

7272
@Inject(method = "remove", at = @At("RETURN"))
7373
private void onRemoved(CallbackInfo callback) {
74-
provider.invalidateCaps();
74+
invalidateCaps();
7575
}
7676

7777
// "well, my approach is that if that becomes an issue, we'll fix it"
@@ -80,7 +80,7 @@ public void remove(boolean keep) {
8080
removed = true;
8181

8282
if (!keep) {
83-
provider.invalidateCaps();
83+
invalidateCaps();
8484
}
8585
}
8686
}

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/ItemStackMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ public CapabilityProvider<ItemStack> getCapabilityProvider() {
4848
@Inject(method = "<init>(Lnet/minecraft/item/ItemConvertible;I)V", at = @At("RETURN"))
4949
private void initializeCapabilities(CallbackInfo callbackInfo) {
5050
// TODO: Fix when IForgeItem is available. This shouldn't be too much of an issue now as the method would return null by default
51-
provider.gatherCapabilities(null);
51+
gatherCapabilities(null);
5252
}
5353

5454
@Inject(method = "<init>(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("RETURN"))
5555
private void deserializeCapabilities(CompoundTag tag, CallbackInfo callbackInfo) {
5656
// TODO: See above TODO
57-
provider.gatherCapabilities(null);
57+
gatherCapabilities(null);
5858

5959
if (tag.containsKey("ForgeCaps")) {
60-
provider.deserializeCaps(tag.getCompound("ForgeCaps"));
60+
deserializeCaps(tag.getCompound("ForgeCaps"));
6161
}
6262
}
6363

6464
@Inject(method = "toTag", at = @At(value = "RETURN"))
6565
private void serializeCapabilities(CompoundTag tag, CallbackInfoReturnable<CompoundTag> callbackInfoReturnable) {
66-
CompoundTag compoundTag = provider.serializeCaps();
66+
CompoundTag compoundTag = serializeCaps();
6767

6868
if (compoundTag != null && !compoundTag.isEmpty()) {
6969
tag.put("ForgeCaps", compoundTag);
@@ -72,11 +72,11 @@ private void serializeCapabilities(CompoundTag tag, CallbackInfoReturnable<Compo
7272

7373
@Redirect(method = "isEqualIgnoreDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;equals(Ljava/lang/Object;)Z"))
7474
private boolean equals(CompoundTag a, Object b, ItemStack stack) {
75-
return a.equals(b) && provider.areCapsCompatible(((ItemStackMixin) (Object) stack).provider);
75+
return a.equals(b) && areCapsCompatible(((ItemStackMixin) (Object) stack).provider);
7676
}
7777

7878
@Redirect(method = "areTagsEqual", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;equals(Ljava/lang/Object;)Z"))
7979
private static boolean equals(CompoundTag a, Object b, ItemStack left, ItemStack right) {
80-
return a.equals(b) && ((ItemStackMixin) (Object) left).provider.areCapsCompatible(((ItemStackMixin) (Object) right).provider);
80+
return a.equals(b) && ((ItemStackMixin) (Object) left).areCapsCompatible(((ItemStackMixin) (Object) right).provider);
8181
}
8282
}

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/ServerWorldMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public abstract class ServerWorldMixin implements CapabilityProviderHolder {
3434
@Inject(method = "<init>", at = @At("TAIL"))
3535
private void initializeCapabilities(CallbackInfo callbackInfo) {
3636
// TODO: Requires Dimension API (IForgeDimension)
37-
getCapabilityProvider().gatherCapabilities(null);
37+
gatherCapabilities(null);
3838
}
3939
}

patchwork-capabilities/src/main/java/com/patchworkmc/mixin/capability/WorldChunkMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public CapabilityProvider<WorldChunk> getCapabilityProvider() {
4444

4545
@Inject(method = "<init>", at = @At("RETURN"))
4646
private void initializeCapabilities(CallbackInfo callbackInfo) {
47-
provider.gatherCapabilities();
47+
gatherCapabilities();
4848
}
4949
}

0 commit comments

Comments
 (0)