Skip to content

Commit

Permalink
Implement Keys.BOUNDING_BOX_BASE_SIZE and Keys.BOUNDING_BOX_HEIGHT
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Nov 24, 2024
1 parent 699df2e commit 2b74710
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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);
}
1 change: 1 addition & 0 deletions src/accessors/resources/mixins.sponge.accessors.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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
}

0 comments on commit 2b74710

Please sign in to comment.