Skip to content

Commit

Permalink
Backport fix for issue #66 (#112)
Browse files Browse the repository at this point in the history
Co-authored-by: IThundxr <[email protected]>
  • Loading branch information
PringlePot and IThundxr authored Feb 14, 2025
1 parent 06322f1 commit d4eeacb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
------------------------------------------------------
Numismatics 1.0.11
------------------------------------------------------
Changes
- You can now insert or extract items from all sides of a vendor

------------------------------------------------------
Numismatics 1.0.10
------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ public ItemStack getSellingItem() {

@Override
public int @NotNull [] getSlotsForFace(@NotNull Direction side) {
if (mode == Mode.BUY)
return side == Direction.DOWN ? new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8} : new int[0];
return side == Direction.DOWN ? new int[0] : new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8};
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8};
}

@Override
Expand All @@ -411,12 +409,12 @@ public boolean canPlaceItem(int index, @NotNull ItemStack stack) {

@Override
public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStack, @Nullable Direction direction) {
return direction != Direction.DOWN && canPlaceItem(index, itemStack);
return canPlaceItem(index, itemStack);
}

@Override
public boolean canTakeItemThroughFace(int index, @NotNull ItemStack stack, @NotNull Direction direction) {
return direction == Direction.DOWN && mode == Mode.BUY;
return mode == Mode.BUY;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,31 @@
import org.spongepowered.asm.mixin.Unique;

@Mixin(VendorBlockEntity.class)
public abstract class VendorBlockEntityCapabilities extends SmartBlockEntity implements ICapabilityProvider {
public abstract class VendorBlockEntityCapabilities extends SmartBlockEntity implements ICapabilityProvider, WorldlyContainer {
public VendorBlockEntityCapabilities(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}

// This is actually just down + all the 5 other sides
@Unique private static final Direction[] numismatics$DIRECTIONS = {Direction.DOWN, Direction.NORTH};
@Unique LazyOptional<? extends IItemHandler>[] numismatics$handlers = SidedInvWrapper.create((WorldlyContainer) this, numismatics$DIRECTIONS);

@Unique LazyOptional<? extends IItemHandler> numismatics$handler = LazyOptional.of(() -> new SidedInvWrapper(this, Direction.NORTH));
@Override
public <T> @NotNull LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nullable Direction facing) {
if (capability == ForgeCapabilities.ITEM_HANDLER && facing != null && !remove) {
if (capability == ForgeCapabilities.ITEM_HANDLER && !remove) {
// If down return the down handler otherwise return the one for all other sides
return facing == Direction.DOWN ? numismatics$handlers[0].cast() : numismatics$handlers[1].cast();
return numismatics$handler.cast();
}

return super.getCapability(capability, facing);
}

@Override
public void reviveCaps() {
super.reviveCaps();
numismatics$handlers = SidedInvWrapper.create((WorldlyContainer) this, numismatics$DIRECTIONS);
}
numismatics$handler = LazyOptional.of(() -> new SidedInvWrapper(this, Direction.NORTH)); }

@Override
public void invalidateCaps() {
super.invalidateCaps();

for (LazyOptional<? extends IItemHandler> createNumismatics$handler : numismatics$handlers) {
createNumismatics$handler.invalidate();
}
numismatics$handler.invalidate();
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ loom.ignoreDependencyLoomVersionValidation=true

# Mod Info
archives_base_name = CreateNumismatics
mod_version = 1.0.10
mod_version = 1.0.11
maven_group = dev.ithundxr.createnumismatics

minecraft_version = 1.20.1
Expand Down

0 comments on commit d4eeacb

Please sign in to comment.