From 59b2eba58633a5cc6df441322ed58c0e2bd3b3a8 Mon Sep 17 00:00:00 2001 From: i509vcb <30619168+i509VCB@users.noreply.github.com> Date: Sun, 5 Jan 2020 00:15:10 -0600 Subject: [PATCH] Implement all missing entities from 1.14 and remove old implementations of data values which override default methods. The real big one, add api$getVanillaValues to all entities and implement about 90% of the adding to Sets --- SpongeAPI | 2 +- .../entity/passive/FoxEntityAccessor.java | 46 ++++++ .../mcp/entity/AgeableEntityMixin_API.java | 41 +---- .../AreaEffectCloudEntityMixin_API.java | 150 +++--------------- .../mixin/api/mcp/entity/EntityMixin_API.java | 141 +++------------- .../api/mcp/entity/LivingEntityMixin_API.java | 18 +++ .../api/mcp/entity/MobEntityMixin_API.java | 20 ++- .../entity/boss/WitherEntityMixin_API.java | 76 ++------- .../dragon/EnderDragonEntityMixin_API.java | 29 ++-- .../effect/LightningBoltEntityMixin_API.java | 30 ++-- .../item/ArmorStandEntityMixin_API.java | 84 ++-------- .../mcp/entity/item/BoatEntityMixin_API.java | 82 ++-------- .../item/EnderCrystalEntityMixin_API.java | 21 +++ .../item/EnderPearlEntityMixin_API.java | 14 ++ .../item/ExperienceOrbEntityMixin_API.java | 33 +--- .../item/EyeOfEnderEntityMixin_API.java | 20 +-- .../item/FallingBlockEntityMixin_API.java | 18 +++ .../item/FireworkRocketEntityMixin_API.java | 65 ++------ .../entity/item/HangingEntityMixin_API.java | 27 +--- .../mcp/entity/item/ItemEntityMixin_API.java | 33 +--- .../entity/item/LeashKnotEntityMixin_API.java | 13 +- .../entity/item/PaintingEntityMixin_API.java | 28 ++-- .../mcp/entity/item/TNTEntityMixin_API.java | 63 ++------ .../AbstractMinecartEntityMixin_API.java | 65 ++------ .../ChestMinecartEntityMixin_API.java | 1 - .../minecart/ContainerMinecartMixin_API.java | 16 +- .../FurnaceMinecartEntityMixin_API.java | 19 ++- .../MinecartCommandBlockEntityMixin_API.java | 14 ++ .../SpawnerMinecartEntityMixin_API.java | 57 +++---- .../minecart/TNTMinecartEntityMixin_API.java | 34 ++-- .../AbstractVillagerEntityMixin_API.java | 14 ++ .../villager/VillagerEntityMixin_API.java | 45 +----- .../AbstractRaiderEntityMixin_API.java | 18 ++- .../entity/monster/BlazeEntityMixin_API.java | 22 ++- .../monster/CaveSpiderEntityMixin_API.java | 13 ++ .../monster/CreeperEntityMixin_API.java | 47 ++---- .../monster/DrownedEntityMixin_API.java | 34 ++++ .../monster/ElderGuardianEntityMixin_API.java | 34 ++++ .../monster/EndermanEntityMixin_API.java | 15 +- .../monster/EndermiteEntityMixin_API.java | 36 +---- .../entity/monster/EvokerEntityMixin_API.java | 12 ++ .../monster/GuardianEntityMixin_API.java | 27 +--- .../monster/PatrollerEntityMixin_API.java | 16 ++ .../monster/PhantomEntityMixin_API.java | 26 ++- .../monster/PillagerEntityMixin_API.java | 12 ++ .../monster/RavagerEntityMixin_API.java | 47 ++---- .../monster/ShulkerEntityMixin_API.java | 48 ++---- .../entity/monster/SlimeEntityMixin_API.java | 33 ++-- .../SpellcastingIllagerEntityMixin_API.java | 24 +-- .../entity/monster/SpiderEntityMixin_API.java | 14 +- .../monster/VindicatorEntityMixin_API.java | 19 +-- .../entity/monster/ZombieEntityMixin_API.java | 1 - .../monster/ZombiePigmanEntityMixin_API.java | 37 ++--- .../ZombieVillagerEntityMixin_API.java | 13 +- .../entity/passive/AnimalEntityMixin_API.java | 15 ++ .../entity/passive/CatEntityMixin_API.java | 56 +++++++ .../passive/ChickenEntityMixin_API.java | 12 ++ .../passive/DolphinEntityMixin_API.java | 47 ++++++ .../entity/passive/FoxEntityMixin_API.java | 25 ++- .../passive/IronGolemEntityMixin_API.java | 13 ++ .../passive/MooshroomEntityMixin_API.java | 12 ++ .../entity/passive/OcelotEntityMixin_API.java | 40 +---- .../entity/passive/PandaEntityMixin_API.java | 61 +++++++ .../entity/passive/ParrotEntityMixin_API.java | 32 ++-- .../entity/passive/PigEntityMixin_API.java | 27 +--- .../passive/PolarBearEntityMixin_API.java | 12 ++ .../entity/passive/RabbitEntityMixin_API.java | 31 +--- .../entity/passive/SheepEntityMixin_API.java | 32 +--- .../passive/TameableEntityMixin_API.java | 17 +- .../entity/passive/TurtleEntityMixin_API.java | 51 ++++++ .../entity/passive/WolfEntityMixin_API.java | 28 ++-- .../fish/AbstractFishEntityMixin_API.java | 35 ++++ .../AbstractGroupFishEntityMixin_API.java | 34 ++++ .../passive/fish/CodEntityMixin_API.java | 34 ++++ .../fish/PufferfishEntityMixin_API.java | 34 ++++ .../passive/fish/SalmonEntityMixin_API.java | 34 ++++ .../fish/TropicalFishEntityMixin_API.java | 48 ++++++ .../AbstractChestedHorseEntityMixin_API.java | 47 ++++++ ...java => AbstractHorseEntityMixin_API.java} | 7 +- .../passive/horse/DonkeyEntityMixin_API.java | 14 +- .../passive/horse/HorseEntityMixin_API.java | 20 ++- .../passive/horse/LlamaEntityMixin_API.java | 45 ++---- .../passive/horse/MuleEntityMixin_API.java | 14 +- .../horse/SkeletonHorseEntityMixin_API.java | 2 +- .../horse/TraderLlamaEntityMixin_API.java | 48 ++++++ .../horse/ZombieHorseEntityMixin_API.java | 2 +- .../entity/player/PlayerEntityMixin_API.java | 1 - .../player/ServerPlayerEntityMixin_API.java | 81 +++------- .../AbstractArrowEntityMixin_API.java | 49 ++---- .../AbstractFireballEntityMixin_API.java | 13 ++ .../DamagingProjectileEntityMixin_API.java | 55 ++----- .../EvokerFangsEntityMixin_API.java | 48 ++++++ .../projectile/FireballEntityMixin_API.java | 14 ++ .../FishingBobberEntityMixin_API.java | 49 ++---- .../projectile/LlamaSpitEntityMixin_API.java | 23 ++- .../projectile/PotionEntityMixin_API.java | 14 +- .../ShulkerBulletEntityMixin_API.java | 65 ++------ .../SmallFireballEntityMixin_API.java | 2 +- .../projectile/SnowballEntityMixin_API.java | 14 ++ .../projectile/ThrowableEntityMixin_API.java | 38 +---- .../projectile/TridentEntityMixin_API.java | 34 ++++ .../WitherSkullEntityMixin_API.java | 17 ++ .../carrier/AbstractHorseEntityMixin_API.java | 10 +- .../spongepowered/common/util/Constants.java | 11 +- .../resources/mixins.common.accessor.json | 1 + src/main/resources/mixins.common.api.json | 17 +- 106 files changed, 1732 insertions(+), 1620 deletions(-) create mode 100644 src/main/java/org/spongepowered/common/mixin/accessor/entity/passive/FoxEntityAccessor.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/DrownedEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ElderGuardianEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/CatEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/DolphinEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PandaEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TurtleEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractFishEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractGroupFishEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/CodEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/PufferfishEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/SalmonEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/TropicalFishEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractChestedHorseEntityMixin_API.java rename src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/{AbstractHorseMixin_API.java => AbstractHorseEntityMixin_API.java} (81%) create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/TraderLlamaEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/EvokerFangsEntityMixin_API.java create mode 100644 src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/TridentEntityMixin_API.java diff --git a/SpongeAPI b/SpongeAPI index d2afa91ad09..e81d89bb7ef 160000 --- a/SpongeAPI +++ b/SpongeAPI @@ -1 +1 @@ -Subproject commit d2afa91ad09418cf8fe195b58b2496a736d622c4 +Subproject commit e81d89bb7ef04957c22c3956e7e85268fd536819 diff --git a/src/main/java/org/spongepowered/common/mixin/accessor/entity/passive/FoxEntityAccessor.java b/src/main/java/org/spongepowered/common/mixin/accessor/entity/passive/FoxEntityAccessor.java new file mode 100644 index 00000000000..f5373446316 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/accessor/entity/passive/FoxEntityAccessor.java @@ -0,0 +1,46 @@ +/* + * 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.mixin.accessor.entity.passive; + +import net.minecraft.entity.passive.FoxEntity; +import net.minecraft.network.datasync.DataParameter; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Optional; +import java.util.UUID; + +@Mixin(FoxEntity.class) +public interface FoxEntityAccessor { + + @Accessor("TRUSTED_UUID_SECONDARY") static DataParameter> accessor$getTrustedUuidSecondary() { + throw new IllegalStateException("Untransformed Accessor!"); + } + + @Accessor("TRUSTED_UUID_MAIN") static DataParameter> accessor$getTrustedUuidMain() { + throw new IllegalStateException("Untransformed Accessor!"); + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AgeableEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AgeableEntityMixin_API.java index 8557f767939..564c6f23df3 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AgeableEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AgeableEntityMixin_API.java @@ -25,48 +25,23 @@ package org.spongepowered.common.mixin.api.mcp.entity; import net.minecraft.entity.AgeableEntity; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.AgeableData; -import org.spongepowered.api.data.value.BoundedValue; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.Ageable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeAgeableData; -import org.spongepowered.common.data.value.SpongeValueFactory; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.util.Constants; + +import java.util.Set; @Mixin(AgeableEntity.class) public abstract class AgeableEntityMixin_API extends CreatureEntityMixin_API implements Ageable { - @Shadow public abstract void setScaleForAge(boolean child); - @Shadow public abstract boolean shadow$isChild(); - - @Shadow public abstract int getGrowingAge(); - @Override - public void setScaleForAge() { - this.setScaleForAge(this.shadow$isChild()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public AgeableData getAgeData() { - return new SpongeAgeableData(this.getGrowingAge(), this.shadow$isChild()); - } + values.add(this.age().asImmutable()); + values.add(this.adult().asImmutable()); - @Override - public BoundedValue.Mutable age() { - return SpongeValueFactory.boundedBuilder(Keys.AGEABLE_AGE) - .minimum(Constants.Entity.Ageable.CHILD) - .maximum(Integer.MAX_VALUE) - .defaultValue(Constants.Entity.Ageable.ADULT) - .actualValue(this.getGrowingAge()) - .build() - ; + return values; } - @Override - public org.spongepowered.api.data.value.Value.Mutable adult() { - return new SpongeValue<>(Keys.IS_ADULT, true, this.shadow$isChild()); - } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AreaEffectCloudEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AreaEffectCloudEntityMixin_API.java index 7bc693351e4..daef7b44f02 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AreaEffectCloudEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/AreaEffectCloudEntityMixin_API.java @@ -27,10 +27,7 @@ import net.minecraft.entity.AreaEffectCloudEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.potion.Potion; -import net.minecraft.util.EnumParticleTypes; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.AreaEffectCloudData; -import org.spongepowered.api.effect.particle.ParticleType; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.effect.particle.ParticleTypes; import org.spongepowered.api.effect.potion.PotionEffect; import org.spongepowered.api.entity.AreaEffectCloud; @@ -38,143 +35,32 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeAreaEffectData; -import org.spongepowered.common.data.value.SpongeValueFactory; -import org.spongepowered.common.data.value.mutable.SpongeListValue; -import org.spongepowered.common.data.value.mutable.SpongeValue; import java.util.List; +import java.util.Set; import java.util.UUID; @SuppressWarnings("unchecked") @Mixin(AreaEffectCloudEntity.class) public abstract class AreaEffectCloudEntityMixin_API extends EntityMixin_API implements AreaEffectCloud { - @Shadow private Potion potion; - @Shadow @Final private List effects; - @Shadow private int duration; - @Shadow private int waitTime; - @Shadow private int reapplicationDelay; - @Shadow private boolean colorSet; - @Shadow private int durationOnUse; - @Shadow private float radiusOnUse; - @Shadow private float radiusPerTick; - @Shadow private LivingEntity owner; - @Shadow private UUID ownerUniqueId; - - @Shadow public abstract float getRadius(); - @Shadow public abstract int getColor(); - @Shadow public abstract EnumParticleTypes getParticle(); - - @Override - public AreaEffectCloudData getAreaEffectCloudData() { - return new SpongeAreaEffectData(Color.ofRgb(this.getColor()), - this.getRadius(), - ParticleTypes.MOB_SPELL, - this.duration, - this.waitTime, - this.radiusOnUse, - this.radiusPerTick, - this.durationOnUse, - this.reapplicationDelay, - (List) (List) this.effects, - this.ticksExisted - ); - } - - @Override - public Mutable color() { - return new SpongeValue<>(Keys.AREA_EFFECT_CLOUD_COLOR, Color.WHITE, Color.ofRgb(this.getColor())); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable radius() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_RADIUS) - .minimum(0D) - .maximum((double) Float.MAX_VALUE) - .defaultValue(0.5D) - .actualValue((double) this.getRadius()) - .build(); - } - - @Override - public Mutable particleType() { - return new SpongeValue<>(Keys.AREA_EFFECT_CLOUD_PARTICLE_EFFECT, ParticleTypes.MOB_SPELL, ParticleTypes.MOB_SPELL); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable duration() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_DURATION) - .minimum(Integer.MIN_VALUE) - .maximum(Integer.MAX_VALUE) - .defaultValue(600) - .actualValue(this.duration) - .build(); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable waitTime() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_WAIT_TIME) - .minimum(0) - .maximum(Integer.MAX_VALUE) - .defaultValue(20) - .actualValue(this.waitTime) - .build(); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable radiusOnUse() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_RADIUS_ON_USE) - .minimum(0.0D) - .maximum((double) Float.MAX_VALUE) - .defaultValue(0.0D) - .actualValue((double) this.radiusOnUse) - .build(); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable radiusPerTick() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_RADIUS_PER_TICK) - .minimum(0.0D) - .maximum((double) Float.MAX_VALUE) - .defaultValue(0.0D) - .actualValue((double) this.radiusPerTick) - .build(); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable durationOnUse() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_DURATION_ON_USE) - .minimum(0) - .maximum(Integer.MAX_VALUE) - .defaultValue(0) - .actualValue(this.durationOnUse) - .build(); - } - - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable applicationDelay() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_DURATION_ON_USE) - .minimum(0) - .maximum(Integer.MAX_VALUE) - .defaultValue(0) - .actualValue(this.reapplicationDelay) - .build(); - } - - @Override - public org.spongepowered.api.data.value.ListValue.Mutable effects() { - return new SpongeListValue<>(Keys.POTION_EFFECTS, (List) (List) this.effects); - } - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable age() { - return SpongeValueFactory.boundedBuilder(Keys.AREA_EFFECT_CLOUD_AGE) - .defaultValue(0) - .minimum(0) - .maximum(Integer.MAX_VALUE) - .actualValue(this.ticksExisted) - .build(); + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.color().asImmutable()); + values.add(this.radius().asImmutable()); + values.add(this.particleEffect().asImmutable()); + values.add(this.duration().asImmutable()); + values.add(this.waitTime().asImmutable()); + values.add(this.radiusOnUse().asImmutable()); + values.add(this.radiusPerTick().asImmutable()); + values.add(this.durationOnUse().asImmutable()); + values.add(this.applicationDelay().asImmutable()); + values.add(this.effects().asImmutable()); + values.add(this.age().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/EntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/EntityMixin_API.java index bf98f9cc9ed..ad7afd812df 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/EntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/EntityMixin_API.java @@ -28,7 +28,6 @@ import com.google.common.collect.Lists; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; @@ -43,12 +42,11 @@ import net.minecraft.world.server.ServerWorld; import org.spongepowered.api.Sponge; import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.IgniteableData; -import org.spongepowered.api.data.manipulator.mutable.entity.VehicleData; import org.spongepowered.api.data.persistence.DataContainer; import org.spongepowered.api.data.persistence.DataView; import org.spongepowered.api.data.persistence.InvalidDataException; import org.spongepowered.api.data.persistence.Queries; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.EntityArchetype; import org.spongepowered.api.entity.EntitySnapshot; import org.spongepowered.api.entity.EntityType; @@ -74,7 +72,6 @@ import org.spongepowered.common.bridge.world.ServerWorldBridge; import org.spongepowered.common.bridge.world.TeleporterBridge; import org.spongepowered.common.bridge.world.chunk.ServerChunkProviderBridge; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeGravityData; import org.spongepowered.common.data.persistence.NbtTranslator; import org.spongepowered.common.data.util.DataUtil; import org.spongepowered.common.entity.EntityUtil; @@ -83,12 +80,12 @@ import org.spongepowered.common.event.tracking.phase.plugin.BasicPluginContext; import org.spongepowered.common.event.tracking.phase.plugin.PluginPhase; import org.spongepowered.common.bridge.network.ServerPlayNetHandlerBridge; -import org.spongepowered.common.registry.type.entity.EntityTypeRegistryModule; import org.spongepowered.common.util.Constants; import org.spongepowered.common.util.VecHelper; import org.spongepowered.math.vector.Vector3d; -import java.util.Collection; + import java.util.EnumSet; +import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Random; @@ -113,43 +110,33 @@ public abstract class EntityMixin_API implements org.spongepowered.api.entity.En @Shadow public double motionZ; @Shadow public float rotationYaw; @Shadow public float rotationPitch; - @Shadow public boolean onGround; @Shadow public boolean isDead; @Shadow public float width; @Shadow public float height; @Shadow protected Random rand; @Shadow public int ticksExisted; @Shadow public int fire; - @Shadow protected EntityDataManager dataManager; @Shadow public int dimension; @Shadow protected UUID entityUniqueID; - + @Shadow public boolean removed; @Shadow public abstract void setPosition(double x, double y, double z); @Shadow public abstract void setDead(); @Shadow public abstract int getAir(); @Shadow public abstract void setAir(int air); - @Shadow public abstract float getEyeHeight(); @Shadow public abstract UUID getUniqueID(); - @Shadow public abstract AxisAlignedBB getEntityBoundingBox(); @Shadow public abstract void setFire(int seconds); @Shadow public abstract CompoundNBT writeToNBT(CompoundNBT compound); @Shadow public abstract boolean attackEntityFrom(DamageSource source, float amount); @Shadow public abstract int getEntityId(); - @Shadow public abstract List shadow$getPassengers(); - @Shadow public abstract net.minecraft.entity.Entity getLowestRidingEntity(); - @Shadow public abstract net.minecraft.entity.Entity getRidingEntity(); - @Shadow public abstract void removePassengers(); - @Shadow public abstract void setItemStackToSlot(EquipmentSlotType slotIn, ItemStack stack); @Shadow public abstract void playSound(SoundEvent soundIn, float volume, float pitch); - @Shadow public abstract boolean hasNoGravity(); @Shadow protected abstract void shadow$setRotation(float yaw, float pitch); + @Shadow protected abstract AxisAlignedBB shadow$getBoundingBox(); + @Shadow @Nullable public abstract MinecraftServer shadow$getServer(); // @formatter:on @Shadow public abstract void dismountRidingEntity(); - @Shadow @Nullable public abstract MinecraftServer shadow$getServer(); - @Override public EntitySnapshot createSnapshot() { return new SpongeEntitySnapshotBuilder().from(this).build(); @@ -414,7 +401,7 @@ public void setRotation(final Vector3d rotation) { @Override public Optional getBoundingBox() { - final AxisAlignedBB boundingBox = this.getEntityBoundingBox(); + final AxisAlignedBB boundingBox = this.shadow$getBoundingBox(); if (boundingBox == null) { return Optional.empty(); } @@ -426,11 +413,6 @@ public Optional getBoundingBox() { } } - @Override - public boolean isOnGround() { - return this.onGround; - } - @Override public boolean isRemoved() { return this.isDead; @@ -467,65 +449,6 @@ public UUID getUniqueId() { return this.entityUniqueID; } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Intrinsic - public List entity$getPassengers() { - return (List) this.shadow$getPassengers(); - } - - @Override - public Optional getVehicle() { - return Optional.ofNullable((org.spongepowered.api.entity.Entity) this.getRidingEntity()); - } - - @Override - public org.spongepowered.api.entity.Entity getBaseVehicle() { - return (org.spongepowered.api.entity.Entity) this.getLowestRidingEntity(); - } - - @Override - public boolean hasPassenger(final org.spongepowered.api.entity.Entity entity) { - checkNotNull(entity); - return entity.getPassengers().contains(this); - } - - @Override - public boolean addPassenger(final org.spongepowered.api.entity.Entity entity) { - checkNotNull(entity); - if (entity.getPassengers().contains(this)) { - throw new IllegalArgumentException(String.format("Cannot add entity %s as a passenger of %s, because the former already has the latter as a passenger!", entity, this)); - } - - return ((net.minecraft.entity.Entity) entity).startRiding((net.minecraft.entity.Entity) (Object) this, true); - } - - @Override - public void removePassenger(final org.spongepowered.api.entity.Entity entity) { - checkNotNull(entity); - if (!entity.getPassengers().contains(this)) { - throw new IllegalArgumentException(String.format("Cannot remove entity %s, because it is not a passenger of %s ", entity, this)); - } - - ((net.minecraft.entity.Entity) entity).stopRiding(); - } - - @Override - public void clearPassengers() { - this.removePassengers(); - } - - @Override - public boolean setVehicle(@Nullable final org.spongepowered.api.entity.Entity entity) { - if (this.getRidingEntity() == null && entity == null) { - return false; - } - if (this.getRidingEntity() != null) { - this.dismountRidingEntity(); - return true; - } - return entity != null && entity.addPassenger(this); - } - @Override public boolean validateRawData(final DataView container) { throw new UnsupportedOperationException(); // TODO Data API @@ -603,29 +526,6 @@ public org.spongepowered.api.entity.Entity copy() { } } - @Override - public Optional getCreator() { - return Optional.empty(); // Mixed in via EntityMixin_TrackerAPI - } - - @Override - public Optional getNotifier() { - return Optional.empty(); // Mixed in via EntityMixin_TrackerAPI - } - - @Override - public void setCreator(@Nullable final UUID uuid) { // Mixed in via EntityMixin_TrackerAPI - } - - @Override - public void setNotifier(@Nullable final UUID uuid) { // Mixed in via EntityMixin_TrackerAPI - } - - @Override - public Vector3d getVelocity() { - return new Vector3d(this.motionX, this.motionY, this.motionZ); - } - @Override public Translation getTranslation() { return this.getType().getTranslation(); @@ -644,16 +544,27 @@ public EntityArchetype createArchetype() { } @Override - public org.spongepowered.api.data.value.Value.Mutable gravity() { - return this.getValue(Keys.HAS_GRAVITY).get(); + public Set> getValues() { + // TODO: Merge custom and Vanilla values and return the merged result. + return this.api$getVanillaValues(); } - protected void spongeApi$supplyVanillaManipulators(final Collection> manipulators) { - this.get(VehicleData.class).ifPresent(manipulators::add); - if (this.fire > 0) { - manipulators.add(this.get(IgniteableData.class).get()); - } - manipulators.add(new SpongeGravityData(!this.hasNoGravity())); + protected Set> api$getVanillaValues() { + final Set> values = new HashSet<>(); + + values.add(this.displayName().asImmutable()); + values.add(this.passengers().asImmutable()); + values.add(this.onGround().asImmutable()); + values.add(this.velocity().asImmutable()); + values.add(this.gravity().asImmutable()); + values.add(this.silent().asImmutable()); + + this.baseVehicle().map(Value::asImmutable).ifPresent(values::add); + this.creator().map(Value::asImmutable).ifPresent(values::add); + this.notifier().map(Value::asImmutable).ifPresent(values::add); + this.fireTicks().map(Value::asImmutable).ifPresent(values::add); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/LivingEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/LivingEntityMixin_API.java index 4ab5fb44d96..f3f112693f8 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/LivingEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/LivingEntityMixin_API.java @@ -29,6 +29,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.Living; import org.spongepowered.api.entity.projectile.Projectile; import org.spongepowered.api.text.Text; @@ -36,7 +37,9 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.entity.projectile.ProjectileLauncher; import org.spongepowered.math.vector.Vector3d; + import java.util.Optional; +import java.util.Set; @SuppressWarnings("rawtypes") @Mixin(value = LivingEntity.class, priority = 999) @@ -58,4 +61,19 @@ public Optional launchProjectile(Class projectileCl public Optional launchProjectile(Class projectileClass, Vector3d velocity) { return ProjectileLauncher.launch(checkNotNull(projectileClass, "projectile class"), this, checkNotNull(velocity, "velocity")); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.health().asImmutable()); + values.add(this.maxHealth().asImmutable()); + values.add(this.lastAttacker().asImmutable()); + values.add(this.headRotation().asImmutable()); + + this.lastDamageReceived().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/MobEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/MobEntityMixin_API.java index c8772fb39a9..9fceb93b6e9 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/MobEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/MobEntityMixin_API.java @@ -24,6 +24,9 @@ */ package org.spongepowered.common.mixin.api.mcp.entity; +import net.minecraft.entity.MobEntity; +import net.minecraft.entity.ai.goal.GoalSelector; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.ai.goal.GoalExecutor; import org.spongepowered.api.entity.ai.goal.GoalExecutorType; import org.spongepowered.api.entity.ai.goal.GoalExecutorTypes; @@ -31,10 +34,9 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import java.util.Optional; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.ai.goal.GoalSelector; +import java.util.Optional; +import java.util.Set; @SuppressWarnings("unchecked") @Mixin(MobEntity.class) @@ -52,4 +54,16 @@ public Optional> getGoal(GoalExecutorType type } return Optional.empty(); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.aiEnabled().asImmutable()); + + this.targetEntity().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/WitherEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/WitherEntityMixin_API.java index b75be4b3367..6dbcd9b422b 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/WitherEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/WitherEntityMixin_API.java @@ -24,86 +24,42 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.boss; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import org.spongepowered.api.boss.ServerBossBar; -import org.spongepowered.api.entity.living.Living; +import net.minecraft.entity.boss.WitherEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.boss.Wither; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.bridge.explosives.FusedExplosiveBridge; import org.spongepowered.common.mixin.api.mcp.entity.monster.MonsterEntityMixin_API; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.boss.WitherEntity; -import net.minecraft.world.ServerBossInfo; +import java.util.Set; @Mixin(value = WitherEntity.class) public abstract class WitherEntityMixin_API extends MonsterEntityMixin_API implements Wither { - @Shadow @Final private ServerBossInfo bossInfo; - @Shadow public abstract int getWatchedTargetId(int p_82203_1_); - @Shadow public abstract void updateWatchedTargetId(int targetOffset, int newId); - @Shadow public abstract void setInvulTime(int ticks); - private int fuseDuration = 220; @Override - public List getTargets() { - List values = new ArrayList<>(); - for (int i = 0; i < 2; i++) { - int id = this.getWatchedTargetId(i); - if (id > 0) { - values.add((Living) this.world.getEntityByID(id)); - } - } - return values; + public void detonate() { + ((FusedExplosiveBridge) this).bridge$setFuseTicksRemaining(1); } @Override - public void setTargets(List targets) { - checkNotNull(targets, "Targets are null!"); - for (int i = 0; i < 2; i++) { - this.updateWatchedTargetId(i, targets.size() > i ? ((LivingEntity) targets.get(i)).getEntityId() : 0); - } - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public ServerBossBar getBossBar() { - return (ServerBossBar) this.bossInfo; - } + // Boss + values.add(this.bossBar().asImmutable()); + // FusedExplosive + values.add(this.primed().asImmutable()); + values.add(this.fuseDuration().asImmutable()); - @Override - public void detonate() { - ((FusedExplosiveBridge) this).bridge$setFuseTicksRemaining(1); - } - - @Override - public void prime() { - checkState(!this.isPrimed(), "already primed"); - if (((FusedExplosiveBridge) this).bridge$shouldPrime()) { - ((FusedExplosiveBridge) this).bridge$setFuseTicksRemaining(this.fuseDuration); - ((FusedExplosiveBridge) this).bridge$postPrime(); - } - } + // Explosive + this.explosionRadius().map(Value::asImmutable).ifPresent(values::add); - @Override - public void defuse() { - checkState(this.isPrimed(), "not primed"); - if (((FusedExplosiveBridge) this).bridge$shouldDefuse()) { - this.setInvulTime(0); - ((FusedExplosiveBridge) this).bridge$postDefuse(); - } - } + values.add(this.targetEntities().asImmutable()); - @Override - public boolean isPrimed() { - return ((FusedExplosiveBridge) this).bridge$getFuseTicksRemaining() > 0; + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/dragon/EnderDragonEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/dragon/EnderDragonEntityMixin_API.java index c32c773acf1..47ab79c1148 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/dragon/EnderDragonEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/boss/dragon/EnderDragonEntityMixin_API.java @@ -29,28 +29,21 @@ import net.minecraft.entity.boss.dragon.EnderDragonEntity; import net.minecraft.entity.boss.dragon.EnderDragonPartEntity; import net.minecraft.entity.boss.dragon.phase.PhaseManager; -import net.minecraft.entity.item.EnderCrystalEntity; -import net.minecraft.world.end.DragonFightManager; -import org.spongepowered.api.boss.ServerBossBar; -import org.spongepowered.api.entity.explosive.EnderCrystal; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.boss.dragon.EnderDragon; import org.spongepowered.api.entity.living.monster.boss.dragon.EnderDragonPart; import org.spongepowered.api.entity.living.monster.boss.dragon.phase.DragonPhaseManager; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.bridge.world.end.DragonFightManagerBridge; import org.spongepowered.common.mixin.api.mcp.entity.MobEntityMixin_API; -import java.util.Optional; import java.util.Set; @Mixin(EnderDragonEntity.class) public abstract class EnderDragonEntityMixin_API extends MobEntityMixin_API implements EnderDragon { @Shadow public EnderDragonPartEntity[] dragonParts; - @Shadow public EnderCrystalEntity closestEnderCrystal; - @Shadow @Final private DragonFightManager fightManager; @Shadow @Final private PhaseManager phaseManager; @Override @@ -65,18 +58,20 @@ public Set getParts() { } @Override - public Optional getHealingCrystal() { - return Optional.ofNullable((EnderCrystal) this.closestEnderCrystal); + public DragonPhaseManager getPhaseManager() { + return (DragonPhaseManager) this.phaseManager; } - @Override - public ServerBossBar getBossBar() { - return (ServerBossBar) ((DragonFightManagerBridge) this.fightManager).bridge$getBossInfo(); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public DragonPhaseManager getPhaseManager() { - return (DragonPhaseManager) this.phaseManager; + // Boss + values.add(this.bossBar().asImmutable()); + + this.healingCrystal().map(Value::asImmutable).ifPresent(values::add); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/effect/LightningBoltEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/effect/LightningBoltEntityMixin_API.java index 2c7dd9a0287..f24c842bce9 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/effect/LightningBoltEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/effect/LightningBoltEntityMixin_API.java @@ -30,6 +30,7 @@ import org.spongepowered.api.data.Transaction; import org.spongepowered.api.data.manipulator.mutable.entity.ExpirableData; import org.spongepowered.api.data.value.BoundedValue; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.weather.LightningBolt; import org.spongepowered.asm.mixin.Mixin; @@ -40,13 +41,14 @@ import java.time.Duration; import java.util.Collection; import java.util.List; +import java.util.Set; + import net.minecraft.entity.effect.LightningBoltEntity; +import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; import org.spongepowered.common.mixin.invalid.api.mcp.entity.effect.EntityWeatherEffectMixin_API; @Mixin(LightningBoltEntity.class) -public abstract class LightningBoltEntityMixin_API extends EntityWeatherEffectMixin_API implements LightningBolt { - - @Shadow private int lightningState; +public abstract class LightningBoltEntityMixin_API extends EntityMixin_API implements LightningBolt { private final List api$struckEntities = Lists.newArrayList(); private final List> api$struckBlocks = Lists.newArrayList(); @@ -67,23 +69,13 @@ public void setEffect(boolean effect) { } @Override - public ExpirableData getExpiringData() { - return new SpongeExpirableData(this.lightningState, 2); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public BoundedValue.Mutable expirationDelay() { - return SpongeValueFactory.boundedBuilder(Keys.EXPIRATION_DELAY) - .minimum((int) Short.MIN_VALUE) - .maximum(2) - .defaultValue(2) - .actualValue(this.lightningState) - .build(); - } + values.add(this.harmful().asImmutable()); + values.add(this.expirationDelay().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getExpiringData()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ArmorStandEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ArmorStandEntityMixin_API.java index 3b05be0632f..e159aa22b6d 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ArmorStandEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ArmorStandEntityMixin_API.java @@ -24,94 +24,32 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import com.google.common.collect.Maps; import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.util.math.Rotations; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.ArmorStandData; -import org.spongepowered.api.data.manipulator.mutable.entity.BodyPartRotationalData; -import org.spongepowered.api.data.manipulator.mutable.entity.DisabledSlotsData; -import org.spongepowered.api.data.type.BodyPart; -import org.spongepowered.api.data.type.BodyParts; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.ArmorStand; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeArmorStandData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeBodyPartRotationalData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeDisabledSlotsData; -import org.spongepowered.common.data.value.mutable.SpongeValue; import org.spongepowered.common.mixin.api.mcp.entity.LivingEntityMixin_API; -import org.spongepowered.common.util.VecHelper; -import org.spongepowered.math.vector.Vector3d; -import java.util.Collection; -import java.util.Map; + +import java.util.Set; @Mixin(ArmorStandEntity.class) @Implements(@Interface(iface = ArmorStand.class, prefix = "armor$")) public abstract class ArmorStandEntityMixin_API extends LivingEntityMixin_API implements ArmorStand { - @Shadow private Rotations leftArmRotation; - @Shadow private Rotations rightArmRotation; - @Shadow private Rotations leftLegRotation; - @Shadow private Rotations rightLegRotation; - - @Shadow public abstract boolean getShowArms(); // getShowArms - @Shadow public abstract boolean hasNoBasePlate(); // hasNoBasePlate - @Shadow public abstract boolean hasMarker(); - @Shadow public abstract boolean shadow$isSmall(); - @Shadow public abstract Rotations shadow$getHeadRotation(); - @Shadow public abstract Rotations getBodyRotation(); - - @Override - public Value.Mutable marker() { - return new SpongeValue<>(Keys.ARMOR_STAND_HAS_MARKER, false, this.hasMarker()); - } - - @Override - public Value.Mutable small() { - return new SpongeValue<>(Keys.ARMOR_STAND_IS_SMALL, false, this.shadow$isSmall()); - } - - @Override - public Value.Mutable basePlate() { - return new SpongeValue<>(Keys.ARMOR_STAND_HAS_BASE_PLATE, true, !this.hasNoBasePlate()); - } - @Override - public Value.Mutable arms() { - return new SpongeValue<>(Keys.ARMOR_STAND_HAS_ARMS, false, this.getShowArms()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public ArmorStandData getArmorStandData() { - return new SpongeArmorStandData(this.hasMarker(), this.shadow$isSmall(), this.getShowArms(), !this.hasNoBasePlate()); - } + values.add(this.marker().asImmutable()); + values.add(this.small().asImmutable()); + values.add(this.basePlate().asImmutable()); + values.add(this.arms().asImmutable()); + values.add(this.placingDisabled().asImmutable()); + values.add(this.takingDisabled().asImmutable()); - @Override - public DisabledSlotsData getDisabledSlotsData() { - return new SpongeDisabledSlotsData(this.takingDisabled().get(), this.placingDisabled().get()); - } - - @Override - public BodyPartRotationalData getBodyPartRotationalData() { - Map rotations = Maps.newHashMapWithExpectedSize(6); - rotations.put(BodyParts.HEAD, VecHelper.toVector3d(this.shadow$getHeadRotation())); - rotations.put(BodyParts.CHEST, VecHelper.toVector3d(this.getBodyRotation())); - rotations.put(BodyParts.LEFT_ARM, VecHelper.toVector3d(this.leftArmRotation)); - rotations.put(BodyParts.RIGHT_ARM, VecHelper.toVector3d(this.rightArmRotation)); - rotations.put(BodyParts.LEFT_LEG, VecHelper.toVector3d(this.leftLegRotation)); - rotations.put(BodyParts.RIGHT_LEG, VecHelper.toVector3d(this.rightLegRotation)); - return new SpongeBodyPartRotationalData(rotations); - } - - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getBodyPartRotationalData()); - manipulators.add(this.getArmorStandData()); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/BoatEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/BoatEntityMixin_API.java index 2da1b1e07d9..e37bf9e2855 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/BoatEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/BoatEntityMixin_API.java @@ -24,93 +24,37 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import org.spongepowered.api.data.DataManipulator.Mutable; +import net.minecraft.entity.item.BoatEntity; +import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.type.WoodTypes; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.Boat; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Intrinsic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.block.SpongeTreeData; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; import java.util.Collection; -import net.minecraft.entity.item.BoatEntity; +import java.util.Set; @Mixin(BoatEntity.class) @Implements(@Interface(iface = Boat.class, prefix = "apiBoat$")) public abstract class BoatEntityMixin_API extends EntityMixin_API implements Boat { - @Shadow public abstract BoatEntity.Type getBoatType(); - - private double maxSpeed = 0.35D; - private boolean moveOnLand = false; - private double occupiedDecelerationSpeed = 0D; - private double unoccupiedDecelerationSpeed = 0.8D; - - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - final BoatEntity.Type boatType = this.getBoatType(); - if (boatType == BoatEntity.Type.OAK) { - manipulators.add(new SpongeTreeData(WoodTypes.OAK)); - } else if ( boatType == BoatEntity.Type.BIRCH) { - manipulators.add(new SpongeTreeData(WoodTypes.BIRCH)); - } else if ( boatType == BoatEntity.Type.JUNGLE) { - manipulators.add(new SpongeTreeData(WoodTypes.JUNGLE)); - } else if ( boatType == BoatEntity.Type.DARK_OAK) { - manipulators.add(new SpongeTreeData(WoodTypes.DARK_OAK)); - } else if ( boatType == BoatEntity.Type.ACACIA) { - manipulators.add(new SpongeTreeData(WoodTypes.ACACIA)); - } else if ( boatType == BoatEntity.Type.SPRUCE) { - manipulators.add(new SpongeTreeData(WoodTypes.SPRUCE)); - } - } - - @Intrinsic - public boolean apiBoat$isInWater() { - return !this.onGround; - } - - @Override - public double getMaxSpeed() { - return this.maxSpeed; - } - - @Override - public void setMaxSpeed(double maxSpeed) { - this.maxSpeed = maxSpeed; - } - - @Override - public boolean canMoveOnLand() { - return this.moveOnLand; - } - - @Override - public void setMoveOnLand(boolean moveOnLand) { - this.moveOnLand = moveOnLand; - } - @Override - public double getOccupiedDeceleration() { - return this.occupiedDecelerationSpeed; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setOccupiedDeceleration(double occupiedDeceleration) { - this.occupiedDecelerationSpeed = occupiedDeceleration; - } + values.add(this.inWater().asImmutable()); + values.add(this.moveOnLand().asImmutable()); + values.add(this.maxSpeed().asImmutable()); + values.add(this.unoccupiedDeceleration().asImmutable()); + values.add(this.occupiedDeceleration().asImmutable()); + values.add(this.woodType().asImmutable()); - @Override - public double getUnoccupiedDeceleration() { - return this.unoccupiedDecelerationSpeed; - } - - @Override - public void setUnoccupiedDeceleration(double unoccupiedDeceleration) { - this.unoccupiedDecelerationSpeed = unoccupiedDeceleration; + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderCrystalEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderCrystalEntityMixin_API.java index 30ddb3b1a1c..ac139618d6a 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderCrystalEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderCrystalEntityMixin_API.java @@ -25,11 +25,18 @@ package org.spongepowered.common.mixin.api.mcp.entity.item; import net.minecraft.entity.item.EnderCrystalEntity; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.api.data.Keys; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.explosive.EnderCrystal; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.bridge.entity.item.EnderCrystalEntityBridge; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; +import javax.annotation.Nullable; +import java.util.Set; + @Mixin(EnderCrystalEntity.class) public abstract class EnderCrystalEntityMixin_API extends EntityMixin_API implements EnderCrystal { @@ -38,4 +45,18 @@ public void detonate() { this.setDead(); ((EnderCrystalEntityBridge) this).bridge$ThrowEventWithDetonation(this.world, null, this.posX, this.posY, this.posZ, true, null); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Explosive + this.explosionRadius().map(Value::asImmutable).ifPresent(values::add); + + values.add(this.showBottom().asImmutable()); + + this.beamTarget().map(Value::asImmutable).ifPresent(values::add); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderPearlEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderPearlEntityMixin_API.java index e603b6a1687..e534ffc6583 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderPearlEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EnderPearlEntityMixin_API.java @@ -25,11 +25,25 @@ package org.spongepowered.common.mixin.api.mcp.entity.item; import net.minecraft.entity.item.EnderPearlEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.EnderPearl; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.common.mixin.api.mcp.entity.projectile.ThrowableEntityMixin_API; +import java.util.Set; + @Mixin(EnderPearlEntity.class) public abstract class EnderPearlEntityMixin_API extends ThrowableEntityMixin_API implements EnderPearl { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Values from DamagingProjectile in EnderPearl + values.add(this.attackDamage().asImmutable()); + values.add(this.customAttackDamage().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ExperienceOrbEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ExperienceOrbEntityMixin_API.java index a5c6e2bc745..ed5dd7cce69 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ExperienceOrbEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ExperienceOrbEntityMixin_API.java @@ -24,42 +24,25 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.ExpOrbData; -import org.spongepowered.api.data.value.Value.Mutable; +import net.minecraft.entity.item.ExperienceOrbEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.ExperienceOrb; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeExpOrbData; -import org.spongepowered.common.data.value.SpongeValueFactory; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import java.util.Collection; -import net.minecraft.entity.item.ExperienceOrbEntity; +import java.util.Set; @Mixin(ExperienceOrbEntity.class) public abstract class ExperienceOrbEntityMixin_API extends EntityMixin_API implements ExperienceOrb { - @Shadow private int xpValue; - @Override - public Mutable experience() { - return SpongeValueFactory.boundedBuilder(Keys.CONTAINED_EXPERIENCE) - .minimum(0) - .maximum(Integer.MAX_VALUE) - .actualValue(this.xpValue) - .defaultValue(0) - .build(); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public ExpOrbData experienceHeld() { - return new SpongeExpOrbData(this.xpValue); - } + values.add(this.experience().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(final Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.experienceHeld()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EyeOfEnderEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EyeOfEnderEntityMixin_API.java index 3e903fc9032..fbc3149cc92 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EyeOfEnderEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/EyeOfEnderEntityMixin_API.java @@ -25,26 +25,26 @@ package org.spongepowered.common.mixin.api.mcp.entity.item; import net.minecraft.entity.item.EyeOfEnderEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.EyeOfEnder; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; +import java.util.Set; + @Mixin(EyeOfEnderEntity.class) public abstract class EyeOfEnderEntityMixin_API extends EntityMixin_API implements EyeOfEnder { - private ProjectileSource projectileSource = ProjectileSource.UNKNOWN; - @Override - public ProjectileSource getShooter() { - return this.projectileSource; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setShooter(ProjectileSource shooter) { - this.projectileSource = shooter; - } + // Projectile + values.add(this.shooter().asImmutable()); + values.add(this.targetLocation().asImmutable()); + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FallingBlockEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FallingBlockEntityMixin_API.java index 83a4c728ebe..b4125a46166 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FallingBlockEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FallingBlockEntityMixin_API.java @@ -25,11 +25,29 @@ package org.spongepowered.common.mixin.api.mcp.entity.item; import net.minecraft.entity.item.FallingBlockEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.FallingBlock; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; +import java.util.Set; + @Mixin(FallingBlockEntity.class) public abstract class FallingBlockEntityMixin_API extends EntityMixin_API implements FallingBlock { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.blockState().asImmutable()); + values.add(this.damagePerBlock().asImmutable()); + values.add(this.maxFallDamage().asImmutable()); + values.add(this.placeAsBlock().asImmutable()); + values.add(this.dropAsItem().asImmutable()); + values.add(this.fallTime().asImmutable()); + values.add(this.hurtEntities().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FireworkRocketEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FireworkRocketEntityMixin_API.java index c0f655fad63..4d2f2c2befe 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FireworkRocketEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/FireworkRocketEntityMixin_API.java @@ -24,22 +24,14 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.collect.Lists; -import org.spongepowered.api.data.DataManipulator.Mutable; -import org.spongepowered.api.data.manipulator.mutable.FireworkEffectData; +import net.minecraft.entity.item.FireworkRocketEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.explosive.FireworkRocket; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.bridge.explosives.FusedExplosiveBridge; -import org.spongepowered.common.data.manipulator.mutable.SpongeFireworkEffectData; -import org.spongepowered.common.data.processor.common.FireworkUtils; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import java.util.Collection; -import net.minecraft.entity.item.FireworkRocketEntity; +import java.util.Set; @Mixin(FireworkRocketEntity.class) public abstract class FireworkRocketEntityMixin_API extends EntityMixin_API implements FireworkRocket { @@ -49,30 +41,6 @@ public abstract class FireworkRocketEntityMixin_API extends EntityMixin_API impl @Shadow public abstract void onUpdate(); - private ProjectileSource projectileSource = ProjectileSource.UNKNOWN; - - @Override - public ProjectileSource getShooter() { - return this.projectileSource; - } - - @Override - public void setShooter(ProjectileSource shooter) { - this.projectileSource = shooter; - } - - - @Override - public FireworkEffectData getFireworkData() { - return new SpongeFireworkEffectData(FireworkUtils.getFireworkEffects(this).orElse(Lists.newArrayList())); - } - - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getFireworkData()); - } - @Override public void detonate() { this.fireworkAge = this.lifetime + 1; @@ -80,24 +48,19 @@ public void detonate() { } @Override - public void prime() { - checkState(!this.isPrimed(), "already primed"); - checkState(this.isDead, "firework about to be primed"); - this.getWorld().spawnEntity(this); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void defuse() { - checkState(this.isPrimed(), "not primed"); - if (((FusedExplosiveBridge) this).bridge$shouldDefuse()) { - this.setDead(); - ((FusedExplosiveBridge) this).bridge$postDefuse(); - } - } + // Projectile + values.add(this.shooter().asImmutable()); - @Override - public boolean isPrimed() { - return this.fireworkAge > 0 && this.fireworkAge <= this.lifetime && !this.isDead; + // FusedExplosive + values.add(this.primed().asImmutable()); + values.add(this.fuseDuration().asImmutable()); + + values.add(this.effects().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/HangingEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/HangingEntityMixin_API.java index 7f86c4ba9f6..8702351ed22 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/HangingEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/HangingEntityMixin_API.java @@ -24,42 +24,29 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.block.DirectionalData; -import org.spongepowered.api.data.value.Value.Mutable; +import net.minecraft.entity.item.HangingEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.hanging.Hanging; import org.spongepowered.api.util.Direction; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.block.SpongeDirectionalData; -import org.spongepowered.common.data.value.mutable.SpongeValue; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; import org.spongepowered.common.util.Constants; import java.util.Collection; - +import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.entity.item.HangingEntity; @Mixin(HangingEntity.class) public abstract class HangingEntityMixin_API extends EntityMixin_API implements Hanging { - @Shadow @Nullable public net.minecraft.util.Direction facingDirection; - @Override - public DirectionalData getDirectionalData() { - return new SpongeDirectionalData(this.facingDirection == null ? Direction.NONE : Constants.DirectionFunctions.getFor(this.facingDirection)); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Mutable direction() { - return new SpongeValue<>(Keys.DIRECTION, this.facingDirection == null ? Direction.NONE : Constants.DirectionFunctions.getFor(this.facingDirection)); - } + values.add(this.direction().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getDirectionalData()); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ItemEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ItemEntityMixin_API.java index 91bc8258bbb..5763ad5eabc 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ItemEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/ItemEntityMixin_API.java @@ -26,50 +26,33 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.RepresentedItemData; -import org.spongepowered.api.data.value.Value.Mutable; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.Item; import org.spongepowered.api.item.ItemType; -import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.text.translation.Translation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.SpongeRepresentedItemData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.item.util.ItemStackUtil; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import java.util.Collection; +import java.util.Set; @Mixin(ItemEntity.class) public abstract class ItemEntityMixin_API extends EntityMixin_API implements Item { - @Shadow public abstract ItemStack getItem(); + @Shadow public abstract ItemStack shadow$getItem(); @Override public Translation getTranslation() { - return ((org.spongepowered.api.item.inventory.ItemStack) this.getItem()).getTranslation(); + return ((org.spongepowered.api.item.inventory.ItemStack) (Object) this.shadow$getItem()).getTranslation(); } @Override - public ItemType getItemType() { - return (ItemType) this.getItem().getItem(); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public RepresentedItemData getItemData() { - return new SpongeRepresentedItemData(ItemStackUtil.snapshotOf(this.getItem())); - } + values.add(this.item().asImmutable()); - @Override - public Mutable item() { - return new SpongeValue<>(Keys.REPRESENTED_ITEM, ItemStackSnapshot.NONE, ItemStackUtil.snapshotOf(this.getItem())); + return values; } - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getItemData()); - } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/LeashKnotEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/LeashKnotEntityMixin_API.java index aad139e0f56..812dedc0b5b 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/LeashKnotEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/LeashKnotEntityMixin_API.java @@ -25,16 +25,23 @@ package org.spongepowered.common.mixin.api.mcp.entity.item; import net.minecraft.entity.item.LeashKnotEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.hanging.LeashKnot; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.common.mixin.api.mcp.entity.item.HangingEntityMixin_API; + +import java.util.Set; @Mixin(LeashKnotEntity.class) public abstract class LeashKnotEntityMixin_API extends HangingEntityMixin_API implements LeashKnot { @Override - public Entity getLeashedEntity() { - return null; + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.leashedEntity().asImmutable()); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/PaintingEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/PaintingEntityMixin_API.java index f7a5a74e4d2..cca1a6fb5e4 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/PaintingEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/PaintingEntityMixin_API.java @@ -24,37 +24,27 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.ArtData; +import net.minecraft.entity.item.PaintingEntity; +import net.minecraft.entity.item.PaintingType; import org.spongepowered.api.data.type.ArtType; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.hanging.Painting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeArtData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.util.Constants; + import java.util.Collection; -import net.minecraft.entity.item.PaintingEntity; +import java.util.Set; @Mixin(PaintingEntity.class) public abstract class PaintingEntityMixin_API extends HangingEntityMixin_API implements Painting { - @Shadow public PaintingEntity.EnumArt art; - @Override - public ArtData getArtData() { - return new SpongeArtData((ArtType) (Object) this.art); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable art() { - return new SpongeValue<>(Keys.ART, Constants.Catalog.DEFAULT_ART, (ArtType) (Object) this.art); - } + values.add(this.art().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getArtData()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/TNTEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/TNTEntityMixin_API.java index fe62e778515..9daf5c69f99 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/TNTEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/TNTEntityMixin_API.java @@ -24,76 +24,41 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item; -import static com.google.common.base.Preconditions.checkState; - -import org.spongepowered.api.Sponge; -import org.spongepowered.api.block.BlockState; -import org.spongepowered.api.block.BlockType; -import org.spongepowered.api.block.BlockTypes; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.item.TNTEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.explosive.fused.PrimedTNT; -import org.spongepowered.api.entity.living.Living; -import org.spongepowered.api.world.BlockChangeFlags; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.bridge.entity.item.EntityTNTPrimedBridge; -import org.spongepowered.common.bridge.explosives.FusedExplosiveBridge; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import org.spongepowered.common.util.Constants; -import java.util.Optional; +import java.util.Set; import javax.annotation.Nullable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.TNTEntity; @Mixin(TNTEntity.class) public abstract class TNTEntityMixin_API extends EntityMixin_API implements PrimedTNT { - private static final BlockType BLOCK_TYPE = BlockTypes.TNT; - - @Shadow private int fuse; @Shadow @Nullable private LivingEntity tntPlacedBy; @Shadow private void explode() { } @Override - public Optional getDetonator() { - return Optional.ofNullable((Living) this.tntPlacedBy); + public void detonate() { + this.setDead(); + this.explode(); } - // FusedExplosive Impl - @Override - public void defuse() { - checkState(this.isPrimed(), "not primed"); - checkState(!((EntityTNTPrimedBridge) this).bridge$isExploding(), "tnt about to explode"); - if (((FusedExplosiveBridge) this).bridge$shouldDefuse()) { - this.setDead(); - // Place a TNT block at the Entity's position - Sponge.getCauseStackManager().pushCause(this); - this.getWorld().setBlock((int) this.posX, (int) this.posY, (int) this.posZ, BlockState.builder().blockType(BLOCK_TYPE).build(), BlockChangeFlags.ALL); - Sponge.getCauseStackManager().popCause(); - ((FusedExplosiveBridge) this).bridge$postDefuse(); - } - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void prime() { - checkState(!this.isPrimed(), "already primed"); - checkState(!((EntityTNTPrimedBridge) this).bridge$isExploding(), "tnt about to explode"); - this.getWorld().spawnEntity(this); - } + // FusedExplosive + values.add(this.primed().asImmutable()); + values.add(this.fuseDuration().asImmutable()); - @Override - public boolean isPrimed() { - return this.fuse > 0 && this.fuse < Constants.Entity.PrimedTNT.DEFAULT_FUSE_DURATION && !this.isDead; - } + this.detonator().map(Value::asImmutable).ifPresent(values::add); - @Override - public void detonate() { - this.setDead(); - this.explode(); + return values; } - - } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/AbstractMinecartEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/AbstractMinecartEntityMixin_API.java index 608e26d495d..09fe9c02fca 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/AbstractMinecartEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/AbstractMinecartEntityMixin_API.java @@ -25,69 +25,28 @@ package org.spongepowered.common.mixin.api.mcp.entity.item.minecart; import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import org.spongepowered.api.entity.vehicle.minecart.Minecart; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.minecart.MinecartEntity; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import org.spongepowered.common.util.Constants; -import org.spongepowered.math.vector.Vector3d; + +import java.util.Set; @Mixin(AbstractMinecartEntity.class) public abstract class AbstractMinecartEntityMixin_API extends EntityMixin_API implements MinecartEntity { - @Shadow protected abstract double shadow$getMaximumSpeed(); - - private double maxSpeed = 0.4D; - private boolean slowWhenEmpty = true; - private Vector3d airborneMod = new Vector3d(Constants.Entity.Minecart.DEFAULT_AIRBORNE_MOD, Constants.Entity.Minecart.DEFAULT_AIRBORNE_MOD, Constants.Entity.Minecart.DEFAULT_AIRBORNE_MOD); - private Vector3d derailedMod = new Vector3d(Constants.Entity.Minecart.DEFAULT_DERAILED_MOD, Constants.Entity.Minecart.DEFAULT_DERAILED_MOD, Constants.Entity.Minecart.DEFAULT_DERAILED_MOD); - - - @Override - public double getSwiftness() { - return this.maxSpeed; - } - - @Override - public void setSwiftness(double maxSpeed) { - this.maxSpeed = maxSpeed; - } - - @Override - public double getPotentialMaxSpeed() { - // SpongeForge replaces this method so it returns the result of the Forge method - return this.shadow$getMaximumSpeed(); - } - @Override - public boolean doesSlowWhenEmpty() { - return this.slowWhenEmpty; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setSlowWhenEmpty(boolean slowWhenEmpty) { - this.slowWhenEmpty = slowWhenEmpty; - } + values.add(this.onRail().asImmutable()); + values.add(this.swiftness().asImmutable()); + values.add(this.potentialMaxSpeed().asImmutable()); + values.add(this.slowsUnoccupied().asImmutable()); + values.add(this.airborneVelocityModifier().asImmutable()); + values.add(this.derailedVelocityModifier().asImmutable()); - @Override - public Vector3d getAirborneVelocityMod() { - return this.airborneMod; - } - - @Override - public void setAirborneVelocityMod(Vector3d airborneMod) { - this.airborneMod = airborneMod; - } - - @Override - public Vector3d getDerailedVelocityMod() { - return this.derailedMod; - } - - @Override - public void setDerailedVelocityMod(Vector3d derailedVelocityMod) { - this.derailedMod = derailedVelocityMod; + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ChestMinecartEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ChestMinecartEntityMixin_API.java index a96a8f7a61a..4ad6ae819d7 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ChestMinecartEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ChestMinecartEntityMixin_API.java @@ -31,5 +31,4 @@ @Mixin(ChestMinecartEntity.class) public abstract class ChestMinecartEntityMixin_API extends ContainerMinecartMixin_API implements ChestMinecart { - } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ContainerMinecartMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ContainerMinecartMixin_API.java index 10e61197e45..1fd64447e9c 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ContainerMinecartMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/ContainerMinecartMixin_API.java @@ -24,15 +24,25 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item.minecart; + +import net.minecraft.entity.item.minecart.ContainerMinecartEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.minecart.carrier.CarrierMinecart; -import org.spongepowered.api.item.inventory.type.CarriedInventory; import org.spongepowered.asm.mixin.Mixin; -import java.util.Optional; -import net.minecraft.entity.item.minecart.ContainerMinecartEntity; +import java.util.Set; @Mixin(ContainerMinecartEntity.class) public abstract class ContainerMinecartMixin_API> extends AbstractMinecartEntityMixin_API implements CarrierMinecart { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // BlockOccupiedMinecart + values.add(this.block().asImmutable()); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/FurnaceMinecartEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/FurnaceMinecartEntityMixin_API.java index 470ca37d36b..ca24e6627a2 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/FurnaceMinecartEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/FurnaceMinecartEntityMixin_API.java @@ -25,23 +25,26 @@ package org.spongepowered.common.mixin.api.mcp.entity.item.minecart; import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.minecart.FurnaceMinecart; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.Set; + @Mixin(FurnaceMinecartEntity.class) public abstract class FurnaceMinecartEntityMixin_API extends AbstractMinecartEntityMixin_API implements FurnaceMinecart { - @Shadow private int fuel; - @Override - public int getFuel() { - return this.fuel; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setFuel(int fuel) { - this.fuel = fuel; + // BlockOccupiedMinecart + values.add(this.block().asImmutable()); + + values.add(this.fuelDuration().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/MinecartCommandBlockEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/MinecartCommandBlockEntityMixin_API.java index 012eb5615f4..2a5a6299f08 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/MinecartCommandBlockEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/MinecartCommandBlockEntityMixin_API.java @@ -26,10 +26,13 @@ import net.minecraft.entity.item.minecart.MinecartCommandBlockEntity; import net.minecraft.tileentity.CommandBlockLogic; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.minecart.CommandBlockMinecart; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.Set; + @Mixin(MinecartCommandBlockEntity.class) public abstract class MinecartCommandBlockEntityMixin_API extends AbstractMinecartEntityMixin_API implements CommandBlockMinecart { @@ -39,4 +42,15 @@ public abstract class MinecartCommandBlockEntityMixin_API extends AbstractMineca public String getName() { return this.getCommandBlockLogic().getName(); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // BlockOccupiedMinecart + values.add(this.block().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/SpawnerMinecartEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/SpawnerMinecartEntityMixin_API.java index 69916c8438a..6aba602bcf5 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/SpawnerMinecartEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/SpawnerMinecartEntityMixin_API.java @@ -24,54 +24,39 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.item.minecart; -import org.spongepowered.api.data.manipulator.mutable.MobSpawnerData; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.minecart.SpawnerMinecart; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.bridge.world.spawner.AbstractSpawnerBridge; -import org.spongepowered.common.data.manipulator.mutable.SpongeMobSpawnerData; -import org.spongepowered.common.data.processor.common.SpawnerUtils; -import java.util.Collection; +import java.util.Set; + import net.minecraft.entity.item.minecart.SpawnerMinecartEntity; import net.minecraft.world.spawner.AbstractSpawner; @Mixin(SpawnerMinecartEntity.class) public abstract class SpawnerMinecartEntityMixin_API extends AbstractMinecartEntityMixin_API implements SpawnerMinecart { - @Shadow @Final private AbstractSpawner mobSpawnerLogic; - @Override - public MobSpawnerData getSpawnerData() { - // TODO - Update once Mixin 0.8 for accessors -// final MobSpawnerBaseLogicAccessor accessor = (MobSpawnerBaseLogicAccessor) this.mobSpawnerLogic; -// return new SpongeMobSpawnerData( -// (short) accessor.accessor$getSpawnDelay(), -// (short) accessor.accessor$getMinSpawnDelay(), -// (short) accessor.accessor$getMaxSpawnDelay(), -// (short) accessor.accessor$getSpawnCount(), -// (short) accessor.accessor$getMaxNearbyEntities(), -// (short) accessor.accessor$getActivatingRangeFromPlayer(), -// (short) accessor.accessor$getSpawnRange(), -// SpawnerUtils.getNextEntity(accessor), -// SpawnerUtils.getEntities(this.mobSpawnerLogic)); - final AbstractSpawnerBridge accessor = (AbstractSpawnerBridge) this.mobSpawnerLogic; - return new SpongeMobSpawnerData( - (short) accessor.bridge$getSpawnDelay(), - (short) accessor.bridge$getMinSpawnDelay(), - (short) accessor.bridge$getMaxSpawnDelay(), - (short) accessor.bridge$getSpawnCount(), - (short) accessor.bridge$getMaxNearbyEntities(), - (short) accessor.bridge$getActivatingRangeFromPlayer(), - (short) accessor.bridge$getSpawnRange(), - SpawnerUtils.getNextEntity(accessor), - SpawnerUtils.getEntities(this.mobSpawnerLogic)); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void spongeApi$supplyVanillaManipulators(final Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getSpawnerData()); + // BlockOccupiedMinecart + values.add(this.block().asImmutable()); + + // Spawner + values.add(this.remainingDelay().asImmutable()); + values.add(this.minimumSpawnDelay().asImmutable()); + values.add(this.maximumSpawnDelay().asImmutable()); + values.add(this.spawnCount().asImmutable()); + values.add(this.maximumNearbyEntities().asImmutable()); + values.add(this.requiredPlayerRange().asImmutable()); + values.add(this.spawnRange().asImmutable()); + values.add(this.nextEntityToSpawn().asImmutable()); + values.add(this.possibleEntitiesToSpawn().asImmutable()); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/TNTMinecartEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/TNTMinecartEntityMixin_API.java index 1f4e88a3226..d87dc21ee93 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/TNTMinecartEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/item/minecart/TNTMinecartEntityMixin_API.java @@ -27,11 +27,14 @@ import static com.google.common.base.Preconditions.checkState; import net.minecraft.entity.item.minecart.TNTMinecartEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.vehicle.minecart.TNTMinecart; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.bridge.explosives.FusedExplosiveBridge; +import java.util.Set; + @Mixin(TNTMinecartEntity.class) public abstract class TNTMinecartEntityMixin_API extends AbstractMinecartEntityMixin_API implements TNTMinecart { @@ -39,28 +42,25 @@ public abstract class TNTMinecartEntityMixin_API extends AbstractMinecartEntityM @Shadow public abstract void ignite(); @Override - public void prime() { - checkState(!this.isPrimed(), "already primed"); - this.ignite(); + public void detonate() { + ((FusedExplosiveBridge) this).bridge$setFuseTicksRemaining(0); } @Override - public void defuse() { - checkState(this.isPrimed(), "not primed"); - if (((FusedExplosiveBridge) this).bridge$shouldDefuse()) { - ((FusedExplosiveBridge) this).bridge$setFuseTicksRemaining(-1); - ((FusedExplosiveBridge) this).bridge$postDefuse(); - } - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public boolean isPrimed() { - return this.minecartTNTFuse >= 0; - } + // BlockOccupiedMinecart + values.add(this.block().asImmutable()); - @Override - public void detonate() { - ((FusedExplosiveBridge) this).bridge$setFuseTicksRemaining(0); + // FusedExplosive + values.add(this.primed().asImmutable()); + values.add(this.fuseDuration().asImmutable()); + + // Explosive + this.explosionRadius().map(Value::asImmutable).ifPresent(values::add); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/AbstractVillagerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/AbstractVillagerEntityMixin_API.java index 24e85b7497a..efdaf287014 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/AbstractVillagerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/AbstractVillagerEntityMixin_API.java @@ -27,6 +27,7 @@ import net.minecraft.entity.merchant.villager.AbstractVillagerEntity; import net.minecraft.entity.player.PlayerEntity; import org.checkerframework.checker.nullness.qual.Nullable; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.Humanoid; import org.spongepowered.api.entity.living.trader.Trader; import org.spongepowered.asm.mixin.Mixin; @@ -34,6 +35,7 @@ import org.spongepowered.common.mixin.api.mcp.entity.AgeableEntityMixin_API; import java.util.Optional; +import java.util.Set; @Mixin(AbstractVillagerEntity.class) public abstract class AbstractVillagerEntityMixin_API extends AgeableEntityMixin_API implements Trader { @@ -50,4 +52,16 @@ public void setCustomer(@Nullable Humanoid humanoid) { this.shadow$setCustomer((PlayerEntity) humanoid); } + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Merchant + values.add(this.tradeOffers().asImmutable()); + + values.add(this.trading().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/VillagerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/VillagerEntityMixin_API.java index 2844f36bf46..8000c16ab2b 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/VillagerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/merchant/villager/VillagerEntityMixin_API.java @@ -24,56 +24,27 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.merchant.villager; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.CareerData; -import org.spongepowered.api.data.type.Career; +import net.minecraft.entity.merchant.villager.VillagerEntity; import org.spongepowered.api.data.value.Value; -import org.spongepowered.api.entity.living.Humanoid; import org.spongepowered.api.entity.living.trader.Villager; -import org.spongepowered.api.item.inventory.Carrier; -import org.spongepowered.api.item.inventory.type.CarriedInventory; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; -import org.spongepowered.asm.mixin.Intrinsic; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.bridge.entity.merchant.villager.VillagerEntityBridge; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeCareerData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.mixin.api.mcp.entity.AgeableEntityMixin_API; -import org.spongepowered.common.util.Constants; -import java.util.Collection; -import java.util.Optional; - -import javax.annotation.Nullable; -import net.minecraft.entity.merchant.villager.VillagerEntity; -import net.minecraft.entity.player.PlayerEntity; +import java.util.Set; @Mixin(VillagerEntity.class) @Implements(@Interface(iface = Villager.class, prefix = "apiVillager$")) public abstract class VillagerEntityMixin_API extends AbstractVillagerEntityMixin_API implements Villager { - @Intrinsic - public boolean apiVillager$isTrading() { - return this.shadow$hasCustomer(); - } - - // Data delegated methods - @Override - public CareerData getCareerData() { - return new SpongeCareerData(((VillagerEntityBridge) this).bridge$getCareer()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable career() { - return new SpongeValue<>(Keys.CAREER, Constants.Catalog.CAREER_DEFAULT, ((VillagerEntityBridge) this).bridge$getCareer()); - } + values.add(this.type().asImmutable()); + values.add(this.profession().asImmutable()); + values.add(this.professionLevel().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getCareerData()); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/AbstractRaiderEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/AbstractRaiderEntityMixin_API.java index f1a9c7b5a33..555b3ddec9e 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/AbstractRaiderEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/AbstractRaiderEntityMixin_API.java @@ -25,21 +25,25 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.AbstractRaiderEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.raider.Raider; -import org.spongepowered.api.raid.Raid; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import java.util.Optional; +import java.util.Set; @Mixin(AbstractRaiderEntity.class) public abstract class AbstractRaiderEntityMixin_API extends PatrollerEntityMixin_API implements Raider { - @Shadow public abstract net.minecraft.world.raid.Raid shadow$getRaid(); - @Override - public Optional getRaid() { - return Optional.ofNullable((Raid) this.shadow$getRaid()); + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.canJoinRaid().asImmutable()); + values.add(this.celebrating().asImmutable()); + + this.raidWave().map(Value::asImmutable).ifPresent(values::add); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/BlazeEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/BlazeEntityMixin_API.java index c0de5bfbd84..6e506c83487 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/BlazeEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/BlazeEntityMixin_API.java @@ -24,29 +24,25 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.Keys; +import net.minecraft.entity.monster.BlazeEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.Blaze; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeFlammableData; -import org.spongepowered.common.data.value.mutable.SpongeValue; + import java.util.Collection; -import net.minecraft.entity.monster.BlazeEntity; +import java.util.Set; @Mixin(BlazeEntity.class) public abstract class BlazeEntityMixin_API extends MonsterEntityMixin_API implements Blaze { - @Shadow public abstract boolean isBurning(); - @Override - public Value.Mutable aflame() { - return new SpongeValue<>(Keys.IS_AFLAME, false, this.isBurning()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(new SpongeFlammableData(this.isBurning())); + values.add(this.aflame().asImmutable()); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CaveSpiderEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CaveSpiderEntityMixin_API.java index 6a747800600..cdbe4bfe412 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CaveSpiderEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CaveSpiderEntityMixin_API.java @@ -25,10 +25,23 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.CaveSpiderEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.spider.CaveSpider; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(CaveSpiderEntity.class) public abstract class CaveSpiderEntityMixin_API extends MonsterEntityMixin_API implements CaveSpider { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Spider + values.add(this.climbing().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CreeperEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CreeperEntityMixin_API.java index f3b674758c2..c6f2c14519e 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CreeperEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/CreeperEntityMixin_API.java @@ -24,59 +24,38 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import static com.google.common.base.Preconditions.checkState; - import net.minecraft.entity.monster.CreeperEntity; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.FuseData; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.Creeper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.bridge.explosives.FusedExplosiveBridge; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeFuseData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.util.Constants; + +import java.util.Set; @Mixin(CreeperEntity.class) public abstract class CreeperEntityMixin_API extends MonsterEntityMixin_API implements Creeper { - @Shadow public abstract int getCreeperState(); - @Shadow public abstract void setCreeperState(int state); @Shadow private void explode() { } // explode - @Shadow public abstract boolean getPowered(); - @Override - public Value.Mutable charged() { - return new SpongeValue<>(Keys.CREEPER_CHARGED, false, this.getPowered()); + public void detonate() { + this.explode(); } @Override - public FuseData getFuseData() { - return new SpongeFuseData(((FusedExplosiveBridge) this).bridge$getFuseDuration(), ((FusedExplosiveBridge) this).bridge$getFuseTicksRemaining()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void prime() { - checkState(!this.isPrimed(), "already primed"); - this.setCreeperState(Constants.Entity.Creeper.STATE_PRIMED); - } + // FusedExplosive + values.add(this.primed().asImmutable()); + values.add(this.fuseDuration().asImmutable()); - @Override - public void defuse() { - checkState(this.isPrimed(), "not primed"); - this.setCreeperState(Constants.Entity.Creeper.STATE_IDLE); - } + // Explosive + this.explosionRadius().map(Value::asImmutable).ifPresent(values::add); - @Override - public boolean isPrimed() { - return this.getCreeperState() == Constants.Entity.Creeper.STATE_PRIMED; - } + values.add(this.charged().asImmutable()); - @Override - public void detonate() { - this.explode(); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/DrownedEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/DrownedEntityMixin_API.java new file mode 100644 index 00000000000..fe652711da8 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/DrownedEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.monster; + +import net.minecraft.entity.monster.DrownedEntity; +import org.spongepowered.api.entity.living.monster.zombie.Drowned; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(DrownedEntity.class) +public abstract class DrownedEntityMixin_API extends ZombieEntityMixin_API implements Drowned { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ElderGuardianEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ElderGuardianEntityMixin_API.java new file mode 100644 index 00000000000..85973e4069a --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ElderGuardianEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.monster; + +import net.minecraft.entity.monster.ElderGuardianEntity; +import org.spongepowered.api.entity.living.monster.guardian.ElderGuardian; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(ElderGuardianEntity.class) +public abstract class ElderGuardianEntityMixin_API extends GuardianEntityMixin_API implements ElderGuardian { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermanEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermanEntityMixin_API.java index b4f23fcb966..dabfcc6a1cc 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermanEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermanEntityMixin_API.java @@ -24,20 +24,25 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.manipulator.mutable.entity.ScreamingData; +import net.minecraft.entity.monster.EndermanEntity; +import org.spongepowered.api.data.Keys; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.Enderman; import org.spongepowered.asm.mixin.Mixin; import java.util.Collection; -import net.minecraft.entity.monster.EndermanEntity; +import java.util.Set; @Mixin(EndermanEntity.class) public abstract class EndermanEntityMixin_API extends MonsterEntityMixin_API implements Enderman { @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.get(ScreamingData.class).get()); + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.screaming().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermiteEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermiteEntityMixin_API.java index 159d763361c..4ba1c618d1d 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermiteEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EndermiteEntityMixin_API.java @@ -24,43 +24,23 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.ExpirableData; -import org.spongepowered.api.data.value.BoundedValue; +import net.minecraft.entity.monster.EndermiteEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.Endermite; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeExpirableData; -import org.spongepowered.common.data.value.SpongeValueFactory; -import org.spongepowered.common.util.Constants; -import java.time.Duration; -import java.util.Collection; -import net.minecraft.entity.monster.EndermiteEntity; +import java.util.Set; @Mixin(EndermiteEntity.class) public abstract class EndermiteEntityMixin_API extends MonsterEntityMixin_API implements Endermite { - @Shadow private int lifetime; - @Override - public ExpirableData getExpirableData() { - return new SpongeExpirableData(this.lifetime, Constants.Entity.Silverfish.MAX_EXPIRATION_TICKS); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public BoundedValue.Mutable expirationDelay() { - return SpongeValueFactory.boundedBuilder(Keys.EXPIRATION_DELAY) - .minimum(0) - .maximum(Constants.Entity.Silverfish.MAX_EXPIRATION_TICKS) - .defaultValue(0) - .actualValue(this.lifetime) - .build(); - } + values.add(this.expirationDelay().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getExpirableData()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EvokerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EvokerEntityMixin_API.java index ff11ba930f5..ae49fab8e7e 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EvokerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/EvokerEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.EvokerEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.raider.illager.spellcaster.Evoker; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(EvokerEntity.class) public abstract class EvokerEntityMixin_API extends SpellcastingIllagerEntityMixin_API implements Evoker { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + this.wololoTarget().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/GuardianEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/GuardianEntityMixin_API.java index 36f3d315299..f34ba9ef3e5 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/GuardianEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/GuardianEntityMixin_API.java @@ -24,34 +24,23 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.GuardianEntity; -import net.minecraft.network.datasync.DataParameter; -import org.spongepowered.api.entity.living.Living; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.guardian.Guardian; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import java.util.Optional; +import java.util.Set; @Mixin(GuardianEntity.class) public abstract class GuardianEntityMixin_API extends MonsterEntityMixin_API implements Guardian { - @Shadow @Final private static DataParameter TARGET_ENTITY; - @Shadow private void setTargetedEntity(int entityId) { } // setTargetedEntity - @Override - public Optional getBeamTarget() { - return Optional.ofNullable((Living) this.world.getEntityByID(this.dataManager.get(TARGET_ENTITY))); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setBeamTarget(Living entity) { - if (entity == null) { - this.setTargetedEntity(0); - } else { - this.setTargetedEntity(((LivingEntity) entity).getEntityId()); - } + this.beamTarget().map(Value::asImmutable).ifPresent(values::add); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PatrollerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PatrollerEntityMixin_API.java index e5390011a77..c8173b75a2d 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PatrollerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PatrollerEntityMixin_API.java @@ -25,10 +25,14 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.PatrollerEntity; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.Patroller; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.Set; + @Mixin(PatrollerEntity.class) public abstract class PatrollerEntityMixin_API extends MonsterEntityMixin_API implements Patroller { @@ -39,4 +43,16 @@ public void findPatrolTarget() { this.shadow$resetPatrolTarget(); } + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.leader().asImmutable()); + values.add(this.patrolling().asImmutable()); + + this.targetPosition().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PhantomEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PhantomEntityMixin_API.java index 2a8f4a7e046..a1948e48b1c 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PhantomEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PhantomEntityMixin_API.java @@ -24,27 +24,25 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import static com.google.common.base.Preconditions.checkNotNull; - import net.minecraft.entity.monster.PhantomEntity; -import org.spongepowered.api.data.type.PhantomPhase; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.Phantom; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.common.mixin.api.mcp.entity.FlyingEntityMixin_API; -@Mixin(PhantomEntity.class) -public abstract class PhantomEntityMixin_API implements Phantom { +import java.util.Set; - @Shadow private PhantomEntity.AttackPhase attackPhase; +@Mixin(PhantomEntity.class) +public abstract class PhantomEntityMixin_API extends FlyingEntityMixin_API implements Phantom { @Override - public PhantomPhase getPhase() { - return (PhantomPhase) (Object) this.attackPhase; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setPhase(PhantomPhase phase) { - checkNotNull(phase); - this.attackPhase = (PhantomEntity.AttackPhase) (Object) phase; + values.add(this.size().asImmutable()); + values.add(this.phase().asImmutable()); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PillagerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PillagerEntityMixin_API.java index 3fb3fe591d1..8449e30127e 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PillagerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/PillagerEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.PillagerEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.raider.illager.Pillager; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(PillagerEntity.class) public abstract class PillagerEntityMixin_API extends AbstractIllagerEntityMixin_API implements Pillager { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.chargingCrossbow().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/RavagerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/RavagerEntityMixin_API.java index 91ac25db0f2..f0923432cd6 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/RavagerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/RavagerEntityMixin_API.java @@ -25,51 +25,28 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.RavagerEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.raider.Ravager; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.util.Constants; + +import java.util.Set; @Mixin(RavagerEntity.class) public abstract class RavagerEntityMixin_API extends AbstractRaiderEntityMixin_API implements Ravager { - @Shadow private int stunTick; - @Shadow private int roarTick; - @Shadow protected abstract boolean shadow$isMovementBlocked(); - @Override - public boolean isImmobilized() { - return this.shadow$isMovementBlocked(); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public boolean isRoaring() { - return this.roarTick > 0; - } - - @Override - public void setRoaring(boolean roaring) { - if (roaring) { - this.roarTick = Constants.Entity.Ravager.ROAR_TIME; - return; - } + values.add(this.attackTime().asImmutable()); + values.add(this.roaringTime().asImmutable()); + values.add(this.stunnedTime().asImmutable()); - this.roarTick = 0; - } - - @Override - public boolean isStunned() { - return this.stunTick > 0; - } - - @Override - public void setStunned(boolean stunned) { - if (stunned) { - this.stunTick = Constants.Entity.Ravager.STUNNED_TIME; - return; - } + values.add(this.stunned().asImmutable()); + values.add(this.roaring().asImmutable()); + values.add(this.immobilized().asImmutable()); - this.stunTick = 0; + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ShulkerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ShulkerEntityMixin_API.java index 1e2f51e1aa3..93f96b5593c 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ShulkerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ShulkerEntityMixin_API.java @@ -24,50 +24,20 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.DyeableData; -import org.spongepowered.api.data.manipulator.mutable.block.DirectionalData; -import org.spongepowered.api.data.type.DyeColor; +import net.minecraft.entity.monster.ShulkerEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.golem.Shulker; import org.spongepowered.api.entity.projectile.EntityTargetingProjectile; -import org.spongepowered.api.util.Direction; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.common.bridge.entity.monster.ShulkerEntityBridge; -import org.spongepowered.common.data.manipulator.mutable.SpongeDyeableData; -import org.spongepowered.common.data.manipulator.mutable.block.SpongeDirectionalData; -import org.spongepowered.common.data.value.mutable.SpongeValue; import org.spongepowered.common.entity.projectile.ProjectileLauncher; import org.spongepowered.common.mixin.api.mcp.entity.passive.GolemEntityMixin_API; -import org.spongepowered.common.util.Constants; -import java.util.Collection; + import java.util.Optional; -import net.minecraft.entity.monster.ShulkerEntity; +import java.util.Set; @Mixin(ShulkerEntity.class) public abstract class ShulkerEntityMixin_API extends GolemEntityMixin_API implements Shulker { - - @Override - public DyeableData getDyeData() { - return new SpongeDyeableData(((ShulkerEntityBridge) this).bridge$getColor()); - } - - @Override - public Value.Mutable color() { - return new SpongeValue<>(Keys.DYE_COLOR, Constants.Catalog.DEFAULT_SHULKER_COLOR, ((ShulkerEntityBridge) this).bridge$getColor()); - } - - @Override - public DirectionalData getDirectionalData() { - return new SpongeDirectionalData(((ShulkerEntityBridge) this).bridge$getDirection()); - } - - @Override - public Value.Mutable direction() { - return new SpongeValue<>(Keys.DIRECTION, ((ShulkerEntityBridge) this).bridge$getDirection()); - } - @Override public

Optional

launchWithTarget(final Class

projectileClass, final org.spongepowered.api.entity.Entity target) { @@ -75,9 +45,13 @@ public

Optional

launchWithTarget(final } @Override - public void spongeApi$supplyVanillaManipulators(final Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getDyeData()); - manipulators.add(this.getDirectionalData()); + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.color().asImmutable()); + values.add(this.direction().asImmutable()); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SlimeEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SlimeEntityMixin_API.java index b3a00b99681..371f03f9d60 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SlimeEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SlimeEntityMixin_API.java @@ -24,41 +24,26 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.SlimeData; -import org.spongepowered.api.data.value.BoundedValue; +import net.minecraft.entity.monster.SlimeEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.slime.Slime; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeSlimeData; -import org.spongepowered.common.data.value.SpongeValueFactory; import org.spongepowered.common.mixin.api.mcp.entity.MobEntityMixin_API; + import java.util.Collection; -import net.minecraft.entity.monster.SlimeEntity; +import java.util.Set; @Mixin(SlimeEntity.class) public abstract class SlimeEntityMixin_API extends MobEntityMixin_API implements Slime { - @Shadow public abstract int getSlimeSize(); - @Override - public BoundedValue.Mutable slimeSize() { - return SpongeValueFactory.boundedBuilder(Keys.SLIME_SIZE) - .minimum(0) - .maximum(Integer.MAX_VALUE) - .defaultValue(1) - .actualValue(this.getSlimeSize()) - .build(); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public SlimeData getSlimeData() { - return new SpongeSlimeData(this.getSlimeSize()); - } + values.add(this.size().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getSlimeData()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpellcastingIllagerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpellcastingIllagerEntityMixin_API.java index a52d73d1e7f..509ec4d996a 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpellcastingIllagerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpellcastingIllagerEntityMixin_API.java @@ -25,25 +25,20 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.SpellcastingIllagerEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.raider.illager.spellcaster.Spellcaster; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.Set; + @Mixin(SpellcastingIllagerEntity.class) public abstract class SpellcastingIllagerEntityMixin_API extends AbstractIllagerEntityMixin_API implements Spellcaster { @Shadow protected int spellTicks; - @Shadow private SpellcastingIllagerEntity.SpellType activeSpell; - @Shadow public abstract boolean shadow$isSpellcasting(); - @Shadow public abstract void shadow$setSpellType(SpellcastingIllagerEntity.SpellType p_193081_1_); - @Shadow protected abstract SpellcastingIllagerEntity.SpellType shadow$getSpellType(); @Override - public boolean isCastingSpell() { - return this.shadow$isSpellcasting(); - } - - public void setCastingSpell(boolean castSpell) { + public void castSpell(boolean castSpell) { if (!castSpell) { this.spellTicks = 0; return; @@ -51,4 +46,15 @@ public void setCastingSpell(boolean castSpell) { // i509 -> TODO: Figure out how to get the casting time from UseSpellGoal. Yes Mojang made spells a goal and their oh so exposed enum SpellType does not refer to the goals. } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.castingTime().asImmutable()); + + this.currentSpell().map(Value::asImmutable).ifPresent(values::add); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpiderEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpiderEntityMixin_API.java index dacc06fbe32..43550b4e180 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpiderEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/SpiderEntityMixin_API.java @@ -25,18 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.SpiderEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.spider.Spider; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; + +import java.util.Set; @Mixin(SpiderEntity.class) public abstract class SpiderEntityMixin_API extends MonsterEntityMixin_API implements Spider { - @Shadow public abstract boolean isBesideClimbableBlock(); - @Override - public boolean isClimbing() { - return this.isBesideClimbableBlock(); + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.climbing()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/VindicatorEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/VindicatorEntityMixin_API.java index 3b41bb04594..3732cf05fdd 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/VindicatorEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/VindicatorEntityMixin_API.java @@ -24,30 +24,23 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.raider.illager.Vindicator; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.value.mutable.SpongeValue; import net.minecraft.entity.monster.VindicatorEntity; -import java.util.Collection; +import java.util.Set; @Mixin(VindicatorEntity.class) public abstract class VindicatorEntityMixin_API extends AbstractIllagerEntityMixin_API implements Vindicator { - @Shadow private boolean johnny; - @Override - public Value.Mutable johnny() { - return new SpongeValue<>(Keys.IS_JOHNNY, false, this.johnny); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(new SpongeJohnnyData(this.johnny)); + values.add(this.johnny().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieEntityMixin_API.java index 507c85506a7..1d79176bb1f 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieEntityMixin_API.java @@ -31,5 +31,4 @@ @Mixin(ZombieEntity.class) public abstract class ZombieEntityMixin_API extends MonsterEntityMixin_API implements Zombie { - } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombiePigmanEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombiePigmanEntityMixin_API.java index c5fa438d2c7..cf256752239 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombiePigmanEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombiePigmanEntityMixin_API.java @@ -24,44 +24,25 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.monster; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.AngerableData; -import org.spongepowered.api.data.value.BoundedValue; +import net.minecraft.entity.monster.ZombiePigmanEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.zombie.ZombiePigman; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeAggressiveData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeAngerableData; -import org.spongepowered.common.data.value.SpongeValueFactory; + import java.util.Collection; -import net.minecraft.entity.monster.ZombiePigmanEntity; +import java.util.Set; @Mixin(ZombiePigmanEntity.class) public abstract class ZombiePigmanEntityMixin_API extends ZombieEntityMixin_API implements ZombiePigman { - @Shadow private int angerLevel; - - @Shadow public abstract boolean isAngry(); - @Override - public AngerableData getAngerData() { - return new SpongeAngerableData(this.angerLevel); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public BoundedValue.Mutable angerLevel() { - return SpongeValueFactory.boundedBuilder(Keys.ANGER_LEVEL) - .actualValue(this.angerLevel) - .defaultValue(0) - .minimum(Integer.MIN_VALUE) - .maximum(Integer.MAX_VALUE) - .build(); - } + values.add(this.angerLevel().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getAngerData()); - manipulators.add(new SpongeAggressiveData(this.isAngry())); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieVillagerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieVillagerEntityMixin_API.java index 5cbd06c1a61..604b772f6bc 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieVillagerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/monster/ZombieVillagerEntityMixin_API.java @@ -25,13 +25,24 @@ package org.spongepowered.common.mixin.api.mcp.entity.monster; import net.minecraft.entity.monster.ZombieVillagerEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.zombie.ZombieVillager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.Set; + @Mixin(ZombieVillagerEntity.class) public abstract class ZombieVillagerEntityMixin_API extends ZombieEntityMixin_API implements ZombieVillager { - @Shadow public abstract int getProfession(); + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.type().asImmutable()); + values.add(this.profession().asImmutable()); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/AnimalEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/AnimalEntityMixin_API.java index 92566e2a26b..9b5bd1dd72b 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/AnimalEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/AnimalEntityMixin_API.java @@ -25,10 +25,25 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.AnimalEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Animal; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.common.mixin.api.mcp.entity.AgeableEntityMixin_API; +import java.util.Set; + @Mixin(AnimalEntity.class) public abstract class AnimalEntityMixin_API extends AgeableEntityMixin_API implements Animal { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.breedTime().asImmutable()); + values.add(this.canBreed().asImmutable()); + + this.breeder().map(Value::asImmutable).ifPresent(values::add); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/CatEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/CatEntityMixin_API.java new file mode 100644 index 00000000000..cf14a8112fa --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/CatEntityMixin_API.java @@ -0,0 +1,56 @@ +/* + * 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.mixin.api.mcp.entity.passive; + +import net.minecraft.entity.passive.CatEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.animal.Cat; +import org.spongepowered.asm.mixin.Mixin; + +import java.util.Set; + +@Mixin(CatEntity.class) +public abstract class CatEntityMixin_API extends TameableEntityMixin_API implements Cat { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Sittable + values.add(this.sitting().asImmutable()); + + // Meow + values.add(this.type().asImmutable()); + values.add(this.lyingDown().asImmutable()); + values.add(this.relaxed().asImmutable()); + values.add(this.collarColor().asImmutable()); + values.add(this.hissing().asImmutable()); + values.add(this.beggingForFood().asImmutable()); + values.add(this.purring().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ChickenEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ChickenEntityMixin_API.java index 9ece437a118..972cdb55db3 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ChickenEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ChickenEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.ChickenEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Chicken; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(ChickenEntity.class) public abstract class ChickenEntityMixin_API extends AnimalEntityMixin_API implements Chicken { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.eggTime().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/DolphinEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/DolphinEntityMixin_API.java new file mode 100644 index 00000000000..fce18d62470 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/DolphinEntityMixin_API.java @@ -0,0 +1,47 @@ +/* + * 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.mixin.api.mcp.entity.passive; + +import net.minecraft.entity.passive.DolphinEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.aquatic.Dolphin; +import org.spongepowered.asm.mixin.Mixin; + +import java.util.Set; + +@Mixin(DolphinEntity.class) +public abstract class DolphinEntityMixin_API extends WaterMobEntityMixin_API implements Dolphin { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.skinMoisture().asImmutable()); + values.add(this.gotFish().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/FoxEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/FoxEntityMixin_API.java index a5210843237..230530ad918 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/FoxEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/FoxEntityMixin_API.java @@ -25,14 +25,17 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.FoxEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Fox; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.common.mixin.accessor.entity.passive.FoxEntityAccessor; +import java.util.Set; import java.util.UUID; @Mixin(FoxEntity.class) -public abstract class FoxEntityMixin_API implements Fox { +public abstract class FoxEntityMixin_API extends AnimalEntityMixin_API implements Fox { @Shadow protected abstract boolean shadow$isTrustedUUID(UUID p_213468_1_); @@ -40,4 +43,24 @@ public abstract class FoxEntityMixin_API implements Fox { public boolean trusts(UUID uniqueId) { return this.shadow$isTrustedUUID(uniqueId); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.type().asImmutable()); + values.add(this.sitting().asImmutable()); + values.add(this.faceplanted().asImmutable()); + values.add(this.defending().asImmutable()); + values.add(this.sleeping().asImmutable()); + values.add(this.pouncing().asImmutable()); + values.add(this.crouching().asImmutable()); + values.add(this.interested().asImmutable()); + + this.firstTrusted().map(Value::asImmutable).ifPresent(values::add); + this.secondTrusted().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/IronGolemEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/IronGolemEntityMixin_API.java index e7d6f796009..5607adaee7e 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/IronGolemEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/IronGolemEntityMixin_API.java @@ -25,10 +25,23 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.IronGolemEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.golem.IronGolem; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.common.mixin.accessor.entity.passive.FoxEntityAccessor; + +import java.util.Set; @Mixin(IronGolemEntity.class) public abstract class IronGolemEntityMixin_API extends GolemEntityMixin_API implements IronGolem { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.playerCreated().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/MooshroomEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/MooshroomEntityMixin_API.java index e30b962a18e..698378f403f 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/MooshroomEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/MooshroomEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.MooshroomEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.cow.Mooshroom; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(MooshroomEntity.class) public abstract class MooshroomEntityMixin_API extends AnimalEntityMixin_API implements Mooshroom { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.type().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/OcelotEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/OcelotEntityMixin_API.java index e42d1161b77..e6a9d28e10f 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/OcelotEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/OcelotEntityMixin_API.java @@ -24,51 +24,27 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.OcelotData; -import org.spongepowered.api.data.type.CatType; +import net.minecraft.entity.passive.OcelotEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Ocelot; import org.spongepowered.api.text.translation.Translation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeOcelotData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeSittingData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.registry.type.entity.OcelotTypeRegistryModule; import org.spongepowered.common.text.translation.SpongeTranslation; -import org.spongepowered.common.util.Constants; + import java.util.Collection; -import net.minecraft.entity.passive.OcelotEntity; +import java.util.Set; @Mixin(OcelotEntity.class) -public abstract class OcelotEntityMixin_API extends TameableEntityMixin_API implements Ocelot { - - @Shadow public abstract int getTameSkin(); +public abstract class OcelotEntityMixin_API extends AnimalEntityMixin_API implements Ocelot { @Override - public OcelotData getOcelotData() { - return new SpongeOcelotData(OcelotTypeRegistryModule.OCELOT_IDMAP.get(this.getTameSkin())); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable variant() { - return new SpongeValue<>(Keys.OCELOT_TYPE, Constants.Entity.Cat.DEFAULT_TYPE, OcelotTypeRegistryModule.OCELOT_IDMAP.get(this.getTameSkin())); - } + values.add(this.trusting().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(new SpongeSittingData(this.shadow$isSitting())); - manipulators.add(this.getOcelotData()); - } - - @Override - public Translation getTranslation() { - if (this.shadow$isTamed()) { - return new SpongeTranslation("entity.Cat.name"); - } - return super.getTranslation(); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PandaEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PandaEntityMixin_API.java new file mode 100644 index 00000000000..740840f8a2d --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PandaEntityMixin_API.java @@ -0,0 +1,61 @@ +/* + * 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.mixin.api.mcp.entity.passive; + +import net.minecraft.entity.passive.PandaEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.animal.Panda; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.common.util.Constants; + +import java.util.Set; + +@Mixin(PandaEntity.class) +public abstract class PandaEntityMixin_API extends AnimalEntityMixin_API implements Panda { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Sittable + values.add(this.sitting().asImmutable()); + + values.add(this.knownGene().asImmutable()); + values.add(this.hiddenGene().asImmutable()); + values.add(this.sneezing().asImmutable()); + values.add(this.lyingOnBack().asImmutable()); + values.add(this.rollingAround().asImmutable()); + values.add(this.unhappyTime().asImmutable()); + values.add(this.eatingTime().asImmutable()); + values.add(this.sneezingTime().asImmutable()); + values.add(this.frightened().asImmutable()); + values.add(this.unhappy().asImmutable()); + values.add(this.eating().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ParrotEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ParrotEntityMixin_API.java index 306e310e0ec..404f2e86800 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ParrotEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/ParrotEntityMixin_API.java @@ -24,20 +24,13 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.ParrotData; -import org.spongepowered.api.data.type.ParrotType; +import net.minecraft.entity.passive.ParrotEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Parrot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeParrotData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeSittingData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.registry.type.entity.ParrotVariantRegistryModule; -import org.spongepowered.common.util.Constants; -import java.util.Collection; -import net.minecraft.entity.passive.ParrotEntity; + +import java.util.Set; @Mixin(ParrotEntity.class) public abstract class ParrotEntityMixin_API extends TameableEntityMixin_API implements Parrot { @@ -45,20 +38,15 @@ public abstract class ParrotEntityMixin_API extends TameableEntityMixin_API impl @Shadow public abstract int getVariant(); @Override - public ParrotData getParrotData() { - return new SpongeParrotData(ParrotVariantRegistryModule.PARROT_VARIANT_IDMAP.get(this.getVariant())); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable type() { - return new SpongeValue<>(Keys.PARROT_TYPE, Constants.Entity.Parrot.DEFAULT_TYPE, ParrotVariantRegistryModule.PARROT_VARIANT_IDMAP.get(this.getVariant())); - } + // Sittable + values.add(this.sitting().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(new SpongeSittingData(this.shadow$isSitting())); - manipulators.add(this.getParrotData()); + values.add(this.type().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PigEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PigEntityMixin_API.java index fb588d4d895..f7e1e913d8b 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PigEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PigEntityMixin_API.java @@ -24,35 +24,24 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.PigSaddleData; +import net.minecraft.entity.passive.PigEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Pig; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongePigSaddleData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import java.util.Collection; -import net.minecraft.entity.passive.PigEntity; + +import java.util.Set; @Mixin(PigEntity.class) public abstract class PigEntityMixin_API extends AnimalEntityMixin_API implements Pig { - @Shadow public abstract boolean getSaddled(); - @Override - public PigSaddleData getPigSaddleData() { - return new SpongePigSaddleData(this.getSaddled()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable saddled() { - return new SpongeValue<>(Keys.IS_SADDLED, false, this.getSaddled()); - } + values.add(this.saddled().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getPigSaddleData()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PolarBearEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PolarBearEntityMixin_API.java index db72fbeb513..dc6b50d37e9 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PolarBearEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/PolarBearEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.PolarBearEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.PolarBear; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(PolarBearEntity.class) public abstract class PolarBearEntityMixin_API extends AnimalEntityMixin_API implements PolarBear { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.standing().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/RabbitEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/RabbitEntityMixin_API.java index 8cb29c7a1bb..d6038f0d309 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/RabbitEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/RabbitEntityMixin_API.java @@ -24,38 +24,23 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.RabbitData; -import org.spongepowered.api.data.type.RabbitType; +import net.minecraft.entity.passive.RabbitEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Rabbit; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeRabbitData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.registry.type.entity.RabbitTypeRegistryModule; -import org.spongepowered.common.util.Constants; -import java.util.Collection; -import net.minecraft.entity.passive.RabbitEntity; + +import java.util.Set; @Mixin(RabbitEntity.class) public abstract class RabbitEntityMixin_API extends AnimalEntityMixin_API implements Rabbit { - @Shadow public abstract int getRabbitType(); - @Override - public RabbitData getRabbitData() { - return new SpongeRabbitData(RabbitTypeRegistryModule.RABBIT_IDMAP.get(this.getRabbitType())); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable type() { - return new SpongeValue<>(Keys.RABBIT_TYPE, Constants.Entity.Rabbit.DEFAULT_TYPE, RabbitTypeRegistryModule.RABBIT_IDMAP.get(this.getRabbitType())); - } + values.add(this.type().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getRabbitData()); + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/SheepEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/SheepEntityMixin_API.java index d5d001c6f40..edb571e9f63 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/SheepEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/SheepEntityMixin_API.java @@ -24,41 +24,23 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.DyeableData; -import org.spongepowered.api.data.type.DyeColor; +import net.minecraft.entity.passive.SheepEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Sheep; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.SpongeDyeableData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeShearedData; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.util.Constants; -import java.util.Collection; -import net.minecraft.entity.passive.SheepEntity; + +import java.util.Set; @Mixin(SheepEntity.class) public abstract class SheepEntityMixin_API extends AnimalEntityMixin_API implements Sheep { - @Shadow public abstract net.minecraft.item.DyeColor getFleeceColor(); - @Shadow public abstract boolean getSheared(); - @Override - public DyeableData getDyeData() { - return new SpongeDyeableData((DyeColor) (Object) this.getFleeceColor()); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Value.Mutable color() { - return new SpongeValue<>(Keys.DYE_COLOR, Constants.Catalog.DEFAULT_SHEEP_COLOR, (DyeColor) (Object) this.getFleeceColor()); - } + values.add(this.color().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getDyeData()); - manipulators.add(new SpongeShearedData(this.getSheared())); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TameableEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TameableEntityMixin_API.java index 62a0e6c2473..9509ac771a5 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TameableEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TameableEntityMixin_API.java @@ -25,13 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive; import net.minecraft.entity.passive.TameableEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.animal.TameableAnimal; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; + +import java.util.Set; @Mixin(TameableEntity.class) -public abstract class TameableEntityMixin_API extends AnimalEntityMixin_API { +public abstract class TameableEntityMixin_API extends AnimalEntityMixin_API implements TameableAnimal { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + this.tamer().map(Value::asImmutable).ifPresent(values::add); - @Shadow public abstract boolean shadow$isTamed(); - @Shadow public abstract boolean shadow$isSitting(); + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TurtleEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TurtleEntityMixin_API.java new file mode 100644 index 00000000000..39891ae579a --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/TurtleEntityMixin_API.java @@ -0,0 +1,51 @@ +/* + * 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.mixin.api.mcp.entity.passive; + +import net.minecraft.entity.passive.TurtleEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.animal.Turtle; +import org.spongepowered.asm.mixin.Mixin; + +import java.util.Set; + +@Mixin(TurtleEntity.class) +public abstract class TurtleEntityMixin_API extends AnimalEntityMixin_API implements Turtle { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.homePosition().asImmutable()); + values.add(this.hasEgg().asImmutable()); + values.add(this.layingEgg().asImmutable()); + values.add(this.travelingPosition().asImmutable()); + values.add(this.goingHome().asImmutable()); + values.add(this.traveling().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/WolfEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/WolfEntityMixin_API.java index 564f6f327d1..beb83997758 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/WolfEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/WolfEntityMixin_API.java @@ -24,25 +24,27 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive; -import org.spongepowered.api.data.manipulator.mutable.entity.SittingData; +import net.minecraft.entity.passive.WolfEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Wolf; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeAggressiveData; -import org.spongepowered.common.mixin.api.mcp.entity.AgeableEntityMixin_API; -import java.util.Collection; -import net.minecraft.entity.passive.WolfEntity; +import java.util.Set; @Mixin(WolfEntity.class) -public abstract class WolfEntityMixin_API extends AgeableEntityMixin_API implements Wolf { - - @Shadow public abstract boolean shadow$isAngry(); +public abstract class WolfEntityMixin_API extends TameableEntityMixin_API implements Wolf { @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.get(SittingData.class).get()); - manipulators.add(new SpongeAggressiveData(this.shadow$isAngry())); + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Sittable + values.add(this.sitting().asImmutable()); + + values.add(this.angry().asImmutable()); + values.add(this.collarColor().asImmutable()); + values.add(this.beggingForFood().asImmutable()); + + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractFishEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractFishEntityMixin_API.java new file mode 100644 index 00000000000..f38e15e010b --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractFishEntityMixin_API.java @@ -0,0 +1,35 @@ +/* + * 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.mixin.api.mcp.entity.passive.fish; + +import net.minecraft.entity.passive.fish.AbstractFishEntity; +import org.spongepowered.api.entity.living.aquatic.fish.Fish; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.common.mixin.api.mcp.entity.passive.WaterMobEntityMixin_API; + +@Mixin(AbstractFishEntity.class) +public abstract class AbstractFishEntityMixin_API extends WaterMobEntityMixin_API implements Fish { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractGroupFishEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractGroupFishEntityMixin_API.java new file mode 100644 index 00000000000..fbc5594fbdb --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/AbstractGroupFishEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.passive.fish; + +import net.minecraft.entity.passive.fish.AbstractGroupFishEntity; +import org.spongepowered.api.entity.living.aquatic.fish.school.SchoolingFish; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(AbstractGroupFishEntity.class) +public abstract class AbstractGroupFishEntityMixin_API extends AbstractFishEntityMixin_API implements SchoolingFish { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/CodEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/CodEntityMixin_API.java new file mode 100644 index 00000000000..969bfe3f8de --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/CodEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.passive.fish; + +import net.minecraft.entity.passive.fish.CodEntity; +import org.spongepowered.api.entity.living.aquatic.fish.school.Cod; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(CodEntity.class) +public abstract class CodEntityMixin_API extends AbstractGroupFishEntityMixin_API implements Cod { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/PufferfishEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/PufferfishEntityMixin_API.java new file mode 100644 index 00000000000..e218d5f5c59 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/PufferfishEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.passive.fish; + +import net.minecraft.entity.passive.fish.PufferfishEntity; +import org.spongepowered.api.entity.living.aquatic.fish.Pufferfish; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(PufferfishEntity.class) +public abstract class PufferfishEntityMixin_API extends AbstractFishEntityMixin_API implements Pufferfish { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/SalmonEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/SalmonEntityMixin_API.java new file mode 100644 index 00000000000..3259a8f045e --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/SalmonEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.passive.fish; + +import net.minecraft.entity.passive.fish.SalmonEntity; +import org.spongepowered.api.entity.living.aquatic.fish.school.Salmon; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(SalmonEntity.class) +public abstract class SalmonEntityMixin_API extends AbstractGroupFishEntityMixin_API implements Salmon { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/TropicalFishEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/TropicalFishEntityMixin_API.java new file mode 100644 index 00000000000..959e544f221 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/fish/TropicalFishEntityMixin_API.java @@ -0,0 +1,48 @@ +/* + * 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.mixin.api.mcp.entity.passive.fish; + +import net.minecraft.entity.passive.fish.TropicalFishEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.aquatic.fish.school.TropicalFish; +import org.spongepowered.asm.mixin.Mixin; + +import java.util.Set; + +@Mixin(TropicalFishEntity.class) +public abstract class TropicalFishEntityMixin_API extends AbstractGroupFishEntityMixin_API implements TropicalFish { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.baseColor().asImmutable()); + values.add(this.patternColor().asImmutable()); + values.add(this.shape().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractChestedHorseEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractChestedHorseEntityMixin_API.java new file mode 100644 index 00000000000..958d068958f --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractChestedHorseEntityMixin_API.java @@ -0,0 +1,47 @@ +/* + * 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.mixin.api.mcp.entity.passive.horse; + +import net.minecraft.entity.passive.horse.AbstractChestedHorseEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.animal.horse.PackHorse; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.common.mixin.inventory.api.carrier.AbstractHorseEntityMixin_API; + +import java.util.Set; + +@Mixin(AbstractChestedHorseEntity.class) +public abstract class AbstractChestedHorseEntityMixin_API extends AbstractHorseEntityMixin_API implements PackHorse { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.displayChest().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractHorseMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractHorseEntityMixin_API.java similarity index 81% rename from src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractHorseMixin_API.java rename to src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractHorseEntityMixin_API.java index 535db32db53..d358474996d 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractHorseMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/AbstractHorseEntityMixin_API.java @@ -25,16 +25,11 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive.horse; import net.minecraft.entity.passive.horse.AbstractHorseEntity; -import net.minecraft.inventory.Inventory; import org.spongepowered.api.entity.living.animal.horse.HorseEntity; -import org.spongepowered.api.item.inventory.Carrier; -import org.spongepowered.api.item.inventory.type.CarriedInventory; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.inventory.util.InventoryUtil; import org.spongepowered.common.mixin.api.mcp.entity.passive.AnimalEntityMixin_API; @Mixin(AbstractHorseEntity.class) -public abstract class AbstractHorseMixin_API extends AnimalEntityMixin_API implements HorseEntity { +public abstract class AbstractHorseEntityMixin_API extends AnimalEntityMixin_API implements HorseEntity { } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/DonkeyEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/DonkeyEntityMixin_API.java index 8dbe78b4f8f..860214d7725 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/DonkeyEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/DonkeyEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive.horse; import net.minecraft.entity.passive.horse.DonkeyEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.horse.Donkey; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(DonkeyEntity.class) -public abstract class DonkeyEntityMixin_API extends AbstractHorseMixin_API implements Donkey { +public abstract class DonkeyEntityMixin_API extends AbstractChestedHorseEntityMixin_API implements Donkey { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + this.tamer().map(Value::asImmutable).ifPresent(values::add); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/HorseEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/HorseEntityMixin_API.java index c7677aee80b..22fc6de8386 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/HorseEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/HorseEntityMixin_API.java @@ -24,10 +24,26 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.passive.horse; +import net.minecraft.entity.passive.horse.HorseEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.horse.Horse; import org.spongepowered.asm.mixin.Mixin; -import net.minecraft.entity.passive.horse.HorseEntity; + +import java.util.Set; @Mixin(HorseEntity.class) -public abstract class HorseEntityMixin_API extends AbstractHorseMixin_API implements Horse { +public abstract class HorseEntityMixin_API extends AbstractHorseEntityMixin_API implements Horse { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.color().asImmutable()); + values.add(this.style().asImmutable()); + + this.tamer().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/LlamaEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/LlamaEntityMixin_API.java index 1ea5a2c4088..85b136f6134 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/LlamaEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/LlamaEntityMixin_API.java @@ -25,53 +25,30 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive.horse; import net.minecraft.entity.passive.horse.LlamaEntity; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.type.LlamaType; -import org.spongepowered.api.data.type.LlamaTypes; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.horse.llama.Llama; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.value.SpongeValueFactory; -import org.spongepowered.common.data.value.mutable.SpongeValue; -import org.spongepowered.common.util.Constants; + +import java.util.Set; @Mixin(LlamaEntity.class) -public abstract class LlamaEntityMixin_API extends AbstractHorseMixin_API implements Llama { +public abstract class LlamaEntityMixin_API extends AbstractChestedHorseEntityMixin_API implements Llama { @Shadow public abstract int getStrength(); @Shadow public abstract int getVariant(); @Shadow public abstract void setVariant(int p_190710_1_); @Override - public Value.Mutable type() { - final int i = this.getVariant(); - final LlamaType variant; - if (i == 0) { - variant = LlamaTypes.CREAMY; - } else if (i == 1) { - variant = LlamaTypes.WHITE; - } else if (i == 2) { - variant = LlamaTypes.BROWN; - } else if (i == 3) { - variant = LlamaTypes.GRAY; - } else { - this.setVariant(0); // Basically some validation - variant = LlamaTypes.CREAMY; - } - return new SpongeValue<>(Keys.LLAMA_TYPE, Constants.Entity.Llama.DEFAULT_TYPE, variant); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public org.spongepowered.api.data.value.BoundedValue.Mutable strength() { - return SpongeValueFactory.getInstance() - .createBoundedValueBuilder(Keys.LLAMA_STRENGTH) - .defaultValue(Constants.Entity.Llama.DEFAULT_STRENGTH) - .minimum(Constants.Entity.Llama.MINIMUM_STRENGTH) - .maximum(Constants.Entity.Llama.MAXIMUM_STRENGTH) - .actualValue(this.getStrength()) - .build(); - } + values.add(this.type().asImmutable()); + values.add(this.strength().asImmutable()); + + this.tamer().map(Value::asImmutable).ifPresent(values::add); + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/MuleEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/MuleEntityMixin_API.java index 7d3540d109f..d0d9e2b5f95 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/MuleEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/MuleEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.passive.horse; import net.minecraft.entity.passive.horse.MuleEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.horse.Mule; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(MuleEntity.class) -public abstract class MuleEntityMixin_API extends AbstractHorseMixin_API implements Mule { +public abstract class MuleEntityMixin_API extends AbstractChestedHorseEntityMixin_API implements Mule { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + this.tamer().map(Value::asImmutable).ifPresent(values::add); + + return values; + } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/SkeletonHorseEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/SkeletonHorseEntityMixin_API.java index 7742438506b..5af702ef89e 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/SkeletonHorseEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/SkeletonHorseEntityMixin_API.java @@ -29,6 +29,6 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(SkeletonHorseEntity.class) -public abstract class SkeletonHorseEntityMixin_API extends AbstractHorseMixin_API implements SkeletonHorse { +public abstract class SkeletonHorseEntityMixin_API extends AbstractHorseEntityMixin_API implements SkeletonHorse { } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/TraderLlamaEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/TraderLlamaEntityMixin_API.java new file mode 100644 index 00000000000..a444a0faf04 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/TraderLlamaEntityMixin_API.java @@ -0,0 +1,48 @@ +/* + * 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.mixin.api.mcp.entity.passive.horse; + +import net.minecraft.entity.passive.horse.TraderLlamaEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.living.animal.horse.llama.TraderLlama; +import org.spongepowered.asm.mixin.Mixin; + +import java.util.Set; + +@Mixin(TraderLlamaEntity.class) +public abstract class TraderLlamaEntityMixin_API extends LlamaEntityMixin_API implements TraderLlama { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.despawnDelay().asImmutable()); + + this.tamer().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/ZombieHorseEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/ZombieHorseEntityMixin_API.java index 77cfb0f0668..610cc1dcbf0 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/ZombieHorseEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/passive/horse/ZombieHorseEntityMixin_API.java @@ -29,6 +29,6 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(ZombieHorseEntity.class) -public abstract class ZombieHorseEntityMixin_API extends AbstractHorseMixin_API implements ZombieHorse { +public abstract class ZombieHorseEntityMixin_API extends AbstractHorseEntityMixin_API implements ZombieHorse { } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/PlayerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/PlayerEntityMixin_API.java index 6b262a815d8..3725d437858 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/PlayerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/PlayerEntityMixin_API.java @@ -62,5 +62,4 @@ public abstract class PlayerEntityMixin_API extends LivingEntityMixin_API { return this.shadow$getName(); } - } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/ServerPlayerEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/ServerPlayerEntityMixin_API.java index e519484a0c6..dfd272e8c8c 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/ServerPlayerEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/player/ServerPlayerEntityMixin_API.java @@ -52,9 +52,6 @@ import org.spongepowered.api.advancement.AdvancementProgress; import org.spongepowered.api.advancement.AdvancementTree; import org.spongepowered.api.block.BlockState; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData; -import org.spongepowered.api.data.manipulator.mutable.entity.JoinData; import org.spongepowered.api.data.type.SkinPart; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.effect.particle.ParticleEffect; @@ -102,9 +99,6 @@ import org.spongepowered.common.bridge.network.ServerPlayNetHandlerBridge; import org.spongepowered.common.bridge.network.play.server.SSendResourcePackPacketBridge; import org.spongepowered.common.bridge.scoreboard.ServerScoreboardBridge; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeGameModeData; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeJoinData; -import org.spongepowered.common.data.value.mutable.SpongeValue; import org.spongepowered.common.effect.particle.SpongeParticleEffect; import org.spongepowered.common.effect.particle.SpongeParticleHelper; import org.spongepowered.common.effect.record.SpongeRecordType; @@ -112,7 +106,6 @@ import org.spongepowered.common.entity.player.tab.SpongeTabList; import org.spongepowered.common.text.SpongeTexts; import org.spongepowered.common.util.BookFaker; -import org.spongepowered.common.util.Constants; import org.spongepowered.common.util.LocaleCache; import org.spongepowered.common.util.NetworkUtil; import org.spongepowered.common.world.storage.SpongePlayerDataHandler; @@ -133,7 +126,7 @@ import javax.annotation.Nullable; @Mixin(ServerPlayerEntity.class) -@Implements(@Interface(iface = Player.class, prefix = "api$")) +@Implements(@Interface(iface = Player.class, prefix = "player$")) public abstract class ServerPlayerEntityMixin_API extends PlayerEntityMixin_API implements Player { @Shadow @Final public MinecraftServer server; @@ -141,12 +134,9 @@ public abstract class ServerPlayerEntityMixin_API extends PlayerEntityMixin_API @Shadow @Final private PlayerAdvancements advancements; @Shadow private String language; @Shadow public ServerPlayNetHandler connection; - @Shadow private PlayerEntity.EnumChatVisibility chatVisibility = PlayerEntity.EnumChatVisibility.FULL; + @Shadow private net.minecraft.entity.player.ChatVisibility chatVisibility = net.minecraft.entity.player.ChatVisibility.FULL; @Shadow private boolean chatColours; - @Shadow public abstract Entity getSpectatingEntity(); - @Shadow public abstract void setSpectatingEntity(Entity entity); - private boolean api$sleepingIgnored; private TabList api$tabList = new SpongeTabList((ServerPlayerEntity) (Object) this); @Nullable private WorldBorder api$worldBorder; @@ -408,21 +398,6 @@ public TabList getTabList() { return this.api$tabList; } - @Override - public JoinData getJoinData() { - return new SpongeJoinData(SpongePlayerDataHandler.getFirstJoined(this.getUniqueID()).get(), Instant.now()); - } - - @Override - public Value.Mutable firstPlayed() { - return new SpongeValue<>(Keys.FIRST_DATE_PLAYED, Instant.EPOCH, SpongePlayerDataHandler.getFirstJoined(this.getUniqueID()).get()); - } - - @Override - public Value.Mutable lastPlayed() { - return new SpongeValue<>(Keys.LAST_DATE_PLAYED, Instant.EPOCH, Instant.now()); - } - @Override public boolean hasPlayedBefore() { final Instant instant = SpongePlayerDataHandler.getFirstJoined(this.getUniqueId()).get(); @@ -432,24 +407,6 @@ public boolean hasPlayedBefore() { return timeSinceFirstJoined.getSeconds() > 0; } - @Override - public GameModeData getGameModeData() { - return new SpongeGameModeData((GameMode) (Object) this.interactionManager.getGameType()); - } - - @Override - public Value.Mutable gameMode() { - return new SpongeValue<>(Keys.GAME_MODE, Constants.Catalog.DEFAULT_GAMEMODE, - (GameMode) (Object) this.interactionManager.getGameType()); - } - - @Override - public void spongeApi$supplyVanillaManipulators(final Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(this.getJoinData()); - manipulators.add(this.getGameModeData()); - } - public void sendBlockChange(final BlockPos pos, final net.minecraft.block.BlockState state) { final SChangeBlockPacket packet = new SChangeBlockPacket(); packet.pos = pos; @@ -478,18 +435,6 @@ public boolean respawnPlayer() { return true; } - @Override - public Optional getSpectatorTarget() { - // For the API, return empty if we're spectating ourself. - @Nonnull final Entity entity = this.getSpectatingEntity(); - return entity == (Object) this ? Optional.empty() : Optional.of((org.spongepowered.api.entity.Entity) entity); - } - - @Override - public void setSpectatorTarget(@Nullable final org.spongepowered.api.entity.Entity entity) { - this.setSpectatingEntity((Entity) entity); - } - @Override public MessageChannelEvent.Chat simulateChat(final Text message, final Cause cause) { checkNotNull(message, "message"); @@ -568,4 +513,26 @@ public boolean setLocation(final Vector3d position, final UUID world) { final World loaded = Sponge.getServer().loadWorld(prop).orElseThrow(() -> new IllegalArgumentException("Invalid World: Could not load world for UUID")); return this.setLocation(new Location<>(loaded, position)); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Humanoid + values.add(this.foodLevel().asImmutable()); + values.add(this.exhaustion().asImmutable()); + values.add(this.saturation().asImmutable()); + values.add(this.gameMode().asImmutable()); + + // Player + values.add(this.firstPlayed().asImmutable()); + values.add(this.lastPlayed().asImmutable()); + values.add(this.sleepingIgnored().asImmutable()); + + // If getSpectatingEntity returns this player, then we are not spectating any other entity, so spectatorTarget would be an Optional.empty() + this.spectatorTarget().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractArrowEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractArrowEntityMixin_API.java index 3fa3bc5f75e..4ab107dc7fb 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractArrowEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractArrowEntityMixin_API.java @@ -24,55 +24,32 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.projectile; -import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.AbstractArrowEntity; -import org.spongepowered.api.data.DataManipulator.Mutable; -import org.spongepowered.api.entity.projectile.arrow.Arrow; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.arrow.ArrowEntity; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import java.util.Collection; - -import javax.annotation.Nullable; +import java.util.Set; @Mixin(AbstractArrowEntity.class) public abstract class AbstractArrowEntityMixin_API extends EntityMixin_API implements ArrowEntity { - @Shadow public Entity shootingEntity; - @Shadow private double damage; + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - // Not all ProjectileSources are entities (e.g. BlockProjectileSource). - // This field is used to store a ProjectileSource that isn't an entity. - @Nullable public ProjectileSource projectileSource; + // Projectile + values.add(this.shooter().asImmutable()); - @Override - public ProjectileSource getShooter() { - if (this.projectileSource != null) { - return this.projectileSource; - } else if (this.shootingEntity instanceof ProjectileSource) { - return (ProjectileSource) this.shootingEntity; - } - return ProjectileSource.UNKNOWN; - } + // DamagingProjectile + values.add(this.attackDamage().asImmutable()); + values.add(this.customAttackDamage().asImmutable()); - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(getKnockbackData()); - } + values.add(this.pickupRule().asImmutable()); + values.add(this.knockbackStrength().asImmutable()); - @Override - public void setShooter(ProjectileSource shooter) { - if (shooter instanceof Entity) { - // This allows things like Vanilla kill attribution to take place - this.shootingEntity = (Entity) shooter; - } else { - this.shootingEntity = null; - } - this.projectileSource = shooter; + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractFireballEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractFireballEntityMixin_API.java index 6c72b75d046..14eef678e72 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractFireballEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/AbstractFireballEntityMixin_API.java @@ -25,9 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.projectile; import net.minecraft.entity.projectile.AbstractFireballEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.explosive.fireball.FireballEntity; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(AbstractFireballEntity.class) public abstract class AbstractFireballEntityMixin_API extends DamagingProjectileEntityMixin_API implements FireballEntity { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.acceleration().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/DamagingProjectileEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/DamagingProjectileEntityMixin_API.java index 108c177b9d3..f01667e5726 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/DamagingProjectileEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/DamagingProjectileEntityMixin_API.java @@ -24,64 +24,29 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.projectile; -import org.spongepowered.api.data.Keys; +import net.minecraft.entity.projectile.DamagingProjectileEntity; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.DamagingProjectile; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.entity.SpongeAccelerationData; -import org.spongepowered.common.data.value.mutable.SpongeValue; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import org.spongepowered.math.vector.Vector3d; -import java.util.Collection; -import javax.annotation.Nullable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.projectile.DamagingProjectileEntity; +import java.util.Set; @Mixin(DamagingProjectileEntity.class) public abstract class DamagingProjectileEntityMixin_API extends EntityMixin_API implements DamagingProjectile { - @Shadow @Nullable public LivingEntity shootingEntity; - - @Shadow public double accelerationX; - @Shadow public double accelerationY; - @Shadow public double accelerationZ; - @Nullable private ProjectileSource projectileSource = null; - - @Override - public Value.Mutable acceleration() { - return new SpongeValue<>(Keys.ACCELERATION, new Vector3d(this.accelerationX, this.accelerationY, this.accelerationZ)); - } - @Override - public ProjectileSource getShooter() { - if (this.shootingEntity instanceof ProjectileSource) { - return (ProjectileSource) this.shootingEntity; - } - - if (this.projectileSource != null) { - return this.projectileSource; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - return ProjectileSource.UNKNOWN; - } + // Projectile + values.add(this.shooter().asImmutable()); - @Override - public void setShooter(final ProjectileSource shooter) { - this.projectileSource = shooter; - if (shooter instanceof LivingEntity) { - this.shootingEntity = (LivingEntity) shooter; - } else { - this.shootingEntity = null; - } - } + // Projectile Data values + values.add(this.attackDamage().asImmutable()); + values.add(this.customAttackDamage().asImmutable()); - @Override - protected void spongeApi$supplyVanillaManipulators(final Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(new SpongeAccelerationData(this.accelerationX, this.accelerationY, this.accelerationZ)); + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/EvokerFangsEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/EvokerFangsEntityMixin_API.java new file mode 100644 index 00000000000..bd3304152bc --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/EvokerFangsEntityMixin_API.java @@ -0,0 +1,48 @@ +/* + * 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.mixin.api.mcp.entity.projectile; + +import net.minecraft.entity.projectile.EvokerFangsEntity; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.projectile.EvokerFangs; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; + +import java.util.Set; + +@Mixin(EvokerFangsEntity.class) +public abstract class EvokerFangsEntityMixin_API extends EntityMixin_API implements EvokerFangs { + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Projectile + values.add(this.shooter().asImmutable()); + + return values; + } + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FireballEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FireballEntityMixin_API.java index 9aea761f42c..09dd9fa55bc 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FireballEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FireballEntityMixin_API.java @@ -25,11 +25,14 @@ package org.spongepowered.common.mixin.api.mcp.entity.projectile; import net.minecraft.entity.projectile.FireballEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.explosive.fireball.ExplosiveFireball; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.bridge.entity.projectile.FireballEntityBridge; +import java.util.Set; + @Mixin(FireballEntity.class) public abstract class FireballEntityMixin_API extends AbstractFireballEntityMixin_API implements ExplosiveFireball { @@ -40,4 +43,15 @@ public void detonate() { ((FireballEntityBridge) this).bridge$throwExplosionEventAndExplode(this.world, null, this.posX, this.posY, this.posZ, this.explosionPower, true, true); this.setDead(); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // Explosive + this.explosionRadius().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FishingBobberEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FishingBobberEntityMixin_API.java index ea39da8433d..8cc635b4e5c 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FishingBobberEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/FishingBobberEntityMixin_API.java @@ -24,58 +24,27 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.projectile; -import org.spongepowered.api.entity.Entity; +import net.minecraft.entity.projectile.FishingBobberEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.FishingBobber; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import java.util.Optional; - -import javax.annotation.Nullable; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.FishingBobberEntity; +import java.util.Set; @Mixin(FishingBobberEntity.class) public abstract class FishingBobberEntityMixin_API extends EntityMixin_API implements FishingBobber { - @Shadow @Nullable private PlayerEntity angler; - @Shadow @Nullable public net.minecraft.entity.Entity caughtEntity; - - @Nullable - private ProjectileSource projectileSource; - @Override - public ProjectileSource getShooter() { - if (this.projectileSource != null) { - return this.projectileSource; - } else if (this.angler != null && this.angler instanceof ProjectileSource) { - return (ProjectileSource) this.angler; - } - return ProjectileSource.UNKNOWN; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setShooter(ProjectileSource shooter) { - if (shooter instanceof PlayerEntity) { - // This allows things like Vanilla kill attribution to take place - this.angler = (PlayerEntity) shooter; - } else { - this.angler = null; - } - this.projectileSource = shooter; - } + // Projectile + values.add(this.shooter().asImmutable()); - @Override - public Optional getHookedEntity() { - return Optional.ofNullable((Entity) this.caughtEntity); - } + this.targetEntity().map(Value::asImmutable).ifPresent(values::add); - @Override - public void setHookedEntity(@Nullable Entity entity) { - this.caughtEntity = (net.minecraft.entity.Entity) entity; + return values; } - } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/LlamaSpitEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/LlamaSpitEntityMixin_API.java index 964c6fc6b0f..0135c61eeef 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/LlamaSpitEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/LlamaSpitEntityMixin_API.java @@ -24,29 +24,24 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.projectile; -import net.minecraft.entity.passive.horse.LlamaEntity; import net.minecraft.entity.projectile.LlamaSpitEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.LlamaSpit; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; +import java.util.Set; + @Mixin(LlamaSpitEntity.class) public abstract class LlamaSpitEntityMixin_API extends EntityMixin_API implements LlamaSpit { - @Shadow public LlamaEntity owner; - @Override - public ProjectileSource getShooter() { - return (ProjectileSource) this.owner; - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public void setShooter(ProjectileSource shooter) { - if (!(shooter instanceof LlamaEntity)) { - throw new IllegalArgumentException("Cound not set this LlamaSpit's shooter as anyone else!"); - } - this.owner = (LlamaEntity) shooter; + values.add(this.shooter().asImmutable()); + + return values; } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/PotionEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/PotionEntityMixin_API.java index 11b1d85536e..3a798147789 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/PotionEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/PotionEntityMixin_API.java @@ -25,10 +25,22 @@ package org.spongepowered.common.mixin.api.mcp.entity.projectile; import net.minecraft.entity.projectile.PotionEntity; -import org.spongepowered.api.projectile.Potion; +import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.projectile.Potion; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(PotionEntity.class) public abstract class PotionEntityMixin_API extends ThrowableEntityMixin_API implements Potion { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + values.add(this.item().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ShulkerBulletEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ShulkerBulletEntityMixin_API.java index d09add86b4a..f04ce295fc5 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ShulkerBulletEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ShulkerBulletEntityMixin_API.java @@ -24,73 +24,30 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.projectile; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.manipulator.mutable.block.DirectionalData; -import org.spongepowered.api.data.value.Value.Mutable; +import net.minecraft.entity.projectile.ShulkerBulletEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.ShulkerBullet; -import org.spongepowered.api.projectile.source.ProjectileSource; -import org.spongepowered.api.util.Direction; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.data.manipulator.mutable.block.SpongeDirectionalData; -import org.spongepowered.common.data.value.mutable.SpongeValue; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import org.spongepowered.common.util.Constants; - -import java.util.Collection; -import javax.annotation.Nullable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.projectile.ShulkerBulletEntity; +import java.util.Set; @Mixin(ShulkerBulletEntity.class) public abstract class ShulkerBulletEntityMixin_API extends EntityMixin_API implements ShulkerBullet { - @Shadow @Nullable private net.minecraft.util.Direction direction; - - @Shadow private LivingEntity owner; - - @Nullable public ProjectileSource projectileSource; - @Override - public DirectionalData getDirectionalData() { - return new SpongeDirectionalData( this.direction != null ? Constants.DirectionFunctions.getFor(this.direction) : Direction.NONE); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - @Override - public Mutable direction() { - return new SpongeValue<>(Keys.DIRECTION, Direction.NONE, this.direction != null ? Constants.DirectionFunctions.getFor(this.direction) : Direction.NONE); - } + // Projectile + values.add(this.shooter().asImmutable()); - @Override - public ProjectileSource getShooter() { - if (this.projectileSource != null) { - return this.projectileSource; - } - - if (this.owner instanceof ProjectileSource) { - return (ProjectileSource) this.owner; - } - - return ProjectileSource.UNKNOWN; - } + // EntityTargettingProjectile + this.targetEntity().map(Value::asImmutable).ifPresent(values::add); - @Override - public void setShooter(ProjectileSource shooter) { - if (shooter instanceof LivingEntity) { - this.owner = (LivingEntity) shooter; - } else { - this.owner = null; - } + values.add(this.direction().asImmutable()); - this.projectileSource = shooter; + return values; } - - @Override - public void spongeApi$supplyVanillaManipulators(Collection> manipulators) { - super.spongeApi$supplyVanillaManipulators(manipulators); - manipulators.add(getTargetData()); - manipulators.add(this.getDirectionalData()); - } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SmallFireballEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SmallFireballEntityMixin_API.java index 47d26ecb119..98a0ef79e82 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SmallFireballEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SmallFireballEntityMixin_API.java @@ -29,6 +29,6 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(SmallFireballEntity.class) -public abstract class SmallFireballEntityMixin_API extends DamagingProjectileEntityMixin_API implements SmallFireball { +public abstract class SmallFireballEntityMixin_API extends AbstractFireballEntityMixin_API implements SmallFireball { } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SnowballEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SnowballEntityMixin_API.java index aeb6dd53680..acd1c3b2e62 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SnowballEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/SnowballEntityMixin_API.java @@ -25,10 +25,24 @@ package org.spongepowered.common.mixin.api.mcp.entity.projectile; import net.minecraft.entity.projectile.SnowballEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.Snowball; import org.spongepowered.asm.mixin.Mixin; +import java.util.Set; + @Mixin(SnowballEntity.class) public abstract class SnowballEntityMixin_API extends ThrowableEntityMixin_API implements Snowball { + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // DamagingProjectile + values.add(this.attackDamage().asImmutable()); + values.add(this.customAttackDamage().asImmutable()); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ThrowableEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ThrowableEntityMixin_API.java index 72c4e3baef4..597fb98d7df 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ThrowableEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/ThrowableEntityMixin_API.java @@ -24,48 +24,24 @@ */ package org.spongepowered.common.mixin.api.mcp.entity.projectile; +import net.minecraft.entity.projectile.ThrowableEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.Projectile; -import org.spongepowered.api.projectile.source.ProjectileSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.mixin.api.mcp.entity.EntityMixin_API; -import javax.annotation.Nullable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.projectile.ThrowableEntity; +import java.util.Set; @Mixin(ThrowableEntity.class) public abstract class ThrowableEntityMixin_API extends EntityMixin_API implements Projectile { - @Shadow protected LivingEntity thrower; - @Shadow private String throwerName; - @Shadow public abstract LivingEntity getThrower(); - - @Nullable - public ProjectileSource projectileSource; - @Override - public ProjectileSource getShooter() { - if (this.projectileSource != null) { - return this.projectileSource; - } else if (this.getThrower() != null && this.getThrower() instanceof ProjectileSource) { - return (ProjectileSource) this.getThrower(); - } + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); - return ProjectileSource.UNKNOWN; - } - - @Override - public void setShooter(ProjectileSource shooter) { - if (shooter instanceof LivingEntity) { - // This allows things like Vanilla kill attribution to take place - this.thrower = (LivingEntity) shooter; - } else { - this.thrower = null; - } + values.add(this.shooter().asImmutable()); - this.throwerName = null; - this.projectileSource = shooter; + return values; } } diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/TridentEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/TridentEntityMixin_API.java new file mode 100644 index 00000000000..f6d231e6bab --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/TridentEntityMixin_API.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.api.mcp.entity.projectile; + +import net.minecraft.entity.projectile.TridentEntity; +import org.spongepowered.api.entity.projectile.arrow.Trident; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(TridentEntity.class) +public abstract class TridentEntityMixin_API extends AbstractArrowEntityMixin_API implements Trident { + +} diff --git a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/WitherSkullEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/WitherSkullEntityMixin_API.java index 363b6cdc72d..ea4d698fa16 100644 --- a/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/WitherSkullEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/api/mcp/entity/projectile/WitherSkullEntityMixin_API.java @@ -25,10 +25,13 @@ package org.spongepowered.common.mixin.api.mcp.entity.projectile; import net.minecraft.entity.projectile.WitherSkullEntity; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.projectile.explosive.WitherSkull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.common.bridge.entity.projectile.WitherSkullEntityBridge; +import java.util.Set; + @Mixin(WitherSkullEntity.class) public abstract class WitherSkullEntityMixin_API extends DamagingProjectileEntityMixin_API implements WitherSkull { @@ -37,4 +40,18 @@ public void detonate() { ((WitherSkullEntityBridge) this).bridge$CreateAndProcessExplosionEvent(this.world, (WitherSkullEntity) (Object) this, this.posX, this.posY, this.posZ, 0, false, true); this.setDead(); } + + @Override + protected Set> api$getVanillaValues() { + final Set> values = super.api$getVanillaValues(); + + // FireballEntity + values.add(this.acceleration().asImmutable()); + + // Explosive + this.explosionRadius().map(Value::asImmutable).ifPresent(values::add); + + return values; + } + } diff --git a/src/main/java/org/spongepowered/common/mixin/inventory/api/carrier/AbstractHorseEntityMixin_API.java b/src/main/java/org/spongepowered/common/mixin/inventory/api/carrier/AbstractHorseEntityMixin_API.java index d31c38d34b4..80f6760a6a4 100644 --- a/src/main/java/org/spongepowered/common/mixin/inventory/api/carrier/AbstractHorseEntityMixin_API.java +++ b/src/main/java/org/spongepowered/common/mixin/inventory/api/carrier/AbstractHorseEntityMixin_API.java @@ -26,18 +26,26 @@ import net.minecraft.entity.passive.horse.AbstractHorseEntity; import net.minecraft.inventory.Inventory; +import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.horse.HorseEntity; import org.spongepowered.api.item.inventory.Carrier; import org.spongepowered.api.item.inventory.type.CarriedInventory; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.inventory.util.InventoryUtil; +import org.spongepowered.common.mixin.api.mcp.entity.passive.AnimalEntityMixin_API; + +import javax.annotation.Nullable; +import java.util.Set; +import java.util.UUID; @Mixin(AbstractHorseEntity.class) -public abstract class AbstractHorseEntityMixin_API implements Carrier { +public abstract class AbstractHorseEntityMixin_API extends AnimalEntityMixin_API implements HorseEntity, Carrier { @Shadow protected Inventory horseChest; + @Shadow @Nullable public abstract UUID shadow$getOwnerUniqueId(); + @SuppressWarnings("unchecked") @Override public CarriedInventory getInventory() { diff --git a/src/main/java/org/spongepowered/common/util/Constants.java b/src/main/java/org/spongepowered/common/util/Constants.java index f706803b5a6..1521a93ff39 100644 --- a/src/main/java/org/spongepowered/common/util/Constants.java +++ b/src/main/java/org/spongepowered/common/util/Constants.java @@ -872,13 +872,22 @@ public static final class Cat { } + public static final class Panda { + + public static final int UNHAPPY_TIME = 32; + } + public static final class Parrot { public static final Supplier DEFAULT_TYPE = ParrotTypes.RED_AND_BLUE; } - public static final class Player { + public static final class Phantom { + public static final double CAT_SCAN_RADIUS = 16.0D; + } + + public static final class Player { public static final double DEFAULT_FLYING_SPEED = 0.05D; public static final double DEFAULT_EXHAUSTION = 0; diff --git a/src/main/resources/mixins.common.accessor.json b/src/main/resources/mixins.common.accessor.json index 8a5958df4f0..f1718949780 100644 --- a/src/main/resources/mixins.common.accessor.json +++ b/src/main/resources/mixins.common.accessor.json @@ -27,6 +27,7 @@ "entity.monster.VindicatorEntityAccessor", "entity.monster.ZombiePigmanEntityAccessor", "entity.passive.AbstractChestedHorseEntityAccessor", + "entity.passive.FoxEntityAccessor", "entity.passive.PigEntityAccessor", "entity.passive.SheepEntityAccessor", "entity.passive.WolfEntityAccessor", diff --git a/src/main/resources/mixins.common.api.json b/src/main/resources/mixins.common.api.json index 5a1a2e86211..09fabb92305 100644 --- a/src/main/resources/mixins.common.api.json +++ b/src/main/resources/mixins.common.api.json @@ -87,6 +87,8 @@ "mcp.entity.monster.BlazeEntityMixin_API", "mcp.entity.monster.CaveSpiderEntityMixin_API", "mcp.entity.monster.CreeperEntityMixin_API", + "mcp.entity.monster.DrownedEntityMixin_API", + "mcp.entity.monster.ElderGuardianEntityMixin_API", "mcp.entity.monster.EndermanEntityMixin_API", "mcp.entity.monster.EndermiteEntityMixin_API", "mcp.entity.monster.EvokerEntityMixin_API", @@ -117,18 +119,28 @@ "mcp.entity.monster.ZombieEntityMixin_API", "mcp.entity.monster.ZombiePigmanEntityMixin_API", "mcp.entity.monster.ZombieVillagerEntityMixin_API", - "mcp.entity.passive.horse.AbstractHorseMixin_API", + "mcp.entity.passive.fish.AbstractFishEntityMixin_API", + "mcp.entity.passive.fish.AbstractGroupFishEntityMixin_API", + "mcp.entity.passive.fish.CodEntityMixin_API", + "mcp.entity.passive.fish.PufferfishEntityMixin_API", + "mcp.entity.passive.fish.SalmonEntityMixin_API", + "mcp.entity.passive.fish.TropicalFishEntityMixin_API", + "mcp.entity.passive.horse.AbstractChestedHorseEntityMixin_API", + "mcp.entity.passive.horse.AbstractHorseEntityMixin_API", "mcp.entity.passive.horse.DonkeyEntityMixin_API", "mcp.entity.passive.horse.HorseEntityMixin_API", "mcp.entity.passive.horse.LlamaEntityMixin_API", "mcp.entity.passive.horse.MuleEntityMixin_API", "mcp.entity.passive.horse.SkeletonHorseEntityMixin_API", + "mcp.entity.passive.horse.TraderLlamaEntityMixin_API", "mcp.entity.passive.horse.ZombieHorseEntityMixin_API", "mcp.entity.passive.AmbientEntityMixin_API", "mcp.entity.passive.AnimalEntityMixin_API", "mcp.entity.passive.BatEntityMixin_API", + "mcp.entity.passive.CatEntityMixin_API", "mcp.entity.passive.ChickenEntityMixin_API", "mcp.entity.passive.CowEntityMixin_API", + "mcp.entity.passive.DolphinEntityMixin_API", "mcp.entity.passive.FoxEntity_TypeMixin_API", "mcp.entity.passive.FoxEntityMixin_API", "mcp.entity.passive.GolemEntityMixin_API", @@ -145,6 +157,7 @@ "mcp.entity.passive.SnowGolemEntityMixin_API", "mcp.entity.passive.SquidEntityMixin_API", "mcp.entity.passive.TameableEntityMixin_API", + "mcp.entity.passive.TurtleEntityMixin_API", "mcp.entity.passive.WaterMobEntityMixin_API", "mcp.entity.passive.WolfEntityMixin_API", "mcp.entity.player.ChatVisibilityMixin_API", @@ -157,6 +170,7 @@ "mcp.entity.projectile.DamagingProjectileEntityMixin_API", "mcp.entity.projectile.DragonFireballEntityMixin_API", "mcp.entity.projectile.EggEntityMixin_API", + "mcp.entity.projectile.EvokerFangsEntityMixin_API", "mcp.entity.projectile.FireballEntityMixin_API", "mcp.entity.projectile.FishingBobberEntityMixin_API", "mcp.entity.projectile.LlamaSpitEntityMixin_API", @@ -166,6 +180,7 @@ "mcp.entity.projectile.SnowballEntityMixin_API", "mcp.entity.projectile.SpectralArrowEntityMixin_API", "mcp.entity.projectile.ThrowableEntityMixin_API", + "mcp.entity.projectile.TridentEntityMixin_API", "mcp.entity.projectile.WitherSkullEntityMixin_API", "mcp.entity.AgeableEntityMixin_API", "mcp.entity.AreaEffectCloudEntityMixin_API",