keepcalm / BukkitForge

The world's first __opensource__ coremod. Also a port of the Bukkit server API to MinecraftForge.
http://www.minecraftforge.net/forum/index.php/topic,3254.0.html
103 stars 60 forks source link

[ScriptCraft] setTypeIdAndData not working with AIR (0) ID #577

Open jmbjorndalen opened 11 years ago

jmbjorndalen commented 11 years ago

I'm running ScriptCraft with Tekkit Lite + BukkitForge (build 255).

In an unmodified ScriptCraft and BukkitForge, I'm unable to set blocks to type 0. ScriptCraft retrieves a block at a given position and uses setTypeIdAndData on the block to set the block type and metadata. This works for any block except air blocks (ID 0).

I'm new to BukkitForge and the Bukkit API, but I think the bug may be in the following line in CraftBlock.java:setTypeIdAndData():

if (type > 4096 || data > 16 ||  net.minecraft.block.Block.blocksList[type] == null) {

What happens if type is 0?

Would something like this work better?

if (type > 4096 || data > 16 ||  (type != 0 && net.minecraft.block.Block.blocksList[type] == null)) {

As a workaround, I've modified ScriptCraft on my server to use block.setTypeId when setting blocks to type 0.

Cheers,

steffengy commented 11 years ago

Interesting... Bukkit is not using any of these checks... @alexbegt You know if they are necessary?