Search in sources :

Example 1 with BalloonHolder

use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder 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 2 with BalloonHolder

use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder 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 3 with BalloonHolder

use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder 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 4 with BalloonHolder

use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder 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)

Example 5 with BalloonHolder

use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder in project endergetic by team-abnormals.

the class ServerWorldMixin 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;
    ServerChunkProvider chunkProvider = ((ServerWorld) (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();
                }
                ((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)

Aggregations

BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)8 BalloonHolder (com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder)8 Inject (org.spongepowered.asm.mixin.injection.Inject)6 ServerWorld (net.minecraft.world.server.ServerWorld)3 ClientChunkProvider (net.minecraft.client.multiplayer.ClientChunkProvider)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 Entity (net.minecraft.entity.Entity)2 ServerChunkProvider (net.minecraft.world.server.ServerChunkProvider)2 S2CUpdateBalloonsMessage (com.minecraftabnormals.endergetic.common.network.entity.S2CUpdateBalloonsMessage)1 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 BoatEntity (net.minecraft.entity.item.BoatEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 PotionEntity (net.minecraft.entity.projectile.PotionEntity)1 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)1 World (net.minecraft.world.World)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 NetworkEvent (net.minecraftforge.fml.network.NetworkEvent)1