Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktpatient committed Sep 8, 2024
2 parents 6b8f2f3 + 05b182b commit 74e592b
Show file tree
Hide file tree
Showing 37 changed files with 1,123 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
16 changes: 16 additions & 0 deletions src/generated/resources/assets/modjam/blockstates/crate.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 3 additions & 0 deletions src/generated/resources/assets/modjam/models/item/crate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "modjam:block/crate"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "modjam:item/crowbar"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"modjam:crate"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"modjam:crate"
]
}
1 change: 1 addition & 0 deletions src/main/java/com/portingdeadmods/modjam/ModJam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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<CrateMenu> {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.jetbrains.annotations.Nullable;

public class ItemTransformationRecipeCategory implements IRecipeCategory<ItemTransformationRecipe> {
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<ItemTransformationRecipe> RECIPE_TYPE =
new RecipeType<>(UID, ItemTransformationRecipe.class);
Expand Down Expand Up @@ -56,18 +56,13 @@ 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
builder.addSlot(RecipeIngredientRole.INPUT, 0,0 ).addItemStack(recipe.getIngredients().get(0).getItems()[0]);
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);
}

}
Original file line number Diff line number Diff line change
@@ -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<ItemStack> 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<ItemStack> getItems() {
return this.items;
}

@Override
protected void setItems(NonNullList<ItemStack> 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);
}
}
Loading

0 comments on commit 74e592b

Please sign in to comment.