generated from NeoForgeMDKs/MDK-1.21-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccf97be
commit 465bede
Showing
7 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/com/nateplays/my_neoforge_mod/block/custom/MagicBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.nateplays.my_neoforge_mod.block.custom; | ||
|
||
import com.nateplays.my_neoforge_mod.item.ModItems; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.item.ItemEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
|
||
public class MagicBlock extends Block { | ||
|
||
public MagicBlock(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { | ||
// return super.useWithoutItem(state, level, pos, player, hitResult); | ||
level.playSound(player, pos, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.BLOCKS, 1f, 1f); | ||
return InteractionResult.SUCCESS; | ||
} | ||
|
||
@Override | ||
public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { | ||
// yes, item entities can step on blocks | ||
if (entity instanceof ItemEntity itemEntity) { | ||
if (itemEntity.getItem().getItem() == ModItems.MALACHITE_CHUNK.get()) { | ||
itemEntity.setItem(new ItemStack(ModItems.MALACHITE_INGOT.get(), itemEntity.getItem().getCount())); | ||
} else { | ||
entity.setDeltaMovement(entity.getDeltaMovement().add(0, 0.5, 0)); | ||
} | ||
} | ||
|
||
super.stepOn(level, pos, state, entity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/my_neoforge_mod/blockstates/magic_block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "my_neoforge_mod:block/magic_block" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/my_neoforge_mod/models/block/magic_block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cube_all", | ||
"textures": { | ||
"all": "my_neoforge_mod:block/magic_block" | ||
} | ||
} |
Binary file added
BIN
+269 Bytes
src/main/resources/assets/my_neoforge_mod/textures/block/magic_block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.