Skip to content

Commit 377fc5f

Browse files
committed
Fix FALLING_BLOCK in entity_spec() and add "damage" boolean
1 parent 69483e7 commit 377fc5f

4 files changed

Lines changed: 25 additions & 6 deletions

File tree

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCFallingBlock.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ public void setDropItem(boolean drop) {
4040
f.setDropItem(drop);
4141
}
4242

43+
@Override
44+
public boolean canHurtEntities() {
45+
return f.canHurtEntities();
46+
}
47+
48+
@Override
49+
public void setHurtEntities(boolean hurt) {
50+
try {
51+
f.setHurtEntities(hurt);
52+
} catch(NoSuchMethodError ex) {
53+
// probably prior to 1.8.8
54+
}
55+
}
56+
4357
@Override
4458
public FallingBlock getHandle() {
4559
return f;

src/main/java/com/laytonsmith/abstraction/entities/MCFallingBlock.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
import com.laytonsmith.abstraction.blocks.MCMaterial;
55

66
public interface MCFallingBlock extends MCEntity {
7-
87
byte getBlockData();
9-
108
int getBlockId();
11-
129
boolean getDropItem();
13-
1410
MCMaterial getMaterial();
15-
1611
void setDropItem(boolean drop);
12+
boolean canHurtEntities();
13+
void setHurtEntities(boolean hurt);
1714
}

src/main/java/com/laytonsmith/core/functions/EntityManagement.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,8 +1860,11 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
18601860
break;
18611861
case FALLING_BLOCK:
18621862
MCFallingBlock block = (MCFallingBlock) entity;
1863-
specArray.set(entity_spec.KEY_FALLING_BLOCK_BLOCK, new CInt(block.getMaterial().getName(), t), t);
1863+
specArray.set(entity_spec.KEY_FALLING_BLOCK_BLOCK, new CString(block.getMaterial().getName(), t), t);
18641864
specArray.set(entity_spec.KEY_FALLING_BLOCK_DROPITEM, CBoolean.get(block.getDropItem()), t);
1865+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_8_X)) {
1866+
specArray.set(entity_spec.KEY_FALLING_BLOCK_DAMAGE, CBoolean.get(block.canHurtEntities()), t);
1867+
}
18651868
break;
18661869
case FIREBALL:
18671870
case SMALL_FIREBALL:
@@ -2089,6 +2092,7 @@ public CHVersion since() {
20892092
private static final String KEY_EXPERIENCE_ORB_AMOUNT = "amount";
20902093
private static final String KEY_FALLING_BLOCK_BLOCK = "block";
20912094
private static final String KEY_FALLING_BLOCK_DROPITEM = "dropitem";
2095+
private static final String KEY_FALLING_BLOCK_DAMAGE = "damage";
20922096
private static final String KEY_FIREBALL_DIRECTION = "direction";
20932097
private static final String KEY_GUARDIAN_ELDER = "elder";
20942098
private static final String KEY_HORSE_COLOR = "color";
@@ -2462,6 +2466,9 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
24622466
case entity_spec.KEY_FALLING_BLOCK_DROPITEM:
24632467
block.setDropItem(Static.getBoolean(specArray.get(index, t), t));
24642468
break;
2469+
case entity_spec.KEY_FALLING_BLOCK_DAMAGE:
2470+
block.setHurtEntities(Static.getBoolean(specArray.get(index, t), t));
2471+
break;
24652472
default:
24662473
throwException(index, t);
24672474
}

src/main/resources/functionDocs/entity_spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ without knowing the rotations on the other axis or of other body parts beforehan
7878
|
7979
* %KEY_FALLING_BLOCK_BLOCK%: The falling block. Not editable.
8080
* %KEY_FALLING_BLOCK_DROPITEM%: If the falling block will break into an item if it cannot be placed.
81+
* %KEY_FALLING_BLOCK_DAMAGE%: If the falling block can damage entities.
8182
|-
8283
| FIREBALL
8384
|

0 commit comments

Comments
 (0)