Closed LukeAppGuy closed 2 years ago
Let me see your plugin code.
tavern.tavernfarming.TavernFarming.placeCrop(TavernFarming.java:256
Are you trying to place an item which is not a seed or which is not a block? Let me also see the item YML configuration.
@LoneDev6
The code that is causing that error is this:
public void placeCrop(Player player, Block farmland, String crop){
player.sendMessage(ChatColor.GREEN + "DEBUG - " + ChatColor.GRAY + "Placed a custom crop seed.");
//Setup persistent block data namespace keys and block id.
String blockID = UUID.randomUUID().toString();
PersistentDataContainer customBlockData = new CustomBlockData(farmland, this);
NamespacedKey growthStage = new NamespacedKey(this, "growthStage");
NamespacedKey cropType = new NamespacedKey(this, "crop");
NamespacedKey id = new NamespacedKey(this, "id");
//Save block id, crop type and growth stage (usually starts at 1)
customBlockData.set(growthStage, PersistentDataType.STRING, "1");
customBlockData.set(cropType, PersistentDataType.STRING, crop);
customBlockData.set(id, PersistentDataType.STRING, blockID);
//Place the custom crop block on the farmland that the player interacted with.
CustomBlock customBlock = CustomBlock.getInstance(crop);
customBlock.place(farmland.getLocation());
World w = player.getWorld();
w.playSound(player.getLocation(), "minecraft:item.crop.plant", SoundCategory.BLOCKS, 1f, 1f);
player.sendMessage(w.getName());
cropLocations.getConfig().set("Locations." + blockID + ".world", w.getName());
cropLocations.getConfig().set("Locations." + blockID + ".age", 0);
cropLocations.getConfig().set("Locations." + blockID + ".x", customBlock.getBlock().getLocation().getX());
cropLocations.getConfig().set("Locations." + blockID + ".y", customBlock.getBlock().getLocation().getY());
cropLocations.getConfig().set("Locations." + blockID + ".z", customBlock.getBlock().getLocation().getZ());
cropLocations.saveConfig();
}
Also the line "256" specifically is this:
CustomBlock customBlock = CustomBlock.getInstance(crop);
This is working 100% fine in previous versions, its nothing to do with the item since that hasn't changed either. Its just a an item with an NBT tag, when the user right clicks farmland with that special seed-item it summons a custom Items Adder block at the farmland. As I say it was working fine until I updated so I'm unsure of what could cause this.
I really doubt it.
It seems you're trying to call CustomBlock#getInstance(String namespacedId)
on an item instead of a block, this is what the error is reporting.
You can use this only if the item is a custom block.
I just tested and it works fine.
CustomBlock customBlock = CustomBlock.getInstance("iasurvival:ruby_block");
Terms
Discord tag (optional)
Holmes#6657
What happened?
I use the Items Adder Java API with a few of my custom written plugins, updating items adder to the latest version on my test server along with the version number in my pom.xml has caused my plugin to fail entirely. I get the following error in the console:
java.lang.ClassCastException: class dev.lone.itemsadder.main.cb cannot be cast to class dev.lone.itemsadder.main.bZ (dev.lone.itemsadder.main.cb and dev.lone.itemsadder.main.bZ are in unnamed module of loader 'ItemsAdder_3.2.0b-beta4.jar' @6e0b2ae3)
I opened a community-help ticket and someone tried to help me resolve the issue although none of their suggestions worked to fix my problem. This seems like a pretty huge issue since it means anyone using the API in their plugin will no longer work.
Steps to reproduce the issue
Use the items adder API with a custom spigot plugin, using any of the API at all gives the error I have posted in this bug report. My dependency in my pom.xml looks like this:
I was using 3.0.0 with my plugins for a while but once I updated the API no longer works.
Server version
Current: git-Purpur-1561 (MC: 1.18.1)*
ItemsAdder Version
ItemsAdder version 3.2.0b-beta4
ProtocolLib Version
ProtocolLib version 4.8.0
LoneLibs Version
LoneLibs version 1.0.19
LightAPI Version (optional)
No response
LibsDisguises Version (optional)
No response
FULL server log
latest.log
Error (optional)
ItemsAdder config.yml
Problematic items yml configuration file (optional)
No response
Other files, you can drag and drop them here to upload. (optional)
No response
Screenshots/Videos (you can drag and drop files or paste links)
No response