Tweaks to jumppad physics.

This commit is contained in:
Steven Lawson 2013-08-13 16:54:20 -04:00
parent f9cbf11abb
commit f1ab8296e4
6 changed files with 55 additions and 28 deletions

View File

@ -1,5 +1,5 @@
#Tue, 13 Aug 2013 18:21:17 +0200
#Tue, 13 Aug 2013 16:50:36 -0400
program.VERSION=2.22
program.BUILDNUM=446
program.BUILDDATE=08/13/2013 06\:21 PM
program.BUILDNUM=458
program.BUILDDATE=08/13/2013 04\:50 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Aug 13 18:21:17 CEST 2013
build.number=447
#Tue Aug 13 16:50:36 EDT 2013
build.number=459

View File

@ -37,7 +37,7 @@ public class Command_jumppads extends TFM_Command
else
{
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
}
}
else
@ -52,8 +52,8 @@ public class Command_jumppads extends TFM_Command
{
if (TFM_Util.isStopCommand(args[1]))
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL);
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
}
else
{

View File

@ -77,7 +77,7 @@ public class TFM_BlockListener implements Listener
Long lastRan = TFM_Heartbeat.getLastRan();
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
{
TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
}
else
{
@ -151,7 +151,7 @@ public class TFM_BlockListener implements Listener
Long lastRan = TFM_Heartbeat.getLastRan();
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
{
TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
}
else
{

View File

@ -401,7 +401,7 @@ public class TFM_PlayerListener implements Listener
Long lastRan = TFM_Heartbeat.getLastRan();
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
{
TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
}
else
{

View File

@ -1,5 +1,7 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -10,6 +12,7 @@ public class TFM_Jumppads
{
public static final Material BLOCK_ID = Material.WOOL;
public static final double DAMPING_COEFFICIENT = 0.8;
public final Map<Player, Boolean> canPushMap = new HashMap<Player, Boolean>();
private JumpPadMode mode = JumpPadMode.OFF;
private double strength = 0.4;
@ -24,6 +27,29 @@ public class TFM_Jumppads
final Block block = event.getTo().getBlock();
final Vector velocity = player.getVelocity().clone();
if (mode == JumpPadMode.MADGEEK)
{
Boolean canPush = canPushMap.get(player);
if (canPush == null)
{
canPush = true;
}
if (block.getRelative(0, -1, 0).getType() == BLOCK_ID)
{
if (canPush)
{
velocity.multiply(strength + 0.85).multiply(-1.0);
}
canPush = false;
}
else
{
canPush = true;
}
canPushMap.put(player, canPush);
}
else
{
if (block.getRelative(0, -1, 0).getType() == BLOCK_ID)
{
velocity.add(new Vector(0.0, strength, 0.0));
@ -51,6 +77,7 @@ public class TFM_Jumppads
velocity.add(new Vector(0.0, 0.0, DAMPING_COEFFICIENT * strength));
}
}
}
if (!player.getVelocity().equals(velocity))
{
@ -81,7 +108,7 @@ public class TFM_Jumppads
public static enum JumpPadMode
{
OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true);
OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true), MADGEEK(true);
private boolean on;
JumpPadMode(boolean on)