Skip to content

Commit

Permalink
Mine bombs: Update and fix some issues with the new mine bomb process…
Browse files Browse the repository at this point in the history
…ing and animations.
  • Loading branch information
rbluer committed Jul 8, 2024
1 parent b30c039 commit 78fc846
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 270 deletions.
3 changes: 3 additions & 0 deletions docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.18b 2024-07-07


* **Mine bombs: Update and fix some issues with the new mine bomb processing and animations.**


* **Prison NBT: removed debug code which was generating a lot of entries in the logs.**


Expand Down
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);
}

}
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();

}


}
Loading

0 comments on commit 78fc846

Please sign in to comment.