Search in sources :

Example 1 with BolloomBalloonEntity

use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity in project endergetic by team-abnormals.

the class EntityEvents method onEntityTracked.

@SubscribeEvent
public static void onEntityTracked(PlayerEvent.StartTracking event) {
    ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer();
    Entity trackingEntity = event.getTarget();
    if (trackingEntity instanceof BolloomBalloonEntity) {
        BolloomBalloonEntity balloon = (BolloomBalloonEntity) trackingEntity;
        Entity attachedEntity = balloon.getAttachedEntity();
        if (attachedEntity != null) {
            EndergeticExpansion.CHANNEL.send(PacketDistributor.PLAYER.with(() -> player), new S2CUpdateBalloonsMessage(attachedEntity));
        }
    } else {
        EndergeticExpansion.CHANNEL.send(PacketDistributor.PLAYER.with(() -> player), new S2CUpdateBalloonsMessage(trackingEntity));
    }
}
Also used : BoatEntity(net.minecraft.entity.item.BoatEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) PotionEntity(net.minecraft.entity.projectile.PotionEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ThrowableEntity(net.minecraft.entity.projectile.ThrowableEntity) Entity(net.minecraft.entity.Entity) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) S2CUpdateBalloonsMessage(com.minecraftabnormals.endergetic.common.network.entity.S2CUpdateBalloonsMessage) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with BolloomBalloonEntity

use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity in project endergetic by team-abnormals.

the class TrackedEntityMixin method updateBalloons.

@Inject(at = @At("HEAD"), method = "sendChanges")
private void updateBalloons(CallbackInfo info) {
    List<BolloomBalloonEntity> currentBalloons = ((BalloonHolder) this.entity).getBalloons();
    if (!currentBalloons.equals(this.prevBalloons)) {
        this.prevBalloons = currentBalloons;
        EndergeticExpansion.CHANNEL.send(PacketDistributor.TRACKING_ENTITY.with(() -> this.entity), new S2CUpdateBalloonsMessage(this.entity));
    }
}
Also used : BalloonHolder(com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) S2CUpdateBalloonsMessage(com.minecraftabnormals.endergetic.common.network.entity.S2CUpdateBalloonsMessage) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with BolloomBalloonEntity

use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity in project endergetic by team-abnormals.

the class ServerWorldMixin method updateEntityRiddenBalloons.

@SuppressWarnings("deprecation")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;rideTick()V", shift = At.Shift.AFTER), method = "tickPassenger")
private void updateEntityRiddenBalloons(Entity ridingEntity, Entity passenger, CallbackInfo info) {
    BalloonHolder balloonHolder = (BalloonHolder) passenger;
    ServerChunkProvider chunkProvider = ((ServerWorld) (Object) this).getChunkSource();
    for (BolloomBalloonEntity balloon : balloonHolder.getBalloons()) {
        if (!balloon.removed && balloon.getAttachedEntity() == passenger) {
            if (chunkProvider.isEntityTickingChunk(balloon)) {
                balloon.setPosAndOldPos(balloon.getX(), balloon.getY(), balloon.getZ());
                balloon.yRotO = balloon.yRot;
                balloon.xRotO = balloon.xRot;
                if (balloon.inChunk) {
                    balloon.tickCount++;
                    balloon.updateAttachedPosition();
                }
                ((ServerWorld) (Object) this).updateChunkPos(balloon);
            }
        } else {
            balloon.detachFromEntity();
        }
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) BalloonHolder(com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with BolloomBalloonEntity

use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity in project endergetic by team-abnormals.

the class ClientWorldMixin method updateEntityRiddenBalloons.

@SuppressWarnings("deprecation")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;rideTick()V", shift = At.Shift.AFTER), method = "tickPassenger")
private void updateEntityRiddenBalloons(Entity ridingEntity, Entity passenger, CallbackInfo info) {
    BalloonHolder balloonHolder = (BalloonHolder) passenger;
    ClientChunkProvider chunkProvider = ((ClientWorld) (Object) this).getChunkSource();
    for (BolloomBalloonEntity balloon : balloonHolder.getBalloons()) {
        if (!balloon.removed && balloon.getAttachedEntity() == passenger) {
            if (chunkProvider.isEntityTickingChunk(balloon)) {
                balloon.setPosAndOldPos(balloon.getX(), balloon.getY(), balloon.getZ());
                balloon.yRotO = balloon.yRot;
                balloon.xRotO = balloon.xRot;
                if (balloon.inChunk) {
                    balloon.tickCount++;
                    balloon.updateAttachedPosition();
                }
                this.callUpdateChunkPos(balloon);
            }
        } else {
            balloon.detachFromEntity();
        }
    }
}
Also used : ClientChunkProvider(net.minecraft.client.multiplayer.ClientChunkProvider) ClientWorld(net.minecraft.client.world.ClientWorld) BalloonHolder(com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with BolloomBalloonEntity

use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity in project endergetic by team-abnormals.

the class ClientWorldMixin method updateBalloons.

@SuppressWarnings("deprecation")
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;inChunk:Z", ordinal = 1, shift = At.Shift.AFTER), method = "tickNonPassenger")
private void updateBalloons(Entity entity, CallbackInfo info) {
    BalloonHolder balloonHolder = (BalloonHolder) entity;
    ClientChunkProvider chunkProvider = ((ClientWorld) (Object) this).getChunkSource();
    for (BolloomBalloonEntity balloon : balloonHolder.getBalloons()) {
        if (!balloon.removed && balloon.getAttachedEntity() == entity) {
            if (chunkProvider.isEntityTickingChunk(balloon)) {
                balloon.setPosAndOldPos(balloon.getX(), balloon.getY(), balloon.getZ());
                balloon.yRotO = balloon.yRot;
                balloon.xRotO = balloon.xRot;
                if (balloon.inChunk) {
                    balloon.tickCount++;
                    balloon.updateAttachedPosition();
                }
                this.callUpdateChunkPos(balloon);
            }
        } else {
            balloon.detachFromEntity();
        }
    }
}
Also used : ClientChunkProvider(net.minecraft.client.multiplayer.ClientChunkProvider) ClientWorld(net.minecraft.client.world.ClientWorld) BalloonHolder(com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)11 BalloonHolder (com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder)9 Inject (org.spongepowered.asm.mixin.injection.Inject)7 Entity (net.minecraft.entity.Entity)4 ServerWorld (net.minecraft.world.server.ServerWorld)4 S2CUpdateBalloonsMessage (com.minecraftabnormals.endergetic.common.network.entity.S2CUpdateBalloonsMessage)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)2 ClientChunkProvider (net.minecraft.client.multiplayer.ClientChunkProvider)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 LivingEntity (net.minecraft.entity.LivingEntity)2 BoatEntity (net.minecraft.entity.item.BoatEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 PotionEntity (net.minecraft.entity.projectile.PotionEntity)2 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)2 World (net.minecraft.world.World)2 ServerChunkProvider (net.minecraft.world.server.ServerChunkProvider)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 EndergeticExpansion (com.minecraftabnormals.endergetic.core.EndergeticExpansion)1 File (java.io.File)1