-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mine bombs: Update and fix some issues with the new mine bomb process…
…ing and animations.
- Loading branch information
Showing
8 changed files
with
306 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 8 additions & 125 deletions
133
prison-core/src/main/java/tech/mcprison/prison/bombs/animations/BombAnimationInfinity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,153 +1,36 @@ | ||
package tech.mcprison.prison.bombs.animations; | ||
|
||
import tech.mcprison.prison.bombs.MineBombData; | ||
import tech.mcprison.prison.bombs.MineBombs; | ||
import tech.mcprison.prison.internal.ArmorStand; | ||
import tech.mcprison.prison.internal.EulerAngle; | ||
import tech.mcprison.prison.internal.ItemStack; | ||
import tech.mcprison.prison.internal.block.PrisonBlock; | ||
import tech.mcprison.prison.output.Output; | ||
import tech.mcprison.prison.util.BluesSemanticVersionComparator; | ||
import tech.mcprison.prison.util.Location; | ||
|
||
public class BombAnimationInfinity | ||
extends BombAnimations { | ||
|
||
|
||
private double eulerAngleX = 1.0; | ||
private double eulerAngleY = 0; | ||
private double eulerAngleZ = 0; | ||
|
||
private double twoPI; | ||
|
||
private ArmorStand armorStand; | ||
|
||
private float entityYaw; | ||
private float entityPitch; | ||
|
||
|
||
|
||
|
||
public BombAnimationInfinity( MineBombData bomb, | ||
PrisonBlock sBombBlock, ItemStack item, | ||
BombAnimationsTask task, | ||
float entityYaw, float entityPitch ) { | ||
super( bomb, sBombBlock, item, task ); | ||
super( bomb, sBombBlock, item, task, entityYaw, entityPitch ); | ||
|
||
this.entityYaw = entityYaw; | ||
this.entityPitch = entityPitch; | ||
|
||
initialize(); | ||
} | ||
|
||
|
||
|
||
public void initialize() { | ||
|
||
this.twoPI = Math.PI * 2; | ||
|
||
|
||
initializeArmorStand(); | ||
} | ||
|
||
private void initializeArmorStand() { | ||
|
||
Location location = getsBlock().getLocation(); | ||
location.setY( location.getY() + 2.5 ); | ||
|
||
location.setYaw( entityYaw ); | ||
location.setPitch( entityPitch + 90 ); | ||
|
||
|
||
double startingAngle = ( 360d / entityYaw ) * twoPI; | ||
|
||
// eulerAngleX += startingAngle; | ||
|
||
EulerAngle arm = new EulerAngle( eulerAngleX + startingAngle, eulerAngleY + startingAngle, eulerAngleZ + startingAngle ); | ||
|
||
|
||
armorStand = location.spawnArmorStand(); | ||
|
||
armorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_KEY, getBomb().getName() ); | ||
|
||
if ( armorStand != null ) { | ||
|
||
armorStand.setVisible(false); | ||
armorStand.setRemoveWhenFarAway(false); | ||
armorStand.setItemInHand( getItem() ); | ||
armorStand.setRightArmPose(arm); | ||
|
||
|
||
if ( initializeCustomName() && getId() == 1 ) { | ||
|
||
//updateArmorStandCustomName(); | ||
armorStand.setCustomName( getTagName() ); | ||
armorStand.setCustomNameVisible(true); | ||
} | ||
else { | ||
|
||
armorStand.setCustomNameVisible(false); | ||
} | ||
|
||
if ( new BluesSemanticVersionComparator().compareMCVersionTo( "1.9.0" ) >= 0 ) { | ||
|
||
armorStand.setGlowing( getBomb().isGlowing() ); | ||
|
||
// setGravity is invalid for spigot 1.8.8: | ||
armorStand.setGravity( getBomb().isGravity() ); | ||
} | ||
} | ||
|
||
if ( Output.get().isDebug() ) { | ||
String msg = String.format( | ||
"### BombAnimationInfinity.initializeArmorStand : id: %s ", | ||
Integer.toString(getId()) | ||
|
||
); | ||
Output.get().logInfo( msg ); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
@Override | ||
public void step() | ||
public void stepAnimation() | ||
{ | ||
|
||
double speed = 0.35; | ||
|
||
eulerAngleX += speed; | ||
eulerAngleY += speed / 3; | ||
eulerAngleZ += speed / 5; | ||
|
||
|
||
EulerAngle arm = new EulerAngle( eulerAngleX, eulerAngleY, eulerAngleZ ); | ||
|
||
armorStand.setRightArmPose(arm); | ||
setEulerAngleX( getEulerAngleX() + speed ); | ||
setEulerAngleY( getEulerAngleY() + speed / 3); | ||
setEulerAngleZ( getEulerAngleZ() + speed / 5 ); | ||
|
||
|
||
if ( eulerAngleX > twoPI ) { | ||
eulerAngleX -= twoPI; | ||
} | ||
if ( eulerAngleY > twoPI ) { | ||
eulerAngleY -= twoPI; | ||
} | ||
if ( eulerAngleZ > twoPI ) { | ||
eulerAngleZ -= twoPI; | ||
} | ||
|
||
|
||
// Track the time that this has lived: | ||
if ( --terminateOnZeroTicks == 0 || !armorStand.isValid() ) { | ||
|
||
armorStand.remove(); | ||
|
||
cancel(); | ||
} | ||
|
||
updateCustomName(); | ||
EulerAngle arm = new EulerAngle( getEulerAngleX(), getEulerAngleY(), getEulerAngleZ() ); | ||
|
||
getArmorStand().setRightArmPose(arm); | ||
} | ||
|
||
} |
88 changes: 2 additions & 86 deletions
88
prison-core/src/main/java/tech/mcprison/prison/bombs/animations/BombAnimationNone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,25 @@ | ||
package tech.mcprison.prison.bombs.animations; | ||
|
||
import tech.mcprison.prison.bombs.MineBombData; | ||
import tech.mcprison.prison.bombs.MineBombs; | ||
import tech.mcprison.prison.internal.ArmorStand; | ||
import tech.mcprison.prison.internal.ItemStack; | ||
import tech.mcprison.prison.internal.block.PrisonBlock; | ||
import tech.mcprison.prison.output.Output; | ||
import tech.mcprison.prison.util.BluesSemanticVersionComparator; | ||
import tech.mcprison.prison.util.Location; | ||
|
||
public class BombAnimationNone | ||
extends BombAnimations { | ||
|
||
private ArmorStand armorStand; | ||
|
||
private float entityYaw; | ||
private float entityPitch; | ||
|
||
|
||
public BombAnimationNone( MineBombData bomb, | ||
PrisonBlock sBombBlock, ItemStack item, | ||
BombAnimationsTask task, | ||
float entityYaw, float entityPitch ) { | ||
super( bomb, sBombBlock, item, task ); | ||
super( bomb, sBombBlock, item, task, entityYaw, entityPitch ); | ||
|
||
this.entityYaw = entityYaw; | ||
this.entityPitch = entityPitch; | ||
|
||
initialize(); | ||
} | ||
|
||
public void initialize() { | ||
|
||
initializeArmorStand(); | ||
} | ||
|
||
private void initializeArmorStand() { | ||
|
||
Location location = getsBlock().getLocation(); | ||
location.setY( location.getY() + 2.5 ); | ||
|
||
location.setYaw( entityYaw ); | ||
location.setPitch( entityPitch + 90 ); | ||
|
||
|
||
armorStand = location.spawnArmorStand(); | ||
|
||
armorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_KEY, getBomb().getName() ); | ||
|
||
if ( armorStand != null ) { | ||
|
||
armorStand.setVisible(false); | ||
armorStand.setRemoveWhenFarAway(false); | ||
armorStand.setItemInHand( getItem() ); | ||
//armorStand.setRightArmPose(arm); | ||
|
||
|
||
if ( initializeCustomName() ) { | ||
|
||
//updateArmorStandCustomName(); | ||
armorStand.setCustomName( getTagName() ); | ||
armorStand.setCustomNameVisible(true); | ||
} | ||
else { | ||
|
||
armorStand.setCustomNameVisible(false); | ||
} | ||
|
||
if ( new BluesSemanticVersionComparator().compareMCVersionTo( "1.9.0" ) >= 0 ) { | ||
|
||
armorStand.setGlowing( getBomb().isGlowing() ); | ||
|
||
// setGravity is invalid for spigot 1.8.8: | ||
armorStand.setGravity( getBomb().isGravity() ); | ||
} | ||
} | ||
|
||
if ( Output.get().isDebug() ) { | ||
String msg = String.format( | ||
"### BombAnimationInfinity.initializeArmorStand : id: %s ", | ||
Integer.toString(getId()) | ||
|
||
); | ||
Output.get().logInfo( msg ); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
@Override | ||
public void step() | ||
public void stepAnimation() | ||
{ | ||
|
||
// Track the time that this has lived: | ||
if ( --terminateOnZeroTicks == 0 || !armorStand.isValid() ) { | ||
|
||
armorStand.remove(); | ||
|
||
cancel(); | ||
} | ||
|
||
updateCustomName(); | ||
|
||
} | ||
|
||
|
||
} |
Oops, something went wrong.