use of org.asassecreations.voxelgame.inventory.ItemPreset in project Voxel_Game by ASasseCreations.
the class AssetLoader method loadBlocks.
public static final Map<String, Block> loadBlocks(final Map<String, BlockTexture> atlasPos) throws MalformedURLException, IOException, URISyntaxException {
final List<String> fileNames = getItems("/def/block", "def");
fileNames.addAll(getItems(Content.MOD_BLOCK_FOLDER, "def", true));
final Map<String, Block> finalBlocks = new HashMap<>();
for (int i = 0; i < fileNames.size(); i++) {
final String block = getName(fileNames.get(i), 3);
final BlockTexture texture = new BlockTexture(0, 0);
boolean breakable = true;
ItemPreset item = null;
final Properties properties = new Properties();
properties.load(Tools.getReader(fileNames.get(i)));
{
texture.left_uv = atlasPos.get(properties.getProperty("left")).left_uv;
texture.right_uv = atlasPos.get(properties.getProperty("right")).right_uv;
texture.top_uv = atlasPos.get(properties.getProperty("top")).top_uv;
texture.bottom_uv = atlasPos.get(properties.getProperty("bottom")).bottom_uv;
texture.front_uv = atlasPos.get(properties.getProperty("front")).front_uv;
texture.back_uv = atlasPos.get(properties.getProperty("back")).back_uv;
if (properties.getProperty("breakable") != null)
breakable = Boolean.parseBoolean(properties.getProperty("breakable"));
if (properties.getProperty("item") != null)
item = ItemPreset.get(properties.getProperty("item"));
}
finalBlocks.put(block, new Block(i, texture, BlockAudio.BLOCK_CLOTH, item, breakable));
}
return finalBlocks;
}
use of org.asassecreations.voxelgame.inventory.ItemPreset in project Voxel_Game by ASasseCreations.
the class AssetLoader method loadItems.
public static final void loadItems() throws IOException, URISyntaxException {
final List<String> itemFileNames = getItems("/def/item", "def");
itemFileNames.addAll(getItems(Content.MOD_ITEM_FOLDER, "def", true));
for (final String s : itemFileNames) {
final String name = getName(s, 3);
final Properties properties = new Properties();
properties.load(Tools.getReader(s));
final ItemPreset item = new ItemPreset();
final String p = properties.getProperty("texture");
item.id = Integer.parseInt(properties.getProperty("id"));
{
for (final String str : ItemPreset.ITEMS.keySet()) {
final ItemPreset i = ItemPreset.ITEMS.get(str);
if (i.id == item.id) {
JOptionPane.showMessageDialog(null, "Item id conflict with \"" + str + "\" and \"" + name + "\" with id " + item.id, "Item not loaded!", JOptionPane.ERROR_MESSAGE);
continue;
}
}
}
if (p.startsWith(":"))
item.image = RawAtlasTile.ORIGINAL_IMAGE.get(p.substring(1));
else
item.image = RawAtlasTile.MODIFIED_IMAGE.get(p);
ItemPreset.ITEMS.put(name, item);
}
}
Aggregations