use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDoom by AzureDoom.
the class ClientPlayNetworkHandlerMixin method onEntitySpawn.
@Inject(method = "onEntitySpawn", at = @At("TAIL"))
private void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo callbackInfo) {
EntityType<?> type = packet.getEntityTypeId();
double x = packet.getX();
double y = packet.getY();
double z = packet.getZ();
PersistentProjectileEntity entity = null;
if (type == ProjectilesEntityRegister.MEATHOOOK_ENTITY)
entity = new MeatHookEntity(world, x, y, z);
if (entity != null) {
Entity owner = world.getEntityById(packet.getEntityData());
if (owner != null)
entity.setOwner(owner);
int id = packet.getId();
entity.updateTrackedPosition(x, y, z);
entity.refreshPositionAfterTeleport(x, y, z);
entity.setPitch((float) (packet.getPitch() * 360) / 256f);
entity.setYaw((float) (packet.getYaw() * 360) / 256f);
entity.setId(id);
entity.setUuid(packet.getUuid());
world.addEntity(id, entity);
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class AnimaConduitShotEnchantmentMixin method onAnimaConduitShotEnchantmentEntityHit.
@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onAnimaConduitShotEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
return;
}
PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
Entity target = entityHitResult.getEntity();
LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
ItemStack mainHandStack = null;
if (shooter != null) {
mainHandStack = shooter.getMainHandStack();
}
if (McdwEnchantsConfig.getValue("anima")) {
if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.ANIMA_CONDUIT, mainHandStack) >= 1)) {
int level = EnchantmentHelper.getLevel(EnchantsRegistry.ANIMA_CONDUIT, mainHandStack);
float healthRegained;
// ANIMA CONDUIT AS PER KILL
if (shooter.getHealth() < shooter.getMaxHealth()) {
healthRegained = (float) (getCurrentExperience((PlayerEntity) shooter) * (0.2 * level));
shooter.heal(healthRegained);
((PlayerEntity) shooter).addExperienceLevels(-999999999);
// this.world.sendEntityStatus(this,(byte)35);
}
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class ChainReactionEnchantmentMixin method onChainReactionEnchantmentEntityHit.
@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onChainReactionEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
return;
}
PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
LivingEntity target = (LivingEntity) entityHitResult.getEntity();
LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
ItemStack mainHandStack = null;
if (shooter != null) {
mainHandStack = shooter.getMainHandStack();
}
if (McdwEnchantsConfig.getValue("chain_reaction")) {
if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, mainHandStack) >= 1)) {
int level = EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, mainHandStack);
if (target == null)
return;
if (level > 0) {
float chainReactionChance = 0;
if (level == 1)
chainReactionChance = 0.1F;
if (level == 2)
chainReactionChance = 0.2F;
if (level == 3)
chainReactionChance = 0.3F;
float chainReactionRand = shooter.getRandom().nextFloat();
if (chainReactionRand <= chainReactionChance) {
ProjectileEffectHelper.fireChainReactionProjectiles(target.getEntityWorld(), target, shooter, 3.15F, 1.0F, persistentProjectileEntity);
}
}
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class GravityShotEnchantmentMixin method onGravityShotEnchantmentEntityHit.
@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onGravityShotEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
return;
}
PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
LivingEntity target = (LivingEntity) entityHitResult.getEntity();
LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
ItemStack mainHandStack = null;
if (shooter != null) {
mainHandStack = shooter.getMainHandStack();
}
if (McdwEnchantsConfig.getValue("gravity")) {
if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, mainHandStack) >= 1)) {
int level = EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, mainHandStack);
float gravityShotRand = shooter.getRandom().nextFloat();
if (gravityShotRand <= 0.2F) {
AOEHelper.pullInNearbyEntities(shooter, target, (level + 1) * 3);
}
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class MultiShotEnchantmentMixin method createMultiShotArrows.
// Bow Multi Shot
@Inject(method = "onStoppedUsing", at = @At("HEAD"))
private void createMultiShotArrows(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfo ci) {
LivingEntity target = user.getAttacking();
boolean uniqueWeaponFlag = stack.getItem() == ItemRegistry.getItem("bow_lost_souls").asItem();
if (McdwEnchantsConfig.getValue("multi_shot")) {
if (uniqueWeaponFlag) {
ArrowItem arrowitem = (ArrowItem) (stack.getItem() instanceof ArrowItem ? stack.getItem() : Items.ARROW);
PersistentProjectileEntity persistentProjectileEntity = arrowitem.createArrow(world, stack, user);
if (!(target == null)) {
// \/\/ Taken from AbstractSkeletonEntity
double d = target.getX() - user.getX();
double e = target.getBodyY(0.3333333333333333D) - persistentProjectileEntity.getY();
double f = target.getZ() - user.getZ();
double g = MathHelper.sqrt((float) (d * d + f * f));
persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - user.world.getDifficulty().getId() * 4));
persistentProjectileEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
world.spawnEntity(persistentProjectileEntity);
}
}
}
}
Aggregations