diff --git a/src/generated/resources/.cache/41a2d86d7e58f5ff289dc10f1d54cfe65982de55 b/src/generated/resources/.cache/41a2d86d7e58f5ff289dc10f1d54cfe65982de55 index cf7900af..c73612eb 100644 --- a/src/generated/resources/.cache/41a2d86d7e58f5ff289dc10f1d54cfe65982de55 +++ b/src/generated/resources/.cache/41a2d86d7e58f5ff289dc10f1d54cfe65982de55 @@ -1 +1,3 @@ -// 1.21.1 2024-09-06T15:44:54.6497465 Tags for minecraft:block mod id modjam +// 1.21.1 2024-09-08T21:50:31.0045618 Tags for minecraft:block mod id modjam +4f2c21d55cdc7aae6eb4ca328cb46cd52b6837c1 data/minecraft/tags/block/mineable/axe.json +4f2c21d55cdc7aae6eb4ca328cb46cd52b6837c1 data/minecraft/tags/block/mineable/pickaxe.json diff --git a/src/generated/resources/.cache/5db5b310cf1abc4c7f33d2d565e2a2290a7f6c4d b/src/generated/resources/.cache/5db5b310cf1abc4c7f33d2d565e2a2290a7f6c4d index ab9af2ee..0ad77f1f 100644 --- a/src/generated/resources/.cache/5db5b310cf1abc4c7f33d2d565e2a2290a7f6c4d +++ b/src/generated/resources/.cache/5db5b310cf1abc4c7f33d2d565e2a2290a7f6c4d @@ -1,8 +1,10 @@ -// 1.21.1 2024-09-08T11:01:34.5874471 Item Models: modjam +// 1.21.1 2024-09-08T20:54:17.6791305 Item Models: modjam 207e815e9b4c9ebca4f444f877e2488a5ce9b1c5 assets/modjam/models/item/aquarine_steel.json 51765874ad3111adf69684269ad9a422bfbaac4a assets/modjam/models/item/aquarine_steel_block.json dd0c37deb1f33fb0844da4a540706681887fc3d4 assets/modjam/models/item/aquatic_catalyst.json 246cda7a0fca8b278dd6ed5392d0ce745d9fa097 assets/modjam/models/item/chiseled_dark_prismarine.json +4d6b8c829a1afa42db37e92f67ddf057d763b124 assets/modjam/models/item/crate.json +b918bbc26234f9f47c0330279cee33fb368261df assets/modjam/models/item/crowbar.json 5dd5fd7a7c348bbaf51df14605c5241bf75e18ae assets/modjam/models/item/dark_prismarine_pillar.json 4d48047a9639345841262719f87f57c3494e4a55 assets/modjam/models/item/deep_sea_drain.json 5b6b9e8621c065cb4167e4b6dfdfaecb0fd7186d assets/modjam/models/item/eas_vial.json diff --git a/src/generated/resources/.cache/7383b985a2cdbb3a068dc5fd3ae4ba545545c370 b/src/generated/resources/.cache/7383b985a2cdbb3a068dc5fd3ae4ba545545c370 index da07c6bf..7ae3030d 100644 --- a/src/generated/resources/.cache/7383b985a2cdbb3a068dc5fd3ae4ba545545c370 +++ b/src/generated/resources/.cache/7383b985a2cdbb3a068dc5fd3ae4ba545545c370 @@ -1,7 +1,8 @@ -// 1.21.1 2024-09-08T14:54:06.450838244 Block States: modjam +// 1.21.1 2024-09-08T21:58:23.7229483 Block States: modjam af3ef9c17c60ced537516e8aa1215fcb76e3683e assets/modjam/blockstates/aquarine_steel_block.json 865a45a4d022b56bc54dc32dae4b666af2df7d6f assets/modjam/blockstates/aquatic_catalyst.json 6e42254717fc67a953282f50517eb06c02193129 assets/modjam/blockstates/chiseled_dark_prismarine.json +3f474de85f7cf428f3ecd383cde71be56c940ecd assets/modjam/blockstates/crate.json 791da2d01b6b33bb1ce175d5c9c1fa5b737c9dfc assets/modjam/blockstates/dark_prismarine_pillar.json 74a08c3614f8cf6dace6f155476015776d839ce1 assets/modjam/blockstates/deep_sea_drain_part.json 5ca1917566d04d2f7fefbfa648958c06d3238f67 assets/modjam/models/block/aquarine_steel_block.json @@ -33,3 +34,5 @@ c6666b1b7a9b97708afc337463d65c098bcd0c38 assets/modjam/models/block/deep_sea_dra 8149cf16f075d4a3e9ccb4f224376ed7011e3db9 assets/modjam/models/block/deep_sea_drain_part_7_open.json c726d4f7c530beadc3bb9035ea46017faba9f4f2 assets/modjam/models/block/deep_sea_drain_part_8.json c726d4f7c530beadc3bb9035ea46017faba9f4f2 assets/modjam/models/block/deep_sea_drain_part_8_open.json +944f8a549bbc7f13a4b7022e63d680f6d533d68b assets/modjam/models/block/rusty_crate.json +e9266445328047f5d61b4e0d111da3842d005fa8 assets/modjam/models/block/rusty_crate_open.json diff --git a/src/generated/resources/assets/modjam/blockstates/crate.json b/src/generated/resources/assets/modjam/blockstates/crate.json new file mode 100644 index 00000000..7015cea4 --- /dev/null +++ b/src/generated/resources/assets/modjam/blockstates/crate.json @@ -0,0 +1,16 @@ +{ + "variants": { + "open=false,rusty=false": { + "model": "modjam:block/crate" + }, + "open=false,rusty=true": { + "model": "modjam:block/rusty_crate" + }, + "open=true,rusty=false": { + "model": "modjam:block/crate_open" + }, + "open=true,rusty=true": { + "model": "modjam:block/rusty_crate_open" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/modjam/models/block/rusty_crate.json b/src/generated/resources/assets/modjam/models/block/rusty_crate.json new file mode 100644 index 00000000..771132d4 --- /dev/null +++ b/src/generated/resources/assets/modjam/models/block/rusty_crate.json @@ -0,0 +1,9 @@ +{ + "parent": "modjam:block/crate", + "textures": { + "2": "modjam:block/crate/rusty_top_inner", + "4": "modjam:block/crate/rusty", + "5": "modjam:block/crate/rusty_top", + "particle": "modjam:block/crate/rusty" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/modjam/models/block/rusty_crate_open.json b/src/generated/resources/assets/modjam/models/block/rusty_crate_open.json new file mode 100644 index 00000000..3ba1841a --- /dev/null +++ b/src/generated/resources/assets/modjam/models/block/rusty_crate_open.json @@ -0,0 +1,9 @@ +{ + "parent": "modjam:block/crate_open", + "textures": { + "2": "modjam:block/crate/rusty_top_inner", + "4": "modjam:block/crate/rusty", + "5": "modjam:block/crate/rusty_top", + "particle": "modjam:block/crate/rusty" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/modjam/models/item/crate.json b/src/generated/resources/assets/modjam/models/item/crate.json new file mode 100644 index 00000000..46dc11ee --- /dev/null +++ b/src/generated/resources/assets/modjam/models/item/crate.json @@ -0,0 +1,3 @@ +{ + "parent": "modjam:block/crate" +} \ No newline at end of file diff --git a/src/generated/resources/assets/modjam/models/item/crowbar.json b/src/generated/resources/assets/modjam/models/item/crowbar.json new file mode 100644 index 00000000..c6790d8c --- /dev/null +++ b/src/generated/resources/assets/modjam/models/item/crowbar.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "modjam:item/crowbar" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/block/mineable/axe.json b/src/generated/resources/data/minecraft/tags/block/mineable/axe.json new file mode 100644 index 00000000..4093cd23 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/block/mineable/axe.json @@ -0,0 +1,5 @@ +{ + "values": [ + "modjam:crate" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/block/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/block/mineable/pickaxe.json new file mode 100644 index 00000000..4093cd23 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/block/mineable/pickaxe.json @@ -0,0 +1,5 @@ +{ + "values": [ + "modjam:crate" + ] +} \ No newline at end of file diff --git a/src/main/java/com/portingdeadmods/modjam/ModJam.java b/src/main/java/com/portingdeadmods/modjam/ModJam.java index 4d436ba3..b459947d 100644 --- a/src/main/java/com/portingdeadmods/modjam/ModJam.java +++ b/src/main/java/com/portingdeadmods/modjam/ModJam.java @@ -41,6 +41,7 @@ public ModJam(IEventBus modEventBus, ModContainer modContainer) { MJCreativeTabs.CREATIVE_MODE_TABS.register(modEventBus); MJDataComponents.DATA_COMPONENT_TYPES.register(modEventBus); MJMultiblocks.MULTIBLOCKS.register(modEventBus); + MJMenuTypes.MENUS.register(modEventBus); modEventBus.addListener(PrismMonocleItem::registerCapabilities); diff --git a/src/main/java/com/portingdeadmods/modjam/client/screen/CrateScreen.java b/src/main/java/com/portingdeadmods/modjam/client/screen/CrateScreen.java new file mode 100644 index 00000000..ac0cb9f8 --- /dev/null +++ b/src/main/java/com/portingdeadmods/modjam/client/screen/CrateScreen.java @@ -0,0 +1,34 @@ +package com.portingdeadmods.modjam.client.screen; + +import com.portingdeadmods.modjam.inventory.CrateMenu; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ShulkerBoxMenu; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public class CrateScreen extends AbstractContainerScreen { + private static final ResourceLocation CONTAINER_TEXTURE = ResourceLocation.withDefaultNamespace("textures/gui/container/shulker_box.png"); + + public CrateScreen(CrateMenu menu, Inventory playerInventory, Component title) { + super(menu, playerInventory, title); + this.imageHeight++; + } + + @Override + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + super.render(guiGraphics, mouseX, mouseY, partialTick); + this.renderTooltip(guiGraphics, mouseX, mouseY); + } + + @Override + protected void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) { + int i = (this.width - this.imageWidth) / 2; + int j = (this.height - this.imageHeight) / 2; + guiGraphics.blit(CONTAINER_TEXTURE, i, j, 0, 0, this.imageWidth, this.imageHeight); + } +} \ No newline at end of file diff --git a/src/main/java/com/portingdeadmods/modjam/compat/jei/ItemTransformationRecipeCategory.java b/src/main/java/com/portingdeadmods/modjam/compat/jei/ItemTransformationRecipeCategory.java index 28a99346..f1036284 100644 --- a/src/main/java/com/portingdeadmods/modjam/compat/jei/ItemTransformationRecipeCategory.java +++ b/src/main/java/com/portingdeadmods/modjam/compat/jei/ItemTransformationRecipeCategory.java @@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable; public class ItemTransformationRecipeCategory implements IRecipeCategory { - private static final ResourceLocation BURN_PROGRESS_SPRITE = ResourceLocation.withDefaultNamespace("container/furnace/burn_progress"); + private static final ResourceLocation BURN_PROGRESS_SPRITE = ResourceLocation.fromNamespaceAndPath(ModJam.MODID,"container/furnace/empty_arrow"); public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "item_transformation"); public static final RecipeType RECIPE_TYPE = new RecipeType<>(UID, ItemTransformationRecipe.class); @@ -56,9 +56,8 @@ public IDrawable getBackground() { @Override public void draw(ItemTransformationRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { IRecipeCategory.super.draw(recipe, recipeSlotsView, guiGraphics, mouseX, mouseY); - guiGraphics.blitSprite(BURN_PROGRESS_SPRITE, 0, 0, 24, 16); + guiGraphics.blitSprite(BURN_PROGRESS_SPRITE, 28, 0, 24, 16); } - @Override public void setRecipe(IRecipeLayoutBuilder builder, ItemTransformationRecipe recipe, IFocusGroup focuses) { //Just one input slot, an arrow and an output slot @@ -66,8 +65,4 @@ public void setRecipe(IRecipeLayoutBuilder builder, ItemTransformationRecipe rec builder.addSlot(RecipeIngredientRole.OUTPUT, 64, 0).addItemStack(recipe.getResultItem(null)); } - public static void drawImg(GuiGraphics guiGraphics, ResourceLocation texturePath, int x, int y, int width, int height) { - guiGraphics.blit(texturePath, x, y, 0, 0, 0, width, height, width, height); - } - } diff --git a/src/main/java/com/portingdeadmods/modjam/content/blockentities/CrateBlockEntity.java b/src/main/java/com/portingdeadmods/modjam/content/blockentities/CrateBlockEntity.java new file mode 100644 index 00000000..567aaf46 --- /dev/null +++ b/src/main/java/com/portingdeadmods/modjam/content/blockentities/CrateBlockEntity.java @@ -0,0 +1,152 @@ +package com.portingdeadmods.modjam.content.blockentities; + +import com.portingdeadmods.modjam.data.MJDataComponents; +import com.portingdeadmods.modjam.inventory.CrateMenu; +import com.portingdeadmods.modjam.registries.MJBlockEntityTypes; +import com.portingdeadmods.modjam.registries.MJDataAttachments; +import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.NonNullList; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.Container; +import net.minecraft.world.ContainerHelper; +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.ChestMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.ContainerOpenersCounter; +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class CrateBlockEntity extends RandomizableContainerBlockEntity { + private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); + private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { + @Override + protected void onOpen(Level p_155062_, BlockPos p_155063_, BlockState p_155064_) { + CrateBlockEntity.this.playSound(p_155064_, SoundEvents.BARREL_OPEN); + } + + @Override + protected void onClose(Level p_155072_, BlockPos p_155073_, BlockState p_155074_) { + CrateBlockEntity.this.playSound(p_155074_, SoundEvents.BARREL_CLOSE); + } + + @Override + protected void openerCountChanged(Level p_155066_, BlockPos p_155067_, BlockState p_155068_, int p_155069_, int p_155070_) { + } + + @Override + protected boolean isOwnContainer(Player p_155060_) { + if (p_155060_.containerMenu instanceof ChestMenu) { + Container container = ((ChestMenu)p_155060_.containerMenu).getContainer(); + return container == CrateBlockEntity.this; + } else { + return false; + } + } + }; + + + public CrateBlockEntity( BlockPos blockPos, BlockState blockState) { + super(MJBlockEntityTypes.CRATE.get(), blockPos, blockState); + } + + @Override + protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.saveAdditional(tag, registries); + if (!this.trySaveLootTable(tag)) { + ContainerHelper.saveAllItems(tag, this.items, registries); + } + } + + @Override + protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.loadAdditional(tag, registries); + this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + if (!this.tryLoadLootTable(tag)) { + ContainerHelper.loadAllItems(tag, this.items, registries); + } + } + + @Override + protected void collectImplicitComponents(DataComponentMap.Builder components) { + super.collectImplicitComponents(components); + components.set(MJDataComponents.OPEN.get(),getBlockState().getValue(BlockStateProperties.OPEN)); + } + + @Override + protected void applyImplicitComponents(DataComponentInput componentInput) { + super.applyImplicitComponents(componentInput); + level.setBlockAndUpdate(getBlockPos(),getBlockState().setValue(BlockStateProperties.OPEN,componentInput.getOrDefault(MJDataComponents.OPEN,false))); + } + + @Override + public int getContainerSize() { + return 27; + } + + @Override + protected NonNullList getItems() { + return this.items; + } + + @Override + protected void setItems(NonNullList items) { + this.items = items; + } + + @Override + protected Component getDefaultName() { + return getBlockState().getBlock().getName(); + } + + @Override + protected AbstractContainerMenu createMenu(int id, Inventory player) { + return new CrateMenu(id,player,this); + } + + @Override + public void startOpen(Player player) { + if (!this.remove && !player.isSpectator()) { + this.openersCounter.incrementOpeners(player, this.getLevel(), this.getBlockPos(), this.getBlockState()); + } + } + + @Override + public void stopOpen(Player player) { + if (!this.remove && !player.isSpectator()) { + this.openersCounter.decrementOpeners(player, this.getLevel(), this.getBlockPos(), this.getBlockState()); + } + } + + public void recheckOpen() { + if (!this.remove) { + this.openersCounter.recheckOpeners(this.getLevel(), this.getBlockPos(), this.getBlockState()); + } + } + + @Override + public boolean canPlaceItem(int slot, ItemStack stack) { + return getBlockState().getValue(BlockStateProperties.OPEN) && super.canPlaceItem(slot, stack); + } + + @Override + public boolean canTakeItem(Container target, int slot, ItemStack stack) { + return getBlockState().getValue(BlockStateProperties.OPEN) && super.canTakeItem(target, slot, stack); + } + + public void playSound(BlockState state, SoundEvent sound) { + double d0 = (double)this.worldPosition.getX() + 0.5; + double d1 = (double)this.worldPosition.getY() + 0.5; + double d2 = (double)this.worldPosition.getZ() + 0.5; + this.level.playSound(null, d0, d1, d2, sound, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F); + } +} diff --git a/src/main/java/com/portingdeadmods/modjam/content/blocks/CrateBlock.java b/src/main/java/com/portingdeadmods/modjam/content/blocks/CrateBlock.java new file mode 100644 index 00000000..ce6ec895 --- /dev/null +++ b/src/main/java/com/portingdeadmods/modjam/content/blocks/CrateBlock.java @@ -0,0 +1,186 @@ +package com.portingdeadmods.modjam.content.blocks; + +import com.mojang.serialization.MapCodec; +import com.portingdeadmods.modjam.content.blockentities.CrateBlockEntity; +import com.portingdeadmods.modjam.registries.MJBlocks; +import com.portingdeadmods.modjam.registries.MJItems; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.stats.Stats; +import net.minecraft.util.RandomSource; +import net.minecraft.world.*; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.piglin.PiglinAi; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +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.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.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +import static net.minecraft.world.level.block.ShulkerBoxBlock.CONTENTS; + +public class CrateBlock extends BaseEntityBlock { + + public static final BooleanProperty RUSTY = BooleanProperty.create("rusty"); + + public CrateBlock(Properties properties) { + super(properties); + registerDefaultState(defaultBlockState() + .setValue(RUSTY,false) + .setValue(BlockStateProperties.OPEN,false) + ); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder.add(RUSTY,BlockStateProperties.OPEN)); + } + + @Override + protected RenderShape getRenderShape(BlockState state) { + return RenderShape.MODEL; + } + + @Override + protected MapCodec codec() { + return simpleCodec(CrateBlock::new); + } + + @Override + protected @NotNull ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + if (level.isClientSide) return ItemInteractionResult.sidedSuccess(true); + if (state.getValue(BlockStateProperties.OPEN)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + if (!(level.getBlockEntity(pos) instanceof CrateBlockEntity be)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + if (stack.isEmpty()) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + if (!stack.is(MJItems.CROWBAR)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + if (player.getCooldowns().isOnCooldown(stack.getItem())) return ItemInteractionResult.FAIL; + if (Math.random() > 0.1){ + be.playSound(state,SoundEvents.ANVIL_HIT); + player.getCooldowns().addCooldown(stack.getItem(),10); + return ItemInteractionResult.FAIL; + } + level.setBlockAndUpdate(pos,state.setValue(BlockStateProperties.OPEN,true)); + player.getCooldowns().addCooldown(stack.getItem(),30); + be.playSound(state,SoundEvents.ANVIL_USE); + + return ItemInteractionResult.SUCCESS; + } + + @Override + protected @NotNull InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { + if (level.isClientSide) { + return InteractionResult.SUCCESS; + } else if (player.isSpectator()) { + return InteractionResult.CONSUME; + } else if (level.getBlockEntity(pos) instanceof CrateBlockEntity be) { + if (state.getValue(BlockStateProperties.OPEN)) { + player.openMenu(be); + player.awardStat(Stats.OPEN_BARREL); + PiglinAi.angerNearbyPiglins(player, true); + } else { + be.playSound(state,SoundEvents.CHEST_LOCKED); + } + return InteractionResult.CONSUME; + } else { + return InteractionResult.PASS; + } + } + + @Override + protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + VoxelShape shape = Shapes.empty(); + shape = Shapes.join(shape, Shapes.box(0.1875, 0.125, 0.1875, 0.8125, 0.75, 0.8125), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0, 0.0625, 0.9375, 0.125, 0.1875), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0, 0.1875, 0.1875, 0.125, 0.8125), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.8125, 0, 0.1875, 0.9375, 0.125, 0.8125), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0, 0.8125, 0.9375, 0.125, 0.9375), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0.125, 0.0625, 0.1875, 0.75, 0.1875), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.8125, 0.125, 0.0625, 0.9375, 0.75, 0.1875), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.8125, 0.125, 0.8125, 0.9375, 0.75, 0.9375), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0.125, 0.8125, 0.1875, 0.75, 0.9375), BooleanOp.OR); + + if (!state.getValue(BlockStateProperties.OPEN)){ + shape = Shapes.join(shape, Shapes.box(0.1875, 0.75, 0.1875, 0.8125, 0.8125, 0.8125), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0.75, 0.8125, 0.9375, 0.875, 0.9375), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0.75, 0.1875, 0.1875, 0.875, 0.8125), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.0625, 0.75, 0.0625, 0.9375, 0.875, 0.1875), BooleanOp.OR); + shape = Shapes.join(shape, Shapes.box(0.8125, 0.75, 0.1875, 0.9375, 0.875, 0.8125), BooleanOp.OR); + } + return shape; + } + + @Override + public @Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new CrateBlockEntity(pos,state); + } + + @Override + public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) { + if (level.isClientSide())return super.playerWillDestroy(level, pos, state, player); + BlockEntity blockentity = level.getBlockEntity(pos); + if (blockentity instanceof CrateBlockEntity be) { + if (be.isEmpty() && !state.getValue(BlockStateProperties.OPEN)){ + ItemStack itemstack = MJBlocks.CRATE.toStack(); + itemstack.applyComponents(blockentity.collectComponents()); + ItemEntity itementity = new ItemEntity( + level, (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5, itemstack + ); + itementity.setDefaultPickUpDelay(); + level.addFreshEntity(itementity); + } + } + + return super.playerWillDestroy(level, pos, state, player); + } + + @Override + protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston) { + if (state.getValue(BlockStateProperties.OPEN)){ + Containers.dropContentsOnDestroy(state, newState, level, pos); + return; + } + super.onRemove(state, level, pos, newState, movedByPiston); + } + + @Override + protected List getDrops(BlockState state, LootParams.Builder params) { + BlockEntity blockentity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); + if (blockentity instanceof CrateBlockEntity be) { + params = params.withDynamicDrop(CONTENTS, p_56219_ -> { + for (int i = 0; i < be.getContainerSize(); i++) { + p_56219_.accept(be.getItem(i)); + } + }); + } + + return super.getDrops(state, params); + } + + + @Override + protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { + BlockEntity blockentity = level.getBlockEntity(pos); + if (blockentity instanceof CrateBlockEntity) { + ((CrateBlockEntity)blockentity).recheckOpen(); + } + } +} diff --git a/src/main/java/com/portingdeadmods/modjam/data/MJDataComponents.java b/src/main/java/com/portingdeadmods/modjam/data/MJDataComponents.java index fa6cc3b0..04ed1a6c 100644 --- a/src/main/java/com/portingdeadmods/modjam/data/MJDataComponents.java +++ b/src/main/java/com/portingdeadmods/modjam/data/MJDataComponents.java @@ -1,8 +1,10 @@ package com.portingdeadmods.modjam.data; +import com.mojang.serialization.Codec; import com.portingdeadmods.modjam.ModJam; import com.portingdeadmods.modjam.data.components.ComponentPowerStorage; import net.minecraft.core.component.DataComponentType; +import net.minecraft.network.codec.ByteBufCodecs; import net.neoforged.neoforge.fluids.SimpleFluidContent; import net.neoforged.neoforge.registries.DeferredRegister; @@ -16,6 +18,8 @@ public final class MJDataComponents { () -> builder -> builder.persistent(ComponentPowerStorage.CODEC).networkSynchronized(ComponentPowerStorage.STREAM_CODEC)); public static final Supplier> FLUID = registerDataComponentType("fluid", () -> builder -> builder.persistent(SimpleFluidContent.CODEC).networkSynchronized(SimpleFluidContent.STREAM_CODEC)); + public static final Supplier> OPEN = registerDataComponentType("open", + () -> builder -> builder.persistent(Codec.BOOL).networkSynchronized(ByteBufCodecs.BOOL)); public static Supplier> registerDataComponentType( String name, Supplier>> builderOperator) { diff --git a/src/main/java/com/portingdeadmods/modjam/datagen/BlockModelProvider.java b/src/main/java/com/portingdeadmods/modjam/datagen/BlockModelProvider.java index 994442e2..6b689258 100644 --- a/src/main/java/com/portingdeadmods/modjam/datagen/BlockModelProvider.java +++ b/src/main/java/com/portingdeadmods/modjam/datagen/BlockModelProvider.java @@ -4,6 +4,7 @@ import com.portingdeadmods.modjam.ModJam; import com.portingdeadmods.modjam.api.multiblocks.Multiblock; import com.portingdeadmods.modjam.content.blocks.AquaticCatalystBlock; +import com.portingdeadmods.modjam.content.blocks.CrateBlock; import com.portingdeadmods.modjam.content.blocks.multiblock.part.DrainPartBlock; import com.portingdeadmods.modjam.content.multiblocks.DrainMultiblock; import com.portingdeadmods.modjam.registries.MJBlocks; @@ -30,8 +31,30 @@ protected void registerStatesAndModels() { simpleBlock(MJBlocks.AQUARINE_STEEL_BLOCK.get()); aquaticCatalyst(MJBlocks.AQUATIC_CATALYST.get()); drainPart(MJBlocks.DRAIN_PART.get(), IntegerRange.of(0, 8)); + crateBlock(MJBlocks.CRATE.get()); } + private void crateBlock(CrateBlock crateBlock) { + VariantBlockStateBuilder builder = getVariantBuilder(crateBlock); + builder.partialState().with(CrateBlock.RUSTY,false).with(BlockStateProperties.OPEN,false) + .modelForState().modelFile(models().getExistingFile(existingModelFile(crateBlock))).addModel(); + builder.partialState().with(CrateBlock.RUSTY,true).with(BlockStateProperties.OPEN,false) + .modelForState().modelFile(rustedCrateModel(crateBlock,false)).addModel(); + builder.partialState().with(CrateBlock.RUSTY,false).with(BlockStateProperties.OPEN,true) + .modelForState().modelFile(models().getExistingFile(extend(existingModelFile(crateBlock),"_open"))).addModel(); + builder.partialState().with(CrateBlock.RUSTY,true).with(BlockStateProperties.OPEN,true) + .modelForState().modelFile(rustedCrateModel(crateBlock,true)).addModel(); + } + + private ModelFile rustedCrateModel(CrateBlock block,boolean open) { + return models().withExistingParent("rusty_" + name(block) + (open ? "_open": ""), extend(existingModelFile(block),open ? "_open":"")) + .texture("2", "modjam:block/crate/rusty_top_inner") + .texture("4", "modjam:block/crate/rusty") + .texture("5", "modjam:block/crate/rusty_top") + .texture("particle", "modjam:block/crate/rusty"); + } + + private void drainPart(DrainPartBlock drainPartBlock, IntegerRange range) { VariantBlockStateBuilder builder = getVariantBuilder(drainPartBlock); builder.partialState().with(DrainMultiblock.FORMED, false) diff --git a/src/main/java/com/portingdeadmods/modjam/datagen/BlockTagProvider.java b/src/main/java/com/portingdeadmods/modjam/datagen/BlockTagProvider.java index 9f4f2264..c17be797 100644 --- a/src/main/java/com/portingdeadmods/modjam/datagen/BlockTagProvider.java +++ b/src/main/java/com/portingdeadmods/modjam/datagen/BlockTagProvider.java @@ -1,8 +1,10 @@ package com.portingdeadmods.modjam.datagen; import com.portingdeadmods.modjam.ModJam; +import com.portingdeadmods.modjam.registries.MJBlocks; import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; +import net.minecraft.tags.BlockTags; import net.neoforged.neoforge.common.data.BlockTagsProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; import org.jetbrains.annotations.Nullable; @@ -18,5 +20,9 @@ public BlockTagProvider(PackOutput output, CompletableFuture> DRAIN_PART = BLOCK_ENTITIES.register("drain_part", () -> BlockEntityType.Builder.of(DrainPartBlockEntity::new, MJBlocks.DRAIN_PART.get()).build(null)); + public static final Supplier> CRATE = BLOCK_ENTITIES.register("crate", + () -> BlockEntityType.Builder.of(CrateBlockEntity::new, + MJBlocks.CRATE.get()).build(null)); } diff --git a/src/main/java/com/portingdeadmods/modjam/registries/MJBlocks.java b/src/main/java/com/portingdeadmods/modjam/registries/MJBlocks.java index 5b18097b..5531ed56 100644 --- a/src/main/java/com/portingdeadmods/modjam/registries/MJBlocks.java +++ b/src/main/java/com/portingdeadmods/modjam/registries/MJBlocks.java @@ -2,6 +2,7 @@ import com.portingdeadmods.modjam.ModJam; import com.portingdeadmods.modjam.content.blocks.AquaticCatalystBlock; +import com.portingdeadmods.modjam.content.blocks.CrateBlock; import com.portingdeadmods.modjam.content.blocks.multiblock.controller.DrainBlock; import com.portingdeadmods.modjam.content.blocks.multiblock.part.DrainPartBlock; import net.minecraft.world.item.BlockItem; @@ -28,6 +29,9 @@ public final class MJBlocks { BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK)); public static final DeferredBlock AQUATIC_CATALYST = registerBlockAndItem("aquatic_catalyst", AquaticCatalystBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.DARK_PRISMARINE).lightLevel(state -> state.getValue(AquaticCatalystBlock.CORE_ACTIVE) ? 12 : 0)); + public static final DeferredBlock CRATE = registerBlockAndItem("crate", CrateBlock::new, + BlockBehaviour.Properties.ofFullCopy(Blocks.BARREL)); + // MULTIBLOCKS public static final DeferredBlock DRAIN = registerBlockAndItem("deep_sea_drain", DrainBlock::new, diff --git a/src/main/java/com/portingdeadmods/modjam/registries/MJItems.java b/src/main/java/com/portingdeadmods/modjam/registries/MJItems.java index f49bfc3a..9bbee8f1 100644 --- a/src/main/java/com/portingdeadmods/modjam/registries/MJItems.java +++ b/src/main/java/com/portingdeadmods/modjam/registries/MJItems.java @@ -43,6 +43,8 @@ public final class MJItems { public static final DeferredItem ELECTROLYTE_ALGAE_SERUM_BUCKET = registerItemBucket("electrolyte_algae_serum_bucket", () -> new BucketItem(MJFluids.ELECTROLYTE_ALGAE_SERUM_SOURCE.get(), new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))); + public static final DeferredItem CROWBAR = registerItem("crowbar",Item::new,new Item.Properties().stacksTo(1)); + public static DeferredItem registerItem(String name, Function itemConstructor, Item.Properties properties) { return registerItem(name, itemConstructor, properties, true); diff --git a/src/main/java/com/portingdeadmods/modjam/registries/MJMenuTypes.java b/src/main/java/com/portingdeadmods/modjam/registries/MJMenuTypes.java new file mode 100644 index 00000000..3651e0bb --- /dev/null +++ b/src/main/java/com/portingdeadmods/modjam/registries/MJMenuTypes.java @@ -0,0 +1,32 @@ +package com.portingdeadmods.modjam.registries; + +import com.mojang.serialization.Codec; +import com.portingdeadmods.modjam.ModJam; +import com.portingdeadmods.modjam.inventory.CrateMenu; +import com.portingdeadmods.modjam.utils.CodecUtils; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.neoforged.neoforge.attachment.AttachmentType; +import net.neoforged.neoforge.common.extensions.IMenuTypeExtension; +import net.neoforged.neoforge.network.IContainerFactory; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; +import net.neoforged.neoforge.registries.NeoForgeRegistries; + +import java.util.Set; +import java.util.function.Supplier; + +public final class MJMenuTypes { + public static final DeferredRegister> MENUS = DeferredRegister.create(BuiltInRegistries.MENU, ModJam.MODID); + + public static final DeferredHolder,MenuType> CRATE = registerMenuType(CrateMenu::new,"crate"); + + + + private static DeferredHolder,MenuType> registerMenuType(IContainerFactory factory, + String name) { + return MENUS.register(name, () -> IMenuTypeExtension.create(factory)); + } +} diff --git a/src/main/resources/assets/modjam/lang/en_us.json b/src/main/resources/assets/modjam/lang/en_us.json index e00453b6..96ff56d6 100644 --- a/src/main/resources/assets/modjam/lang/en_us.json +++ b/src/main/resources/assets/modjam/lang/en_us.json @@ -11,11 +11,13 @@ "item.modjam.electrolyte_algae_serum_bucket": "Electrolyte Algae Serum (EAS) Bucket", "item.modjam.glass_vial": "Glass Vial", "item.modjam.eas_vial": "Vial of Electrolyte Algae Serum", + "item.modjam.crowbar": "Crowbar", "block.modjam.aquarine_steel_block": "Aquarine Steel Block", "block.modjam.aquatic_catalyst": "Aquatic Catalyst", "block.modjam.dark_prismarine_pillar": "Dark Prismarine Pillar", "block.modjam.chiseled_dark_prismarine": "Chiseled Dark Prismarine", + "block.modjam.crate": "Crate", "multiblock.info.failed_to_construct": "Missing or invalid block", diff --git a/src/main/resources/assets/modjam/models/block/crate.json b/src/main/resources/assets/modjam/models/block/crate.json new file mode 100644 index 00000000..fd570a46 --- /dev/null +++ b/src/main/resources/assets/modjam/models/block/crate.json @@ -0,0 +1,238 @@ +{ + "credit": "Made with Blockbench and by iglee42", + "parent": "minecraft:block/cube_bottom_top", + "texture_size": [14, 14], + "textures": { + "2": "modjam:block/crate/top_inner", + "4": "modjam:block/crate/base", + "5": "modjam:block/crate/top", + "particle": "modjam:block/crate/base" + }, + "elements": [ + { + "from": [3, 2, 3], + "to": [13, 12, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [15, 11.75, 15]}, + "faces": { + "north": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "east": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "south": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "west": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#2"}, + "down": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#5"} + } + }, + { + "from": [1, 0, 13], + "to": [15, 2, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 12]}, + "faces": { + "north": {"uv": [16, 13.71429, 0, 16], "texture": "#5"}, + "east": {"uv": [16, 13.71429, 13.71429, 16], "texture": "#4"}, + "south": {"uv": [0, 13.71429, 16, 16], "texture": "#4"}, + "west": {"uv": [2.28571, 13.71429, 0, 16], "texture": "#4"}, + "up": {"uv": [0, 13.71429, 16, 16], "texture": "#5"}, + "down": {"uv": [16, 0, 0, 2.28571], "texture": "#5"} + } + }, + { + "from": [13, 0, 3], + "to": [15, 2, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 12]}, + "faces": { + "east": {"uv": [4.57143, 0, 16, 2.28571], "rotation": 180, "texture": "#4"}, + "west": {"uv": [13.71429, 2.28571, 16, 13.71429], "rotation": 90, "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 13.71429], "texture": "#5"}, + "down": {"uv": [0, 0, 11.42857, 2.28571], "rotation": 90, "texture": "#5"} + } + }, + { + "from": [1, 0, 3], + "to": [3, 2, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [-12, 1, 12]}, + "faces": { + "east": {"uv": [0, 13.71429, 2.28571, 2.28571], "rotation": 90, "texture": "#5"}, + "west": {"uv": [0, 16, 11.42857, 13.71429], "rotation": 180, "texture": "#4"}, + "up": {"uv": [0, 2.28571, 2.28571, 13.71429], "texture": "#5"}, + "down": {"uv": [0, 13.71429, 11.42857, 16], "rotation": 90, "texture": "#5"} + } + }, + { + "from": [1, 0, 1], + "to": [15, 2, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 0]}, + "faces": { + "north": {"uv": [16, 2.28571, 0, 0], "texture": "#4"}, + "east": {"uv": [13.71429, 2.28571, 16, 0], "texture": "#4"}, + "south": {"uv": [0, 0, 16, 2.28571], "texture": "#5"}, + "west": {"uv": [0, 2.28571, 2.28571, 0], "texture": "#4"}, + "up": {"uv": [0, 0, 16, 2.28571], "texture": "#5"}, + "down": {"uv": [16, 2.28571, 0, 0], "texture": "#5"} + } + }, + { + "from": [1, 2, 1], + "to": [3, 12, 3], + "rotation": {"angle": 0, "axis": "z", "origin": [2, 1, 0]}, + "faces": { + "north": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "east": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "south": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "west": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "rotation": 270, "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "rotation": 270, "texture": "#4"} + } + }, + { + "from": [13, 2, 1], + "to": [15, 12, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [14, 7, 2]}, + "faces": { + "north": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "east": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "south": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "west": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "rotation": 180, "texture": "#4"} + } + }, + { + "from": [13, 2, 13], + "to": [15, 12, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [14, 7, 14]}, + "faces": { + "north": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "east": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "south": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "west": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "rotation": 90, "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "rotation": 90, "texture": "#4"} + } + }, + { + "from": [1, 2, 13], + "to": [3, 12, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [2, 7, 14]}, + "faces": { + "north": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "east": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "south": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "west": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "rotation": 180, "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "texture": "#4"} + } + }, + { + "from": [3, 12, 3], + "to": [13, 13, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "east": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "up": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#5"}, + "down": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#5"} + } + }, + { + "from": [1, 12, 13], + "to": [15, 14, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [16, 13.71429, 0, 16], "texture": "#5"}, + "east": {"uv": [16, 16, 13.71429, 13.71429], "texture": "#4"}, + "south": {"uv": [0, 16, 16, 13.71429], "texture": "#4"}, + "west": {"uv": [2.28571, 16, 0, 13.71429], "texture": "#4"}, + "up": {"uv": [0, 13.71429, 16, 16], "texture": "#5"}, + "down": {"uv": [16, 0, 0, 2.28571], "texture": "#4"} + } + }, + { + "from": [1, 12, 3], + "to": [3, 14, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "east": {"uv": [0, 2.28571, 2.28571, 13.71429], "rotation": 90, "texture": "#5"}, + "west": {"uv": [0, 13.71429, 11.42857, 16], "rotation": 180, "texture": "#4"}, + "up": {"uv": [0, 2.28571, 2.28571, 13.71429], "texture": "#5"}, + "down": {"uv": [0, 13.71429, 11.42857, 16], "rotation": 90, "texture": "#4"} + } + }, + { + "from": [1, 12, 1], + "to": [15, 14, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [16, 0, 0, 2.28571], "texture": "#4"}, + "east": {"uv": [13.71429, 0, 16, 2.28571], "texture": "#4"}, + "south": {"uv": [0, 2.28571, 16, 0], "texture": "#5"}, + "west": {"uv": [0, 0, 2.28571, 2.28571], "texture": "#4"}, + "up": {"uv": [0, 0, 16, 2.28571], "texture": "#5"}, + "down": {"uv": [16, 2.28571, 0, 0], "texture": "#4"} + } + }, + { + "from": [13, 12, 3], + "to": [15, 14, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "east": {"uv": [4.57143, 2.28571, 16, 0], "rotation": 180, "texture": "#4"}, + "west": {"uv": [13.71429, 13.71429, 16, 2.28571], "rotation": 90, "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 13.71429], "texture": "#5"}, + "down": {"uv": [0, 0, 11.42857, 2.28571], "rotation": 90, "texture": "#4"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + }, + "groups": [ + { + "name": "inner", + "origin": [0, 12, 0], + "color": 0, + "children": [0] + }, + { + "name": "outer", + "origin": [0, 13, 0], + "color": 0, + "children": [1, 2, 3, 4, 5, 6, 7, 8] + }, + { + "name": "top", + "origin": [0, 13, 12], + "color": 0, + "children": [9, 10, 11, 12, 13] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/modjam/models/block/crate_open.json b/src/main/resources/assets/modjam/models/block/crate_open.json new file mode 100644 index 00000000..0eaa232a --- /dev/null +++ b/src/main/resources/assets/modjam/models/block/crate_open.json @@ -0,0 +1,238 @@ +{ + "credit": "Made with Blockbench and by iglee42", + "parent": "minecraft:block/cube_bottom_top", + "texture_size": [14, 14], + "textures": { + "2": "modjam:block/crate/top_inner", + "4": "modjam:block/crate/base", + "5": "modjam:block/crate/top", + "particle": "modjam:block/crate/base" + }, + "elements": [ + { + "from": [3, 2, 3], + "to": [13, 12, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [15, 11.75, 15]}, + "faces": { + "north": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "east": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "south": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "west": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#4"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#2"}, + "down": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "texture": "#5"} + } + }, + { + "from": [1, 0, 13], + "to": [15, 2, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 12]}, + "faces": { + "north": {"uv": [16, 13.71429, 0, 16], "texture": "#5"}, + "east": {"uv": [16, 13.71429, 13.71429, 16], "texture": "#4"}, + "south": {"uv": [0, 13.71429, 16, 16], "texture": "#4"}, + "west": {"uv": [2.28571, 13.71429, 0, 16], "texture": "#4"}, + "up": {"uv": [0, 13.71429, 16, 16], "texture": "#5"}, + "down": {"uv": [16, 0, 0, 2.28571], "texture": "#5"} + } + }, + { + "from": [13, 0, 3], + "to": [15, 2, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 12]}, + "faces": { + "east": {"uv": [4.57143, 0, 16, 2.28571], "rotation": 180, "texture": "#4"}, + "west": {"uv": [13.71429, 2.28571, 16, 13.71429], "rotation": 90, "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 13.71429], "texture": "#5"}, + "down": {"uv": [0, 0, 11.42857, 2.28571], "rotation": 90, "texture": "#5"} + } + }, + { + "from": [1, 0, 3], + "to": [3, 2, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [-12, 1, 12]}, + "faces": { + "east": {"uv": [0, 13.71429, 2.28571, 2.28571], "rotation": 90, "texture": "#5"}, + "west": {"uv": [0, 16, 11.42857, 13.71429], "rotation": 180, "texture": "#4"}, + "up": {"uv": [0, 2.28571, 2.28571, 13.71429], "texture": "#5"}, + "down": {"uv": [0, 13.71429, 11.42857, 16], "rotation": 90, "texture": "#5"} + } + }, + { + "from": [1, 0, 1], + "to": [15, 2, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 0]}, + "faces": { + "north": {"uv": [16, 2.28571, 0, 0], "texture": "#4"}, + "east": {"uv": [13.71429, 2.28571, 16, 0], "texture": "#4"}, + "south": {"uv": [0, 0, 16, 2.28571], "texture": "#5"}, + "west": {"uv": [0, 2.28571, 2.28571, 0], "texture": "#4"}, + "up": {"uv": [0, 0, 16, 2.28571], "texture": "#5"}, + "down": {"uv": [16, 2.28571, 0, 0], "texture": "#5"} + } + }, + { + "from": [1, 2, 1], + "to": [3, 12, 3], + "rotation": {"angle": 0, "axis": "z", "origin": [2, 1, 0]}, + "faces": { + "north": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "east": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "south": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "west": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "rotation": 270, "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "rotation": 270, "texture": "#4"} + } + }, + { + "from": [13, 2, 1], + "to": [15, 12, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [14, 7, 2]}, + "faces": { + "north": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "east": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "south": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "west": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "rotation": 180, "texture": "#4"} + } + }, + { + "from": [13, 2, 13], + "to": [15, 12, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [14, 7, 14]}, + "faces": { + "north": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "east": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "south": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "west": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "rotation": 90, "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "rotation": 90, "texture": "#4"} + } + }, + { + "from": [1, 2, 13], + "to": [3, 12, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [2, 7, 14]}, + "faces": { + "north": {"uv": [16, 14.85714, 13.71429, 3.42857], "texture": "#5"}, + "east": {"uv": [2.28571, 2.28571, 0, 13.71429], "rotation": 180, "texture": "#4"}, + "south": {"uv": [2.28571, 13.71429, 0, 2.28571], "texture": "#5"}, + "west": {"uv": [13.71429, 14.85714, 16, 3.42857], "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 0], "rotation": 180, "texture": "#4"}, + "down": {"uv": [0, 2.28571, 2.28571, 0], "texture": "#4"} + } + }, + { + "from": [3, 12, 13], + "to": [13, 13, 23], + "rotation": {"angle": -22.5, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "east": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 16, 1], "texture": "#missing"}, + "up": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "rotation": 270, "texture": "#5"}, + "down": {"uv": [2.28571, 2.28571, 13.71429, 13.71429], "rotation": 90, "texture": "#5"} + } + }, + { + "from": [13, 12, 11], + "to": [15, 14, 25], + "rotation": {"angle": -22.5, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [16, 16, 13.71429, 13.71429], "texture": "#4"}, + "east": {"uv": [0, 16, 16, 13.71429], "texture": "#4"}, + "south": {"uv": [2.28571, 16, 0, 13.71429], "texture": "#4"}, + "west": {"uv": [16, 13.71429, 0, 16], "texture": "#5"}, + "up": {"uv": [0, 13.71429, 16, 16], "rotation": 270, "texture": "#5"}, + "down": {"uv": [16, 0, 0, 2.28571], "rotation": 90, "texture": "#4"} + } + }, + { + "from": [3, 12, 23], + "to": [13, 14, 25], + "rotation": {"angle": -22.5, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [0, 2.28571, 2.28571, 13.71429], "rotation": 90, "texture": "#5"}, + "south": {"uv": [0, 13.71429, 11.42857, 16], "rotation": 180, "texture": "#4"}, + "up": {"uv": [0, 2.28571, 2.28571, 13.71429], "rotation": 270, "texture": "#5"}, + "down": {"uv": [0, 13.71429, 11.42857, 16], "rotation": 180, "texture": "#4"} + } + }, + { + "from": [1, 12, 11], + "to": [3, 14, 25], + "rotation": {"angle": -22.5, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [13.71429, 0, 16, 2.28571], "texture": "#4"}, + "east": {"uv": [0, 2.28571, 16, 0], "texture": "#5"}, + "south": {"uv": [0, 0, 2.28571, 2.28571], "texture": "#4"}, + "west": {"uv": [16, 0, 0, 2.28571], "texture": "#4"}, + "up": {"uv": [0, 0, 16, 2.28571], "rotation": 270, "texture": "#5"}, + "down": {"uv": [16, 2.28571, 0, 0], "rotation": 90, "texture": "#4"} + } + }, + { + "from": [3, 12, 11], + "to": [13, 14, 13], + "rotation": {"angle": -22.5, "axis": "y", "origin": [13, 11.75, 13]}, + "faces": { + "north": {"uv": [4.57143, 2.28571, 16, 0], "rotation": 180, "texture": "#4"}, + "south": {"uv": [13.71429, 13.71429, 16, 2.28571], "rotation": 90, "texture": "#5"}, + "up": {"uv": [13.71429, 2.28571, 16, 13.71429], "rotation": 270, "texture": "#5"}, + "down": {"uv": [0, 0, 11.42857, 2.28571], "rotation": 180, "texture": "#4"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + }, + "groups": [ + { + "name": "inner", + "origin": [0, 12, 0], + "color": 0, + "children": [0] + }, + { + "name": "outer", + "origin": [0, 13, 0], + "color": 0, + "children": [1, 2, 3, 4, 5, 6, 7, 8] + }, + { + "name": "top", + "origin": [0, 13, 12], + "color": 0, + "children": [9, 10, 11, 12, 13] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/modjam/textures/block/crate/base.png b/src/main/resources/assets/modjam/textures/block/crate/base.png new file mode 100644 index 00000000..4c54701f Binary files /dev/null and b/src/main/resources/assets/modjam/textures/block/crate/base.png differ diff --git a/src/main/resources/assets/modjam/textures/block/crate/rusty.png b/src/main/resources/assets/modjam/textures/block/crate/rusty.png new file mode 100644 index 00000000..dbcadce5 Binary files /dev/null and b/src/main/resources/assets/modjam/textures/block/crate/rusty.png differ diff --git a/src/main/resources/assets/modjam/textures/block/crate/rusty_top.png b/src/main/resources/assets/modjam/textures/block/crate/rusty_top.png new file mode 100644 index 00000000..fce904c9 Binary files /dev/null and b/src/main/resources/assets/modjam/textures/block/crate/rusty_top.png differ diff --git a/src/main/resources/assets/modjam/textures/block/crate/rusty_top_inner.png b/src/main/resources/assets/modjam/textures/block/crate/rusty_top_inner.png new file mode 100644 index 00000000..65ceb11e Binary files /dev/null and b/src/main/resources/assets/modjam/textures/block/crate/rusty_top_inner.png differ diff --git a/src/main/resources/assets/modjam/textures/block/crate/top.png b/src/main/resources/assets/modjam/textures/block/crate/top.png new file mode 100644 index 00000000..9bcc5ca5 Binary files /dev/null and b/src/main/resources/assets/modjam/textures/block/crate/top.png differ diff --git a/src/main/resources/assets/modjam/textures/block/crate/top_inner.png b/src/main/resources/assets/modjam/textures/block/crate/top_inner.png new file mode 100644 index 00000000..be1e475a Binary files /dev/null and b/src/main/resources/assets/modjam/textures/block/crate/top_inner.png differ diff --git a/src/main/resources/assets/modjam/textures/gui/sprites/container/furnace/empty_arrow.png b/src/main/resources/assets/modjam/textures/gui/sprites/container/furnace/empty_arrow.png new file mode 100644 index 00000000..116926b5 Binary files /dev/null and b/src/main/resources/assets/modjam/textures/gui/sprites/container/furnace/empty_arrow.png differ diff --git a/src/main/resources/assets/modjam/textures/item/crowbar.png b/src/main/resources/assets/modjam/textures/item/crowbar.png new file mode 100644 index 00000000..208e8764 Binary files /dev/null and b/src/main/resources/assets/modjam/textures/item/crowbar.png differ diff --git a/src/main/resources/data/modjam/loot_table/blocks/crate.json b/src/main/resources/data/modjam/loot_table/blocks/crate.json new file mode 100644 index 00000000..eff35cf5 --- /dev/null +++ b/src/main/resources/data/modjam/loot_table/blocks/crate.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:copy_components", + "include": [ + "minecraft:custom_name", + "minecraft:container", + "minecraft:lock", + "minecraft:container_loot", + "modjam:open" + ], + "source": "block_entity" + } + ], + "name": "modjam:crate" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "modjam:blocks/crate" +} \ No newline at end of file