-
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
Showing
14 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
14 changes: 7 additions & 7 deletions
14
src/main/generated/.cache/378f9509398ea584ca54616156177f9ec588f984
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
// 1.21.1 2024-09-15T22:30:18.7957421 Tutorial Mod/Block Loot Tables | ||
// 1.21.1 2024-09-15T23:45:22.4559283 Tutorial Mod/Block Loot Tables | ||
1382e8045641fe6784d8535d113c80a6028a5ace data\tutorialmod\loot_table\blocks\pink_garnet_pressure_plate.json | ||
cedbc7c7be44e1b0df48ece4790b5266a35f2b72 data\tutorialmod\loot_table\blocks\pink_garnet_slab.json | ||
574a89ee1b10a8e85c7f90b61a61c3dd6edeb638 data\tutorialmod\loot_table\blocks\pink_garnet_trapdoor.json | ||
f9fed56792aac989521a48d25cde5a55d5973db4 data\tutorialmod\loot_table\blocks\pink_garnet_fence_gate.json | ||
c524d99e89d1a6b91131c503e69d1343642df802 data\tutorialmod\loot_table\blocks\raw_pink_garnet_block.json | ||
fdb21182d3115edeb12f16aa5d40f8aca9e17f9a data\tutorialmod\loot_table\blocks\pink_garnet_button.json | ||
3bfcba243820f2344471574d75b7b48ba680fd3f data\tutorialmod\loot_table\blocks\pink_garnet_door.json | ||
e324243da1cda477b8f75c1cf06f408d17143f95 data\tutorialmod\loot_table\blocks\pink_garnet_wall.json | ||
940d49e1ad8940b0f97eab05f81d6734b7dc942f data\tutorialmod\loot_table\blocks\pink_garnet_fence.json | ||
81e1cfbc4d86d3fd0189a0c8ea6ecf867f65d766 data\tutorialmod\loot_table\blocks\pink_garnet_ore.json | ||
cbb358d78cd57da58c907a35212d486fa6f68efa data\tutorialmod\loot_table\blocks\magic_block.json | ||
20c1b94f16da89972e44952293dc87c35d46d12c data\tutorialmod\loot_table\blocks\pink_garnet_block.json | ||
64c3df15b6e946537414a0cc30f320d8b8019264 data\tutorialmod\loot_table\blocks\pink_garnet_stairs.json | ||
a8a175045f0d3d679e9afac5111d25b6d0b78ab7 data\tutorialmod\loot_table\blocks\pink_garnet_deepslate_ore.json | ||
cedbc7c7be44e1b0df48ece4790b5266a35f2b72 data\tutorialmod\loot_table\blocks\pink_garnet_slab.json | ||
574a89ee1b10a8e85c7f90b61a61c3dd6edeb638 data\tutorialmod\loot_table\blocks\pink_garnet_trapdoor.json | ||
c524d99e89d1a6b91131c503e69d1343642df802 data\tutorialmod\loot_table\blocks\raw_pink_garnet_block.json | ||
fdb21182d3115edeb12f16aa5d40f8aca9e17f9a data\tutorialmod\loot_table\blocks\pink_garnet_button.json | ||
81e1cfbc4d86d3fd0189a0c8ea6ecf867f65d766 data\tutorialmod\loot_table\blocks\pink_garnet_ore.json | ||
64c3df15b6e946537414a0cc30f320d8b8019264 data\tutorialmod\loot_table\blocks\pink_garnet_stairs.json |
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/80beaa027efbcf9e17d04d48300d7784fb0cb57f
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
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/dfb0a8ea05a472c697eb35080aef6b0f1497af5b
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
4 changes: 2 additions & 2 deletions
4
src/main/generated/.cache/f3f56cafc2cbe41709406bb540eb1fca38a90f18
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// 1.21.1 2024-09-15T22:30:18.794746 Tutorial Mod/Tags for minecraft:item | ||
// 1.21.1 2024-09-15T23:45:22.4549278 Tutorial Mod/Tags for minecraft:item | ||
092261f42ebfb549fb26de57a2f4a5a8b86bc6b9 data\tutorialmod\tags\item\transformable_items.json | ||
8f653a3350d8f1fbd15d245e7de66379a30930e2 data\minecraft\tags\item\swords.json | ||
a83d7a926074b69c0b715a6d7e603b0fc4c78d11 data\minecraft\tags\item\hoes.json | ||
8ced195f504be266fa1818b0cfbd2ee244987195 data\minecraft\tags\item\axes.json | ||
351330e211b4558f91f0550566fbac71f5a3b2e5 data\minecraft\tags\item\shovels.json | ||
8ced195f504be266fa1818b0cfbd2ee244987195 data\minecraft\tags\item\axes.json | ||
840726859672b531edb33e064e2e0943de7fc82d data\minecraft\tags\item\pickaxes.json |
6 changes: 6 additions & 0 deletions
6
src/main/generated/assets/tutorialmod/models/item/pink_garnet_hammer.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:item/handheld", | ||
"textures": { | ||
"layer0": "tutorialmod:item/pink_garnet_hammer" | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
src/main/java/net/kaupenjoe/tutorialmod/item/custom/HammerItem.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,53 @@ | ||
package net.kaupenjoe.tutorialmod.item.custom; | ||
|
||
import net.minecraft.item.MiningToolItem; | ||
import net.minecraft.item.ToolMaterial; | ||
import net.minecraft.registry.tag.BlockTags; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.hit.HitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class HammerItem extends MiningToolItem { | ||
public HammerItem(ToolMaterial material, Settings settings) { | ||
super(material, BlockTags.PICKAXE_MINEABLE, settings); | ||
} | ||
|
||
public static List<BlockPos> getBlocksToBeDestroyed(int range, BlockPos initalBlockPos, ServerPlayerEntity player) { | ||
List<BlockPos> positions = new ArrayList<>(); | ||
HitResult hit = player.raycast(20, 0, false); | ||
if (hit.getType() == HitResult.Type.BLOCK) { | ||
BlockHitResult blockHit = (BlockHitResult) hit; | ||
|
||
if(blockHit.getSide() == Direction.DOWN || blockHit.getSide() == Direction.UP) { | ||
for(int x = -range; x <= range; x++) { | ||
for(int y = -range; y <= range; y++) { | ||
positions.add(new BlockPos(initalBlockPos.getX() + x, initalBlockPos.getY(), initalBlockPos.getZ() + y)); | ||
} | ||
} | ||
} | ||
|
||
if(blockHit.getSide() == Direction.NORTH || blockHit.getSide() == Direction.SOUTH) { | ||
for(int x = -range; x <= range; x++) { | ||
for(int y = -range; y <= range; y++) { | ||
positions.add(new BlockPos(initalBlockPos.getX() + x, initalBlockPos.getY() + y, initalBlockPos.getZ())); | ||
} | ||
} | ||
} | ||
|
||
if(blockHit.getSide() == Direction.EAST || blockHit.getSide() == Direction.WEST) { | ||
for(int x = -range; x <= range; x++) { | ||
for(int y = -range; y <= range; y++) { | ||
positions.add(new BlockPos(initalBlockPos.getX(), initalBlockPos.getY() + y, initalBlockPos.getZ() + x)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return positions; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/net/kaupenjoe/tutorialmod/util/HammerUsageEvent.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,44 @@ | ||
package net.kaupenjoe.tutorialmod.util; | ||
|
||
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; | ||
import net.kaupenjoe.tutorialmod.item.custom.HammerItem; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class HammerUsageEvent implements PlayerBlockBreakEvents.Before{ | ||
// Done with the help of https://github.com/CoFH/CoFHCore/blob/c23d117dcd3b3b3408a138716b15507f709494cd/src/main/java/cofh/core/event/AreaEffectEvents.java | ||
private static final Set<BlockPos> HARVESTED_BLOCKS = new HashSet<>(); | ||
|
||
@Override | ||
public boolean beforeBlockBreak(World world, PlayerEntity player, BlockPos pos, | ||
BlockState state, @Nullable BlockEntity blockEntity) { | ||
ItemStack mainHandItem = player.getMainHandStack(); | ||
|
||
if(mainHandItem.getItem() instanceof HammerItem hammer && player instanceof ServerPlayerEntity serverPlayer) { | ||
if(HARVESTED_BLOCKS.contains(pos)) { | ||
return true; | ||
} | ||
|
||
for(BlockPos position : HammerItem.getBlocksToBeDestroyed(1, pos, serverPlayer)) { | ||
if(pos == position || !hammer.isCorrectForDrops(mainHandItem, world.getBlockState(position))) { | ||
continue; | ||
} | ||
|
||
HARVESTED_BLOCKS.add(position); | ||
serverPlayer.interactionManager.tryBreakBlock(position); | ||
HARVESTED_BLOCKS.remove(position); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
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
Binary file added
BIN
+430 Bytes
src/main/resources/assets/tutorialmod/textures/item/pink_garnet_hammer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.