-
Posts
7 -
Joined
-
Last visited
Everything posted by hasanchik
-
Sorry for the late reply, but how do I make one of these custom datapack types? Looking at the PreparableReloadListener class and its subclasses hasn't helped me much. And when I do have set up one of these classes, how do I get values from it like described in my post?
-
So for this metal detector item I'm making I need a key-value pair structure officially supported by Mojang in a json file. I have been recommended tags but those simply just don't fit for my needs. The problem I'm having is that the official tags are very limited, see below. I want the player to be able to choose which type of ore they want to detect rather than to just detect all ores and point to the closest ore. You could also implement a "valuabilityscore" system or something like that but tags still wouldn't work for that. Here's the structure I have to work with: { "replace": false, "values": [ { "id": "minecraft:iron_ore", "findingDistanceMultiplier": 1, "values": [ "#minecraft:iron_ores" ] }, { "id": "minecraft:gold_ore", "findingDistanceMultiplier": 0.5, "values": [ "#minecraft:gold_ores" ] }, { "id": "minecraft:copper_ore", "findingDistanceMultiplier": 1.5, "values": [ "#minecraft:copper_ores" ] }, { "id": "minecraft:ancient_debris", "findingDistanceMultiplier": 0.2, "values": [ "minecraft:ancient_debris" ] } ] } I don't know if it's a good idea to every time loop through these to find the value field. It just feels hacky and it's frustrating to implement. Here's the structure I want to work with: { "replace": false, "values": [ "minecraft:iron_ore": { "findingDistanceMultiplier": 1, "values": [ "#minecraft:iron_ores" ] }, "minecraft:gold_ore": { "findingDistanceMultiplier": 0.5, "values": [ "#minecraft:gold_ores" ] }, "minecraft:copper_ore": { "findingDistanceMultiplier": 1.5, "values": [ "#minecraft:copper_ores" ] }, "minecraft:ancient_debris": { "findingDistanceMultiplier": 0.2, "values": [ "minecraft:ancient_debris" ] } ] } Is it possible to implement the latter in one way or the other in vanilla Minecraft? If so, how would I even use it? It would be nice to have that mod compatibility. But I could also use the former data structure if I can figure out how to loop through the Json file and find the value field i'm looking for. If you have answers to any of these question please do respond
-
I need a way to store this type of hashmap somewhere that is supported by vanilla Minecraft in a json file: protected static HashMap<String, String[]> detectableBlocks = new HashMap<>(); I want to do this for mod compatibility and ease of use. For example if another mod wants to integrate into mine that is supported What i'm trying to do here basically is have a "type" of block that is detectable. For example you have '"iron_ore": ["deepslate_iron_ore", "iron_ore"], "diamond_ore": ["deepslate_diamond_ore", "diamond_ore"]' ect. I have looked at "data/minecraft/tags" but it's not clear to me how they are used and why I should use them. The Forge documentations have no simple explanations for these sorts of stuff, so it's hard for me to understand. But that doesn't matter since the value field in a tag json file is an array and not a hashmap anyway. Is there an equivalent of what I described above in the data folder? Or do I have to make my own custom folder?
-
Hello there, So while I was trying to make my mod I encountered a simple yet pretty difficult problem. How do you get a block (server side perhaps?) from a blockPosition? The particular problem i'm having is getting a World class which then allows you to get a block. Here are the pieces of code I need to use this for: package net.hasanchik.neutroneum.util; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.NotNull; import net.minecraft.world.level.; public class BasicUtils { public static class BlockUtils { public static BlockPos divideBlockPos(@NotNull BlockPos position, int divisor) { return new BlockPos(position.getX()/divisor, position.getY()/divisor, position.getZ()/divisor); } public static Block[] getAllBlocksInRectangle(BlockPos position, BlockPos size, @NotNull Boolean centered) { BlockPos startingPosition = position; if (centered) { startingPosition.subtract(divideBlockPos(size, 2)); } for (int x = position.getX(); x <= size.getX(); x++) { for (int y = position.getY(); y <= size.getY(); y++) { for (int z = position.getZ(); z <= size.getZ(); z++) { World.world.getBlockState(new BlockPos(x, y, z)).getBlock(); } } } } public static Block getAllBlocksInBox() { } } } package net.hasanchik.neutroneum.item.custom; import net.hasanchik.neutroneum.util.BasicUtils; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import java.util.HashMap; public class MetalDetectorItem extends Item { //TODO: find better way of storing detectable blocks public static final int animationFrames = 31; protected static HashMap<String, String> detectableBlocks = new HashMap<>(); protected Integer closestOreDistance = 0; protected int public MetalDetectorItem(Properties properties) { super(properties); } private void print(String message, Player player) { player.sendSystemMessage(Component.literal(message)); } public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { if(!level.isClientSide() && hand == InteractionHand.MAIN_HAND) { BlockPos playerBlockPos = BlockPos.containing(player.getPosition(1)); BlockPos[] blocks = BasicUtils.BlockUtils.getAllBlocksInRectangle(); this.closestOreDistance = RandomSource.createNewThreadLocalInstance().nextInt(animationFrames); print("test " + this.getClosestOreDistance(), player); } return super.use(level, player, hand); } public int getClosestOreDistance() { System.out.println(this.closestOreDistance); return this.closestOreDistance; } } Please keep in mind that the code isn't finished yet
-
[SOLVED] Enchantment or electricity effect on a block
hasanchik replied to hasanchik's topic in Modder Support
Thank you for your insight, but how do you change the functionality of an already existing block though? I'm talking about the copper block here which has no (real) functionality AFAIK. What i mean by that is to extend a simple block without any funcionality that is not a class (like stone) into a block that has functionality which is a class (like TNT). Is this possible without modifying existing registries? Will this maybe cause some issues, and is it much better and easier to make your own custom block? Sorry for the rate reply, i had school and all of that stuff 😅 -
[SOLVED] Enchantment or electricity effect on a block
hasanchik replied to hasanchik's topic in Modder Support
In that post it uses block entities. Is this possible with normal blocks? Furthermore, do block entities even have an impact on performance? Sorry if I ask too many questions, I just need to gather some info before I can work on this more -
Hello there, So i'm trying to figure out how to make a enchantment glint or electricity (from a charged creeper) kind of effect appear on an already existing block. I'm new to modding so I do not know at all how to do this. I'm trying to make a mod that gives copper a good use and introduces an electricity system. I took my inspiration from this video: https://www.youtube.com/watch?v=Tpm3yx1FFqo&t=400s As you can see at the timestamp 400s the video shows "charged" copper blocks which is what i'm going for here. Here's another example: https://www.reddit.com/r/Minecraft/comments/ysbm94/putting_the_enchantment_glint_on_blocks/ If you were to go with this approach you would need to replace the enchanting texture with another one. Is it also possible to make these textures appear on the surface of the block and not a bit above it like armour? And just to clarify, is it also possible to make this happen an already existing block like cut copper? I fully know the Java language, but I do not know how to mod. (i acidentally pressed enter while i was making the topic, oops)