Search in sources :

Example 1 with GameStateChangeS2CPacket

use of net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket in project MCDoom by AzureDoom.

the class ChaingunBulletEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.arrow(this, this);
    } else {
        damageSource2 = DamageSource.arrow(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, projectiledamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 2 with GameStateChangeS2CPacket

use of net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket in project MCDoom by AzureDoom.

the class ShotgunShellEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.arrow(this, this);
    } else {
        damageSource2 = DamageSource.arrow(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, shelldamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 3 with GameStateChangeS2CPacket

use of net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket in project BleachHack by BleachDrinker420.

the class Ambience method readPacket.

@BleachSubscribe
public void readPacket(EventPacket.Read event) {
    if (event.getPacket() instanceof GameStateChangeS2CPacket && getSetting(0).asToggle().getState()) {
        GameStateChangeS2CPacket packet = (GameStateChangeS2CPacket) event.getPacket();
        if (packet.getReason() == GameStateChangeS2CPacket.RAIN_STARTED) {
            weatherManager.setRain(1f);
        } else if (packet.getReason() == GameStateChangeS2CPacket.RAIN_STOPPED) {
            weatherManager.setRain(0f);
        } else if (packet.getReason() == GameStateChangeS2CPacket.RAIN_GRADIENT_CHANGED) {
            weatherManager.setRain(packet.getValue());
        } else if (packet.getReason() == GameStateChangeS2CPacket.THUNDER_GRADIENT_CHANGED) {
            weatherManager.setThunder(packet.getValue());
        } else {
            return;
        }
        event.setCancelled(true);
    } else if (event.getPacket() instanceof DisconnectS2CPacket && getSetting(0).asToggle().getState()) {
        weatherManager.reset();
    } else if (event.getPacket() instanceof WorldTimeUpdateS2CPacket && getSetting(1).asToggle().getState()) {
        event.setCancelled(true);
    }
}
Also used : WorldTimeUpdateS2CPacket(net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with GameStateChangeS2CPacket

use of net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket in project MCDoom by AzureDoom.

the class EnergyCellEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.arrow(this, this);
    } else {
        damageSource2 = DamageSource.arrow(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, projectiledamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 5 with GameStateChangeS2CPacket

use of net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket in project MCDoom by AzureDoom.

the class UnmaykrBoltEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.magic(this, this);
    } else {
        damageSource2 = DamageSource.magic(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, projectiledamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) TickingLightEntity(mod.azure.doom.entity.tileentity.TickingLightEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Aggregations

GameStateChangeS2CPacket (net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket)7 IconofsinEntity (mod.azure.doom.entity.tierboss.IconofsinEntity)6 Entity (net.minecraft.entity.Entity)6 LivingEntity (net.minecraft.entity.LivingEntity)6 DamageSource (net.minecraft.entity.damage.DamageSource)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)6 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)6 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)6 TickingLightEntity (mod.azure.doom.entity.tileentity.TickingLightEntity)2 BlockEntity (net.minecraft.block.entity.BlockEntity)2 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)1 DisconnectS2CPacket (net.minecraft.network.packet.s2c.play.DisconnectS2CPacket)1 WorldTimeUpdateS2CPacket (net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1