Search in sources :

Example 1 with PlayerProperties

use of mod.azure.doom.util.PlayerProperties in project MCDoom by AzureDoom.

the class SuperShotgun method onStoppedUsing.

@Override
public void onStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int remainingUseTicks) {
    if (entityLiving instanceof PlayerEntity) {
        PlayerEntity playerentity = (PlayerEntity) entityLiving;
        if (stack.getDamage() < (stack.getMaxDamage() - 2)) {
            if (playerentity.getMainHandStack().getItem() instanceof SuperShotgun) {
                playerentity.getItemCooldownManager().set(this, 24);
                if (!worldIn.isClient) {
                    ShotgunShellEntity abstractarrowentity = createArrow(worldIn, stack, playerentity);
                    abstractarrowentity.setVelocity(playerentity, playerentity.getPitch(), playerentity.getYaw() + 1, 0.0F, 1.0F * 3.0F, 1.0F);
                    worldIn.spawnEntity(abstractarrowentity);
                    ShotgunShellEntity abstractarrowentity1 = createArrow(worldIn, stack, playerentity);
                    abstractarrowentity1.setVelocity(playerentity, playerentity.getPitch(), playerentity.getYaw() - 1, 0.0F, 1.0F * 3.0F, 1.0F);
                    worldIn.spawnEntity(abstractarrowentity1);
                    stack.damage(2, entityLiving, p -> p.sendToolBreakStatus(entityLiving.getActiveHand()));
                    worldIn.playSound((PlayerEntity) null, playerentity.getX(), playerentity.getY(), playerentity.getZ(), ModSoundEvents.SUPER_SHOTGUN_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F);
                    final int id = GeckoLibUtil.guaranteeIDForStack(stack, (ServerWorld) worldIn);
                    GeckoLibNetwork.syncAnimation(playerentity, this, id, ANIM_OPEN);
                    for (PlayerEntity otherPlayer : PlayerLookup.tracking(playerentity)) {
                        GeckoLibNetwork.syncAnimation(otherPlayer, this, id, ANIM_OPEN);
                    }
                    worldIn.setBlockState(playerentity.getCameraBlockPos(), DoomBlocks.TICKING_LIGHT_BLOCK.getDefaultState());
                }
            }
        } else {
            worldIn.playSound((PlayerEntity) null, playerentity.getX(), playerentity.getY(), playerentity.getZ(), ModSoundEvents.EMPTY, SoundCategory.PLAYERS, 1.0F, 1.5F);
            ((PlayerProperties) playerentity).setHasMeatHook(false);
        }
    }
}
Also used : ShotgunShellEntity(mod.azure.doom.entity.projectiles.ShotgunShellEntity) PlayerProperties(mod.azure.doom.util.PlayerProperties) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with PlayerProperties

use of mod.azure.doom.util.PlayerProperties in project MCDoom by AzureDoom.

the class SuperShotgun method inventoryTick.

@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
    if (world.isClient) {
        if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof SuperShotgun && ClientInit.reload.isPressed() && selected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.SUPERSHOTGUN, passedData);
        }
    }
    if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof SuperShotgun && selected && ((PlayerProperties) entity).hasMeatHook()) {
        ((PlayerProperties) entity).setHasMeatHook(false);
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerProperties(mod.azure.doom.util.PlayerProperties) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 3 with PlayerProperties

use of mod.azure.doom.util.PlayerProperties 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

PlayerProperties (mod.azure.doom.util.PlayerProperties)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 MeatHookEntity (mod.azure.doom.entity.projectiles.MeatHookEntity)1 ShotgunShellEntity (mod.azure.doom.entity.projectiles.ShotgunShellEntity)1 ItemStack (net.minecraft.item.ItemStack)1 PacketByteBuf (net.minecraft.network.PacketByteBuf)1