Skip to content

Commit

Permalink
fix: fix shulker box related bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jan 14, 2025
1 parent 1ab2f61 commit 3b4f7e0
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Unless otherwise specified, any version comparison below is the comparison of se
- (API) Methods `BlockEntityFurnaceBaseComponent#getStoredXP` and `BlockEntityFurnaceBaseComponent#setStoredXP` now
accept `int` instead of `float`.
- (API) Renamed `Structure#pickStructure` to `Structure#pick`.
- (API) Renamed `ItemItemStorableComponentImpl` to `ItemStuffStorableComponentImpl`, and now `ItemShulkerBoxStack`
extends `ItemStuffStorableComponent`.
- Removed useless class `PackageClassLoaderUtils`, dependency `org.reflections.reflections` is also removed.
- Added `-dev` suffix to api version in development build.
- Changed `ContainerActionProcessorHolder` to a final class instead of an interface, because this abstraction is
Expand All @@ -75,6 +77,7 @@ Unless otherwise specified, any version comparison below is the comparison of se

- (API) `BlockHangingSignBehavior` now extends `BlockEntityHolderComponent<BlockEntityHangingSign>` which was forgotten
to be added.
- Fixed the `ClassCastException` when breaking shulker box.
- Fixed the bug that interacting with door doesn't have any sound.
- Waxing copper-made block using honeycomb won't call `BlockFadeEvent` now.
- Fixed the bug that player can still open enchant table even if he is sneaking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import java.util.List;

/**
* ItemItemStorableComponent is used in item that can store items,
* such as shulker boxes.
* ItemStuffStorableComponent is used in item that can store items, such as shulker boxes.
*
* @author daoge_cmd
*/
public interface ItemItemStorableComponent extends ItemComponent {
public interface ItemStuffStorableComponent extends ItemComponent {
/**
* Get the stored items.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.allaymc.api.item.interfaces;

import org.allaymc.api.item.ItemStack;
import org.allaymc.api.item.component.ItemStuffStorableComponent;

public interface ItemShulkerBoxStack extends ItemStack {
public interface ItemShulkerBoxStack extends ItemStack, ItemStuffStorableComponent {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.allaymc.api.entity.Entity;
import org.allaymc.api.entity.interfaces.EntityPlayer;
import org.allaymc.api.item.ItemStack;
import org.allaymc.api.item.component.ItemItemStorableComponent;
import org.allaymc.api.item.component.ItemStuffStorableComponent;
import org.allaymc.server.component.annotation.Dependency;
import org.cloudburstmc.protocol.bedrock.data.GameType;

Expand Down Expand Up @@ -41,7 +41,7 @@ protected ItemStack createShulkerBoxDrop(BlockStateWithPos blockState) {
var container = blockEntity.getContainer();
var containerItems = container.saveNBT();
var drop = blockState.blockState().toItemStack();
((ItemItemStorableComponent) drop).setStoredItems(containerItems);
((ItemStuffStorableComponent) drop).setStoredItems(containerItems);
return drop;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ protected void tryApplyBlockEntityNBT(Dimension dimension, Vector3ic placeBlockP
builder.remove("x");
builder.remove("y");
builder.remove("z");
blockEntity.loadNBT(this.blockEntityNBT);
blockEntity.loadNBT(builder.build());
}

protected void tryConsumeItem(EntityPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.Setter;
import org.allaymc.api.blockentity.component.BlockEntityContainerHolderComponent;
import org.allaymc.api.eventbus.EventHandler;
import org.allaymc.api.item.component.ItemItemStorableComponent;
import org.allaymc.api.item.component.ItemStuffStorableComponent;
import org.allaymc.server.item.component.event.CItemLoadExtraTagEvent;
import org.allaymc.server.item.component.event.CItemPlacedAsBlockEvent;
import org.allaymc.server.item.component.event.CItemSaveExtraTagEvent;
Expand All @@ -17,7 +17,7 @@
/**
* @author daoge_cmd
*/
public class ItemItemStorableComponentImpl implements ItemItemStorableComponent {
public class ItemStuffStorableComponentImpl implements ItemStuffStorableComponent {
@Setter
protected List<NbtMap> storedItems = List.of();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lombok.experimental.Delegate;
import org.allaymc.api.component.interfaces.Component;
import org.allaymc.api.item.component.ItemItemStorableComponent;
import org.allaymc.api.item.component.ItemStuffStorableComponent;
import org.allaymc.api.item.initinfo.ItemStackInitInfo;
import org.allaymc.api.item.interfaces.ItemShulkerBoxStack;
import org.allaymc.server.component.interfaces.ComponentProvider;
Expand All @@ -11,7 +11,7 @@

public class ItemShulkerBoxStackImpl extends ItemStackImpl implements ItemShulkerBoxStack {
@Delegate
protected ItemItemStorableComponent itemStorableComponent;
protected ItemStuffStorableComponent stuffStorableComponent;

public ItemShulkerBoxStackImpl(ItemStackInitInfo initInfo, List<ComponentProvider<? extends Component>> componentProviders) {
super(initInfo, componentProviders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,92 +580,92 @@ public static void initShulkerBox() {
ItemTypes.BLACK_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.BLACK_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.BLUE_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.BLUE_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.BROWN_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.BROWN_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.CYAN_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.CYAN_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.GRAY_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.GRAY_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.GREEN_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.GREEN_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.LIGHT_BLUE_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.LIGHT_BLUE_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.LIGHT_GRAY_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.LIGHT_GRAY_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.LIME_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.LIME_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.MAGENTA_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.MAGENTA_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.ORANGE_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.ORANGE_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.PINK_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.PINK_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.PURPLE_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.PURPLE_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.RED_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.RED_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.UNDYED_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.UNDYED_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.WHITE_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.WHITE_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
ItemTypes.YELLOW_SHULKER_BOX = AllayItemType
.builder(ItemShulkerBoxStackImpl.class)
.vanillaItem(ItemId.YELLOW_SHULKER_BOX)
.addComponent(ItemItemStorableComponentImpl::new, ItemItemStorableComponentImpl.class)
.addComponent(ItemStuffStorableComponentImpl::new, ItemStuffStorableComponentImpl.class)
.build();
}

Expand Down

0 comments on commit 3b4f7e0

Please sign in to comment.