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
2e1b5bb
commit 824438f
Showing
8 changed files
with
73 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
src/main/java/net/strangergamer/mccourse/item/custom/ChainsawItem.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,34 @@ | ||
package net.strangergamer.mccourse.item.custom; | ||
|
||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.tags.BlockTags; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
import net.minecraft.world.level.Level; | ||
|
||
import java.util.Objects; | ||
|
||
public class ChainsawItem extends Item { | ||
public ChainsawItem(Properties pProperties) { | ||
super(pProperties); | ||
} | ||
|
||
@Override | ||
public InteractionResult useOn(UseOnContext pContext) { | ||
Level level = pContext.getLevel(); | ||
|
||
if(!level.isClientSide()) { | ||
if(level.getBlockState(pContext.getClickedPos()).is(BlockTags.LOGS)) { | ||
level.destroyBlock(pContext.getClickedPos(), true, pContext.getPlayer()); | ||
|
||
pContext.getItemInHand().hurtAndBreak(1, ((ServerLevel) level), ((ServerPlayer) pContext.getPlayer()), | ||
item -> Objects.requireNonNull(pContext.getPlayer()).onEquippedItemBroken(item, EquipmentSlot.MAINHAND)); | ||
} | ||
} | ||
|
||
return InteractionResult.CONSUME; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "mccourse:item/chainsaw" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
{ | ||
"type": "minecraft:crafting_shaped", | ||
"category": "misc", | ||
"pattern": [ | ||
" #", | ||
" # ", | ||
"+ " | ||
], | ||
"key": { | ||
"#": { | ||
"item": "minecraft:iron_ingot" | ||
}, | ||
"+": { | ||
"item": "minecraft:leather" | ||
} | ||
}, | ||
"result": { | ||
"id": "mccourse:black_opal_block", | ||
"count": 1 | ||
} | ||
} |