Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container improvements. #125

Open
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
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;
Expand Down Expand Up @@ -64,4 +66,14 @@ protected void setItems(NonNullList<ItemStack> itemStacks) {
public int getContainerSize() {
return 27;
}

@Override
public void startOpen(Player player) {
player.playSound(SoundEvents.CHEST_OPEN, 1.0f, 1.0f);
}

@Override
public void stopOpen(Player player) {
player.playSound(SoundEvents.CHEST_CLOSE, 1.0f, 1.0f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.Container;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -105,6 +107,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.COUNTER, ConstantComponents.HAMMER_USE_LOOK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.Container;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
Expand Down Expand Up @@ -82,6 +84,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.HAMMER_USE_LOOK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import earth.terrarium.handcrafted.common.utils.TooltipUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand Down Expand Up @@ -45,6 +48,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.SHEET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.Container;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
Expand Down Expand Up @@ -96,6 +98,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.HAMMER_USE_LOOK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import earth.terrarium.handcrafted.common.utils.TooltipUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand Down Expand Up @@ -45,6 +48,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.SHEET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.Container;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
Expand Down Expand Up @@ -96,6 +98,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.HAMMER_USE_LOOK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import earth.terrarium.handcrafted.common.utils.TooltipUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand Down Expand Up @@ -45,6 +48,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new ContainerBlockEntity(pos, state);
}

@Override
protected boolean hasAnalogOutputSignal(BlockState state) {
return true;
}

@Override
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)level.getBlockEntity(pos));
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
TooltipUtils.addDescriptionComponent(tooltipComponents, ConstantComponents.SHEET);
Expand Down
Loading