Skip to content

Commit 152a6ac

Browse files
committed
more work on DisplayEntities
more stuf
1 parent 1098194 commit 152a6ac

File tree

8 files changed

+233
-3
lines changed

8 files changed

+233
-3
lines changed

src/main/java/org/spongepowered/api/data/Keys.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
import org.spongepowered.api.entity.FallingBlock;
114114
import org.spongepowered.api.entity.Item;
115115
import org.spongepowered.api.entity.ai.goal.GoalExecutorTypes;
116+
import org.spongepowered.api.entity.display.BillboardType;
117+
import org.spongepowered.api.entity.display.DisplayEntity;
118+
import org.spongepowered.api.entity.display.ItemDisplayType;
119+
import org.spongepowered.api.entity.display.TextDisplay;
116120
import org.spongepowered.api.entity.explosive.EndCrystal;
117121
import org.spongepowered.api.entity.explosive.Explosive;
118122
import org.spongepowered.api.entity.explosive.fused.FusedExplosive;
@@ -477,6 +481,11 @@ public final class Keys {
477481
*/
478482
public static final Key<Value<Boolean>> BEDS_USABLE = Keys.key(ResourceKey.sponge("beds_usable"), Boolean.class);
479483

484+
/**
485+
* The {@link BillboardType} of a {@link DisplayEntity}.
486+
*/
487+
public static final Key<Value<BillboardType>> BILLBOARD_TYPE = Keys.key(ResourceKey.sponge("billboard_type"), BillboardType.class);
488+
480489
/**
481490
* The default temperature of a {@link Biome} or the biome at a specific {@link ServerLocation}.
482491
* For the exact block temperature see {@link #BLOCK_TEMPERATURE}.
@@ -810,6 +819,7 @@ public final class Keys {
810819
* <p>On an {@link ItemStack}, this represents the {@link Keys#CUSTOM_NAME} or if not set the {@link ItemType}s translation.
811820
* <p>On a {@link BlockEntity}, this usually represents the name displayed in its {@link org.spongepowered.api.item.inventory.Container}
812821
* <p>On a {@link WorldTemplate} or {@link ServerWorldProperties}, this represents the display name of the corresponding {@link ServerWorld}</p>
822+
* <p>On a {@link TextDisplay} this is modifiable.</p>
813823
*/
814824
public static final Key<Value<Component>> DISPLAY_NAME = Keys.key(ResourceKey.sponge("display_name"), Component.class);
815825

@@ -1954,6 +1964,11 @@ public final class Keys {
19541964
*/
19551965
public static final Key<Value<Boolean>> IS_WET = Keys.key(ResourceKey.sponge("is_wet"), Boolean.class);
19561966

1967+
/**
1968+
* The {@link ItemDisplayType display type} of a {@link org.spongepowered.api.entity.display.ItemDisplay}.
1969+
*/
1970+
public static final Key<Value<ItemDisplayType>> ITEM_DISPLAY_TYPE = Keys.key(ResourceKey.sponge("item_display_type"), ItemDisplayType.class);
1971+
19571972
/**
19581973
* The durability of an {@link ItemStack}. {@link #MAX_DURABILITY}
19591974
*/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.entity.display;
26+
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
29+
30+
@CatalogedBy(BillboardTypes.class)
31+
public interface BillboardType extends DefaultedRegistryValue {
32+
33+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.entity.display;
26+
27+
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
29+
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
31+
import org.spongepowered.api.registry.RegistryKey;
32+
import org.spongepowered.api.registry.RegistryScope;
33+
import org.spongepowered.api.registry.RegistryScopes;
34+
import org.spongepowered.api.registry.RegistryTypes;
35+
36+
@RegistryScopes(scopes = RegistryScope.GAME)
37+
public final class BillboardTypes {
38+
39+
// @formatter:off
40+
// SORTFIELDS:ON
41+
public static final DefaultedRegistryReference<BillboardType> CENTER = BillboardTypes.key(ResourceKey.sponge("center"));
42+
43+
public static final DefaultedRegistryReference<BillboardType> FIXED = BillboardTypes.key(ResourceKey.sponge("fixed"));
44+
45+
public static final DefaultedRegistryReference<BillboardType> HORIZONTAL = BillboardTypes.key(ResourceKey.sponge("horizontal"));
46+
47+
public static final DefaultedRegistryReference<BillboardType> VERTICAL = BillboardTypes.key(ResourceKey.sponge("vertical"));
48+
49+
// SORTFIELDS:OFF
50+
// @formatter:on
51+
private BillboardTypes() {
52+
}
53+
54+
public static Registry<BillboardType> registry() {
55+
return Sponge.game().registry(RegistryTypes.BILLBOARD_TYPE);
56+
}
57+
58+
private static DefaultedRegistryReference<BillboardType> key(final ResourceKey location) {
59+
return RegistryKey.of(RegistryTypes.BILLBOARD_TYPE, location).asDefaultedReference(Sponge::game);
60+
}
61+
}

src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.spongepowered.api.entity.display;
2626

27+
import org.spongepowered.api.data.Keys;
2728
import org.spongepowered.api.entity.Entity;
2829

2930
public interface DisplayEntity extends Entity {
@@ -32,9 +33,9 @@ public interface DisplayEntity extends Entity {
3233

3334
// TODO interpolation?
3435

35-
// default BillboardType billboardType() {
36-
// return this.require(Keys.BILLBOARD_TYPE);
37-
// }
36+
default BillboardType billboardType() {
37+
return this.require(Keys.BILLBOARD_TYPE);
38+
}
3839
//
3940
// default int skyLight() {
4041
// // TODO impl

src/main/java/org/spongepowered/api/entity/display/ItemDisplay.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,13 @@ default ItemStackSnapshot displayedItem() {
4040
return this.require(Keys.ITEM_STACK_SNAPSHOT);
4141
}
4242

43+
/**
44+
* Returns the {@link ItemDisplayType display type}.
45+
*
46+
* @return the display type
47+
*/
48+
default ItemDisplayType displayType() {
49+
return this.require(Keys.ITEM_DISPLAY_TYPE);
50+
}
51+
4352
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.entity.display;
26+
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
29+
30+
@CatalogedBy(ItemDisplayTypes.class)
31+
public interface ItemDisplayType extends DefaultedRegistryValue {
32+
33+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.entity.display;
26+
27+
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
29+
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
31+
import org.spongepowered.api.registry.RegistryKey;
32+
import org.spongepowered.api.registry.RegistryScope;
33+
import org.spongepowered.api.registry.RegistryScopes;
34+
import org.spongepowered.api.registry.RegistryTypes;
35+
36+
@SuppressWarnings("unused")
37+
@RegistryScopes(scopes = RegistryScope.GAME)
38+
public final class ItemDisplayTypes {
39+
40+
// @formatter:off
41+
// SORTFIELDS:OFF
42+
public static final DefaultedRegistryReference<ItemDisplayType> FIRSTPERSON_LEFTHAND = ItemDisplayTypes.key(ResourceKey.sponge("firstperson_lefthand"));
43+
44+
public static final DefaultedRegistryReference<ItemDisplayType> FIRSTPERSON_RIGHTHAND = ItemDisplayTypes.key(ResourceKey.sponge("firstperson_righthand"));
45+
46+
public static final DefaultedRegistryReference<ItemDisplayType> FIXED = ItemDisplayTypes.key(ResourceKey.sponge("fixed"));
47+
48+
public static final DefaultedRegistryReference<ItemDisplayType> GROUND = ItemDisplayTypes.key(ResourceKey.sponge("ground"));
49+
50+
public static final DefaultedRegistryReference<ItemDisplayType> GUI = ItemDisplayTypes.key(ResourceKey.sponge("gui"));
51+
52+
public static final DefaultedRegistryReference<ItemDisplayType> HEAD = ItemDisplayTypes.key(ResourceKey.sponge("head"));
53+
54+
public static final DefaultedRegistryReference<ItemDisplayType> NONE = ItemDisplayTypes.key(ResourceKey.sponge("none"));
55+
56+
public static final DefaultedRegistryReference<ItemDisplayType> THIRDPERSON_LEFTHAND = ItemDisplayTypes.key(ResourceKey.sponge("thirdperson_lefthand"));
57+
58+
public static final DefaultedRegistryReference<ItemDisplayType> THIRDPERSON_RIGHTHAND = ItemDisplayTypes.key(ResourceKey.sponge("thirdperson_righthand"));
59+
60+
// SORTFIELDS:OFF
61+
// @formatter:on
62+
private ItemDisplayTypes() {
63+
}
64+
65+
public static Registry<ItemDisplayType> registry() {
66+
return Sponge.game().registry(RegistryTypes.ITEM_DISPLAY_TYPE);
67+
}
68+
69+
private static DefaultedRegistryReference<ItemDisplayType> key(final ResourceKey location) {
70+
return RegistryKey.of(RegistryTypes.ITEM_DISPLAY_TYPE, location).asDefaultedReference(Sponge::game);
71+
}
72+
}

src/main/java/org/spongepowered/api/registry/RegistryTypes.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
import org.spongepowered.api.entity.ai.goal.GoalType;
104104
import org.spongepowered.api.entity.attribute.AttributeOperation;
105105
import org.spongepowered.api.entity.attribute.type.AttributeType;
106+
import org.spongepowered.api.entity.display.BillboardType;
107+
import org.spongepowered.api.entity.display.ItemDisplayType;
106108
import org.spongepowered.api.entity.living.monster.boss.dragon.phase.DragonPhaseType;
107109
import org.spongepowered.api.entity.living.player.chat.ChatVisibility;
108110
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
@@ -287,6 +289,8 @@ public final class RegistryTypes {
287289

288290
public static final DefaultedRegistryType<BellAttachmentType> BELL_ATTACHMENT_TYPE = RegistryTypes.spongeKeyInGame("bell_attachment_type");
289291

292+
public static final DefaultedRegistryType<BillboardType> BILLBOARD_TYPE = RegistryTypes.spongeKeyInGame("billboard_type");
293+
290294
public static final DefaultedRegistryType<BoatType> BOAT_TYPE = RegistryTypes.spongeKeyInGame("boat_type");
291295

292296
public static final DefaultedRegistryType<BodyPart> BODY_PART = RegistryTypes.spongeKeyInGame("body_part");
@@ -381,6 +385,8 @@ public final class RegistryTypes {
381385

382386
public static final DefaultedRegistryType<ItemTier> ITEM_TIER = RegistryTypes.spongeKeyInGame("item_tier");
383387

388+
public static final DefaultedRegistryType<ItemDisplayType> ITEM_DISPLAY_TYPE = RegistryTypes.spongeKeyInGame("item_display_type");
389+
384390
public static final DefaultedRegistryType<JigsawBlockOrientation> JIGSAW_BLOCK_ORIENTATION = RegistryTypes.spongeKeyInGame("jigsaw_block_orientation");
385391

386392
public static final DefaultedRegistryType<LightType> LIGHT_TYPE = RegistryTypes.spongeKeyInGame("light_type");

0 commit comments

Comments
 (0)