Search in sources :

Example 1 with MeatHookEntity

use of mod.azure.doom.entity.projectiles.MeatHookEntity 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);
    }
}
Also used : Entity(net.minecraft.entity.Entity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) MeatHookEntity(mod.azure.doom.entity.projectiles.MeatHookEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) MeatHookEntity(mod.azure.doom.entity.projectiles.MeatHookEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with MeatHookEntity

use of mod.azure.doom.entity.projectiles.MeatHookEntity in project MCDoom by AzureDoom.

the class SuperShotgun method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    ItemStack stack = user.getOffHandStack();
    if (stack.getDamage() < (stack.getMaxDamage() - 2)) {
        if (!world.isClient && stack.getItem() instanceof SuperShotgun) {
            if (!((PlayerProperties) user).hasMeatHook()) {
                MeatHookEntity hookshot = new MeatHookEntity(world, user);
                hookshot.setProperties(stack, DoomMod.config.weapons.max_meathook_distance, 10, user.getPitch(), user.getYaw(), 0f, 1.5f);
                hookshot.getDataTracker().set(MeatHookEntity.FORCED_YAW, user.getYaw());
                world.spawnEntity(hookshot);
            }
            ((PlayerProperties) user).setHasMeatHook(!((PlayerProperties) user).hasMeatHook());
        }
    }
    return super.use(world, user, hand);
}
Also used : MeatHookEntity(mod.azure.doom.entity.projectiles.MeatHookEntity) ItemStack(net.minecraft.item.ItemStack) PlayerProperties(mod.azure.doom.util.PlayerProperties)

Aggregations

MeatHookEntity (mod.azure.doom.entity.projectiles.MeatHookEntity)2 PlayerProperties (mod.azure.doom.util.PlayerProperties)1 Entity (net.minecraft.entity.Entity)1 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1