Compare commits

...

8 Commits

Author SHA1 Message Date
Kaupenjoe
ebe192ee05 jei comapt 2023-10-08 15:44:56 +02:00
Kaupenjoe
cca4154b93 recipe types 2023-10-06 17:15:56 +02:00
Kaupenjoe
8c989e0174 block entity 2023-10-06 16:03:58 +02:00
Kaupenjoe
3a6aa1140d attack animation 2023-09-30 15:47:50 +02:00
Kaupenjoe
bfd445c5a2 custom entity 2023-09-30 15:12:27 +02:00
Kaupenjoe
3df4bc942e custom music disc 2023-08-28 16:16:51 +02:00
Kaupenjoe
23db75e368 custom sounds 2023-08-28 14:06:56 +02:00
Kaupenjoe
d59ec7e69b custom villagers 2023-08-28 12:35:56 +02:00
65 changed files with 2104 additions and 5 deletions

View File

@@ -153,6 +153,11 @@ repositories {
// flatDir {
// dir 'libs'
// }
maven {
// location of the maven that hosts JEI files since January 2023
name = "Jared's maven"
url = "https://maven.blamejared.com/"
}
}
dependencies {
@@ -169,6 +174,12 @@ dependencies {
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
// compile against the JEI API but do not include it at runtime
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"))
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}"))
// at runtime, use the full JEI jar for Forge
runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}"))
// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"

View File

@@ -38,6 +38,10 @@ mapping_channel=parchment
mapping_version=2023.06.26-1.20.1
## Dependency Properties
jei_version=15.2.0.27
## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}

View File

@@ -1,10 +1,12 @@
// 1.20.1 2023-08-25T20:00:29.1439601 Item Models: tutorialmod
// 1.20.1 2023-10-06T15:59:16.5190353 Item Models: tutorialmod
f746b64540daf2ab6302b3ec01a78490c48fc10b assets/tutorialmod/models/item/bar_brawl_music_disc.json
d3e9cad00ae44c9319dfbb411667eb4a09a63e57 assets/tutorialmod/models/item/catmint.json
6126e26da373f9113d9e9be875b14a0d13857444 assets/tutorialmod/models/item/corn.json
4c5c277fa6360b149d6c3ab20584fcc4450cda27 assets/tutorialmod/models/item/corn_seeds.json
93719e53df04c62d91023fe733206eb93b7aac86 assets/tutorialmod/models/item/metal_detector.json
d56de8e6898d1c12a15eca045badafe1947aa387 assets/tutorialmod/models/item/pine_cone.json
d24305376f58c1ef118279a5c8f5b087a07b1d47 assets/tutorialmod/models/item/raw_sapphire.json
63ec6c618a3a23eab4cab9c52d7d3250de9b516e assets/tutorialmod/models/item/rhino_spawn_egg.json
0a16bffc527696b64e4304b7efccfda93e2b9422 assets/tutorialmod/models/item/sapphire.json
72e891dd0d4eeff5cd14ecf7f4740f6ba5e7017b assets/tutorialmod/models/item/sapphire_axe.json
4c7ede3e69b2d6ae39f0373cb461b96f53f14b41 assets/tutorialmod/models/item/sapphire_boots.json

View File

@@ -1,2 +1,4 @@
// 1.20.1 2023-08-07T09:00:54.5654219 Tags for minecraft:item mod id tutorialmod
// 1.20.1 2023-08-28T16:11:02.6575435 Tags for minecraft:item mod id tutorialmod
526ec127a145db02975e7ec564384fa0a5389523 data/minecraft/tags/items/creeper_drop_music_discs.json
526ec127a145db02975e7ec564384fa0a5389523 data/minecraft/tags/items/music_discs.json
2514998bb25494de346fa0d088b7e216d8165efd data/minecraft/tags/items/trimmable_armor.json

View File

@@ -1,8 +1,9 @@
// 1.20.1 2023-08-25T20:00:29.1439601 Block States: tutorialmod
// 1.20.1 2023-10-06T16:01:04.4071152 Block States: tutorialmod
4f6f6f43eb03fe4d9e5ce223f245812e0d7eae93 assets/tutorialmod/blockstates/catmint.json
d537bf85846bd7eeffa314408c867cc1a7d531d5 assets/tutorialmod/blockstates/corn_crop.json
a3ad172be3e203ff6840db063558f809a86ca15a assets/tutorialmod/blockstates/deepslate_sapphire_ore.json
890efea75d7398469e0d7d5704472303c35fae62 assets/tutorialmod/blockstates/end_stone_sapphire_ore.json
ff720ea0aea021144b8557786f6e7f9dead2fd78 assets/tutorialmod/blockstates/gem_polishing_station.json
0198f629d0db6eb40ebd91067bbe631626116b54 assets/tutorialmod/blockstates/nether_sapphire_ore.json
55ae2b8c248ffe83a87a26b6c0f87c784f9049db assets/tutorialmod/blockstates/potted_catmint.json
2f46112fe9e6610ea4c37e87e511da1849b54274 assets/tutorialmod/blockstates/raw_sapphire_block.json
@@ -75,6 +76,7 @@ b14b9dd2aa2d96cbbb4d20f9d0741c1bf4476786 assets/tutorialmod/models/block/strawbe
71616f74a5e0922f50c9869941f63040b82c0499 assets/tutorialmod/models/item/catmint.json
251495c94fbf35dd43cd773e6cf31533a8b72f09 assets/tutorialmod/models/item/deepslate_sapphire_ore.json
bf5cdde3dfa3effdde9c4358ecb01c39922d7945 assets/tutorialmod/models/item/end_stone_sapphire_ore.json
c6fe90ee84600fb9c1f42a398459a0d8b38fe198 assets/tutorialmod/models/item/gem_polishing_station.json
81ecae58cc575e9ce9d7f21881bbccb6bbfb4432 assets/tutorialmod/models/item/nether_sapphire_ore.json
1a7f76b967a6270a0443871f08ca1a655740a97d assets/tutorialmod/models/item/potted_catmint.json
a7f864f8f8c67b25b34627c0dd8357e96b5d5c79 assets/tutorialmod/models/item/raw_sapphire_block.json

View File

@@ -1,8 +1,9 @@
// 1.20.1 2023-08-25T20:00:29.1418946 Loot Tables
// 1.20.1 2023-10-06T15:59:16.5165086 Loot Tables
a5308914890f4fbc6d39248caa834f368767be60 data/tutorialmod/loot_tables/blocks/catmint.json
6c9ebf0160580ee21535fe3b1a2a5cd808cacb89 data/tutorialmod/loot_tables/blocks/corn_crop.json
3655045aeb4e2ae62e9069b0db07927965a12389 data/tutorialmod/loot_tables/blocks/deepslate_sapphire_ore.json
629bc7af98fd6a08d902f9c3e46896fc09101f43 data/tutorialmod/loot_tables/blocks/end_stone_sapphire_ore.json
ae181fa3b2781be60d3127b43d33111085e53d7d data/tutorialmod/loot_tables/blocks/gem_polishing_station.json
c615daffa6bb4a20fd0f4d36534331bdbeff2746 data/tutorialmod/loot_tables/blocks/nether_sapphire_ore.json
64ba5568715cb39bbac17bf9a847cf65f79bec13 data/tutorialmod/loot_tables/blocks/potted_catmint.json
81e9322ae4c5141fd110a8f87cc92d7af008fd1e data/tutorialmod/loot_tables/blocks/raw_sapphire_block.json

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,7 @@
{
"variants": {
"": {
"model": "tutorialmod:block/gem_polishing_station"
}
}
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "tutorialmod:item/bar_brawl_music_disc"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "tutorialmod:block/gem_polishing_station"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "minecraft:item/template_spawn_egg"
}

View File

@@ -0,0 +1,5 @@
{
"values": [
"tutorialmod:bar_brawl_music_disc"
]
}

View File

@@ -0,0 +1,5 @@
{
"values": [
"tutorialmod:bar_brawl_music_disc"
]
}

View File

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

View File

@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "tutorialmod:gem_polishing_station"
}
],
"rolls": 1.0
}
],
"random_sequence": "tutorialmod:blocks/gem_polishing_station"
}

View File

@@ -2,9 +2,20 @@ package net.kaupenjoe.tutorialmod;
import com.mojang.logging.LogUtils;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.block.entity.ModBlockEntities;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.entity.client.RhinoRenderer;
import net.kaupenjoe.tutorialmod.item.ModCreativeModTabs;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.loot.ModLootModifiers;
import net.kaupenjoe.tutorialmod.recipe.ModRecipes;
import net.kaupenjoe.tutorialmod.screen.GemPolishingStationScreen;
import net.kaupenjoe.tutorialmod.screen.ModMenuTypes;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.kaupenjoe.tutorialmod.villager.ModVillagers;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FlowerPotBlock;
@@ -35,6 +46,15 @@ public class TutorialMod {
ModBlocks.register(modEventBus);
ModLootModifiers.register(modEventBus);
ModVillagers.register(modEventBus);
ModSounds.register(modEventBus);
ModEntities.register(modEventBus);
ModBlockEntities.register(modEventBus);
ModMenuTypes.register(modEventBus);
ModRecipes.register(modEventBus);
modEventBus.addListener(this::commonSetup);
@@ -66,7 +86,9 @@ public class TutorialMod {
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
EntityRenderers.register(ModEntities.RHINO.get(), RhinoRenderer::new);
MenuScreens.register(ModMenuTypes.GEM_POLISHING_MENU.get(), GemPolishingStationScreen::new);
}
}
}

View File

@@ -2,9 +2,11 @@ package net.kaupenjoe.tutorialmod.block;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.custom.CornCropBlock;
import net.kaupenjoe.tutorialmod.block.custom.GemPolishingStationBlock;
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 +45,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(),
@@ -86,6 +88,11 @@ public class ModBlocks {
BlockBehaviour.Properties.copy(Blocks.POTTED_ALLIUM).noOcclusion()));
public static final RegistryObject<Block> GEM_POLISHING_STATION = registerBlock("gem_polishing_station",
() -> new GemPolishingStationBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).noOcclusion()));
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
RegistryObject<T> toReturn = BLOCKS.register(name, block);
registerBlockItem(name, toReturn);

View File

@@ -0,0 +1,84 @@
package net.kaupenjoe.tutorialmod.block.custom;
import net.kaupenjoe.tutorialmod.block.entity.GemPolishingStationBlockEntity;
import net.kaupenjoe.tutorialmod.block.entity.ModBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.Nullable;
public class GemPolishingStationBlock extends BaseEntityBlock {
public static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 12, 16);
public GemPolishingStationBlock(Properties pProperties) {
super(pProperties);
}
@Override
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
return SHAPE;
}
@Override
public RenderShape getRenderShape(BlockState pState) {
return RenderShape.MODEL;
}
@Override
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
if (pState.getBlock() != pNewState.getBlock()) {
BlockEntity blockEntity = pLevel.getBlockEntity(pPos);
if (blockEntity instanceof GemPolishingStationBlockEntity) {
((GemPolishingStationBlockEntity) blockEntity).drops();
}
}
super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving);
}
@Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
if (!pLevel.isClientSide()) {
BlockEntity entity = pLevel.getBlockEntity(pPos);
if(entity instanceof GemPolishingStationBlockEntity) {
NetworkHooks.openScreen(((ServerPlayer)pPlayer), (GemPolishingStationBlockEntity)entity, pPos);
} else {
throw new IllegalStateException("Our Container provider is missing!");
}
}
return InteractionResult.sidedSuccess(pLevel.isClientSide());
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
return new GemPolishingStationBlockEntity(pPos, pState);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, BlockState pState, BlockEntityType<T> pBlockEntityType) {
if(pLevel.isClientSide()) {
return null;
}
return createTickerHelper(pBlockEntityType, ModBlockEntities.GEM_POLISHING_BE.get(),
(pLevel1, pPos, pState1, pBlockEntity) -> pBlockEntity.tick(pLevel1, pPos, pState1));
}
}

View File

@@ -0,0 +1,191 @@
package net.kaupenjoe.tutorialmod.block.entity;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.recipe.GemPolishingRecipe;
import net.kaupenjoe.tutorialmod.screen.GemPolishingStationMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Container;
import net.minecraft.world.Containers;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public class GemPolishingStationBlockEntity extends BlockEntity implements MenuProvider {
private final ItemStackHandler itemHandler = new ItemStackHandler(2);
private static final int INPUT_SLOT = 0;
private static final int OUTPUT_SLOT = 1;
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
protected final ContainerData data;
private int progress = 0;
private int maxProgress = 78;
public GemPolishingStationBlockEntity(BlockPos pPos, BlockState pBlockState) {
super(ModBlockEntities.GEM_POLISHING_BE.get(), pPos, pBlockState);
this.data = new ContainerData() {
@Override
public int get(int pIndex) {
return switch (pIndex) {
case 0 -> GemPolishingStationBlockEntity.this.progress;
case 1 -> GemPolishingStationBlockEntity.this.maxProgress;
default -> 0;
};
}
@Override
public void set(int pIndex, int pValue) {
switch (pIndex) {
case 0 -> GemPolishingStationBlockEntity.this.progress = pValue;
case 1 -> GemPolishingStationBlockEntity.this.maxProgress = pValue;
}
}
@Override
public int getCount() {
return 2;
}
};
}
@Override
public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
if(cap == ForgeCapabilities.ITEM_HANDLER) {
return lazyItemHandler.cast();
}
return super.getCapability(cap, side);
}
@Override
public void onLoad() {
super.onLoad();
lazyItemHandler = LazyOptional.of(() -> itemHandler);
}
@Override
public void invalidateCaps() {
super.invalidateCaps();
lazyItemHandler.invalidate();
}
public void drops() {
SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots());
for(int i = 0; i < itemHandler.getSlots(); i++) {
inventory.setItem(i, itemHandler.getStackInSlot(i));
}
Containers.dropContents(this.level, this.worldPosition, inventory);
}
@Override
public Component getDisplayName() {
return Component.translatable("block.tutorialmod.gem_polishing_station");
}
@Nullable
@Override
public AbstractContainerMenu createMenu(int pContainerId, Inventory pPlayerInventory, Player pPlayer) {
return new GemPolishingStationMenu(pContainerId, pPlayerInventory, this, this.data);
}
@Override
protected void saveAdditional(CompoundTag pTag) {
pTag.put("inventory", itemHandler.serializeNBT());
pTag.putInt("gem_polishing_station.progress", progress);
super.saveAdditional(pTag);
}
@Override
public void load(CompoundTag pTag) {
super.load(pTag);
itemHandler.deserializeNBT(pTag.getCompound("inventory"));
progress = pTag.getInt("gem_polishing_station.progress");
}
public void tick(Level pLevel, BlockPos pPos, BlockState pState) {
if(hasRecipe()) {
increaseCraftingProgress();
setChanged(pLevel, pPos, pState);
if(hasProgressFinished()) {
craftItem();
resetProgress();
}
} else {
resetProgress();
}
}
private void resetProgress() {
progress = 0;
}
private void craftItem() {
Optional<GemPolishingRecipe> recipe = getCurrentRecipe();
ItemStack result = recipe.get().getResultItem(null);
this.itemHandler.extractItem(INPUT_SLOT, 1, false);
this.itemHandler.setStackInSlot(OUTPUT_SLOT, new ItemStack(result.getItem(),
this.itemHandler.getStackInSlot(OUTPUT_SLOT).getCount() + result.getCount()));
}
private boolean hasRecipe() {
Optional<GemPolishingRecipe> recipe = getCurrentRecipe();
if(recipe.isEmpty()) {
return false;
}
ItemStack result = recipe.get().getResultItem(getLevel().registryAccess());
return canInsertAmountIntoOutputSlot(result.getCount()) && canInsertItemIntoOutputSlot(result.getItem());
}
private Optional<GemPolishingRecipe> getCurrentRecipe() {
SimpleContainer inventory = new SimpleContainer(this.itemHandler.getSlots());
for(int i = 0; i < itemHandler.getSlots(); i++) {
inventory.setItem(i, this.itemHandler.getStackInSlot(i));
}
return this.level.getRecipeManager().getRecipeFor(GemPolishingRecipe.Type.INSTANCE, inventory, level);
}
private boolean canInsertItemIntoOutputSlot(Item item) {
return this.itemHandler.getStackInSlot(OUTPUT_SLOT).isEmpty() || this.itemHandler.getStackInSlot(OUTPUT_SLOT).is(item);
}
private boolean canInsertAmountIntoOutputSlot(int count) {
return this.itemHandler.getStackInSlot(OUTPUT_SLOT).getCount() + count <= this.itemHandler.getStackInSlot(OUTPUT_SLOT).getMaxStackSize();
}
private boolean hasProgressFinished() {
return progress >= maxProgress;
}
private void increaseCraftingProgress() {
progress++;
}
}

View File

@@ -0,0 +1,24 @@
package net.kaupenjoe.tutorialmod.block.entity;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModBlockEntities {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, TutorialMod.MOD_ID);
public static final RegistryObject<BlockEntityType<GemPolishingStationBlockEntity>> GEM_POLISHING_BE =
BLOCK_ENTITIES.register("gem_polishing_be", () ->
BlockEntityType.Builder.of(GemPolishingStationBlockEntity::new,
ModBlocks.GEM_POLISHING_STATION.get()).build(null));
public static void register(IEventBus eventBus) {
BLOCK_ENTITIES.register(eventBus);
}
}

View File

@@ -0,0 +1,60 @@
package net.kaupenjoe.tutorialmod.compat;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.recipe.GemPolishingRecipe;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
public class GemPolishingCategory implements IRecipeCategory<GemPolishingRecipe> {
public static final ResourceLocation UID = new ResourceLocation(TutorialMod.MOD_ID, "gem_polishing");
public static final ResourceLocation TEXTURE = new ResourceLocation(TutorialMod.MOD_ID,
"textures/gui/gem_polishing_station_gui.png");
public static final RecipeType<GemPolishingRecipe> GEM_POLISHING_TYPE =
new RecipeType<>(UID, GemPolishingRecipe.class);
private final IDrawable background;
private final IDrawable icon;
public GemPolishingCategory(IGuiHelper helper) {
this.background = helper.createDrawable(TEXTURE, 0, 0, 176, 85);
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.GEM_POLISHING_STATION.get()));
}
@Override
public RecipeType<GemPolishingRecipe> getRecipeType() {
return GEM_POLISHING_TYPE;
}
@Override
public Component getTitle() {
return Component.translatable("block.tutorialmod.gem_polishing_station");
}
@Override
public IDrawable getBackground() {
return this.background;
}
@Override
public IDrawable getIcon() {
return this.icon;
}
@Override
public void setRecipe(IRecipeLayoutBuilder builder, GemPolishingRecipe recipe, IFocusGroup focuses) {
builder.addSlot(RecipeIngredientRole.INPUT, 80, 11).addIngredients(recipe.getIngredients().get(0));
builder.addSlot(RecipeIngredientRole.OUTPUT, 80, 59).addItemStack(recipe.getResultItem(null));
}
}

View File

@@ -0,0 +1,42 @@
package net.kaupenjoe.tutorialmod.compat;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.recipe.GemPolishingRecipe;
import net.kaupenjoe.tutorialmod.screen.GemPolishingStationScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeManager;
import java.util.List;
@JeiPlugin
public class JEITutorialModPlugin implements IModPlugin {
@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(TutorialMod.MOD_ID, "jei_plugin");
}
@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
registration.addRecipeCategories(new GemPolishingCategory(registration.getJeiHelpers().getGuiHelper()));
}
@Override
public void registerRecipes(IRecipeRegistration registration) {
RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
List<GemPolishingRecipe> polishingRecipes = recipeManager.getAllRecipesFor(GemPolishingRecipe.Type.INSTANCE);
registration.addRecipes(GemPolishingCategory.GEM_POLISHING_TYPE, polishingRecipes);
}
@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
registration.addRecipeClickArea(GemPolishingStationScreen.class, 60, 30, 20, 30,
GemPolishingCategory.GEM_POLISHING_TYPE);
}
}

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

@@ -4,12 +4,14 @@ import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.block.custom.CornCropBlock;
import net.kaupenjoe.tutorialmod.block.custom.StrawberryCropBlock;
import net.minecraft.client.model.Model;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.RegistryObject;
@@ -52,6 +54,9 @@ public class ModBlockStateProvider extends BlockStateProvider {
blockTexture(ModBlocks.CATMINT.get())).renderType("cutout"));
simpleBlockWithItem(ModBlocks.POTTED_CATMINT.get(), models().singleTexture("potted_catmint", new ResourceLocation("flower_pot_cross"), "plant",
blockTexture(ModBlocks.CATMINT.get())).renderType("cutout"));
simpleBlockWithItem(ModBlocks.GEM_POLISHING_STATION.get(),
new ModelFile.UncheckedModelFile(modLoc("block/gem_polishing_station")));
}

View File

@@ -53,6 +53,8 @@ public class ModItemModelProvider extends ItemModelProvider {
simpleItem(ModItems.CORN);
simpleItem(ModItems.CORN_SEEDS);
simpleItem(ModItems.BAR_BRAWL_MUSIC_DISC);
simpleBlockItem(ModBlocks.SAPPHIRE_DOOR);
fenceItem(ModBlocks.SAPPHIRE_FENCE, ModBlocks.SAPPHIRE_BLOCK);
@@ -78,6 +80,8 @@ public class ModItemModelProvider extends ItemModelProvider {
trimmedArmorItem(ModItems.SAPPHIRE_BOOTS);
simpleBlockItemBlockTexture(ModBlocks.CATMINT);
withExistingParent(ModItems.RHINO_SPANW_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
}
// Shoutout to El_Redstoniano for making this

View File

@@ -25,5 +25,11 @@ public class ModItemTagGenerator extends ItemTagsProvider {
ModItems.SAPPHIRE_CHESTPLATE.get(),
ModItems.SAPPHIRE_LEGGINGS.get(),
ModItems.SAPPHIRE_BOOTS.get());
this.tag(ItemTags.MUSIC_DISCS)
.add(ModItems.BAR_BRAWL_MUSIC_DISC.get());
this.tag(ItemTags.CREEPER_DROP_MUSIC_DISCS)
.add(ModItems.BAR_BRAWL_MUSIC_DISC.get());
}
}

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

@@ -80,6 +80,8 @@ public class ModBlockLootTables extends BlockLootSubProvider {
this.dropSelf(ModBlocks.CATMINT.get());
this.add(ModBlocks.POTTED_CATMINT.get(), createPotFlowerItemTable(ModBlocks.CATMINT.get()));
this.dropSelf(ModBlocks.GEM_POLISHING_STATION.get());
}
protected LootTable.Builder createCopperLikeOreDrops(Block pBlock, Item item) {

View File

@@ -0,0 +1,24 @@
package net.kaupenjoe.tutorialmod.entity;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModEntities {
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES =
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, TutorialMod.MOD_ID);
public static final RegistryObject<EntityType<RhinoEntity>> RHINO =
ENTITY_TYPES.register("rhino", () -> EntityType.Builder.of(RhinoEntity::new, MobCategory.CREATURE)
.sized(2.5f, 2.5f).build("rhino"));
public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus);
}
}

View File

@@ -0,0 +1,88 @@
package net.kaupenjoe.tutorialmod.entity.ai;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
public class RhinoAttackGoal extends MeleeAttackGoal {
private final RhinoEntity entity;
private int attackDelay = 40;
private int ticksUntilNextAttack = 40;
private boolean shouldCountTillNextAttack = false;
public RhinoAttackGoal(PathfinderMob pMob, double pSpeedModifier, boolean pFollowingTargetEvenIfNotSeen) {
super(pMob, pSpeedModifier, pFollowingTargetEvenIfNotSeen);
entity = ((RhinoEntity) pMob);
}
@Override
public void start() {
super.start();
attackDelay = 40;
ticksUntilNextAttack = 40;
}
@Override
protected void checkAndPerformAttack(LivingEntity pEnemy, double pDistToEnemySqr) {
if (isEnemyWithinAttackDistance(pEnemy, pDistToEnemySqr)) {
shouldCountTillNextAttack = true;
if(isTimeToStartAttackAnimation()) {
entity.setAttacking(true);
}
if(isTimeToAttack()) {
this.mob.getLookControl().setLookAt(pEnemy.getX(), pEnemy.getEyeY(), pEnemy.getZ());
performAttack(pEnemy);
}
} else {
resetAttackCooldown();
shouldCountTillNextAttack = false;
entity.setAttacking(false);
entity.attackAnimationTimeout = 0;
}
}
private boolean isEnemyWithinAttackDistance(LivingEntity pEnemy, double pDistToEnemySqr) {
return pDistToEnemySqr <= this.getAttackReachSqr(pEnemy);
}
protected void resetAttackCooldown() {
this.ticksUntilNextAttack = this.adjustedTickDelay(attackDelay * 2);
}
protected boolean isTimeToAttack() {
return this.ticksUntilNextAttack <= 0;
}
protected boolean isTimeToStartAttackAnimation() {
return this.ticksUntilNextAttack <= attackDelay;
}
protected int getTicksUntilNextAttack() {
return this.ticksUntilNextAttack;
}
protected void performAttack(LivingEntity pEnemy) {
this.resetAttackCooldown();
this.mob.swing(InteractionHand.MAIN_HAND);
this.mob.doHurtTarget(pEnemy);
}
@Override
public void tick() {
super.tick();
if(shouldCountTillNextAttack) {
this.ticksUntilNextAttack = Math.max(this.ticksUntilNextAttack - 1, 0);
}
}
@Override
public void stop() {
entity.setAttacking(false);
super.stop();
}
}

View File

@@ -0,0 +1,369 @@
package net.kaupenjoe.tutorialmod.entity.animations;
import net.minecraft.client.animation.AnimationChannel;
import net.minecraft.client.animation.AnimationDefinition;
import net.minecraft.client.animation.Keyframe;
import net.minecraft.client.animation.KeyframeAnimations;
public class ModAnimationDefinitions {
public static final AnimationDefinition RHINO_IDLE = AnimationDefinition.Builder.withLength(2f).looping()
.addAnimation("rhino",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("body",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -0.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.posVec(0f, -0.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.degreeVec(1f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.degreeVec(-1f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR))).build();
public static final AnimationDefinition RHINO_WALK = AnimationDefinition.Builder.withLength(2f).looping()
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.125f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.75f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 1.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.9167666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.9167666f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.9167666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.9167666f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.degreeVec(7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.9167666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.9167666f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.degreeVec(-7.16f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.degreeVec(-2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.posVec(0f, -1.25f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.degreeVec(5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.degreeVec(7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.degreeVec(5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.2916767f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5834334f, KeyframeAnimations.posVec(0f, 1.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.2916767f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5834334f, KeyframeAnimations.degreeVec(-7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.degreeVec(-7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.degreeVec(-2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.degreeVec(10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.posVec(0f, -1f, -1f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.posVec(0f, -1f, 1f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.degreeVec(-5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.degreeVec(-2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.degreeVec(10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.degreeVec(17.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR))).build();
public static final AnimationDefinition RHINO_ATTACK = AnimationDefinition.Builder.withLength(4f).looping()
.addAnimation("skull",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.5f, KeyframeAnimations.degreeVec(22.5f, 0f, -45f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(22.5f, 0f, -45f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2.5f, KeyframeAnimations.degreeVec(-60.03f, 17.68f, -19.21f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(3.5f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(4f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR))).build();
public static final AnimationDefinition RHINO_SIT = AnimationDefinition.Builder.withLength(2f).looping()
.addAnimation("rhino",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("body",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -4f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -4.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.posVec(0f, -4.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.posVec(0f, -4f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, -4f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("body",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(-7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -11f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 3f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(-25f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 2f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -11f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 4f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(-22.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(25f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 2f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 2f),
AnimationChannel.Interpolations.LINEAR))).build();
}

View File

@@ -0,0 +1,11 @@
package net.kaupenjoe.tutorialmod.entity.client;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.resources.ResourceLocation;
public class ModModelLayers {
public static final ModelLayerLocation RHINO_LAYER = new ModelLayerLocation(
new ResourceLocation(TutorialMod.MOD_ID, "rhino_layer"), "main");
}

View File

@@ -0,0 +1,111 @@
package net.kaupenjoe.tutorialmod.entity.client;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.kaupenjoe.tutorialmod.entity.animations.ModAnimationDefinitions;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
public class RhinoModel<T extends Entity> extends HierarchicalModel<T> {
private final ModelPart rhino;
private final ModelPart head;
public RhinoModel(ModelPart root) {
this.rhino = root.getChild("rhino");
this.head = rhino.getChild("body").getChild("torso").getChild("head");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition rhino = partdefinition.addOrReplaceChild("rhino", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 2.5F));
PartDefinition body = rhino.addOrReplaceChild("body", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition torso = body.addOrReplaceChild("torso", CubeListBuilder.create().texOffs(0, 0).addBox(-10.0F, -38.0F, -26.0F, 20.0F, 24.0F, 16.0F, new CubeDeformation(0.0F))
.texOffs(0, 41).addBox(-9.0F, -37.0F, -10.0F, 18.0F, 25.0F, 16.0F, new CubeDeformation(0.0F))
.texOffs(53, 67).addBox(-7.0F, -37.0F, 6.0F, 14.0F, 21.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition head = torso.addOrReplaceChild("head", CubeListBuilder.create(), PartPose.offset(0.0F, -21.0F, -26.0F));
PartDefinition skull = head.addOrReplaceChild("skull", CubeListBuilder.create().texOffs(69, 29).addBox(-6.0F, -9.0F, -12.0F, 12.0F, 20.0F, 12.0F, new CubeDeformation(0.0F))
.texOffs(0, 8).addBox(-1.0F, -1.0F, -15.0F, 2.0F, 2.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition horn = skull.addOrReplaceChild("horn", CubeListBuilder.create().texOffs(0, 102).addBox(-5.0F, -5.0F, -9.0F, 5.0F, 5.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.5F, 8.5F, -11.0F, -0.1745F, 0.0F, 0.0F));
PartDefinition horn2 = horn.addOrReplaceChild("horn2", CubeListBuilder.create().texOffs(103, 15).addBox(-3.0F, -3.0F, -9.0F, 3.0F, 3.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.0F, -1.0F, -9.0F, -0.4363F, 0.0F, 0.0F));
PartDefinition left_ear = skull.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -5.0F, -0.5F, 4.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(5.0F, -8.0F, -9.5F));
PartDefinition right_ear = skull.addOrReplaceChild("right_ear", CubeListBuilder.create().texOffs(0, 0).mirror().addBox(-3.0F, -5.0F, -0.5F, 4.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-5.0F, -8.0F, -9.5F));
PartDefinition left_eye = skull.addOrReplaceChild("left_eye", CubeListBuilder.create().texOffs(55, 46).addBox(-0.45F, -0.4F, -0.9F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(57, 46).addBox(-0.55F, -1.6F, -1.1F, 1.0F, 3.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(5.8F, 5.1F, -9.4F, 0.2618F, 0.0F, 0.0F));
PartDefinition left_eyelid = skull.addOrReplaceChild("left_eyelid", CubeListBuilder.create().texOffs(42, 85).addBox(-0.55F, -2.1F, -1.6F, 1.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(5.05F, 5.1F, -9.4F));
PartDefinition right_eyelid = skull.addOrReplaceChild("right_eyelid", CubeListBuilder.create().texOffs(42, 85).mirror().addBox(-0.45F, -2.1F, -1.6F, 1.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-5.05F, 5.1F, -9.4F));
PartDefinition right_eye = skull.addOrReplaceChild("right_eye", CubeListBuilder.create().texOffs(55, 46).mirror().addBox(-0.55F, -0.4F, -0.9F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false)
.texOffs(57, 46).mirror().addBox(-0.45F, -1.6F, -1.1F, 1.0F, 3.0F, 3.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(-5.8F, 5.1F, -9.4F, 0.2618F, 0.0F, 0.0F));
PartDefinition tail = torso.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(16, 88).addBox(-1.5F, 0.0F, 0.0F, 3.0F, 0.0F, 13.0F, new CubeDeformation(0.0F))
.texOffs(57, 0).addBox(-2.5F, 0.0F, 13.0F, 5.0F, 0.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -35.0F, 22.0F, -1.309F, 0.0F, 0.0F));
PartDefinition left_back_leg = body.addOrReplaceChild("left_back_leg", CubeListBuilder.create().texOffs(73, 0).addBox(-4.5F, -4.5F, -5.0F, 9.0F, 13.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(7.0F, -28.5F, 15.5F));
PartDefinition left_back_knee = left_back_leg.addOrReplaceChild("left_back_knee", CubeListBuilder.create().texOffs(98, 62).addBox(-3.5F, 0.0F, -1.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 8.5F, -3.0F));
PartDefinition left_back_heel = left_back_knee.addOrReplaceChild("left_back_heel", CubeListBuilder.create().texOffs(54, 105).addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 10.0F, -0.5F));
PartDefinition right_back_leg = body.addOrReplaceChild("right_back_leg", CubeListBuilder.create().texOffs(73, 0).mirror().addBox(-4.5F, -4.5F, -5.0F, 9.0F, 13.0F, 10.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-7.0F, -28.5F, 15.5F));
PartDefinition right_back_knee = right_back_leg.addOrReplaceChild("right_back_knee", CubeListBuilder.create().texOffs(98, 62).mirror().addBox(-3.5F, 0.0F, -1.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 8.5F, -3.0F));
PartDefinition right_back_heel = right_back_knee.addOrReplaceChild("right_back_heel", CubeListBuilder.create().texOffs(54, 105).mirror().addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 10.0F, -0.5F));
PartDefinition right_front_leg = body.addOrReplaceChild("right_front_leg", CubeListBuilder.create().texOffs(100, 111).mirror().addBox(-3.5F, -3.0F, -3.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-7.0F, -17.0F, -20.5F));
PartDefinition right_front_knee = right_front_leg.addOrReplaceChild("right_front_knee", CubeListBuilder.create().texOffs(54, 105).mirror().addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 7.0F, -2.5F));
PartDefinition left_front_leg = body.addOrReplaceChild("left_front_leg", CubeListBuilder.create().texOffs(100, 111).addBox(-3.5F, -3.0F, -3.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offset(7.0F, -17.0F, -20.5F));
PartDefinition left_front_knee = left_front_leg.addOrReplaceChild("left_front_knee", CubeListBuilder.create().texOffs(54, 105).addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 7.0F, -2.5F));
return LayerDefinition.create(meshdefinition, 128, 128);
}
@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.root().getAllParts().forEach(ModelPart::resetPose);
this.applyHeadRotation(netHeadYaw, headPitch, ageInTicks);
this.animateWalk(ModAnimationDefinitions.RHINO_WALK, limbSwing, limbSwingAmount, 2f, 2.5f);
this.animate(((RhinoEntity) entity).idleAnimationState, ModAnimationDefinitions.RHINO_IDLE, ageInTicks, 1f);
this.animate(((RhinoEntity) entity).attackAnimationState, ModAnimationDefinitions.RHINO_ATTACK, ageInTicks, 1f);
}
private void applyHeadRotation(float pNetHeadYaw, float pHeadPitch, float pAgeInTicks) {
pNetHeadYaw = Mth.clamp(pNetHeadYaw, -30.0F, 30.0F);
pHeadPitch = Mth.clamp(pHeadPitch, -25.0F, 45.0F);
this.head.yRot = pNetHeadYaw * ((float)Math.PI / 180F);
this.head.xRot = pHeadPitch * ((float)Math.PI / 180F);
}
@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
rhino.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}
@Override
public ModelPart root() {
return rhino;
}
}

View File

@@ -0,0 +1,30 @@
package net.kaupenjoe.tutorialmod.entity.client;
import com.mojang.blaze3d.vertex.PoseStack;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
public class RhinoRenderer extends MobRenderer<RhinoEntity, RhinoModel<RhinoEntity>> {
public RhinoRenderer(EntityRendererProvider.Context pContext) {
super(pContext, new RhinoModel<>(pContext.bakeLayer(ModModelLayers.RHINO_LAYER)), 2f);
}
@Override
public ResourceLocation getTextureLocation(RhinoEntity pEntity) {
return new ResourceLocation(TutorialMod.MOD_ID, "textures/entity/rhino.png");
}
@Override
public void render(RhinoEntity pEntity, float pEntityYaw, float pPartialTicks, PoseStack pMatrixStack,
MultiBufferSource pBuffer, int pPackedLight) {
if(pEntity.isBaby()) {
pMatrixStack.scale(0.5f, 0.5f, 0.5f);
}
super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight);
}
}

View File

@@ -0,0 +1,154 @@
package net.kaupenjoe.tutorialmod.entity.custom;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.entity.ai.RhinoAttackGoal;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.AnimationState;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.*;
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
public class RhinoEntity extends Animal {
private static final EntityDataAccessor<Boolean> ATTACKING =
SynchedEntityData.defineId(RhinoEntity.class, EntityDataSerializers.BOOLEAN);
public RhinoEntity(EntityType<? extends Animal> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
}
public final AnimationState idleAnimationState = new AnimationState();
private int idleAnimationTimeout = 0;
public final AnimationState attackAnimationState = new AnimationState();
public int attackAnimationTimeout = 0;
@Override
public void tick() {
super.tick();
if(this.level().isClientSide()) {
setupAnimationStates();
}
}
private void setupAnimationStates() {
if(this.idleAnimationTimeout <= 0) {
this.idleAnimationTimeout = this.random.nextInt(40) + 80;
this.idleAnimationState.start(this.tickCount);
} else {
--this.idleAnimationTimeout;
}
if(this.isAttacking() && attackAnimationTimeout <= 0) {
attackAnimationTimeout = 80; // Length in ticks of your animation
attackAnimationState.start(this.tickCount);
} else {
--this.attackAnimationTimeout;
}
if(!this.isAttacking()) {
attackAnimationState.stop();
}
}
@Override
protected void updateWalkAnimation(float pPartialTick) {
float f;
if(this.getPose() == Pose.STANDING) {
f = Math.min(pPartialTick * 6F, 1f);
} else {
f = 0f;
}
this.walkAnimation.update(f, 0.2f);
}
public void setAttacking(boolean attacking) {
this.entityData.set(ATTACKING, attacking);
}
public boolean isAttacking() {
return this.entityData.get(ATTACKING);
}
@Override
protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(ATTACKING, false);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new RhinoAttackGoal(this, 1.0D, true));
this.goalSelector.addGoal(1, new BreedGoal(this, 1.15D));
this.goalSelector.addGoal(2, new TemptGoal(this, 1.2D, Ingredient.of(Items.COOKED_BEEF), false));
this.goalSelector.addGoal(3, new FollowParentGoal(this, 1.1D));
this.goalSelector.addGoal(4, new WaterAvoidingRandomStrollGoal(this, 1.1D));
this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 3f));
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
}
public static AttributeSupplier.Builder createAttributes() {
return Animal.createLivingAttributes()
.add(Attributes.MAX_HEALTH, 20D)
.add(Attributes.FOLLOW_RANGE, 24D)
.add(Attributes.MOVEMENT_SPEED, 0.25D)
.add(Attributes.ARMOR_TOUGHNESS, 0.1f)
.add(Attributes.ATTACK_KNOCKBACK, 0.5f)
.add(Attributes.ATTACK_DAMAGE, 2f);
}
@Nullable
@Override
public AgeableMob getBreedOffspring(ServerLevel pLevel, AgeableMob pOtherParent) {
return ModEntities.RHINO.get().create(pLevel);
}
@Override
public boolean isFood(ItemStack pStack) {
return pStack.is(Items.COOKED_BEEF);
}
@Nullable
@Override
protected SoundEvent getAmbientSound() {
return SoundEvents.HOGLIN_AMBIENT;
}
@Nullable
@Override
protected SoundEvent getHurtSound(DamageSource pDamageSource) {
return SoundEvents.RAVAGER_HURT;
}
@Nullable
@Override
protected SoundEvent getDeathSound() {
return SoundEvents.DOLPHIN_DEATH;
}
}

View File

@@ -0,0 +1,17 @@
package net.kaupenjoe.tutorialmod.event;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.client.ModModelLayers;
import net.kaupenjoe.tutorialmod.entity.client.RhinoModel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ModEventBusClientEvents {
@SubscribeEvent
public static void registerLayer(EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(ModModelLayers.RHINO_LAYER, RhinoModel::createBodyLayer);
}
}

View File

@@ -0,0 +1,16 @@
package net.kaupenjoe.tutorialmod.event;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEventBusEvents {
@SubscribeEvent
public static void registerAttributes(EntityAttributeCreationEvent event) {
event.put(ModEntities.RHINO.get(), RhinoEntity.createAttributes().build());
}
}

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

@@ -46,6 +46,9 @@ public class ModCreativeModTabs {
pOutput.accept(ModItems.CORN.get());
pOutput.accept(ModItems.CORN_SEEDS.get());
pOutput.accept(ModItems.BAR_BRAWL_MUSIC_DISC.get());
pOutput.accept(ModItems.RHINO_SPANW_EGG.get());
pOutput.accept(ModBlocks.SAPPHIRE_BLOCK.get());
pOutput.accept(ModBlocks.RAW_SAPPHIRE_BLOCK.get());
@@ -69,6 +72,7 @@ public class ModCreativeModTabs {
pOutput.accept(ModBlocks.SAPPHIRE_TRAPDOOR.get());
pOutput.accept(ModBlocks.CATMINT.get());
pOutput.accept(ModBlocks.GEM_POLISHING_STATION.get());
})
.build());

View File

@@ -2,10 +2,13 @@ package net.kaupenjoe.tutorialmod.item;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.item.custom.FuelItem;
import net.kaupenjoe.tutorialmod.item.custom.MetalDetectorItem;
import net.kaupenjoe.tutorialmod.item.custom.ModArmorItem;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.minecraft.world.item.*;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@@ -61,6 +64,11 @@ public class ModItems {
public static final RegistryObject<Item> CORN = ITEMS.register("corn",
() -> new Item(new Item.Properties()));
public static final RegistryObject<Item> BAR_BRAWL_MUSIC_DISC = ITEMS.register("bar_brawl_music_disc",
() -> new RecordItem(6, ModSounds.BAR_BRAWL, new Item.Properties().stacksTo(1), 2440));
public static final RegistryObject<Item> RHINO_SPANW_EGG = ITEMS.register("rhino_spawn_egg",
() -> new ForgeSpawnEggItem(ModEntities.RHINO, 0x7e9680, 0xc5d1c5, new Item.Properties()));
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);

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,118 @@
package net.kaupenjoe.tutorialmod.recipe;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.*;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
public class GemPolishingRecipe implements Recipe<SimpleContainer> {
private final NonNullList<Ingredient> inputItems;
private final ItemStack output;
private final ResourceLocation id;
public GemPolishingRecipe(NonNullList<Ingredient> inputItems, ItemStack output, ResourceLocation id) {
this.inputItems = inputItems;
this.output = output;
this.id = id;
}
@Override
public boolean matches(SimpleContainer pContainer, Level pLevel) {
if(pLevel.isClientSide()) {
return false;
}
return inputItems.get(0).test(pContainer.getItem(0));
}
@Override
public NonNullList<Ingredient> getIngredients() {
return inputItems;
}
@Override
public ItemStack assemble(SimpleContainer pContainer, RegistryAccess pRegistryAccess) {
return output.copy();
}
@Override
public boolean canCraftInDimensions(int pWidth, int pHeight) {
return true;
}
@Override
public ItemStack getResultItem(RegistryAccess pRegistryAccess) {
return output.copy();
}
@Override
public ResourceLocation getId() {
return id;
}
@Override
public RecipeSerializer<?> getSerializer() {
return Serializer.INSTANCE;
}
@Override
public RecipeType<?> getType() {
return Type.INSTANCE;
}
public static class Type implements RecipeType<GemPolishingRecipe> {
public static final Type INSTANCE = new Type();
public static final String ID = "gem_polishing";
}
public static class Serializer implements RecipeSerializer<GemPolishingRecipe> {
public static final Serializer INSTANCE = new Serializer();
public static final ResourceLocation ID = new ResourceLocation(TutorialMod.MOD_ID, "gem_polishing");
@Override
public GemPolishingRecipe fromJson(ResourceLocation pRecipeId, JsonObject pSerializedRecipe) {
ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(pSerializedRecipe, "output"));
JsonArray ingredients = GsonHelper.getAsJsonArray(pSerializedRecipe, "ingredients");
NonNullList<Ingredient> inputs = NonNullList.withSize(1, Ingredient.EMPTY);
for(int i = 0; i < inputs.size(); i++) {
inputs.set(i, Ingredient.fromJson(ingredients.get(i)));
}
return new GemPolishingRecipe(inputs, output, pRecipeId);
}
@Override
public @Nullable GemPolishingRecipe fromNetwork(ResourceLocation pRecipeId, FriendlyByteBuf pBuffer) {
NonNullList<Ingredient> inputs = NonNullList.withSize(pBuffer.readInt(), Ingredient.EMPTY);
for(int i = 0; i < inputs.size(); i++) {
inputs.set(i, Ingredient.fromNetwork(pBuffer));
}
ItemStack output = pBuffer.readItem();
return new GemPolishingRecipe(inputs, output, pRecipeId);
}
@Override
public void toNetwork(FriendlyByteBuf pBuffer, GemPolishingRecipe pRecipe) {
pBuffer.writeInt(pRecipe.inputItems.size());
for (Ingredient ingredient : pRecipe.getIngredients()) {
ingredient.toNetwork(pBuffer);
}
pBuffer.writeItemStack(pRecipe.getResultItem(null), false);
}
}
}

View File

@@ -0,0 +1,20 @@
package net.kaupenjoe.tutorialmod.recipe;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModRecipes {
public static final DeferredRegister<RecipeSerializer<?>> SERIALIZERS =
DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, TutorialMod.MOD_ID);
public static final RegistryObject<RecipeSerializer<GemPolishingRecipe>> GEM_POLISHING_SERIALIZER =
SERIALIZERS.register("gem_polishing", () -> GemPolishingRecipe.Serializer.INSTANCE);
public static void register(IEventBus eventBus) {
SERIALIZERS.register(eventBus);
}
}

View File

@@ -0,0 +1,123 @@
package net.kaupenjoe.tutorialmod.screen;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.block.entity.GemPolishingStationBlockEntity;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.*;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.items.SlotItemHandler;
public class GemPolishingStationMenu extends AbstractContainerMenu {
public final GemPolishingStationBlockEntity blockEntity;
private final Level level;
private final ContainerData data;
public GemPolishingStationMenu(int pContainerId, Inventory inv, FriendlyByteBuf extraData) {
this(pContainerId, inv, inv.player.level().getBlockEntity(extraData.readBlockPos()), new SimpleContainerData(2));
}
public GemPolishingStationMenu(int pContainerId, Inventory inv, BlockEntity entity, ContainerData data) {
super(ModMenuTypes.GEM_POLISHING_MENU.get(), pContainerId);
checkContainerSize(inv, 2);
blockEntity = ((GemPolishingStationBlockEntity) entity);
this.level = inv.player.level();
this.data = data;
addPlayerInventory(inv);
addPlayerHotbar(inv);
this.blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(iItemHandler -> {
this.addSlot(new SlotItemHandler(iItemHandler, 0, 80, 11));
this.addSlot(new SlotItemHandler(iItemHandler, 1, 80, 59));
});
addDataSlots(data);
}
public boolean isCrafting() {
return data.get(0) > 0;
}
public int getScaledProgress() {
int progress = this.data.get(0);
int maxProgress = this.data.get(1); // Max Progress
int progressArrowSize = 26; // This is the height in pixels of your arrow
return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0;
}
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
// must assign a slot number to each of the slots used by the GUI.
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
private static final int HOTBAR_SLOT_COUNT = 9;
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
// THIS YOU HAVE TO DEFINE!
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
@Override
public ItemStack quickMoveStack(Player playerIn, int pIndex) {
Slot sourceSlot = slots.get(pIndex);
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
ItemStack sourceStack = sourceSlot.getItem();
ItemStack copyOfSourceStack = sourceStack.copy();
// Check if the slot clicked is one of the vanilla container slots
if (pIndex < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
// This is a vanilla container slot so merge the stack into the tile inventory
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
+ TE_INVENTORY_SLOT_COUNT, false)) {
return ItemStack.EMPTY; // EMPTY_ITEM
}
} else if (pIndex < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
// This is a TE slot so merge the stack into the players inventory
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
return ItemStack.EMPTY;
}
} else {
System.out.println("Invalid slotIndex:" + pIndex);
return ItemStack.EMPTY;
}
// If stack size == 0 (the entire stack was moved) set slot contents to null
if (sourceStack.getCount() == 0) {
sourceSlot.set(ItemStack.EMPTY);
} else {
sourceSlot.setChanged();
}
sourceSlot.onTake(playerIn, sourceStack);
return copyOfSourceStack;
}
@Override
public boolean stillValid(Player pPlayer) {
return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()),
pPlayer, ModBlocks.GEM_POLISHING_STATION.get());
}
private void addPlayerInventory(Inventory playerInventory) {
for (int i = 0; i < 3; ++i) {
for (int l = 0; l < 9; ++l) {
this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 84 + i * 18));
}
}
}
private void addPlayerHotbar(Inventory playerInventory) {
for (int i = 0; i < 9; ++i) {
this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
}
}
}

View File

@@ -0,0 +1,52 @@
package net.kaupenjoe.tutorialmod.screen;
import com.mojang.blaze3d.systems.RenderSystem;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
public class GemPolishingStationScreen extends AbstractContainerScreen<GemPolishingStationMenu> {
private static final ResourceLocation TEXTURE =
new ResourceLocation(TutorialMod.MOD_ID, "textures/gui/gem_polishing_station_gui.png");
public GemPolishingStationScreen(GemPolishingStationMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
super(pMenu, pPlayerInventory, pTitle);
}
@Override
protected void init() {
super.init();
this.inventoryLabelY = 10000;
this.titleLabelY = 10000;
}
@Override
protected void renderBg(GuiGraphics guiGraphics, float pPartialTick, int pMouseX, int pMouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, TEXTURE);
int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2;
guiGraphics.blit(TEXTURE, x, y, 0, 0, imageWidth, imageHeight);
renderProgressArrow(guiGraphics, x, y);
}
private void renderProgressArrow(GuiGraphics guiGraphics, int x, int y) {
if(menu.isCrafting()) {
guiGraphics.blit(TEXTURE, x + 85, y + 30, 176, 0, 8, menu.getScaledProgress());
}
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
renderBackground(guiGraphics);
super.render(guiGraphics, mouseX, mouseY, delta);
renderTooltip(guiGraphics, mouseX, mouseY);
}
}

View File

@@ -0,0 +1,28 @@
package net.kaupenjoe.tutorialmod.screen;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.network.IContainerFactory;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModMenuTypes {
public static final DeferredRegister<MenuType<?>> MENUS =
DeferredRegister.create(ForgeRegistries.MENU_TYPES, TutorialMod.MOD_ID);
public static final RegistryObject<MenuType<GemPolishingStationMenu>> GEM_POLISHING_MENU =
registerMenuType("gem_polishing_menu", GemPolishingStationMenu::new);
private static <T extends AbstractContainerMenu>RegistryObject<MenuType<T>> registerMenuType(String name, IContainerFactory<T> factory) {
return MENUS.register(name, () -> IForgeMenuType.create(factory));
}
public static void register(IEventBus eventBus) {
MENUS.register(eventBus);
}
}

View File

@@ -0,0 +1,39 @@
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 RegistryObject<SoundEvent> BAR_BRAWL = registerSoundEvents("bar_brawl");
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

@@ -23,6 +23,9 @@
"item.tutorialmod.corn": "Corn",
"item.tutorialmod.corn_seeds": "Corn Seeds",
"item.tutorialmod.bar_brawl_music_disc": "Bar Brawl Music Disc",
"item.tutorialmod.bar_brawl_music_disc.desc": "Bryan Tech - Bar Brawl (CC0)",
"block.tutorialmod.sapphire_block": "Block of Sapphire",
"block.tutorialmod.raw_sapphire_block": "Block of Raw Sapphire",
@@ -45,8 +48,14 @@
"block.tutorialmod.catmint": "Catmint",
"block.tutorialmod.gem_polishing_station": "Gem Polishing Station",
"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,198 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"3": "tutorialmod:block/gem_polishing_station_texture",
"particle": "tutorialmod:block/gem_polishing_station_texture"
},
"elements": [
{
"name": "left_leg",
"from": [14, 0, 0],
"to": [16, 4, 2],
"faces": {
"north": {"uv": [6, 5, 6.5, 6.5], "texture": "#3"},
"east": {"uv": [6.5, 0, 7, 1.5], "texture": "#3"},
"south": {"uv": [6.5, 1.5, 7, 3], "texture": "#3"},
"west": {"uv": [6.5, 5, 7, 6.5], "texture": "#3"},
"up": {"uv": [8.5, 4.5, 8, 4], "texture": "#3"},
"down": {"uv": [8.5, 4.5, 8, 5], "texture": "#3"}
}
},
{
"name": "right_leg",
"from": [0, 0, 0],
"to": [2, 4, 2],
"faces": {
"north": {"uv": [6, 6.5, 6.5, 8], "texture": "#3"},
"east": {"uv": [6.5, 6.5, 7, 8], "texture": "#3"},
"south": {"uv": [7, 0, 7.5, 1.5], "texture": "#3"},
"west": {"uv": [7, 1.5, 7.5, 3], "texture": "#3"},
"up": {"uv": [6.5, 8.5, 6, 8], "texture": "#3"},
"down": {"uv": [7, 8, 6.5, 8.5], "texture": "#3"}
}
},
{
"name": "right_back_leg",
"from": [0, 0, 14],
"to": [2, 4, 16],
"faces": {
"north": {"uv": [4, 7, 4.5, 8.5], "texture": "#3"},
"east": {"uv": [4.5, 7, 5, 8.5], "texture": "#3"},
"south": {"uv": [5, 7, 5.5, 8.5], "texture": "#3"},
"west": {"uv": [7, 5, 7.5, 6.5], "texture": "#3"},
"up": {"uv": [7.5, 8.5, 7, 8], "texture": "#3"},
"down": {"uv": [2, 8.25, 1.5, 8.75], "texture": "#3"}
}
},
{
"name": "left_back_leg",
"from": [14, 0, 14],
"to": [16, 4, 16],
"faces": {
"north": {"uv": [5.5, 7, 6, 8.5], "texture": "#3"},
"east": {"uv": [7, 6.5, 7.5, 8], "texture": "#3"},
"south": {"uv": [7.5, 0, 8, 1.5], "texture": "#3"},
"west": {"uv": [7.5, 1.5, 8, 3], "texture": "#3"},
"up": {"uv": [2.5, 8.75, 2, 8.25], "texture": "#3"},
"down": {"uv": [8.75, 2, 8.25, 2.5], "texture": "#3"}
}
},
{
"name": "base",
"from": [0, 4, 0],
"to": [16, 12, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 3, 0]},
"faces": {
"north": {"uv": [4, 3, 8, 5], "texture": "#3"},
"east": {"uv": [4, 3, 8, 5], "texture": "#3"},
"south": {"uv": [4, 3, 8, 5], "texture": "#3"},
"west": {"uv": [4, 3, 8, 5], "texture": "#3"},
"up": {"uv": [4, 4, 0, 0], "texture": "#3"},
"down": {"uv": [4, 4, 0, 8], "texture": "#3"}
}
},
{
"from": [5, 12.002, 5],
"to": [11, 12.002, 11],
"faces": {
"north": {"uv": [0, 0, 1.5, 0], "texture": "#missing"},
"east": {"uv": [1, 5.5, 2.5, 5.5], "texture": "#3"},
"south": {"uv": [1, 5.5, 2.5, 5.5], "texture": "#3"},
"west": {"uv": [1, 5.5, 2.5, 5.5], "texture": "#3"},
"up": {"uv": [1, 5.5, 2.5, 7], "texture": "#3"},
"down": {"uv": [1, 5.5, 2.5, 7], "texture": "#3"}
}
},
{
"from": [5, 12, 11],
"to": [11, 13, 11],
"faces": {
"north": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"east": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"south": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"west": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"up": {"uv": [0, 0, 1.5, 0.25], "texture": "#3"},
"down": {"uv": [0, 0, 1.5, 0.25], "texture": "#3"}
}
},
{
"from": [5, 12, 5],
"to": [11, 13, 5],
"faces": {
"north": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"east": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"south": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"west": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"up": {"uv": [0, 0, 1.5, 0.25], "texture": "#3"},
"down": {"uv": [0, 0, 1.5, 0.25], "texture": "#3"}
}
},
{
"from": [11, 12, 5],
"to": [11, 13, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 12.5, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"east": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"south": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"west": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"up": {"uv": [0, 0, 1.5, 0.25], "rotation": 270, "texture": "#3"},
"down": {"uv": [0, 0, 1.5, 0.25], "rotation": 90, "texture": "#3"}
}
},
{
"from": [5, 12, 5],
"to": [5, 13, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 12.5, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"east": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"south": {"uv": [0, 0, 0, 0.5], "texture": "#3"},
"west": {"uv": [0, 0, 1.5, 0.5], "texture": "#3"},
"up": {"uv": [0, 0, 1.5, 0.25], "rotation": 270, "texture": "#3"},
"down": {"uv": [0, 0, 1.5, 0.25], "rotation": 90, "texture": "#3"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [47, 19, 0],
"translation": [0, 0, 0.5],
"scale": [0.275, 0.275, 0.275]
},
"thirdperson_lefthand": {
"rotation": [47, 19, 0],
"translation": [0, 0, 0.5],
"scale": [0.275, 0.275, 0.275]
},
"firstperson_righthand": {
"translation": [0, 1.25, 0],
"scale": [0.75, 0.75, 0.75]
},
"firstperson_lefthand": {
"translation": [0, 1.25, 0],
"scale": [0.75, 0.75, 0.75]
},
"ground": {
"scale": [0.55, 0.55, 0.55]
},
"gui": {
"rotation": [25, -145, 0],
"translation": [0, 2.25, 0],
"scale": [0.7, 0.7, 0.7]
},
"head": {
"translation": [0, 7, 0]
},
"fixed": {
"rotation": [-17, 52, 0],
"translation": [0, 2.25, -3.75],
"scale": [0.55, 0.55, 0.55]
}
},
"groups": [
{
"name": "VoxelShapes",
"origin": [8, 8, 8],
"color": 0,
"nbt": "{}",
"children": [
{
"name": "table",
"origin": [11.5, 2.5, 5],
"color": 0,
"nbt": "{}",
"children": [0, 1, 2, 3, 4]
},
{
"name": "tray",
"origin": [8, 8, 8],
"color": 0,
"nbt": "{}",
"children": [5, 6, 7, 8, 9]
}
]
}
]
}

View File

@@ -0,0 +1,46 @@
{
"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"
]
},
"bar_brawl": {
"sounds": [
{
"name": "tutorialmod:bar_brawl",
"stream": true
}
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

View File

@@ -0,0 +1,12 @@
{
"type": "tutorialmod:gem_polishing",
"ingredients": [
{
"item": "minecraft:coal"
}
],
"output": {
"count": 7,
"item": "minecraft:diamond"
}
}

View File

@@ -0,0 +1,12 @@
{
"type": "tutorialmod:gem_polishing",
"ingredients": [
{
"item": "tutorialmod:raw_sapphire"
}
],
"output": {
"count": 3,
"item": "tutorialmod:sapphire"
}
}