<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package snowballmadness;

import com.google.common.base.Preconditions;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.util.*;

/**
 * This snowball logic spawns
 *
 * @author christopherjohnson
 */
public class BouncySnowballLogic extends SnowballLogic {
    private final int numberOfSlimeballs;
    private final InventorySlice inventory;

    public BouncySnowballLogic(int numberOfSlimeballs, InventorySlice inventory) {
        this.numberOfSlimeballs = numberOfSlimeballs;
        this.inventory = Preconditions.checkNotNull(inventory);

    }

    @Override
    public void hit(Snowball snowball, SnowballInfo info) {
        super.hit(snowball, info);

        World world = snowball.getWorld();
        LivingEntity shooter = snowball.getShooter();
        Location source = snowball.getLocation().clone();
        source.setY(source.getY() + 0.25);

        Vector bounce = snowball.getVelocity().clone();
        bounce.setY(-(bounce.getY()));
        //we are not going to amplify the bounce because the initial velocity should
        //be what's amplified. Thus we needn't amplify it again.

        Snowball skipper = world.spawn(source, Snowball.class);
        skipper.setShooter(shooter);
        skipper.setVelocity(bounce);

        performLaunch(inventory, skipper, info);
        //this should produce one bounce without any trouble
        //two possibilities for completing it.
        //One, it bounces forever until it hits somewhere with a solid block over where it hit
        //Two, it bounces the number of slimeballs you have in there, and then goes off.
        //I'm not sure quite how to make it 'launch itself' rather than a payload snowball,
        //but it's probably trivial.

    }

    @Override
    public String toString() {
        return String.format("%s -> (x%d) %s",
                super.toString());
    }
}<commit_msg>Increasing numbers of slimeballs multiply the speed of the bounce. Aim across nearby flat thing for high velocity cannon beyond what sugar/cake can do, but very tough to control.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package snowballmadness;

import com.google.common.base.Preconditions;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.util.*;

/**
 * This snowball logic spawns
 *
 * @author christopherjohnson
 */
public class BouncySnowballLogic extends SnowballLogic {

    private final int numberOfSlimeballs;
    private final InventorySlice inventory;

    public BouncySnowballLogic(int numberOfSlimeballs, InventorySlice inventory) {
        this.numberOfSlimeballs = numberOfSlimeballs;
        this.inventory = Preconditions.checkNotNull(inventory);

    }

    @Override
    public void hit(Snowball snowball, SnowballInfo info) {
        super.hit(snowball, info);

        World world = snowball.getWorld();
        LivingEntity shooter = snowball.getShooter();
        Location source = snowball.getLocation().clone();
        source.setY(source.getY() + 0.25);

        Vector bounce = snowball.getVelocity().clone();
        bounce.setY(-(bounce.getY()));
        bounce.multiply(numberOfSlimeballs);
        //for fun, we are going to multiply the bounce by the number of slimeballs.
        //This can send glowstone TNT bombs into the stratosphere!

        Snowball skipper = world.spawn(source, Snowball.class);
        skipper.setShooter(shooter);
        skipper.setVelocity(bounce);

        performLaunch(inventory, skipper, info);
        //this should produce one bounce without any trouble
        //two possibilities for completing it.
        //One, it bounces forever until it hits somewhere with a solid block over where it hit
        //Two, it bounces the number of slimeballs you have in there, and then goes off.
        //I'm not sure quite how to make it 'launch itself' rather than a payload snowball,
        //but it's probably trivial.

    }

    @Override
    public String toString() {
        return String.format("%s -> (x%d) %s",
                super.toString(),
                numberOfSlimeballs,
                createLogic(inventory));
    }
}
{'fraction_non_alphanumeric': 0.09008379888268156, 'fraction_numerical': 0.0013966480446927375, 'mean_word_length': 2.8746618575293055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2012521', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1149, 'n_words': 392}