Skip to content

Commit e9f0591

Browse files
committed
Rename Component to CardinalComponent
1 parent 65ad81e commit e9f0591

53 files changed

Lines changed: 259 additions & 234 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,10 @@
1-
/*
2-
* Cardinal-Components-API
3-
* Copyright (C) 2019-2025 Ladysnake
4-
*
5-
* Permission is hereby granted, free of charge, to any person obtaining a copy
6-
* of this software and associated documentation files (the "Software"), to deal
7-
* in the Software without restriction, including without limitation the rights
8-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
* copies of the Software, and to permit persons to whom the Software is
10-
* furnished to do so, subject to the following conditions:
11-
*
12-
* The above copyright notice and this permission notice shall be included in all
13-
* copies or substantial portions of the Software.
14-
*
15-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19-
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20-
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21-
* OR OTHER DEALINGS IN THE SOFTWARE.
22-
*/
231
package org.ladysnake.cca.api.v3.component;
242

25-
import net.minecraft.nbt.CompoundTag;
26-
import net.minecraft.world.level.storage.ValueInput;
27-
import net.minecraft.world.level.storage.ValueOutput;
28-
import org.jetbrains.annotations.Contract;
3+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
294

305
/**
31-
* The base interface for components.
32-
*
33-
* @since 2.7.0
6+
* @deprecated replâce with {@link org.ladysnake.cca.api.v8.component.CardinalComponent}
7+
* (renamed because of collisions with Minecraft's other components)
348
*/
35-
public interface Component {
36-
37-
/**
38-
* Reads this component's properties from a {@link CompoundTag}.
39-
*
40-
* @param readView a {@code NbtCompound} on which this component's serializable data has been written
41-
* @implNote implementations should not assert that the data written on the tag corresponds to any
42-
* specific scheme, as saved data is susceptible to external tempering, and may come from an earlier
43-
* version.
44-
*/
45-
@Contract(mutates = "this")
46-
void readData(ValueInput readView);
47-
48-
/**
49-
* Writes this component's properties to a {@link CompoundTag}.
50-
*
51-
* @param writeView a {@code NbtCompound} on which to write this component's serializable data
52-
*/
53-
@Contract(mutates = "param1")
54-
void writeData(ValueOutput writeView);
55-
}
9+
@Deprecated(since = "8.0.0")
10+
public interface Component extends CardinalComponent { }

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentAccess.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent;
2626
import org.ladysnake.cca.api.v3.component.sync.ComponentPacketWriter;
2727
import org.ladysnake.cca.api.v3.component.sync.PlayerSyncPredicate;
28+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2829

2930
import java.util.NoSuchElementException;
3031

@@ -45,7 +46,7 @@ public interface ComponentAccess {
4546
* @throws NullPointerException if {@code key} is null
4647
* @throws NoSuchElementException if this provider does not provide the desired type of component
4748
*/
48-
default <C extends Component> C getComponent(ComponentKey<C> key) {
49+
default <C extends CardinalComponent> C getComponent(ComponentKey<C> key) {
4950
return key.get(this.asComponentProvider());
5051
}
5152

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentContainer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
package org.ladysnake.cca.api.v3.component;
2424

2525
import net.fabricmc.api.EnvType;
26-
import net.minecraft.nbt.CompoundTag;
2726
import net.minecraft.core.HolderLookup;
27+
import net.minecraft.nbt.CompoundTag;
2828
import net.minecraft.world.level.storage.ValueInput;
2929
import net.minecraft.world.level.storage.ValueOutput;
3030
import org.jetbrains.annotations.ApiStatus;
@@ -39,6 +39,7 @@
3939
import org.ladysnake.cca.api.v3.component.tick.ServerTickingComponent;
4040
import org.ladysnake.cca.api.v3.util.CheckEnvironment;
4141
import org.ladysnake.cca.api.v3.util.NbtSerializable;
42+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
4243
import org.ladysnake.cca.internal.base.GenericContainerBuilder;
4344
import org.ladysnake.cca.internal.base.asm.AsmGeneratedCallback;
4445
import org.ladysnake.cca.internal.base.asm.StaticComponentPluginBase;
@@ -101,7 +102,7 @@ public interface ComponentContainer extends NbtSerializable {
101102
*/
102103
@Nullable
103104
@ApiStatus.Experimental
104-
default ComponentKey<?> getKey(Component component) {
105+
default ComponentKey<?> getKey(CardinalComponent component) {
105106
for (ComponentKey<?> key : keys()) {
106107
if (key.getInternal(this) == component) {
107108
return key;
@@ -218,18 +219,18 @@ final class Builder<T> extends GenericContainerBuilder<ComponentFactory<T, ?>, F
218219
}
219220

220221
@Contract(mutates = "this")
221-
public <C extends Component> Builder<T> component(ComponentKey<C> key, ComponentFactory<T, ? extends C> factory) {
222+
public <C extends CardinalComponent> Builder<T> component(ComponentKey<C> key, ComponentFactory<T, ? extends C> factory) {
222223
return this.component(key, key.getComponentClass(), factory);
223224
}
224225

225226
@Contract(mutates = "this")
226-
public <C extends Component> Builder<T> component(ComponentKey<? super C> key, Class<C> implClass, ComponentFactory<T, ? extends C> factory) {
227+
public <C extends CardinalComponent> Builder<T> component(ComponentKey<? super C> key, Class<C> implClass, ComponentFactory<T, ? extends C> factory) {
227228
return this.component(key, implClass, factory, Set.of());
228229
}
229230

230231
@ApiStatus.Experimental
231232
@Contract(mutates = "this")
232-
public <C extends Component> Builder<T> component(ComponentKey<? super C> key, Class<C> implClass, ComponentFactory<T, ? extends C> factory, Set<ComponentKey<?>> dependencies) {
233+
public <C extends CardinalComponent> Builder<T> component(ComponentKey<? super C> key, Class<C> implClass, ComponentFactory<T, ? extends C> factory, Set<ComponentKey<?>> dependencies) {
233234
super.component(key, implClass, factory, dependencies);
234235
return this;
235236
}

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,25 @@
2323
package org.ladysnake.cca.api.v3.component;
2424

2525
import org.jetbrains.annotations.Contract;
26+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2627

2728
/**
2829
* A single-arg component factory.
2930
*
30-
* <p>When invoked, the factory must return a {@link Component} of the right type.
31+
* <p>When invoked, the factory must return a {@link CardinalComponent} of the right type.
3132
*
3233
* @since 3.0.0
3334
*/
3435
@FunctionalInterface
35-
public interface ComponentFactory<T, C extends Component> {
36+
public interface ComponentFactory<T, C extends CardinalComponent> {
3637
/**
37-
* Instantiates a {@link Component} for the given provider.
38+
* Instantiates a {@link CardinalComponent} for the given provider.
3839
*
3940
* <p>The component returned by this method will be available
4041
* on the provider as soon as all component factories have been invoked.
4142
*
4243
* @param t the factory argument
43-
* @return a new {@link Component}
44+
* @return a new {@link CardinalComponent}
4445
*/
4546
@Contract(value = "_ -> new", pure = true)
4647
C createComponent(T t);

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentKey.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent;
3737
import org.ladysnake.cca.api.v3.component.sync.ComponentPacketWriter;
3838
import org.ladysnake.cca.api.v3.component.sync.PlayerSyncPredicate;
39+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
3940
import org.ladysnake.cca.internal.base.ComponentsInternals;
4041
import org.ladysnake.cca.internal.base.asm.CcaBootstrap;
4142

@@ -46,15 +47,15 @@
4647
import static net.minecraft.network.chat.Component.literal;
4748

4849
/**
49-
* A key for retrieving {@link Component} instances from component providers.
50+
* A key for retrieving {@link CardinalComponent} instances from component providers.
5051
*
5152
* <p> A {@link ComponentKey} must be registered for every component type through
5253
* {@link ComponentRegistryV3#getOrCreate(Identifier, Class)}.
5354
*
5455
* @see ComponentRegistryV3
5556
*/
5657
@ApiStatus.NonExtendable
57-
public abstract class ComponentKey<C extends Component> {
58+
public abstract class ComponentKey<C extends CardinalComponent> {
5859

5960
public final Identifier getId() {
6061
return this.id;

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentRegistry.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import net.minecraft.resources.Identifier;
2626
import org.jetbrains.annotations.ApiStatus;
2727
import org.jetbrains.annotations.Contract;
28+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2829
import org.ladysnake.cca.internal.base.ComponentRegistryImpl;
2930

3031
import javax.annotation.Nullable;
@@ -36,7 +37,7 @@
3637
* <p> A {@code ComponentRegistry} is used for registering components and obtaining
3738
* {@link ComponentKey} instances serving as keys for those components.
3839
*
39-
* @see Component
40+
* @see CardinalComponent
4041
* @see ComponentKey
4142
* @since 2.7.0
4243
*/
@@ -66,13 +67,13 @@ public final class ComponentRegistry {
6667
* @param componentId a unique identifier for the registered component type
6768
* @param componentClass the interface or class of which to obtain a {@link ComponentKey}
6869
* @return a shared instance of {@link ComponentKey}
69-
* @throws IllegalArgumentException if {@code componentClass} does not extend {@link Component}
70+
* @throws IllegalArgumentException if {@code componentClass} does not extend {@link CardinalComponent}
7071
* @throws IllegalStateException if a different component class has been registered with the same {@code componentId},
7172
* or if {@code componentId} has not been statically declared as a custom data value.
7273
* @apiNote It is recommended that {@code componentClass} be an interface, so that other
7374
* mods can interact with a well-defined API rather than directly accessing internals.
7475
*/
75-
public static <C extends Component> ComponentKey<C> getOrCreate(Identifier componentId, Class<C> componentClass) {
76+
public static <C extends CardinalComponent> ComponentKey<C> getOrCreate(Identifier componentId, Class<C> componentClass) {
7677
return ComponentRegistryV3.INSTANCE.getOrCreate(componentId, componentClass);
7778
}
7879

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentRegistryV3.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import net.minecraft.resources.Identifier;
2626
import org.jetbrains.annotations.ApiStatus;
2727
import org.jetbrains.annotations.Contract;
28+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2829
import org.ladysnake.cca.internal.base.ComponentRegistryImpl;
2930

3031
import javax.annotation.Nullable;
@@ -37,7 +38,7 @@
3738
* {@link ComponentKey} instances serving as keys for those components.
3839
*
3940
* @see ComponentKey
40-
* @see Component
41+
* @see CardinalComponent
4142
* @see ComponentRegistry
4243
* @since 2.5.0
4344
*/
@@ -72,13 +73,13 @@ public interface ComponentRegistryV3 {
7273
* @param componentId a unique identifier for the registered component type
7374
* @param componentClass the interface or class of which to obtain a {@link ComponentKey}
7475
* @return a shared instance of {@link ComponentKey}
75-
* @throws IllegalArgumentException if {@code componentClass} does not extend {@link Component}
76+
* @throws IllegalArgumentException if {@code componentClass} does not extend {@link CardinalComponent}
7677
* @throws IllegalStateException if a different component class has been registered with the same {@code componentId},
7778
* or if {@code componentId} has not been statically declared as a custom data value.
7879
* @apiNote It is recommended that {@code componentClass} be an interface, so that other
7980
* mods can interact with a well-defined API rather than directly accessing internals.
8081
*/
81-
<C extends Component> ComponentKey<C> getOrCreate(Identifier componentId, Class<C> componentClass);
82+
<C extends CardinalComponent> ComponentKey<C> getOrCreate(Identifier componentId, Class<C> componentClass);
8283

8384
/**
8485
* Directly retrieves a ComponentKey using its id.

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/ComponentV3.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package org.ladysnake.cca.api.v3.component;
2424

2525
import net.minecraft.world.item.ItemStack;
26+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2627

2728
/**
2829
* The base interface for components.
@@ -33,6 +34,6 @@
3334
*
3435
* @since 2.5.0
3536
*/
36-
public interface ComponentV3 extends Component {
37+
public interface ComponentV3 extends CardinalComponent {
3738

3839
}

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/CopyableComponent.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@
2222
*/
2323
package org.ladysnake.cca.api.v3.component;
2424

25-
import net.minecraft.nbt.CompoundTag;
2625
import net.minecraft.core.HolderLookup;
26+
import net.minecraft.nbt.CompoundTag;
27+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2728

2829
/**
2930
* A component that can copy its data from another component of the same type.
3031
*
3132
* @param <C> the type of components that this component may copy
3233
* @since 2.3.0
3334
*/
34-
public interface CopyableComponent<C extends Component> extends Component {
35+
public interface CopyableComponent<C extends CardinalComponent> extends CardinalComponent {
3536
/**
3637
* Copies the data from {@code other} into {@code this}.
3738
*
38-
* @implSpec The default implementation {@linkplain Component#writeData(net.minecraft.world.level.storage.ValueOutput) serializes}
39-
* the component data to a {@link CompoundTag} and calls {@link Component#readData(net.minecraft.world.level.storage.ValueInput)}.
39+
* @implSpec The default implementation {@linkplain CardinalComponent#writeData(net.minecraft.world.level.storage.ValueOutput) serializes}
40+
* the component data to a {@link CompoundTag} and calls {@link CardinalComponent#readData(net.minecraft.world.level.storage.ValueInput)}.
4041
* @implNote The default implementation should generally be overridden.
4142
* The serialization done by the default implementation assumes NBT consistency
4243
* between implementations, and is generally slower than a direct copy.

cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/TransientComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
import net.minecraft.world.level.storage.ValueInput;
2626
import net.minecraft.world.level.storage.ValueOutput;
2727
import org.jetbrains.annotations.Nullable;
28+
import org.ladysnake.cca.api.v8.component.CardinalComponent;
2829

2930
/**
3031
* Utility interface for components that do not hold any data
3132
*/
32-
public interface TransientComponent extends Component {
33+
public interface TransientComponent extends CardinalComponent {
3334
@Override
3435
default void readData(ValueInput readView) {
3536
// Nothing to read

0 commit comments

Comments
 (0)