Return empty stack if data is invalid, instead of returning default one.

This commit is contained in:
Florian Nücke
2022-02-13 23:38:42 +01:00
parent df60bd8f50
commit 6148eff484
2 changed files with 4 additions and 4 deletions

View File

@@ -55,12 +55,12 @@ public abstract class AbstractBlockDeviceItem extends ModItem {
public ItemStack withData(final ItemStack stack, final BlockDeviceData data) {
if (stack.isEmpty() || stack.getItem() != this) {
return stack;
return ItemStack.EMPTY;
}
final ResourceLocation key = BlockDeviceDataRegistry.getKey(data);
if (key == null) {
return stack;
return ItemStack.EMPTY;
}
ItemStackUtils.getOrCreateModDataTag(stack).putString(DATA_TAG_NAME, key.toString());

View File

@@ -53,12 +53,12 @@ public final class FlashMemoryWithExternalDataItem extends ModItem {
public ItemStack withFirmware(final ItemStack stack, final Firmware firmware) {
if (stack.isEmpty() || stack.getItem() != this) {
return stack;
return ItemStack.EMPTY;
}
final ResourceLocation key = FirmwareRegistry.getKey(firmware);
if (key == null) {
return stack;
return ItemStack.EMPTY;
}
ItemStackUtils.getOrCreateModDataTag(stack).putString(FIRMWARE_TAG_NAME, key.toString());