From 902438adb514e2d0ed8f15f1210f6f5538618a89 Mon Sep 17 00:00:00 2001 From: Starexify Date: Mon, 28 Oct 2024 18:10:28 +0100 Subject: [PATCH] 1.0.0 --- .../nmt/blockstates/ender_brewing_stand.json | 57 +++++++ .../resources/assets/nmt/lang/en_us.json | 2 + .../nmt/models/block/ender_brewing_stand.json | 9 + .../block/ender_brewing_stand_bottle0.json | 8 + .../block/ender_brewing_stand_bottle1.json | 8 + .../block/ender_brewing_stand_bottle2.json | 8 + .../block/ender_brewing_stand_empty0.json | 8 + .../block/ender_brewing_stand_empty1.json | 8 + .../block/ender_brewing_stand_empty2.json | 8 + .../nmt/models/item/ender_brewing_stand.json | 6 + .../blocks/ender_brewing_stand.json | 30 ++++ src/main/java/net/nova/nmt/NoMoreThings.java | 1 + .../nmt/block/EnderBrewingStandBlock.java | 127 ++++++++++++++ .../EnderBrewingStandBlockEntity.java | 156 ++++++++++++++++++ .../nmt/data/BlockStateAndModelProvider.java | 92 +++++++---- .../java/net/nova/nmt/data/LangProvider.java | 4 + .../nova/nmt/data/loot/BlockLootTables.java | 2 + .../java/net/nova/nmt/init/CreativeTab.java | 1 + .../net/nova/nmt/init/NMTBlockEntities.java | 18 ++ .../java/net/nova/nmt/init/NMTBlocks.java | 14 +- .../java/net/nova/nmt/init/NMTPotions.java | 25 ++- .../java/net/nova/nmt/util/NMTPotion.java | 11 -- .../textures/block/ender_brewing_stand.png | Bin 0 -> 370 bytes .../block/ender_brewing_stand_base.png | Bin 0 -> 235 bytes .../nmt/textures/item/ender_brewing_stand.png | Bin 0 -> 275 bytes 25 files changed, 541 insertions(+), 62 deletions(-) create mode 100644 src/generated/resources/assets/nmt/blockstates/ender_brewing_stand.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle0.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle1.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle2.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty0.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty1.json create mode 100644 src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty2.json create mode 100644 src/generated/resources/assets/nmt/models/item/ender_brewing_stand.json create mode 100644 src/generated/resources/data/nmt/loot_table/blocks/ender_brewing_stand.json create mode 100644 src/main/java/net/nova/nmt/block/EnderBrewingStandBlock.java create mode 100644 src/main/java/net/nova/nmt/blockentity/EnderBrewingStandBlockEntity.java create mode 100644 src/main/java/net/nova/nmt/init/NMTBlockEntities.java delete mode 100644 src/main/java/net/nova/nmt/util/NMTPotion.java create mode 100644 src/main/resources/assets/nmt/textures/block/ender_brewing_stand.png create mode 100644 src/main/resources/assets/nmt/textures/block/ender_brewing_stand_base.png create mode 100644 src/main/resources/assets/nmt/textures/item/ender_brewing_stand.png diff --git a/src/generated/resources/assets/nmt/blockstates/ender_brewing_stand.json b/src/generated/resources/assets/nmt/blockstates/ender_brewing_stand.json new file mode 100644 index 0000000..86f9c57 --- /dev/null +++ b/src/generated/resources/assets/nmt/blockstates/ender_brewing_stand.json @@ -0,0 +1,57 @@ +{ + "multipart": [ + { + "apply": { + "model": "nmt:block/ender_brewing_stand" + } + }, + { + "apply": { + "model": "nmt:block/ender_brewing_stand_bottle0" + }, + "when": { + "has_bottle_0": "true" + } + }, + { + "apply": { + "model": "nmt:block/ender_brewing_stand_bottle1" + }, + "when": { + "has_bottle_1": "true" + } + }, + { + "apply": { + "model": "nmt:block/ender_brewing_stand_bottle2" + }, + "when": { + "has_bottle_2": "true" + } + }, + { + "apply": { + "model": "nmt:block/ender_brewing_stand_empty0" + }, + "when": { + "has_bottle_0": "false" + } + }, + { + "apply": { + "model": "nmt:block/ender_brewing_stand_empty1" + }, + "when": { + "has_bottle_1": "false" + } + }, + { + "apply": { + "model": "nmt:block/ender_brewing_stand_empty2" + }, + "when": { + "has_bottle_2": "false" + } + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/lang/en_us.json b/src/generated/resources/assets/nmt/lang/en_us.json index 4b30d95..8e98c39 100644 --- a/src/generated/resources/assets/nmt/lang/en_us.json +++ b/src/generated/resources/assets/nmt/lang/en_us.json @@ -1,6 +1,8 @@ { + "block.nmt.ender_brewing_stand": "Ender Brewing Stand", "block.nmt.obsidian_glass": "Obsidian Glass", "block.nmt.obsidian_glass_pane": "Obsidian Glass Pane", + "container.ender_brewing": "Ender Brewing Stand", "effect.nmt.burn": "Burn", "item.nmt.awfully_potion.effect.awfully": "Awfully Potion", "item.nmt.lava_bottle.effect.lava": "Lava Bottle", diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand.json new file mode 100644 index 0000000..675a025 --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand.json @@ -0,0 +1,9 @@ +{ + "parent": "minecraft:block/brewing_stand", + "render_type": "minecraft:cutout", + "textures": { + "base": "nmt:block/ender_brewing_stand_base", + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle0.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle0.json new file mode 100644 index 0000000..0b40e08 --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle0.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/brewing_stand_bottle0", + "render_type": "minecraft:cutout", + "textures": { + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle1.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle1.json new file mode 100644 index 0000000..31b39ed --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle1.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/brewing_stand_bottle1", + "render_type": "minecraft:cutout", + "textures": { + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle2.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle2.json new file mode 100644 index 0000000..c7a361f --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_bottle2.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/brewing_stand_bottle2", + "render_type": "minecraft:cutout", + "textures": { + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty0.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty0.json new file mode 100644 index 0000000..3325a66 --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty0.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/brewing_stand_empty0", + "render_type": "minecraft:cutout", + "textures": { + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty1.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty1.json new file mode 100644 index 0000000..8267568 --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty1.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/brewing_stand_empty1", + "render_type": "minecraft:cutout", + "textures": { + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty2.json b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty2.json new file mode 100644 index 0000000..fa483a5 --- /dev/null +++ b/src/generated/resources/assets/nmt/models/block/ender_brewing_stand_empty2.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/brewing_stand_empty2", + "render_type": "minecraft:cutout", + "textures": { + "particle": "nmt:block/ender_brewing_stand", + "stand": "nmt:block/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/nmt/models/item/ender_brewing_stand.json b/src/generated/resources/assets/nmt/models/item/ender_brewing_stand.json new file mode 100644 index 0000000..146784d --- /dev/null +++ b/src/generated/resources/assets/nmt/models/item/ender_brewing_stand.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "nmt:item/ender_brewing_stand" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/nmt/loot_table/blocks/ender_brewing_stand.json b/src/generated/resources/data/nmt/loot_table/blocks/ender_brewing_stand.json new file mode 100644 index 0000000..dd4f366 --- /dev/null +++ b/src/generated/resources/data/nmt/loot_table/blocks/ender_brewing_stand.json @@ -0,0 +1,30 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name" + ], + "source": "block_entity" + } + ], + "name": "nmt:ender_brewing_stand" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "nmt:blocks/ender_brewing_stand" +} \ No newline at end of file diff --git a/src/main/java/net/nova/nmt/NoMoreThings.java b/src/main/java/net/nova/nmt/NoMoreThings.java index e2d73bd..603c692 100644 --- a/src/main/java/net/nova/nmt/NoMoreThings.java +++ b/src/main/java/net/nova/nmt/NoMoreThings.java @@ -20,6 +20,7 @@ public NoMoreThings(IEventBus bus) { CreativeTab.CREATIVE_TAB.register(bus); NMTPotions.POTIONS.register(bus); NMTEffects.MOB_EFFECTS.register(bus); + NMTBlockEntities.BLOCK_ENTITIES.register(bus); bus.addListener(DataGenerators::gatherData); } diff --git a/src/main/java/net/nova/nmt/block/EnderBrewingStandBlock.java b/src/main/java/net/nova/nmt/block/EnderBrewingStandBlock.java new file mode 100644 index 0000000..b548340 --- /dev/null +++ b/src/main/java/net/nova/nmt/block/EnderBrewingStandBlock.java @@ -0,0 +1,127 @@ +package net.nova.nmt.block; + +import com.mojang.serialization.MapCodec; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.stats.Stats; +import net.minecraft.util.RandomSource; +import net.minecraft.world.Containers; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +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.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.nova.nmt.blockentity.EnderBrewingStandBlockEntity; +import net.nova.nmt.init.NMTBlockEntities; + +import javax.annotation.Nullable; + +public class EnderBrewingStandBlock extends BaseEntityBlock { + public static final MapCodec CODEC = simpleCodec(EnderBrewingStandBlock::new); + public static final BooleanProperty[] HAS_BOTTLE = new BooleanProperty[]{ + BlockStateProperties.HAS_BOTTLE_0, BlockStateProperties.HAS_BOTTLE_1, BlockStateProperties.HAS_BOTTLE_2 + }; + protected static final VoxelShape SHAPE = Shapes.or(Block.box(1.0, 0.0, 1.0, 15.0, 2.0, 15.0), Block.box(7.0, 0.0, 7.0, 9.0, 14.0, 9.0)); + + @Override + public MapCodec codec() { + return CODEC; + } + + + public EnderBrewingStandBlock(Properties properties) { + super(properties); + this.registerDefaultState( + this.stateDefinition + .any() + .setValue(HAS_BOTTLE[0], Boolean.valueOf(false)) + .setValue(HAS_BOTTLE[1], Boolean.valueOf(false)) + .setValue(HAS_BOTTLE[2], Boolean.valueOf(false)) + ); + } + + @Override + protected RenderShape getRenderShape(BlockState state) { + return RenderShape.MODEL; + } + + @Override + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new EnderBrewingStandBlockEntity(pos, state); + } + + @Nullable + @Override + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + return level.isClientSide ? null : createTickerHelper(blockEntityType, NMTBlockEntities.ENDER_BREWING_STAND.get(), EnderBrewingStandBlockEntity::serverTick); + } + + @Override + protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + return SHAPE; + } + + @Override + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { + if (level.isClientSide) { + return InteractionResult.SUCCESS; + } else { + BlockEntity blockentity = level.getBlockEntity(pos); + if (blockentity instanceof EnderBrewingStandBlockEntity) { + player.openMenu((EnderBrewingStandBlockEntity)blockentity); + player.awardStat(Stats.INTERACT_WITH_BREWINGSTAND); + } + + return InteractionResult.CONSUME; + } + } + + @Override + public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { + double d0 = (double)pos.getX() + 0.4 + (double)random.nextFloat() * 0.2; + double d1 = (double)pos.getY() + 0.7 + (double)random.nextFloat() * 0.3; + double d2 = (double)pos.getZ() + 0.4 + (double)random.nextFloat() * 0.2; + level.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0, 0.0, 0.0); + } + + @Override + protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) { + Containers.dropContentsOnDestroy(state, newState, level, pos); + super.onRemove(state, level, pos, newState, isMoving); + } + + @Override + protected boolean hasAnalogOutputSignal(BlockState state) { + return true; + } + + @Override + protected int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]); + } + + @Override + protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { + return false; + } +} diff --git a/src/main/java/net/nova/nmt/blockentity/EnderBrewingStandBlockEntity.java b/src/main/java/net/nova/nmt/blockentity/EnderBrewingStandBlockEntity.java new file mode 100644 index 0000000..ef64c11 --- /dev/null +++ b/src/main/java/net/nova/nmt/blockentity/EnderBrewingStandBlockEntity.java @@ -0,0 +1,156 @@ +package net.nova.nmt.blockentity; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.WorldlyContainer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.BrewingStandMenu; +import net.minecraft.world.inventory.ContainerData; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.PotionBrewing; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.nova.nmt.init.NMTBlockEntities; +import net.nova.nmt.init.NMTItems; + +import javax.annotation.Nullable; + +public class EnderBrewingStandBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer { + private static final int INGREDIENT_SLOT = 3; + private static final int FUEL_SLOT = 4; + private static final int[] SLOTS_FOR_UP = new int[]{3}; + private static final int[] SLOTS_FOR_DOWN = new int[]{0, 1, 2, 3}; + private static final int[] SLOTS_FOR_SIDES = new int[]{0, 1, 2, 4}; + public static final int FUEL_USES = 20; + public static final int DATA_BREW_TIME = 0; + public static final int DATA_FUEL_USES = 1; + public static final int NUM_DATA_VALUES = 2; + + private NonNullList items = NonNullList.withSize(5, ItemStack.EMPTY); + int brewTime; + private boolean[] lastPotionCount; + private Item ingredient; + int fuel; + + protected final ContainerData dataAccess = new ContainerData() { + @Override + public int get(int p_59038_) { + return switch (p_59038_) { + case 0 -> EnderBrewingStandBlockEntity.this.brewTime; + case 1 -> EnderBrewingStandBlockEntity.this.fuel; + default -> 0; + }; + } + + @Override + public void set(int p_59040_, int p_59041_) { + switch (p_59040_) { + case 0: + EnderBrewingStandBlockEntity.this.brewTime = p_59041_; + break; + case 1: + EnderBrewingStandBlockEntity.this.fuel = p_59041_; + } + } + + @Override + public int getCount() { + return 2; + } + }; + + public EnderBrewingStandBlockEntity(BlockPos pos, BlockState state) { + super(NMTBlockEntities.ENDER_BREWING_STAND.get(), pos, state); + } + + @Override + protected Component getDefaultName() { + return Component.translatable("container.ender_brewing"); + } + + @Override + public int getContainerSize() { + return this.items.size(); + } + + @Override + protected NonNullList getItems() { + return this.items; + } + + @Override + protected void setItems(NonNullList items) { + this.items = items; + } + + public static void serverTick(Level level, BlockPos pos, BlockState state, EnderBrewingStandBlockEntity blockEntity) { + + } + + @Override + protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.loadAdditional(tag, registries); + this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + ContainerHelper.loadAllItems(tag, this.items, registries); + this.brewTime = tag.getShort("BrewTime"); + if (this.brewTime > 0) { + this.ingredient = this.items.get(3).getItem(); + } + + this.fuel = tag.getByte("Fuel"); + } + + @Override + protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.saveAdditional(tag, registries); + tag.putShort("BrewTime", (short)this.brewTime); + ContainerHelper.saveAllItems(tag, this.items, registries); + tag.putByte("Fuel", (byte)this.fuel); + } + + @Override + public boolean canPlaceItem(int index, ItemStack stack) { + PotionBrewing potionbrewing = this.level != null ? this.level.potionBrewing() : PotionBrewing.EMPTY; + if (index == 3) { + return potionbrewing.isIngredient(stack); + } else { + return index == 4 + ? stack.is(Items.WIND_CHARGE) + : (potionbrewing.isInput(stack) || stack.is(NMTItems.OBSIDIAN_GLASS_BOTTLE)) + && this.getItem(index).isEmpty(); + } + } + + @Override + public int[] getSlotsForFace(Direction side) { + if (side == Direction.UP) { + return SLOTS_FOR_UP; + } else { + return side == Direction.DOWN ? SLOTS_FOR_DOWN : SLOTS_FOR_SIDES; + } + } + + @Override + public boolean canPlaceItemThroughFace(int index, ItemStack itemStack, @Nullable Direction direction) { + return this.canPlaceItem(index, itemStack); + } + + @Override + public boolean canTakeItemThroughFace(int index, ItemStack stack, Direction direction) { + return index == 3 ? stack.is(NMTItems.OBSIDIAN_GLASS_BOTTLE) : true; + } + + @Override + protected AbstractContainerMenu createMenu(int id, Inventory player) { + return new BrewingStandMenu(id, player, this, this.dataAccess); + } +} diff --git a/src/main/java/net/nova/nmt/data/BlockStateAndModelProvider.java b/src/main/java/net/nova/nmt/data/BlockStateAndModelProvider.java index 9b92c41..3ef0ebb 100644 --- a/src/main/java/net/nova/nmt/data/BlockStateAndModelProvider.java +++ b/src/main/java/net/nova/nmt/data/BlockStateAndModelProvider.java @@ -3,21 +3,12 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; -import net.minecraft.data.models.blockstates.Condition; -import net.minecraft.data.models.blockstates.MultiPartGenerator; -import net.minecraft.data.models.blockstates.Variant; -import net.minecraft.data.models.blockstates.VariantProperties; -import net.minecraft.data.models.model.ModelLocationUtils; -import net.minecraft.data.models.model.ModelTemplates; -import net.minecraft.data.models.model.TextureMapping; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.neoforged.neoforge.client.model.generators.BlockStateProvider; import net.neoforged.neoforge.client.model.generators.ModelBuilder; import net.neoforged.neoforge.client.model.generators.ModelFile; -import net.neoforged.neoforge.client.model.generators.MultiPartBlockStateBuilder; import net.neoforged.neoforge.common.data.ExistingFileHelper; import net.nova.nmt.init.NMTBlocks; @@ -31,6 +22,50 @@ public BlockStateAndModelProvider(PackOutput output, ExistingFileHelper existing @Override protected void registerStatesAndModels() { createGlassBlock(NMTBlocks.OBSIDIAN_GLASS.get(), NMTBlocks.OBSIDIAN_GLASS_PANE.get()); + createBrewingStand(NMTBlocks.ENDER_BREWING_STAND.get()); + } + + // Methods + public void createBrewingStand(Block block) { + itemModels().basicItem(block.asItem()); + + getMultipartBuilder(block) + .part().modelFile(models().withExistingParent(name(block), mcLoc("brewing_stand")) + .texture("particle", "block/" + name(block)) + .texture("base", "block/" + name(block) + "_base") + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel() + .end() + .part().modelFile(models().withExistingParent(name(block) + "_bottle0", mcLoc("brewing_stand").withSuffix("_bottle0")) + .texture("particle", "block/" + name(block)) + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel().condition(BlockStateProperties.HAS_BOTTLE_0, true) + .end() + .part().modelFile(models().withExistingParent(name(block) + "_bottle1", mcLoc("brewing_stand").withSuffix("_bottle1")) + .texture("particle", "block/" + name(block)) + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel().condition(BlockStateProperties.HAS_BOTTLE_1, true) + .end() + .part().modelFile(models().withExistingParent(name(block)+ "_bottle2", mcLoc("brewing_stand").withSuffix("_bottle2")) + .texture("particle", "block/" + name(block)) + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel().condition(BlockStateProperties.HAS_BOTTLE_2, true) + .end() + .part().modelFile(models().withExistingParent(name(block)+ "_empty0", mcLoc("brewing_stand").withSuffix("_empty0")) + .texture("particle", "block/" + name(block)) + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel().condition(BlockStateProperties.HAS_BOTTLE_0, false) + .end() + .part().modelFile(models().withExistingParent(name(block)+ "_empty1", mcLoc("brewing_stand").withSuffix("_empty1")) + .texture("particle", "block/" + name(block)) + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel().condition(BlockStateProperties.HAS_BOTTLE_1, false) + .end() + .part().modelFile(models().withExistingParent(name(block)+ "_empty2", mcLoc("brewing_stand").withSuffix("_empty2")) + .texture("particle", "block/" + name(block)) + .texture("stand", "block/" + name(block)).renderType(RenderType.CUTOUT.name)) + .addModel().condition(BlockStateProperties.HAS_BOTTLE_2, false) + .end(); } public void createGlassBlock(Block glassBlock, Block paneBlock) { @@ -49,42 +84,31 @@ public void createGlassBlock(Block glassBlock, Block paneBlock) { .texture("layer0", glassBlockTexture).renderType(RenderType.TRANSLUCENT.name); getMultipartBuilder(paneBlock) - .part().modelFile(postModel).addModel().end() - .part().modelFile(sideModel) - .addModel() - .condition(BlockStateProperties.NORTH, true) + .part().modelFile(postModel).addModel() .end() .part().modelFile(sideModel) - .rotationY(90) - .addModel() - .condition(BlockStateProperties.EAST, true) + .addModel().condition(BlockStateProperties.NORTH, true) .end() - .part().modelFile(sideAltModel) - .addModel() - .condition(BlockStateProperties.SOUTH, true) + .part().modelFile(sideModel).rotationY(90) + .addModel().condition(BlockStateProperties.EAST, true) .end() .part().modelFile(sideAltModel) - .rotationY(90) - .addModel() - .condition(BlockStateProperties.WEST, true) + .addModel().condition(BlockStateProperties.SOUTH, true) + .end() + .part().modelFile(sideAltModel).rotationY(90) + .addModel().condition(BlockStateProperties.WEST, true) .end() .part().modelFile(noSideModel) - .addModel() - .condition(BlockStateProperties.NORTH, false) + .addModel().condition(BlockStateProperties.NORTH, false) .end() .part().modelFile(noSideAltModel) - .addModel() - .condition(BlockStateProperties.EAST, false) + .addModel().condition(BlockStateProperties.EAST, false) .end() - .part().modelFile(noSideAltModel) - .rotationY(90) - .addModel() - .condition(BlockStateProperties.SOUTH, false) + .part().modelFile(noSideAltModel).rotationY(90) + .addModel().condition(BlockStateProperties.SOUTH, false) .end() - .part().modelFile(noSideModel) - .rotationY(270) - .addModel() - .condition(BlockStateProperties.WEST, false) + .part().modelFile(noSideModel).rotationY(270) + .addModel().condition(BlockStateProperties.WEST, false) .end(); } diff --git a/src/main/java/net/nova/nmt/data/LangProvider.java b/src/main/java/net/nova/nmt/data/LangProvider.java index c2d2df0..1ca8c9d 100644 --- a/src/main/java/net/nova/nmt/data/LangProvider.java +++ b/src/main/java/net/nova/nmt/data/LangProvider.java @@ -22,6 +22,7 @@ protected void addTranslations() { // Blocks addBlock(NMTBlocks.OBSIDIAN_GLASS, "Obsidian Glass"); addBlock(NMTBlocks.OBSIDIAN_GLASS_PANE, "Obsidian Glass Pane"); + addBlock(NMTBlocks.ENDER_BREWING_STAND, "Ender Brewing Stand"); // Items addItem(NMTItems.OBSIDIAN_GLASS_BOTTLE, "Obsidian Glass Bottle"); @@ -34,6 +35,9 @@ protected void addTranslations() { // Mob Effects addEffect(NMTEffects.BURN::value, "Burn"); + + // Block Entity + add("container.ender_brewing", "Ender Brewing Stand"); } public void addObsidianPotion(Supplier key, Holder potionName, String name) { diff --git a/src/main/java/net/nova/nmt/data/loot/BlockLootTables.java b/src/main/java/net/nova/nmt/data/loot/BlockLootTables.java index 0e9a089..e2ef158 100644 --- a/src/main/java/net/nova/nmt/data/loot/BlockLootTables.java +++ b/src/main/java/net/nova/nmt/data/loot/BlockLootTables.java @@ -5,6 +5,7 @@ import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.nova.nmt.init.NMTBlocks; import java.util.Optional; @@ -22,6 +23,7 @@ protected BlockLootTables(HolderLookup.Provider pProvider) { protected void generate() { dropSelf(NMTBlocks.OBSIDIAN_GLASS.get()); dropWhenSilkTouch(NMTBlocks.OBSIDIAN_GLASS_PANE.get()); + add(NMTBlocks.ENDER_BREWING_STAND.get(), this::createNameableBlockEntityTable); } // Loot method diff --git a/src/main/java/net/nova/nmt/init/CreativeTab.java b/src/main/java/net/nova/nmt/init/CreativeTab.java index 2d03cb9..c1d9172 100644 --- a/src/main/java/net/nova/nmt/init/CreativeTab.java +++ b/src/main/java/net/nova/nmt/init/CreativeTab.java @@ -22,6 +22,7 @@ public class CreativeTab { // Blocks output.accept(NMTBlocks.OBSIDIAN_GLASS); output.accept(NMTBlocks.OBSIDIAN_GLASS_PANE); + output.accept(NMTBlocks.ENDER_BREWING_STAND); // Items output.accept(NMTItems.OBSIDIAN_GLASS_BOTTLE); diff --git a/src/main/java/net/nova/nmt/init/NMTBlockEntities.java b/src/main/java/net/nova/nmt/init/NMTBlockEntities.java new file mode 100644 index 0000000..8224be4 --- /dev/null +++ b/src/main/java/net/nova/nmt/init/NMTBlockEntities.java @@ -0,0 +1,18 @@ +package net.nova.nmt.init; + +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.neoforged.neoforge.registries.DeferredRegister; +import net.nova.nmt.blockentity.EnderBrewingStandBlockEntity; + +import java.util.function.Supplier; + +import static net.nova.nmt.NoMoreThings.MODID; + +public class NMTBlockEntities { + public static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, MODID); + + public static final Supplier> ENDER_BREWING_STAND = BLOCK_ENTITIES.register("ender_brewing_stand", + () -> BlockEntityType.Builder.of(EnderBrewingStandBlockEntity::new, NMTBlocks.ENDER_BREWING_STAND.get()).build(null) + ); +} diff --git a/src/main/java/net/nova/nmt/init/NMTBlocks.java b/src/main/java/net/nova/nmt/init/NMTBlocks.java index 17642e4..cd67344 100644 --- a/src/main/java/net/nova/nmt/init/NMTBlocks.java +++ b/src/main/java/net/nova/nmt/init/NMTBlocks.java @@ -6,10 +6,7 @@ import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.StainedGlassBlock; -import net.minecraft.world.level.block.StainedGlassPaneBlock; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; @@ -17,6 +14,7 @@ import net.neoforged.neoforge.registries.DeferredBlock; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; +import net.nova.nmt.block.EnderBrewingStandBlock; import java.util.function.Supplier; @@ -25,6 +23,7 @@ public class NMTBlocks { public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID); + // Obsidian Glass public static DeferredBlock OBSIDIAN_GLASS = registerBlock("obsidian_glass", () -> new StainedGlassBlock(DyeColor.PURPLE, BlockBehaviour.Properties.of() .mapColor(MapColor.COLOR_BLACK) .instrument(NoteBlockInstrument.HAT) @@ -46,6 +45,13 @@ public class NMTBlocks { .noOcclusion() )); + public static final DeferredBlock ENDER_BREWING_STAND = registerBlock("ender_brewing_stand", () -> new EnderBrewingStandBlock(BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_BLACK) + .requiresCorrectToolForDrops() + .strength(0.5F).lightLevel(light -> 12) + .noOcclusion() + )); + // Methods private static boolean never(BlockState state, BlockGetter blockGetter, BlockPos pos) { return false; diff --git a/src/main/java/net/nova/nmt/init/NMTPotions.java b/src/main/java/net/nova/nmt/init/NMTPotions.java index a88cf35..d6ac711 100644 --- a/src/main/java/net/nova/nmt/init/NMTPotions.java +++ b/src/main/java/net/nova/nmt/init/NMTPotions.java @@ -12,17 +12,16 @@ public class NMTPotions { public static final DeferredRegister POTIONS = DeferredRegister.create(Registries.POTION, MODID); - public static final Holder AWFULLY = registerPotion("awfully"); - - public static final Holder LAVA = registerPotion("lava", new MobEffectInstance(NMTEffects.BURN, 900)); - - // Method - public static Holder registerPotion(String name, MobEffectInstance... effects) { - return POTIONS.register(name, () -> new Potion(effects) { - @Override - public boolean isEnabled(FeatureFlagSet enabledFeatures) { - return false; - } - }); - } + public static final Holder AWFULLY = POTIONS.register("awfully", () -> new Potion() { + @Override + public boolean isEnabled(FeatureFlagSet enabledFeatures) { + return false; + } + }); + public static final Holder LAVA = POTIONS.register("lava", () -> new Potion(new MobEffectInstance(NMTEffects.BURN, 900)) { + @Override + public boolean isEnabled(FeatureFlagSet enabledFeatures) { + return false; + } + }); } diff --git a/src/main/java/net/nova/nmt/util/NMTPotion.java b/src/main/java/net/nova/nmt/util/NMTPotion.java deleted file mode 100644 index d7a3ad9..0000000 --- a/src/main/java/net/nova/nmt/util/NMTPotion.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.nova.nmt.util; - -import net.minecraft.world.flag.FeatureFlagSet; -import net.minecraft.world.item.alchemy.Potion; - -public class NMTPotion extends Potion { - @Override - public boolean isEnabled(FeatureFlagSet enabledFeatures) { - return false; - } -} diff --git a/src/main/resources/assets/nmt/textures/block/ender_brewing_stand.png b/src/main/resources/assets/nmt/textures/block/ender_brewing_stand.png new file mode 100644 index 0000000000000000000000000000000000000000..944f74ff2bbde3cec51fb0bc325fc4b081f557cf GIT binary patch literal 370 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Lh(0G|+78yg#6UtdE*!^FhIZ;#H($;ia%C^gyYM@B~e|Mu+v|NoP{Z6>&x zlI@T=eI$QV+SEDae*4sD`t^BeIx*f$tCq zGm2_>H2?);JY5_^Brf~*UF2*q;Bo0ct>o_Y-@EyoViUJTG={I{3E Z<^~Jrr@xL541o49c)I$ztaD0e0su1{Oilm* literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/nmt/textures/item/ender_brewing_stand.png b/src/main/resources/assets/nmt/textures/item/ender_brewing_stand.png new file mode 100644 index 0000000000000000000000000000000000000000..fca121fdcaad61492474564961792ef0fb8b79e3 GIT binary patch literal 275 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}50G|+7AZ=)9`0dlP|NsAgdvrD^DCqyUXVKBo-(HlBSEK+1BRpLkLo|YW&)nrZ zAi%@=VBu?i>-Yb6EsiMIs{Ar@-x58UpPY;xC$pUx0%tS73z*-}xPp7~_3tZPrtR}h zxa;6^a~IEvC6(+;MUQZ0zBCt|CuY39a?=xr2dwWla=V