Skip to content

Commit 3812d10

Browse files
committed
Merge remote-tracking branch 'origin/master-1.21-lts' into master-1.21
2 parents aaeedd8 + d7547a8 commit 3812d10

6 files changed

Lines changed: 79 additions & 15 deletions

File tree

CHANGELOG-1.21.1.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
# Changelog for Minecraft 1.21.1
22
All notable changes to this project will be documented in this file.
33

4+
<a name="1.21.1-2.11.3"></a>
5+
## [1.21.1-2.11.3](https://github.com/CyclopsMC/CommonCapabilities/compare/1.21.1-2.11.2...1.21.1-2.11.3) - 2025-12-21 16:25:29
6+
7+
8+
### Added
9+
* Add translations through Crowdin (#44)
10+
11+
### Fixed
12+
* Fix bundle overfilling through item capability, Closes #45
13+
414
<a name="1.21.1-2.11.2"></a>
5-
## [1.21.1-2.11.2](https://github.com/CyclopsMC/CommonCapabilities/compare/1.21.1-2.11.1...1.21.1-2.11.2) - 2025-11-16 16:50:45
15+
## [1.21.1-2.11.2](https://github.com/CyclopsMC/CommonCapabilities/compare/1.21.1-2.11.1...1.21.1-2.11.2) - 2025-11-16 16:50:45 +0100
616

717

818
### Changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ org.gradle.daemon=false
3131
org.gradle.caching=true
3232

3333
# Dependencies
34-
cyclopscore_version=1.25.5-868
34+
cyclopscore_version=1.25.5-871
3535
rfapi_version=1.12-2.1.0.7
3636
enderio_version=3.0.0.40_alpha
3737
endercore_version=0.4.0.24-alpha
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.25.1 or higher.
3+
4+
Additions:
5+
* Add translations through Crowdin (#44)
6+
7+
Fixes:
8+
* Fix bundle overfilling through item capability, Closes #45

src/main/java/org/cyclops/commoncapabilities/gametest/GameTestsVanillaCapabilitiesItemItemHandler.java

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void testItemItemHandlerCapItemShulkerboxAdd(GameTestHelper helper) {
4040
}
4141

4242
@GameTest(template = TEMPLATE_EMPTY)
43-
public void testEntityItemCapItemShulkerboxRemove(GameTestHelper helper) {
43+
public void testItemItemHandlerCapItemShulkerboxRemove(GameTestHelper helper) {
4444
// Create shulker box itemstack
4545
ItemStack itemStack = new ItemStack(Items.SHULKER_BOX);
4646

@@ -61,7 +61,7 @@ public void testEntityItemCapItemShulkerboxRemove(GameTestHelper helper) {
6161

6262
@GameTest(template = TEMPLATE_EMPTY)
6363
public void testItemItemHandlerCapItemBundleAdd(GameTestHelper helper) {
64-
// Create shulker box itemstack
64+
// Create bundle itemstack
6565
ItemStack itemStack = new ItemStack(Items.BUNDLE);
6666

6767
// Add item to shulker box
@@ -79,8 +79,8 @@ public void testItemItemHandlerCapItemBundleAdd(GameTestHelper helper) {
7979
}
8080

8181
@GameTest(template = TEMPLATE_EMPTY)
82-
public void testEntityItemCapItemBundleRemove(GameTestHelper helper) {
83-
// Create shulker box itemstack
82+
public void testItemItemHandlerCapItemBundleRemove(GameTestHelper helper) {
83+
// Create bundle itemstack
8484
ItemStack itemStack = new ItemStack(Items.BUNDLE);
8585

8686
// Remove item from shulker box
@@ -100,7 +100,7 @@ public void testEntityItemCapItemBundleRemove(GameTestHelper helper) {
100100

101101
@GameTest(template = TEMPLATE_EMPTY)
102102
public void testItemItemHandlerCapItemBundleAddMultiple(GameTestHelper helper) {
103-
// Create shulker box itemstack
103+
// Create bundle itemstack
104104
ItemStack itemStack = new ItemStack(Items.BUNDLE);
105105

106106
// Add item to shulker box
@@ -131,8 +131,8 @@ public void testItemItemHandlerCapItemBundleAddMultiple(GameTestHelper helper) {
131131
}
132132

133133
@GameTest(template = TEMPLATE_EMPTY)
134-
public void testEntityItemCapItemBundleRemoveMultiple(GameTestHelper helper) {
135-
// Create shulker box itemstack
134+
public void testItemItemHandlerCapItemBundleRemoveMultiple(GameTestHelper helper) {
135+
// Create bundle itemstack
136136
ItemStack itemStack = new ItemStack(Items.BUNDLE);
137137

138138
// Remove item from shulker box
@@ -160,4 +160,52 @@ public void testEntityItemCapItemBundleRemoveMultiple(GameTestHelper helper) {
160160
});
161161
}
162162

163+
@GameTest(template = TEMPLATE_EMPTY)
164+
public void testItemItemHandlerCapItemBundleAddRejectOverfullSameSlot(GameTestHelper helper) {
165+
// Create bundle itemstack
166+
ItemStack itemStack = new ItemStack(Items.BUNDLE);
167+
168+
// Add item to shulker box
169+
ResourceHandler<ItemResource> itemHandler = itemStack.getCapability(Capabilities.Item.ITEM, ItemAccess.forStack(itemStack));
170+
int inserted1;
171+
int inserted2;
172+
try (var tx = Transaction.openRoot()) {
173+
inserted1 = itemHandler.insert(0, ItemResource.of(Items.APPLE), 32, tx);
174+
inserted2 = itemHandler.insert(0, ItemResource.of(Items.APPLE), 64, tx);
175+
tx.commit();
176+
}
177+
178+
helper.succeedIf(() -> {
179+
helper.assertValueEqual(32, inserted1, "Inserted 1");
180+
helper.assertValueEqual(32, inserted2, "Inserted 2");
181+
helper.assertTrue(itemHandler.getResource(0).getItem() == Items.APPLE, "Item was not added");
182+
helper.assertValueEqual(64, itemHandler.getAmountAsInt(0), "Item stored count");
183+
});
184+
}
185+
186+
@GameTest(template = TEMPLATE_EMPTY)
187+
public void testItemItemHandlerCapItemBundleAddRejectOverfullOtherSlot(GameTestHelper helper) {
188+
// Create bundle itemstack
189+
ItemStack itemStack = new ItemStack(Items.BUNDLE);
190+
191+
// Add item to shulker box
192+
ResourceHandler<ItemResource> itemHandler = itemStack.getCapability(Capabilities.Item.ITEM, ItemAccess.forStack(itemStack));
193+
int inserted1;
194+
int inserted2;
195+
try (var tx = Transaction.openRoot()) {
196+
inserted1 = itemHandler.insert(0, ItemResource.of(Items.APPLE), 32, tx);
197+
inserted2 = itemHandler.insert(1, ItemResource.of(Items.APPLE), 64, tx);
198+
tx.commit();
199+
}
200+
201+
helper.succeedIf(() -> {
202+
helper.assertValueEqual(32, inserted1, "Inserted 1");
203+
helper.assertValueEqual(32, inserted2, "Inserted 2");
204+
helper.assertTrue(itemHandler.getResource(0).getItem() == Items.APPLE, "Item was not added in slot 0");
205+
helper.assertTrue(itemHandler.getResource(1).getItem() == Items.APPLE, "Item was not added in slot 1");
206+
helper.assertValueEqual(itemHandler.getAmountAsInt(0), 32, "Item stored count slot 0");
207+
helper.assertValueEqual(itemHandler.getAmountAsInt(1), 32, "Item stored count slot 1");
208+
});
209+
}
210+
163211
}

src/main/java/org/cyclops/commoncapabilities/modcompat/vanilla/capability/itemhandler/VanillaItemBundleItemHandler.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,12 @@ public boolean isValid(int slot, ItemResource itemResource) {
5252
return itemResource.isEmpty() || (itemResource.getItem().canFitInsideContainerItems());
5353
}
5454

55-
protected boolean isAmountValid(ItemStack stack) {
56-
return getMaxAmountToAdd(stack) > 0;
57-
}
58-
5955
@Override
6056
public int insert(int slot, ItemResource itemResource, int amount, TransactionContext transaction) {
61-
if (!(isValid(slot, itemResource) && isAmountValid(itemResource.toStack(amount)))) {
57+
if (!(isValid(slot, itemResource))) {
6258
return 0;
6359
}
64-
return super.insert(slot, itemResource, amount, transaction);
60+
return super.insert(slot, itemResource, Math.min(amount, getMaxAmountToAdd(itemResource.toStack(amount))), transaction);
6561
}
6662

6763
// Copied from BundleContents

src/main/resources/assets/commoncapabilities/lang/pt_br.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2+
"_comment": "# Capability settings",
23
"config.commoncapabilities": "Configuração do %s",
4+
"recipecomponent.minecraft.itemstack": "Item",
35
"recipecomponent.minecraft.fluidstack": "Fluido",
46
"recipecomponent.minecraft.energy": "Energia",
57
"capability.commoncapabilities.inventoryState": "Estado do inventário",

0 commit comments

Comments
 (0)