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

Commit 46e4014

Browse files
committed
Update JavaDoc
1 parent 051af5b commit 46e4014

8 files changed

Lines changed: 43 additions & 39 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ private void initializeCapabilities(CallbackInfo callbackInfo) {
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 = serializeCaps();
58+
CompoundTag capabilities = serializeCaps();
5959

60-
if (compoundTag != null) {
61-
tag.put("ForgeCaps", compoundTag);
60+
if (capabilities != null) {
61+
tag.put("ForgeCaps", capabilities);
6262
}
6363
}
6464

patchwork-capabilities/src/main/java/net/minecraftforge/common/capabilities/Capability.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public interface IStorage<T> {
9191
* @param capability The capability being stored.
9292
* @param instance An instance of that capability's interface.
9393
* @param side The side of the object the instance is associated with.
94-
* @param nbt A tag holding the data. Must not be null, as doesn't make sense to call this function with nothing to read...
94+
* @param nbt A {@link Tag} holding the data. Must not be null, as doesn't make sense to call this function with nothing to read...
9595
*/
9696
void readNBT(Capability<T> capability, T instance, Direction side, Tag nbt);
9797
}

patchwork-capabilities/src/main/java/net/minecraftforge/common/capabilities/CapabilityDispatcher.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
/**
4040
* A high-speed implementation of a {@link Capability} delegator.
4141
* This is used to wrap the results of the {@link net.minecraftforge.event.AttachCapabilitiesEvent}.
42-
* It is HIGHLY recommended that you DO NOT use this approach unless
42+
*
43+
* <p>It is HIGHLY recommended that you DO NOT use this approach unless
4344
* you MUST delegate to multiple providers instead just implementing
4445
* your handlers using normal if statements.
4546
*
@@ -59,34 +60,34 @@ public CapabilityDispatcher(Map<Identifier, ICapabilityProvider> providers, List
5960

6061
@SuppressWarnings("unchecked")
6162
public CapabilityDispatcher(Map<Identifier, ICapabilityProvider> providers, List<Runnable> listeners, @Nullable ICapabilityProvider parent) {
62-
List<ICapabilityProvider> lstCaps = Lists.newArrayList();
63-
List<INBTSerializable<Tag>> lstWriters = Lists.newArrayList();
64-
List<String> lstNames = Lists.newArrayList();
65-
this.listeners = listeners;
63+
List<ICapabilityProvider> capabilities = Lists.newArrayList();
64+
List<INBTSerializable<Tag>> writers = Lists.newArrayList();
65+
List<String> names = Lists.newArrayList();
6666

6767
// Parents go first!
6868
if (parent != null) {
69-
lstCaps.add(parent);
69+
capabilities.add(parent);
7070

7171
if (parent instanceof INBTSerializable) {
72-
lstWriters.add((INBTSerializable<Tag>) parent);
73-
lstNames.add("Parent");
72+
writers.add((INBTSerializable<Tag>) parent);
73+
names.add("Parent");
7474
}
7575
}
7676

7777
for (Map.Entry<Identifier, ICapabilityProvider> entry : providers.entrySet()) {
7878
ICapabilityProvider prov = entry.getValue();
79-
lstCaps.add(prov);
79+
capabilities.add(prov);
8080

8181
if (prov instanceof INBTSerializable) {
82-
lstWriters.add((INBTSerializable<Tag>) prov);
83-
lstNames.add(entry.getKey().toString());
82+
writers.add((INBTSerializable<Tag>) prov);
83+
names.add(entry.getKey().toString());
8484
}
8585
}
8686

87-
this.providers = lstCaps.toArray(new ICapabilityProvider[0]);
88-
writers = lstWriters.toArray(new INBTSerializable[0]);
89-
names = lstNames.toArray(new String[0]);
87+
this.listeners = listeners;
88+
this.providers = capabilities.toArray(new ICapabilityProvider[0]);
89+
this.writers = writers.toArray(new INBTSerializable[0]);
90+
this.names = names.toArray(new String[0]);
9091
}
9192

9293
@Nonnull
@@ -144,8 +145,9 @@ public void deserializeNBT(CompoundTag tag) {
144145
// Called from ItemStack to compare equality.
145146
// Only compares serializable caps.
146147
public boolean areCompatible(@Nullable CapabilityDispatcher other) {
148+
// Do some checks before costly NBT serialization and comparisons
147149
if (other == null) {
148-
return this.writers.length == 0; // Done this way so we can do some pre-checks before doing the costly NBT serialization and compare
150+
return this.writers.length == 0;
149151
}
150152

151153
if (this.writers.length == 0) {

patchwork-capabilities/src/main/java/net/minecraftforge/common/capabilities/CapabilityInject.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import java.lang.annotation.Target;
2626

2727
/**
28-
* When placed on a FIELD, the field will be set to an
29-
* instance of Capability once that capability is registered.
28+
* When placed on a field, the field will be set to an
29+
* instance of {@link Capability} once that capability is registered.
3030
* That field must be static and be able to hold a instance
3131
* of 'Capability'
3232
*
@@ -36,7 +36,7 @@
3636
* private static final Capability&lt;IExampleCapability&gt; TEST_CAP = null;
3737
* </blockquote>
3838
*
39-
* <p>When placed on a METHOD, the method will be invoked once the
39+
* <p>When placed on a method, the method will be invoked once the
4040
* capability is registered. This allows you to have a 'enable features'
4141
* callback. It MUST have one parameter of type 'Capability;
4242
*
@@ -46,7 +46,7 @@
4646
* private static void capRegistered(Capability&lt;IExampleCapability&gt; cap) {}
4747
* </blockquote>
4848
*
49-
* <b>Warning</b>: Capability injections are run in the thread that the capablity is registered.
49+
* <b>Warning</b>: Capability injections are run in the thread that the capability is registered.
5050
* Due to parallel mod loading, this can potentially be off of the main thread.
5151
*/
5252
@Retention(RetentionPolicy.RUNTIME)

patchwork-capabilities/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public enum CapabilityManager {
4040
private final Map<String, Capability<?>> providers = new HashMap<>();
4141

4242
/**
43-
* Registers a capability to be consumed by others.
43+
* Registers a {@link Capability} to be consumed by others.
4444
* APIs who define the capability should call this.
4545
* To retrieve the Capability instance, use the @CapabilityInject annotation.
4646
* This method is safe to call during parallel mod loading.

patchwork-capabilities/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public interface ICapabilityProvider {
3030
/**
3131
* Retrieves the {@link LazyOptional optional} handler for the capability requested on the specific side.
3232
* The return value <strong>CAN</strong> be the same for multiple faces.
33-
* Modders are encouraged to cache this value, using the listener capabilities of the optional to
33+
*
34+
* <p>Modders are encouraged to cache this value, using the listener capabilities of the optional to
3435
* be notified if the requested capability get lost.
3536
*
3637
* @param capability The {@link Capability capability} to check

patchwork-capabilities/src/main/java/net/minecraftforge/common/util/INBTSerializable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* An interface designed to unify various things in the Minecraft
26-
* code base that can be serialized to and from a NBT tag.
26+
* code base that can be serialized to and from an {@link Tag NBT tag}
2727
*/
2828
public interface INBTSerializable<T extends Tag> {
2929
T serializeNBT();

patchwork-capabilities/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
import net.minecraft.util.Identifier;
3232

3333
/**
34-
* Fired whenever an object with Capabilities support (currently {@link net.minecraft.block.entity.BlockEntity block entities}, {@link net.minecraft.item.Item items}, and {@link javax.swing.text.html.parser.Entity entities})
34+
* Fired whenever an object with Capabilities support (currently {@link net.minecraft.block.entity.BlockEntity block entities}, {@link net.minecraft.item.ItemStack items}, {@link net.minecraft.entity.Entity entities}, {@link net.minecraft.world.World worlds} and {@link net.minecraft.world.chunk.WorldChunk chunks})
3535
* is created. Allowing for the attachment of arbitrary capability providers.
3636
*
3737
* <p>Please note that as this is fired for ALL object creations efficient code is recommended.
3838
* And if possible use one of the sub-classes to filter your intended objects.
3939
*/
4040
public class AttachCapabilitiesEvent<T> extends GenericEvent<T> {
41-
private final T obj;
42-
private final Map<Identifier, ICapabilityProvider> caps = Maps.newLinkedHashMap();
43-
private final Map<Identifier, ICapabilityProvider> view = Collections.unmodifiableMap(caps);
41+
private final T object;
42+
private final Map<Identifier, ICapabilityProvider> capabilities = Maps.newLinkedHashMap();
43+
private final Map<Identifier, ICapabilityProvider> view = Collections.unmodifiableMap(capabilities);
4444
private final List<Runnable> listeners = Lists.newArrayList();
4545
private final List<Runnable> listenersView = Collections.unmodifiableList(listeners);
4646

@@ -49,32 +49,33 @@ public AttachCapabilitiesEvent() {
4949
this(null, null);
5050
}
5151

52-
public AttachCapabilitiesEvent(Class<T> type, T obj) {
52+
public AttachCapabilitiesEvent(Class<T> type, T object) {
5353
super(type);
54-
this.obj = obj;
54+
this.object = object;
5555
}
5656

5757
/**
58-
* Retrieves the object that is being created, Not much state is set.
58+
* Retrieves the object that is being created.<br>
59+
* <b>Note:</b> Object creation is still incomplete at this point
5960
*/
6061
public T getObject() {
61-
return this.obj;
62+
return this.object;
6263
}
6364

6465
/**
65-
* Adds a capability to be attached to this object.
66+
* Adds a {@link net.minecraftforge.common.capabilities.Capability} to be attached to this object.
6667
* Keys MUST be unique, it is suggested that you set the domain to your mod ID.
67-
* If the capability is an instance of INBTSerializable, this key will be used when serializing this capability.
68+
* If the capability is an instance of {@link net.minecraftforge.common.util.INBTSerializable}, this key will be used when serializing this capability.
6869
*
6970
* @param key The name of owner of this capability provider.
70-
* @param cap The capability provider
71+
* @param cap The {@link ICapabilityProvider capability provider}
7172
*/
7273
public void addCapability(Identifier key, ICapabilityProvider cap) {
73-
if (caps.containsKey(key)) {
74+
if (capabilities.containsKey(key)) {
7475
throw new IllegalStateException("Duplicate Capability Key: " + key + " " + cap);
7576
}
7677

77-
this.caps.put(key, cap);
78+
this.capabilities.put(key, cap);
7879
}
7980

8081
/**

0 commit comments

Comments
 (0)