mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-03 00:17:15 +00:00
cleanup CrucibleDataProvider and fix furniture support
This commit is contained in:
parent
747be7aa09
commit
0f3c52a5aa
@ -26,6 +26,7 @@ import com.volmit.iris.engine.data.cache.Cache;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
|
import com.volmit.iris.util.data.IrisBlockData;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||||
import io.lumine.mythic.bukkit.utils.serialize.Chroma;
|
import io.lumine.mythic.bukkit.utils.serialize.Chroma;
|
||||||
@ -53,25 +54,26 @@ public class CrucibleDataProvider extends ExternalDataProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
Iris.info("Setting up MythicCrucible Link...");
|
Iris.info("Setting up MythicCrucible Link...");
|
||||||
try(MythicCrucible crucible = MythicCrucible.inst()) {
|
try {
|
||||||
this.itemManager = crucible.getItemManager();
|
this.itemManager = MythicCrucible.inst().getItemManager();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Iris.error("Failed to set up MythicCrucible Link: Unable to fetch MythicCrucible instance!");
|
Iris.error("Failed to set up MythicCrucible Link: Unable to fetch MythicCrucible instance!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
|
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
|
||||||
this.getItemTypes();
|
CrucibleItem crucibleItem = this.itemManager.getItem(blockId.key())
|
||||||
this.getBlockTypes();
|
.orElseThrow(() -> new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()));
|
||||||
Optional<CrucibleItem> opt = this.itemManager.getItem(blockId.key());
|
CustomBlockItemContext blockItemContext = crucibleItem.getBlockData();
|
||||||
CustomBlockItemContext blockItemContext = opt.orElseThrow(() ->
|
FurnitureItemContext furnitureItemContext = crucibleItem.getFurnitureData();
|
||||||
new MissingResourceException("Failed to find ItemData for block!", blockId.namespace(), blockId.key()))
|
if (furnitureItemContext != null) {
|
||||||
.getBlockData();
|
return new IrisBlockData(furnitureItemContext.getFurnitureMaterial().createBlockData(), ExternalDataSVC.buildState(blockId, state));
|
||||||
if (blockItemContext == null) throw new MissingResourceException("ItemData was not a block!", blockId.namespace(), blockId.key());
|
} else if (blockItemContext != null) {
|
||||||
return blockItemContext.getBlockData();
|
return blockItemContext.getBlockData();
|
||||||
}
|
}
|
||||||
|
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
|
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
|
||||||
@ -89,8 +91,10 @@ public class CrucibleDataProvider extends ExternalDataProvider {
|
|||||||
if (item.getBlockData() == null) continue;
|
if (item.getBlockData() == null) continue;
|
||||||
try {
|
try {
|
||||||
Identifier key = new Identifier("crucible", item.getInternalName());
|
Identifier key = new Identifier("crucible", item.getInternalName());
|
||||||
|
if (getBlockData(key) != null) {
|
||||||
Iris.info("getBlockTypes: Block loaded '" + item.getInternalName() + "'");
|
Iris.info("getBlockTypes: Block loaded '" + item.getInternalName() + "'");
|
||||||
if (getBlockData(key) != null) names.add(key);
|
names.add(key);
|
||||||
|
}
|
||||||
} catch (MissingResourceException ignored) {}
|
} catch (MissingResourceException ignored) {}
|
||||||
}
|
}
|
||||||
return names.toArray(new Identifier[0]);
|
return names.toArray(new Identifier[0]);
|
||||||
@ -102,8 +106,10 @@ public class CrucibleDataProvider extends ExternalDataProvider {
|
|||||||
for (CrucibleItem item : this.itemManager.getItems()) {
|
for (CrucibleItem item : this.itemManager.getItems()) {
|
||||||
try {
|
try {
|
||||||
Identifier key = new Identifier("crucible", item.getInternalName());
|
Identifier key = new Identifier("crucible", item.getInternalName());
|
||||||
|
if (getItemStack(key) != null) {
|
||||||
Iris.info("getItemTypes: Item loaded '" + item.getInternalName() + "'");
|
Iris.info("getItemTypes: Item loaded '" + item.getInternalName() + "'");
|
||||||
if (getItemStack(key) != null) names.add(key);
|
names.add(key);
|
||||||
|
}
|
||||||
} catch (MissingResourceException ignored) {}
|
} catch (MissingResourceException ignored) {}
|
||||||
}
|
}
|
||||||
return names.toArray(new Identifier[0]);
|
return names.toArray(new Identifier[0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user