Skip to content
Permalink
Browse files

Make a few changes to how CartBooster works. Gold now sets to max spe…

…ed, rather than 100.
  • Loading branch information...
me4502 committed Dec 10, 2016
1 parent d6ab9db commit 8437e369fefbaa2fe0b43d60728abfae05e0b0df
@@ -31,8 +31,8 @@ public void onVehicleCreate(VehicleCreateEvent event) {
@Override
public void loadConfiguration (YAMLProcessor config, String path) {

config.setComment(path + "max-speed", "Sets the max speed of carts. Normal max speed speed is 0.4D");
maxSpeed = config.getDouble(path + "max-speed", 0.4);
config.setComment(path + "max-speed", "Sets the max speed modifier of carts. Normal max speed speed is 0.4D");
maxSpeed = config.getDouble(path + "max-speed", 1);

config.setComment(path + "off-rail-speed", "Sets the off-rail speed modifier of carts. 0 is none.");
offRail = config.getDouble(path + "off-rail-speed", 0);
@@ -150,7 +150,7 @@ public void onSignChange(SignChangeEvent event) {
lineFound = sign;
lineNum = 1;
break;
} else if (getName().equalsIgnoreCase("messager") && lines[0].equalsIgnoreCase("[" + sign + "]")) {
} else if (this instanceof CartMessenger && lines[0].equalsIgnoreCase("[" + sign + "]")) {
found = true;
lineFound = sign;
lineNum = 0;
@@ -1,5 +1,6 @@
package com.sk89q.craftbook.mechanics.minecart.blocks;

import org.bukkit.entity.Minecart;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;

@@ -19,22 +20,19 @@ public void onVehicleImpact(CartBlockImpactEvent event) {
// enabled?
if (Power.OFF == isActive(event.getBlocks())) return;

double multiplier;
Vector newVelocity = event.getVehicle().getVelocity();

if(event.getBlocks().matches(minecartSpeedModMaxBoostBlock))
multiplier = 100;
else if(event.getBlocks().matches(minecartSpeedMod25xBoostBlock))
multiplier = 1.25;
if(event.getBlocks().matches(minecartSpeedModMaxBoostBlock)) {
newVelocity.normalize().multiply(event.getMinecart().getMaxSpeed());
} else if(event.getBlocks().matches(minecartSpeedMod25xBoostBlock))
newVelocity.multiply(1.25d);
else if(event.getBlocks().matches(minecartSpeedMod20xSlowBlock))
multiplier = 0.8;
newVelocity.multiply(0.8d);
else if(event.getBlocks().matches(minecartSpeedMod50xSlowBlock))
multiplier = 0.5;
newVelocity.multiply(0.5d);
else
return;

// speed up or down
Vector newVelocity;
newVelocity = event.getVehicle().getVelocity().multiply(multiplier);
// go
event.getVehicle().setVelocity(newVelocity);
}

0 comments on commit 8437e36

Please sign in to comment.
You can’t perform that action at this time.