diff --git a/SpongeAPI b/SpongeAPI index 529eaa9f17d..f695db1d1c5 160000 --- a/SpongeAPI +++ b/SpongeAPI @@ -1 +1 @@ -Subproject commit 529eaa9f17db8589abafa1db3b565efc2276aa84 +Subproject commit f695db1d1c59306d75c1ebf93e9c021335905e09 diff --git a/src/accessors/java/org/spongepowered/common/accessor/world/entity/InteractionAccessor.java b/src/accessors/java/org/spongepowered/common/accessor/world/entity/InteractionAccessor.java new file mode 100644 index 00000000000..f890218652e --- /dev/null +++ b/src/accessors/java/org/spongepowered/common/accessor/world/entity/InteractionAccessor.java @@ -0,0 +1,41 @@ +/* + * This file is part of Sponge, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.common.accessor.world.entity; + +import net.minecraft.world.entity.Interaction; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(Interaction.class) +public interface InteractionAccessor { + + @Invoker("getWidth") float invoker$getWidth(); + + @Invoker("getHeight") float invoker$getHeight(); + + @Invoker("setWidth") void invoker$setWidth(float width); + + @Invoker("setHeight") void invoker$setHeight(float height); +} diff --git a/src/accessors/resources/mixins.sponge.accessors.json b/src/accessors/resources/mixins.sponge.accessors.json index 24d57dc1f66..720308e5176 100644 --- a/src/accessors/resources/mixins.sponge.accessors.json +++ b/src/accessors/resources/mixins.sponge.accessors.json @@ -66,6 +66,7 @@ "world.entity.EntityAccessor", "world.entity.EntityTypeAccessor", "world.entity.ExperienceOrbAccessor", + "world.entity.InteractionAccessor", "world.entity.LightningBoltAccessor", "world.entity.LivingEntityAccessor", "world.entity.MobAccessor", diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java b/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java index 5e62f6e798b..69937fac579 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java @@ -249,6 +249,10 @@ public static void register(final DataProviderRegistrator registrator) { ((PortalProcessorBridge)h.portalProcess).bridge$init(h.level()); }) .delete(h -> h.portalProcess = null) + .create(Keys.BOUNDING_BOX_BASE_SIZE) + .get(h -> (double) h.getBbWidth()) + .create(Keys.BOUNDING_BOX_HEIGHT) + .get(h -> (double) h.getBbHeight()) .asMutable(EntityMaxAirBridge.class) .create(Keys.MAX_AIR) .get(EntityMaxAirBridge::bridge$getMaxAir) diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/EntityDataProviders.java b/src/main/java/org/spongepowered/common/data/provider/entity/EntityDataProviders.java index 29910a3ecac..39a1ea8b74a 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/EntityDataProviders.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/EntityDataProviders.java @@ -75,6 +75,7 @@ public void registerProviders() { HorseData.register(this.registrator); HumanData.register(this.registrator); IdentifiableData.register(this.registrator); + InteractionData.register(this.registrator); InvulnerableData.register(this.registrator); IronGolemData.register(this.registrator); ItemData.register(this.registrator); diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/InteractionData.java b/src/main/java/org/spongepowered/common/data/provider/entity/InteractionData.java new file mode 100644 index 00000000000..363bcbacff2 --- /dev/null +++ b/src/main/java/org/spongepowered/common/data/provider/entity/InteractionData.java @@ -0,0 +1,49 @@ +/* + * This file is part of Sponge, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.common.data.provider.entity; + +import org.spongepowered.api.data.Keys; +import org.spongepowered.common.accessor.world.entity.InteractionAccessor; +import org.spongepowered.common.data.provider.DataProviderRegistrator; + +public final class InteractionData { + + private InteractionData() { + } + + // @formatter:off + public static void register(final DataProviderRegistrator registrator) { + registrator + .asMutable(InteractionAccessor.class) + .create(Keys.BOUNDING_BOX_BASE_SIZE) + .get(h -> (double) h.invoker$getWidth()) + .set((h, v) -> h.invoker$setWidth(v.floatValue())) + .create(Keys.BOUNDING_BOX_HEIGHT) + .get(h -> (double) h.invoker$getHeight()) + .set((h, v) -> h.invoker$setHeight(v.floatValue())) + ; + } + // @formatter:on +}