Skip to content

Commit

Permalink
Add EntityCategory to API
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
  • Loading branch information
gabizou committed Sep 15, 2021
1 parent cc3c29f commit 007abba
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.animal.Fox;
import net.minecraft.world.entity.animal.MushroomCow;
Expand Down Expand Up @@ -206,6 +207,7 @@ private void loadEnumRegistries() {
this.knownName(RegistryTypes.BANNER_PATTERN_SHAPE, BannerPattern.values(), b -> ((BannerPatternAccessor) (Object) b).accessor$filename());
this.automaticName(RegistryTypes.TROPICAL_FISH_SHAPE, TropicalFish.Pattern.values());
this.automaticName(RegistryTypes.HEIGHT_TYPE, Heightmap.Types.values());
this.knownName(RegistryTypes.ENTITY_CATEGORY, MobCategory.values(), MobCategory::getName);
}

private static RegistryLoader<Criterion> criterion() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.mixin.api.minecraft.world.entity;

import net.minecraft.world.entity.MobCategory;
import org.spongepowered.api.entity.EntityCategory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(MobCategory.class)
public abstract class MobCategoryMixin_API implements EntityCategory {

@Shadow public abstract boolean shadow$isFriendly();
@Shadow public abstract int shadow$getDespawnDistance();

@Override
public boolean friendly() {
return this.shadow$isFriendly();
}

@Override
public int despawnDistance() {
return this.shadow$getDespawnDistance();
}
}
3 changes: 2 additions & 1 deletion src/mixins/resources/mixins.sponge.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"minecraft.world.entity.HumanoidArmMixin_API",
"minecraft.world.entity.LightningBoltMixin_API",
"minecraft.world.entity.LivingEntityMixin_API",
"minecraft.world.entity.MobCategoryMixin_API",
"minecraft.world.entity.MobMixin_API",
"minecraft.world.entity.PathfinderMobMixin_API",
"minecraft.world.entity.TamableAnimalMixin_API",
Expand Down Expand Up @@ -182,8 +183,8 @@
"minecraft.world.entity.monster.PatrollingMonsterMixin_API",
"minecraft.world.entity.monster.Phantom_AttackPhaseMixin_API",
"minecraft.world.entity.monster.PhantomMixin_API",
"minecraft.world.entity.monster.PiglinMixin_API",
"minecraft.world.entity.monster.PiglinBruteMixin_API",
"minecraft.world.entity.monster.PiglinMixin_API",
"minecraft.world.entity.monster.PillagerMixin_API",
"minecraft.world.entity.monster.RangedAttackMobMixin_API",
"minecraft.world.entity.monster.RavagerMixin_API",
Expand Down

0 comments on commit 007abba

Please sign in to comment.