First Commit
This commit is contained in:
19
src/main/java/ovh/herisson/hornofthewild/HornOfTheWild.java
Normal file
19
src/main/java/ovh/herisson/hornofthewild/HornOfTheWild.java
Normal file
@ -0,0 +1,19 @@
|
||||
package ovh.herisson.hornofthewild;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class HornOfTheWild implements ModInitializer {
|
||||
|
||||
public static final String MOD_ID = "hotw";
|
||||
|
||||
public static final HornOfTheWildItem hornofthewild = new HornOfTheWildItem(new Item.Settings());
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Registry.register(Registries.ITEM, new Identifier(MOD_ID, "hornofthewild"), hornofthewild);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package ovh.herisson.hornofthewild;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsage;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HornOfTheWildItem extends Item {
|
||||
public static final TagKey<Block> HORN_BREAKABLE = TagKey.of(RegistryKeys.BLOCK, new Identifier(HornOfTheWild.MOD_ID, "hotw_breakable"));
|
||||
public HornOfTheWildItem(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxUseTime(ItemStack itemStack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
|
||||
return ItemUsage.consumeHeldItem(world, playerEntity, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void usageTick(World world, LivingEntity livingEntity, ItemStack itemStack, int time) {
|
||||
if (!world.isClient) {
|
||||
if(time % 5 == 0){
|
||||
HornBeat(world, itemStack, livingEntity.getBlockPos(), livingEntity);
|
||||
}
|
||||
world.playSound(null, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), SoundEvents.ENTITY_HORSE_BREATHE, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAction getUseAction(ItemStack itemStack) {
|
||||
return UseAction.BOW;
|
||||
}
|
||||
|
||||
private static boolean canHarvest(World world, ItemStack stack, BlockPos pos, LivingEntity livingEntity) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
return state.isIn(HORN_BREAKABLE);
|
||||
}
|
||||
|
||||
private static void HornBeat(World world, ItemStack stack, BlockPos srcPos, LivingEntity livingEntity){
|
||||
int range = 12;
|
||||
int rangeY = 3;
|
||||
|
||||
List<BlockPos> coords = new ArrayList<>();
|
||||
for (BlockPos pos: BlockPos.iterate(srcPos.add(-range, -rangeY, -range), srcPos.add(range, rangeY, range))){
|
||||
if(HornOfTheWildItem.canHarvest(world, stack, pos, livingEntity)){
|
||||
coords.add(pos.toImmutable());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(coords);
|
||||
|
||||
int count = Math.min(coords.size(), 32);
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPos currCoords = coords.get(i);
|
||||
BlockState state = world.getBlockState(currCoords);
|
||||
BlockEntity be = world.getBlockEntity(currCoords);
|
||||
world.breakBlock(currCoords, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package ovh.herisson.hornofthewild.client;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public class HornofthewildClient implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
}
|
||||
}
|
3
src/main/resources/assets/hotw/lang/en_us.json
Normal file
3
src/main/resources/assets/hotw/lang/en_us.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"item.hotw.hornofthewild": "Horn Of The Wild"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "hotw:item/hornofthewild"
|
||||
}
|
||||
}
|
BIN
src/main/resources/assets/hotw/textures/item/hornofthewild.png
Normal file
BIN
src/main/resources/assets/hotw/textures/item/hornofthewild.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 432 B |
@ -0,0 +1,20 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" # ",
|
||||
"#F#",
|
||||
"## "
|
||||
],
|
||||
"key": {
|
||||
"#": {
|
||||
"tag": "minecraft:logs"
|
||||
},
|
||||
"F": {
|
||||
"item": "minecraft:fern"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "hotw:hornofthewild",
|
||||
"count": 1
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "minecraft:stonecutting",
|
||||
"ingredient": {
|
||||
"item": "minecraft:goat_horn"
|
||||
},
|
||||
"result": "hotw:hornofthewild",
|
||||
"count": 1,
|
||||
"category": "misc"
|
||||
}
|
16
src/main/resources/data/hotw/tags/blocks/hotw_breakable.json
Normal file
16
src/main/resources/data/hotw/tags/blocks/hotw_breakable.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"#minecraft:leaves",
|
||||
"#minecraft:crops",
|
||||
"#minecraft:fire",
|
||||
"#minecraft:flowers",
|
||||
|
||||
"minecraft:grass",
|
||||
"minecraft:large_fern",
|
||||
|
||||
"minecraft:tall_seagrass",
|
||||
"minecraft:seagrass",
|
||||
"minecraft:kelp_plant"
|
||||
]
|
||||
}
|
28
src/main/resources/fabric.mod.json
Normal file
28
src/main/resources/fabric.mod.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "hornofthewild",
|
||||
"version": "${version}",
|
||||
"name": "HornOfTheWild",
|
||||
"description": "Horn of the wild from botania",
|
||||
"authors": [],
|
||||
"contact": {},
|
||||
"license": "MIT",
|
||||
"icon": "assets/hornofthewild/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"ovh.herisson.hornofthewild.client.HornofthewildClient"
|
||||
],
|
||||
"main": [
|
||||
"ovh.herisson.hornofthewild.HornOfTheWild"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"hornofthewild.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=${loader_version}",
|
||||
"fabric": "*",
|
||||
"minecraft": "${minecraft_version}"
|
||||
}
|
||||
}
|
13
src/main/resources/hornofthewild.mixins.json
Normal file
13
src/main/resources/hornofthewild.mixins.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "ovh.herisson.hornofthewild.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user