Jump to content

[1.17.x] How to make a block that can become indestructible when I apply some powder on it ?


Vat1n

Recommended Posts

Hello,

I'm a newbie in the Minecraft modding but I know the Java's basics. I use Intellij IDEA. The mod is intended for 1.17.x

I'm making a sort of Aether Mod (in order to train). Currently, I am creating a block which can become indestructible when I apply some Luminite powder (a new crystal transformed into powder). This block is called Urzil and it will be used in the dungeon where it is, by default, indestructible.

My question is how should I proceed to code that ? Should I look the Redstone-Lamp-Block JavaClass and "copy" the code or should I search through the tons of Minecraft code until I find the good method per example ?

I have created an abstract JavaClass called "ChargeableBlocks"  (in a folder named "Common") which contains the Urzil feature. As a matter of fact, I planned to create other ones for more dungeons. Then, I will place the UrzilClass in the same folder

I watched some video (TurtyWurty and Kaupenjoe) but I understand nothing that can help me.

The part of ChargeableBlock's JavaClass below is obviously incomplete. I haven't coded the Luminite Powder yet.

If someone can help (or correct) me please. I'm lost

 

-Vat1n-

 

package fr.vat.mymod.common.block;

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;

public abstract class ChargeableBlocks extends Block {
    public static final BooleanProperty CHARGED = BooleanProperty.create("charged");


    public ChargeableBlocks(BlockBehaviour.Properties properties) {
        super(properties);
        this.registerDefaultState(this.defaultBlockState().setValue(CHARGED, Boolean.valueOf(false)));
    }

    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
        pBuilder.add(CHARGED);
    }

    @Override
    public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) 	{
    }
}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • That's what's so odd. Because I shift-clicked to get the file path & it literally is the same exact thing: (copy + pasted from folder) "C:\Program Files\Java\jdk-17\bin\javaw.exe"
    • updated a few mods and now my pack won't load https://paste.ee/p/0sUrp
    • I have installed Forge 1000 times and in different versions, but every time I enter a server or world, it loads the entire square and then it says ''Saving world''. After that, Minecraft closes and the launcher opens with a window displaying error code ''-1''. I don't even have any mods installed, it doesn't let me join any world or server. I contacted Minecraft support, and they told me to talk to you. I hope you can help me with this issue, I'm waiting for your response.
    • I'm trying to make a Event that is fired if a Player is swimming. Here is the Event Class: public class PlayerSwimEvent extends PlayerEvent { public PlayerSwimEvent(Player player) { super(player); } } Here is the Hooks (similar to ForgeHooks Class) that has Methods for the Events: public class EventHooks { public static void onPlayerSwim(Player player) { MinecraftForge.EVENT_BUS.post(new PlayerSwimEvent(player)); } } And here is the Mixin Class: @Mixin(value = Player.class) public class MixinPlayerSwimEvent { @Inject(method = "isSwimming", at = @At("HEAD")) public boolean isSwimming(CallbackInfoReturnable<Boolean> cir) { Player player = null; if (!player.getAbilities().flying && !player.isSpectator()) { EventHooks.onPlayerSwim(player); } return cir.getReturnValue(); } } My Issue is now that I don't get it to work because of the missing Parameter Player. Can someone help with this?
    • Official Website: https://informalhouse.com/r31p [Tap To Order Now] Perma Health Keto Gummies Canada if you're looking for a feature upgrade that will aid in your weight loss. It's among the most well-known weight loss supplements that are currently available, and many people have reported that it has assisted them in losing weight and maintaining their current physical appearance because it is believed to have a number of health benefits when taken over an extended period of time. Order Now:- https://groups.google.com/g/perma-health-keto-gummies-canada-quebec-try/c/4Um2uvnP-9g https://groups.google.com/g/active-keto-capsules-reviews-australia-public/c/kDDPgO8i8N4 https://gamma.app/public/Active-Keto-Capsules-Australia-weight-loss--l3anbew5k3vo5xl https://gamma.app/public/Perma-Health-Keto-Gummies-Canada-Quebec-Buy-5lhwh920bh1hzfd https://medium.com/@jon2023lee/perma-health-keto-gummies-canada-quebec-healthy-weight-loss-88a1bf673d72 https://medium.com/@jon2023lee/active-keto-capsules-australia-increased-energy-d80bc3aa5fc6 https://groups.google.com/g/chemistbuy--warehouse-keto-gummies-australia/c/L9ehZw7QxvA https://groups.google.com/g/mozilla.dev.platform/c/DUplSCW14Ds https://groups.google.com/g/mozilla.dev.platform/c/mxfTITHqHQU https://groups.google.com/g/active-keto-capsules-reviews-australia/c/xIM5sHObvSA https://www.facebook.com/ChemistWarehouseKetoGummiesAustraliasale https://www.facebook.com/ActiveketocapsulesreviewsAustralia https://gamma.app/public/Chemist-Warehouse-Keto-Gummies-Australia-Do-whatever-it-takes-not-5hixkohxcxt89to?mode=doc https://gamma.app/public/Active-keto-capsules-reviews-Australia-Crazy-Deals-Todays-best-of-iksqml7nl380vmp?mode=doc   
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.