Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin cleanup of core plugin entity mixins #2503

Merged
merged 1 commit into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.spongepowered.common.data.processor.common.AbstractEntitySingleDataProcessor;
import org.spongepowered.common.data.value.immutable.ImmutableSpongeValue;
import org.spongepowered.common.data.value.mutable.SpongeValue;
import org.spongepowered.common.bridge.entity.merchant.villager.VillagerEntityBridge;

import java.util.Optional;
import net.minecraft.entity.merchant.villager.VillagerEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.EndDimension;
Expand All @@ -75,7 +76,6 @@
import org.spongepowered.api.util.Transform;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.gamerule.GameRules;
import org.spongepowered.api.world.storage.WorldProperties;
import org.spongepowered.api.world.teleport.PortalAgent;
import org.spongepowered.common.SpongeImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.GameRules;
import net.minecraft.world.server.ServerWorld;
import org.apache.logging.log4j.Level;
import org.spongepowered.api.Sponge;
Expand Down Expand Up @@ -110,7 +111,6 @@
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.explosion.Explosion;
import org.spongepowered.api.world.gamerule.GameRules;
import org.spongepowered.api.world.storage.WorldProperties;
import org.spongepowered.asm.util.PrettyPrinter;
import org.spongepowered.common.SpongeImpl;
Expand Down Expand Up @@ -810,8 +810,8 @@ public static Optional<DestructEntityEvent.Death> callDestructEntityEventDeath(f
if (entity instanceof ServerPlayerEntity) {
originalChannel = channel = ((ServerPlayerEntityBridge) entity).bridge$getDeathMessageChannel();
} else {
originalChannel = MessageChannel.TO_NONE;
channel = MessageChannel.TO_NONE;
originalChannel = MessageChannel.toNone();
channel = MessageChannel.toNone();
}
if (source instanceof EntityDamageSource) {
final EntityDamageSource damageSource = (EntityDamageSource) source;
Expand Down Expand Up @@ -839,8 +839,8 @@ public static Optional<DestructEntityEvent.Death> callDestructEntityEventDeath(f

final Cause cause = isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(), source == null ? entity : source);
final DestructEntityEvent.Death event = SpongeEventFactory.createDestructEntityEventDeath(cause,
originalChannel, Optional.of(channel), formatter,
(Living) entity, entity.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY), messageCancelled);
originalChannel, Optional.of(channel), (Living) entity,
formatter, entity.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY), messageCancelled);
SpongeImpl.postEvent(event, true); // Client code should be able to cancel the death event if server cancels it.
final Text message = event.getMessage();
// Check the event isn't cancelled either. If it is, then don't spawn the message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -393,7 +394,7 @@ public static void generateCauseFor(final DamageSource damageSource, final Cause
}

public static List<DamageFunction> createAttackEnchantmentFunction(
final net.minecraft.item.ItemStack heldItem, final EnumCreatureAttribute creatureAttribute, final float attackStrength) {
final net.minecraft.item.ItemStack heldItem, final CreatureAttribute creatureAttribute, final float attackStrength) {
final Multimap<Enchantment, Integer> enchantments = LinkedHashMultimap.create();
final List<DamageFunction> damageModifierFunctions = new ArrayList<>();
if (!heldItem.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ public void unwind(final EntityDeathContext context) {
if (((PlayerEntityBridge) entityPlayer).bridge$keepInventory()) {
keepInventoryRule = entityPlayer.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY);
// Set global keep-inventory gamerule so mods do not drop items
entityPlayer.world.getGameRules().setOrCreateGameRule(GameRules.KEEP_INVENTORY, "true");
entityPlayer.world.getGameRules().get(GameRules.KEEP_INVENTORY).set(true, entityPlayer.getServer());
}
}
SpongeCommonEventFactory.callDropItemDestruct(entities, context);

if (entityPlayer != null) {
if (((PlayerEntityBridge) entityPlayer).bridge$keepInventory()) {
// Restore global keep-inventory gamerule
entityPlayer.world.getGameRules().setOrCreateGameRule(GameRules.KEEP_INVENTORY, String.valueOf(keepInventoryRule));
entityPlayer.world.getGameRules().get(GameRules.KEEP_INVENTORY).set(keepInventoryRule, entityPlayer.getServer());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.invalid.api.mcp.entity.passive;
package org.spongepowered.common.mixin.api.mcp.item;

import net.minecraft.entity.merchant.IMerchant;
import net.minecraft.entity.merchant.villager.VillagerEntity;
import net.minecraft.item.MerchantOffer;
import net.minecraft.item.MerchantOffers;
import org.spongepowered.api.item.merchant.Merchant;
Expand All @@ -37,7 +36,7 @@
import java.util.Random;

@Mixin(MerchantOffers.class)
public interface EntityVillager_ITradeListMixin_API extends TradeOfferListMutator, VillagerEntity.ITradeList {
public interface MerchantOffersMixin_API extends TradeOfferListMutator {

@Override
default void accept(final Merchant owner, final List<TradeOffer> tradeOffers, final Random random) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ private void callReadyToMateOnAgeUp(final int age, final CallbackInfo ci) {
private void callReadyToMateEvent() {
if (!((WorldBridge) this.world).bridge$isFake() && ShouldFire.BREED_ENTITY_EVENT_READY_TO_MATE && ((AgeableEntity) (Object) this) instanceof AnimalEntity) {
final org.spongepowered.api.event.entity.BreedingEvent.ReadyToMate event =
SpongeEventFactory.createBreedEntityEventReadyToMate(Sponge.getCauseStackManager().getCurrentCause(), Optional.empty(), (Animal)
this);
SpongeEventFactory.createBreedingEventReadyToMate(Sponge.getCauseStackManager().getCurrentCause(), (Animal) this);
SpongeImpl.postEvent(event);
}
}
Expand Down
Loading