Skip to content

Commit

Permalink
Some fixes for block data conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
retrooper committed May 8, 2024
1 parent ba21fa9 commit 1bad630
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.common.collect.MapMaker;
import io.netty.buffer.PooledByteBufAllocator;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -205,7 +206,7 @@ private static void initMethods() {
WRITE_ITEM_STACK_IN_PACKET_DATA_SERIALIZER_METHOD = Reflection.getMethod(NMS_PACKET_DATA_SERIALIZER_CLASS, 0, NMS_ITEM_STACK_CLASS);
}

GET_COMBINED_ID = Reflection.getMethod(BLOCK_CLASS, IBLOCK_DATA_CLASS, 0, int.class);
GET_COMBINED_ID = Reflection.getMethod(BLOCK_CLASS, int.class, 0, IBLOCK_DATA_CLASS);
GET_BY_COMBINED_ID = Reflection.getMethod(BLOCK_CLASS, IBLOCK_DATA_CLASS, 0, int.class);
if (CRAFT_BLOCK_DATA_CLASS != null) {
GET_CRAFT_BLOCK_DATA_FROM_IBLOCKDATA = Reflection.getMethodExact(CRAFT_BLOCK_DATA_CLASS, "fromData", CRAFT_BLOCK_DATA_CLASS, IBLOCK_DATA_CLASS);
Expand Down Expand Up @@ -791,18 +792,21 @@ public static MaterialData getBlockDataByCombinedId(int combinedID) {
//TODO Finish for 1.7.10
throw new IllegalStateException("This operation is not supported yet on 1.7.10!");
}
/*Object iBlockDataObj = null;
Object iBlockDataObj = null;
try {
iBlockDataObj = GET_BY_COMBINED_ID.invoke(null, combinedID);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}*/
/*
}

try {
return (BlockData) GET_CRAFT_BLOCK_DATA_FROM_IBLOCKDATA.invoke(null, iBlockDataObj);
Class<?> blockData = Reflection.getClassByNameWithoutException("org.bukkit.block.data.BlockData");
Object bd = (blockData.cast(GET_CRAFT_BLOCK_DATA_FROM_IBLOCKDATA.invoke(null, iBlockDataObj)));
Method materialMethod = Reflection.getMethod(blockData, Material.class, 0);
return new MaterialData((Material) materialMethod.invoke(bd));
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}*/
}

return null;
}
Expand Down

0 comments on commit 1bad630

Please sign in to comment.