#Cancel block place
35 messages · Page 1 of 1 (latest)
It should work for 1.20-1.20.4, and there's branches going down to 1.15.x if you're going that low
thx
@past spindle Are you trying to stop from placing a specific block, rather than just the name? If so, check what type the block is. No need to try and check names.
i already fixed the problem, but thank you
+👍
there's actually a pumpkin with lang name
that why it's like an item
Not sure what you mean by that, but it's a lot safer (and probably faster) to just check if it's a pumpkin rather than testing if it's named "Pumpkin" in the same language. Especially if someone renames the item.
if i use just pumpkin, i can't place just pumpkin
and, do you now how to ignore capslock in string?
String#toLowerCase or something like that
Then you compare with a lower case string
@maiden flame
sorry for asking again, but idk why this is again not working, if you have time, can you help me?
if (stack.getName() == null || !equalsIgnoreCase((stack.getName().toString()), (Text.translatable("item.cherrytown.gold_cherry_vision").toString()))){ return true; } else if (stack.getName() == null || !equalsIgnoreCase((stack.getName().toString()), (Text.translatable("item.gold_cherrytown.gold_cherry_vision").toString()))){ return true; } else if (stack.getName() == null || !equalsIgnoreCase((stack.getName().toString()), (Text.translatable("text.gold_cherrytown.gold_cherry_vision").toString()))){ return true; }
its comparing to string with equalsignorecase
no errors in ide*
if its identical no matter capslock, then true
so its reversed
and if item its not that = true
So you're trying to prevent yourself from placing everything except this gold_cherry_vision thing, right?
include*
Ok, so only that? First off, you're trying to compare a strings for the objects, not the strings that are the names. Second, that's a strange way of doing it - you're making a lot more work for yourself.
Next, I don't know where equalsIgnoreCase came from, that's an instance method in String, but I suppose that doesn't matter since we don't need it.
You're needing stack.getItem().equals(*/ Wherever your item is*/.*/ITEM_NAME*/)
That's all?
2 days 💀
OK, well there's your problem :P
Here's some good resources to help you get started
Minecraft modding is a really hard place to start
!!learnjava
To start modding Minecraft using Fabric, it's strongly recommended to know Java.
Minecraft, in its codebase, and mods, using Fabric API, use more advanced Java concepts like lambdas, generics and polymorphism.
If you don't know all of these concepts, you may have some difficulties modding.
Here are some online resources that will help learning Java
JetBrains Academy (free online course): https://www.jetbrains.com/academy/
Codecademy (free online course): https://www.codecademy.com/learn/learn-java
University of Helsinki (free online course): https://java-programming.mooc.fi/
Basic Java Tutorials: https://docs.oracle.com/javase/tutorial/
Introduction to Programming using Java by David J. Eck (free online textbook): http://math.hws.edu/javanotes/
After Learning Java
For most mods you will want to make, you will have to use the Spongepowered Mixin Java library.
To learn more about Mixin, you can use the faq/mixin bot tag by typing !!faq/mixin in #bot-posting .