@@ -21,6 +21,7 @@ public class ShotEntity extends ThrownItemEntity implements FlyingItemEntity {
21
21
private LivingEntity in ;
22
22
private float damage =6 ;
23
23
private String extra ="" ;
24
+ private int tickAge ;
24
25
25
26
26
27
public ShotEntity (EntityType <? extends ThrownItemEntity > entityType , World world , LivingEntity caster , Item toShow , float damageTo , String special ) {
@@ -29,16 +30,23 @@ public ShotEntity(EntityType<? extends ThrownItemEntity> entityType, World world
29
30
setItem (new ItemStack (toShow ));
30
31
damage =damageTo ;
31
32
extra =special ;
32
- //setNoGravity(false);
33
-
34
33
}
34
+
35
35
public ShotEntity (World world )
36
36
{
37
37
super (Pirates .SHOT_ENTITY_TYPE , world );
38
38
}
39
39
40
40
@ Override
41
41
public void tick () {
42
+ if (this .tickAge > 500 ) {
43
+ if (!this .getWorld ().isClient ()) {
44
+ explode ();
45
+ }
46
+ } else {
47
+ this .tickAge ++;
48
+ }
49
+
42
50
if (!getWorld ().isClient () && getVelocity ().length () > 0.85 ) {
43
51
((ServerWorld )getWorld ()).spawnParticles (ParticleTypes .CLOUD , getX (), getY (), getZ (), 1 , 0 , 0 , 0 , 0 );
44
52
}
@@ -49,8 +57,7 @@ public void tick () {
49
57
protected void onCollision (HitResult hitResult ) {
50
58
super .onCollision (hitResult );
51
59
if (!this .getWorld ().isClient ) {
52
- this .getWorld ().createExplosion (this , this .getX (), this .getY (), this .getZ (), 2.2f , extra .contains ("fire" ), World .ExplosionSourceType .TNT );
53
- this .discard ();
60
+ explode ();
54
61
}
55
62
}
56
63
@@ -60,11 +67,15 @@ protected void onEntityHit(EntityHitResult entityHitResult) {
60
67
Entity entity = entityHitResult .getEntity ();
61
68
entity .damage (this .getDamageSources ().explosion (null ), damage );
62
69
if (!this .getWorld ().isClient ) {
63
- this .getWorld ().createExplosion (this , this .getX (), this .getY (), this .getZ (), 2.2f , extra .contains ("fire" ), World .ExplosionSourceType .TNT );
64
- this .discard ();
70
+ explode ();
65
71
}
66
72
}
67
73
74
+ private void explode () {
75
+ this .getWorld ().createExplosion (this , this .getX (), this .getY (), this .getZ (), 2.2f , extra .contains ("fire" ), World .ExplosionSourceType .TNT );
76
+ this .discard ();
77
+ }
78
+
68
79
@ Override
69
80
protected Item getDefaultItem () {
70
81
return Pirates .CANNONBALL_ENT ;
0 commit comments