generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- It can be open with a crowbar - When broke when it's closed, it keep the loot - When broke when it's open, it drop the loot and stay open when replaced - Rusty Version (can be changed with debug stick) - Can be broke with an axe and a pickaxe
- Loading branch information
Showing
35 changed files
with
1,121 additions
and
3 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
src/generated/resources/.cache/41a2d86d7e58f5ff289dc10f1d54cfe65982de55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
4 changes: 3 additions & 1 deletion
4
src/generated/resources/.cache/5db5b310cf1abc4c7f33d2d565e2a2290a7f6c4d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/generated/resources/assets/modjam/blockstates/crate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/generated/resources/assets/modjam/models/block/rusty_crate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/generated/resources/assets/modjam/models/block/rusty_crate_open.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"parent": "modjam:block/crate" | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/modjam/models/item/crowbar.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "modjam:item/crowbar" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/generated/resources/data/minecraft/tags/block/mineable/axe.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"modjam:crate" | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/generated/resources/data/minecraft/tags/block/mineable/pickaxe.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"modjam:crate" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/portingdeadmods/modjam/client/screen/CrateScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
152 changes: 152 additions & 0 deletions
152
src/main/java/com/portingdeadmods/modjam/content/blockentities/CrateBlockEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.