Compare commits

...

2 Commits

Author SHA1 Message Date
Kaupenjoe
23db75e368 custom sounds 2023-08-28 14:06:56 +02:00
Kaupenjoe
d59ec7e69b custom villagers 2023-08-28 12:35:56 +02:00
19 changed files with 177 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
// 1.20.1 2023-08-28T12:32:21.1985044 Tags for minecraft:point_of_interest_type mod id tutorialmod
83f1c4f1a14965cf8c4c3a99edb0f816c3115ee6 data/minecraft/tags/point_of_interest_type/acquirable_job_site.json

View File

@@ -0,0 +1,8 @@
{
"values": [
{
"id": "tutorialmod:sound_poi",
"required": false
}
]
}

View File

@@ -5,6 +5,8 @@ import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.item.ModCreativeModTabs;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.loot.ModLootModifiers;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.kaupenjoe.tutorialmod.villager.ModVillagers;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FlowerPotBlock;
@@ -35,6 +37,9 @@ public class TutorialMod {
ModBlocks.register(modEventBus);
ModLootModifiers.register(modEventBus);
ModVillagers.register(modEventBus);
ModSounds.register(modEventBus);
modEventBus.addListener(this::commonSetup);

View File

@@ -5,6 +5,7 @@ import net.kaupenjoe.tutorialmod.block.custom.CornCropBlock;
import net.kaupenjoe.tutorialmod.block.custom.SoundBlock;
import net.kaupenjoe.tutorialmod.block.custom.StrawberryCropBlock;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.effect.MobEffects;
@@ -43,7 +44,7 @@ public class ModBlocks {
.strength(5f).requiresCorrectToolForDrops(), UniformInt.of(3, 7)));
public static final RegistryObject<Block> SOUND_BLOCK = registerBlock("sound_block",
() -> new SoundBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK)));
() -> new SoundBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(ModSounds.SOUND_BLOCK_SOUNDS)));
public static final RegistryObject<Block> SAPPHIRE_STAIRS = registerBlock("sapphire_stairs",
() -> new StairBlock(() -> ModBlocks.SAPPHIRE_BLOCK.get().defaultBlockState(),

View File

@@ -31,5 +31,6 @@ public class DataGenerators {
generator.addProvider(event.includeServer(), new ModItemTagGenerator(packOutput, lookupProvider, blockTagGenerator.contentsGetter(), existingFileHelper));
generator.addProvider(event.includeServer(), new ModGlobalLootModifiersProvider(packOutput));
generator.addProvider(event.includeServer(), new ModPoiTypeTagsProvider(packOutput, lookupProvider, existingFileHelper));
}
}

View File

@@ -0,0 +1,24 @@
package net.kaupenjoe.tutorialmod.datagen;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.PoiTypeTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.PoiTypeTags;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
public class ModPoiTypeTagsProvider extends PoiTypeTagsProvider {
public ModPoiTypeTagsProvider(PackOutput pOutput, CompletableFuture<HolderLookup.Provider> pProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(pOutput, pProvider, TutorialMod.MOD_ID, existingFileHelper);
}
@Override
protected void addTags(HolderLookup.Provider pProvider) {
tag(PoiTypeTags.ACQUIRABLE_JOB_SITE)
.addOptional(new ResourceLocation(TutorialMod.MOD_ID, "sound_poi"));
}
}

View File

@@ -2,7 +2,9 @@ package net.kaupenjoe.tutorialmod.event;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.villager.ModVillagers;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.EnchantedBookItem;
@@ -56,6 +58,20 @@ public class ModEvents {
enchantedBook,
2, 8, 0.02f));
}
if(event.getType() == ModVillagers.SOUND_MASTER.get()) {
Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades();
trades.get(1).add((pTrader, pRandom) -> new MerchantOffer(
new ItemStack(Items.EMERALD, 16),
new ItemStack(ModBlocks.SOUND_BLOCK.get(), 1),
16, 8, 0.02f));
trades.get(2).add((pTrader, pRandom) -> new MerchantOffer(
new ItemStack(Items.EMERALD, 6),
new ItemStack(ModBlocks.SAPPHIRE_ORE.get(), 2),
5, 12, 0.02f));
}
}
@SubscribeEvent

View File

@@ -1,9 +1,11 @@
package net.kaupenjoe.tutorialmod.item.custom;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.kaupenjoe.tutorialmod.util.ModTags;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
@@ -37,6 +39,9 @@ public class MetalDetectorItem extends Item {
outputValuableCoordinates(positionClicked.below(i), player, state.getBlock());
foundBlock = true;
pContext.getLevel().playSeededSound(null, positionClicked.getX(), positionClicked.getY(), positionClicked.getZ(),
ModSounds.METAL_DETECTOR_FOUND_ORE.get(), SoundSource.BLOCKS, 1f, 1f, 0);
break;
}
}

View File

@@ -0,0 +1,37 @@
package net.kaupenjoe.tutorialmod.sound;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.common.util.ForgeSoundType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModSounds {
public static final DeferredRegister<SoundEvent> SOUND_EVENTS =
DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, TutorialMod.MOD_ID);
public static final RegistryObject<SoundEvent> METAL_DETECTOR_FOUND_ORE = registerSoundEvents("metal_detector_found_ore");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_BREAK = registerSoundEvents("sound_block_break");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_STEP = registerSoundEvents("sound_block_step");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_FALL = registerSoundEvents("sound_block_fall");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_PLACE = registerSoundEvents("sound_block_place");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_HIT = registerSoundEvents("sound_block_hit");
public static final ForgeSoundType SOUND_BLOCK_SOUNDS = new ForgeSoundType(1f, 1f,
ModSounds.SOUND_BLOCK_BREAK, ModSounds.SOUND_BLOCK_STEP, ModSounds.SOUND_BLOCK_PLACE,
ModSounds.SOUND_BLOCK_HIT, ModSounds.SOUND_BLOCK_FALL);
private static RegistryObject<SoundEvent> registerSoundEvents(String name) {
return SOUND_EVENTS.register(name, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(TutorialMod.MOD_ID, name)));
}
public static void register(IEventBus eventBus) {
SOUND_EVENTS.register(eventBus);
}
}

View File

@@ -0,0 +1,35 @@
package net.kaupenjoe.tutorialmod.villager;
import com.google.common.collect.ImmutableSet;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModVillagers {
public static final DeferredRegister<PoiType> POI_TYPES =
DeferredRegister.create(ForgeRegistries.POI_TYPES, TutorialMod.MOD_ID);
public static final DeferredRegister<VillagerProfession> VILLAGER_PROFESSIONS =
DeferredRegister.create(ForgeRegistries.VILLAGER_PROFESSIONS, TutorialMod.MOD_ID);
public static final RegistryObject<PoiType> SOUND_POI = POI_TYPES.register("sound_poi",
() -> new PoiType(ImmutableSet.copyOf(ModBlocks.SOUND_BLOCK.get().getStateDefinition().getPossibleStates()),
1, 1));
public static final RegistryObject<VillagerProfession> SOUND_MASTER =
VILLAGER_PROFESSIONS.register("soundmaster", () -> new VillagerProfession("soundmaster",
holder -> holder.get() == SOUND_POI.get(), holder -> holder.get() == SOUND_POI.get(),
ImmutableSet.of(), ImmutableSet.of(), SoundEvents.VILLAGER_WORK_ARMORER));
public static void register(IEventBus eventBus) {
POI_TYPES.register(eventBus);
VILLAGER_PROFESSIONS.register(eventBus);
}
}

View File

@@ -47,6 +47,10 @@
"tooltip.tutorialmod.metal_detector.tooltip": "Finds valuables underground!",
"entity.minecraft.villager.tutorialmod.soundmaster": "Sound Master",
"sounds.tutorialmod.metal_detector_found_ore": "Metal Detector Jingle",
"creativetab.tutorial_tab": "Sapphire Tutorial Tab"
}

View File

@@ -0,0 +1,38 @@
{
"metal_detector_found_ore": {
"subtitles": "sounds.tutorialmod.metal_detector_found_ore",
"sounds": [
"tutorialmod:metal_detector_found_ore"
]
},
"sound_block_break": {
"subtitle": "sounds.tutorialmod.sound_block_break",
"sounds": [
"tutorialmod:sound_block_break"
]
},
"sound_block_step": {
"subtitle": "sounds.tutorialmod.sound_block_step",
"sounds": [
"tutorialmod:sound_block_step"
]
},
"sound_block_place": {
"subtitle": "sounds.tutorialmod.sound_block_place",
"sounds": [
"tutorialmod:sound_block_place"
]
},
"sound_block_hit": {
"subtitle": "sounds.tutorialmod.sound_block_hit",
"sounds": [
"tutorialmod:sound_block_hit"
]
},
"sound_block_fall": {
"subtitle": "sounds.tutorialmod.sound_block_fall",
"sounds": [
"tutorialmod:sound_block_fall"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB