different texture for linked chest, fixed double chest

This commit is contained in:
Jenny 2025-05-02 14:45:51 +02:00
parent fe45e71669
commit fa53e02141
Signed by: Jenny
GPG Key ID: 2072A14E40940632
5 changed files with 24 additions and 6 deletions

View File

@ -38,12 +38,12 @@ mod_name=Networked Chests
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=0.1.1
mod_version=0.2.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=com.jenny
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=Jenny
mod_authors=xJenny69
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=

View File

@ -2,6 +2,7 @@ package com.jenny.networked_chests.items;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@ -15,7 +16,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -62,6 +63,7 @@ public class ChestInterface extends Item {
if (chestLocation == null) {
chestLocation = new CompoundTag();
}
chestLocation.putInt("CustomModelData", 1);
chestLocation.putInt("chest_pos_x", blockPos.getX());
chestLocation.putInt("chest_pos_y", blockPos.getY());
chestLocation.putInt("chest_pos_z", blockPos.getZ());
@ -77,8 +79,9 @@ public class ChestInterface extends Item {
private void openChest(Level level, ServerPlayer player, ItemStack itemStack) {
if (chestSet(itemStack)) {
if (isChest(level, getPos(itemStack))) {
((ChestBlockEntity) level.getBlockEntity(getPos(itemStack))).startOpen(player);
player.openMenu((ChestBlockEntity) level.getBlockEntity(getPos(itemStack)));
level.getBlockState(getPos(itemStack)).use(level, player, InteractionHand.MAIN_HAND, new BlockHitResult(player.position(), Direction.DOWN, getPos(itemStack), false));
//((ChestBlockEntity) level.getBlockEntity(getPos(itemStack))).startOpen(player);
//player.openMenu((ChestBlockEntity) level.getBlockEntity(getPos(itemStack)));
} else {
unsetChest(itemStack);
messageChestMissing(player);
@ -97,6 +100,7 @@ public class ChestInterface extends Item {
private void unsetChest(ItemStack itemStack) {
CompoundTag cTag = itemStack.getTag();
assert cTag != null;
cTag.remove("CustomModelData");
cTag.remove("chest_pos_x");
cTag.remove("chest_pos_y");
cTag.remove("chest_pos_z");

View File

@ -2,5 +2,13 @@
"parent": "minecraft:item/generated",
"textures": {
"layer0": "networked_chests:item/chest_interface"
},
"overrides": [
{
"predicate": {
"custom_model_data": 1
},
"model": "networked_chests:item/chest_interface_linked"
}
]
}

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B