-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改了一部分ItemReg和ItemProperties,修正了Crafting Remainder注册会导致游戏无法正常启动的问题。
- Loading branch information
1 parent
04e434d
commit cdd9dc6
Showing
5 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/kasuga/lib/core/base/item_helper/ExternalProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kasuga.lib.core.base.item_helper; | ||
|
||
import net.minecraft.world.item.Item; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.Supplier; | ||
|
||
public class ExternalProperties extends Item.Properties { | ||
|
||
@Nonnull | ||
Supplier<Item> craftingRemainderItem = () -> null; | ||
|
||
public ExternalProperties craftRemainder(Supplier<Item> craftingReminderItem) { | ||
this.craftingRemainderItem = craftingReminderItem; | ||
return this; | ||
} | ||
|
||
/** | ||
* Don't use, use {@link ExternalProperties#craftRemainder(Supplier)} instead. | ||
* @param pCraftingRemainingItem Don't use. | ||
* @return self. | ||
*/ | ||
@Deprecated | ||
@Override | ||
public Item.Properties craftRemainder(Item pCraftingRemainingItem) { | ||
return this; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/kasuga/lib/core/base/item_helper/ExternalRemainderBlockItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package kasuga.lib.core.base.item_helper; | ||
|
||
import net.minecraft.world.item.BlockItem; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.block.Block; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.Supplier; | ||
|
||
public class ExternalRemainderBlockItem extends BlockItem { | ||
|
||
@Nonnull | ||
private final Supplier<Item> craftingRemainder; | ||
public ExternalRemainderBlockItem(Block pBlock, Properties pProperties) { | ||
super(pBlock, pProperties); | ||
if (pProperties instanceof ExternalProperties externalProperties) | ||
craftingRemainder = externalProperties.craftingRemainderItem; | ||
else | ||
craftingRemainder = () -> null; | ||
} | ||
|
||
@Nonnull | ||
public Supplier<Item> getCraftingRemainder() { | ||
return craftingRemainder; | ||
} | ||
|
||
@Override | ||
public boolean hasCraftingRemainingItem(ItemStack stack) { | ||
return super.hasCraftingRemainingItem(stack) || craftingRemainder.get() != null; | ||
} | ||
|
||
@Override | ||
public ItemStack getCraftingRemainingItem(ItemStack itemStack) { | ||
ItemStack remain = super.getCraftingRemainingItem(itemStack); | ||
if (remain == ItemStack.EMPTY && craftingRemainder.get() != null) { | ||
remain = craftingRemainder.get().getDefaultInstance(); | ||
} | ||
return remain; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/kasuga/lib/core/base/item_helper/ExternalRemainderItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package kasuga.lib.core.base.item_helper; | ||
|
||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.Supplier; | ||
|
||
public class ExternalRemainderItem extends Item { | ||
|
||
@Nonnull | ||
private final Supplier<Item> craftingRemainder; | ||
public ExternalRemainderItem(Properties pProperties) { | ||
super(pProperties); | ||
if (pProperties instanceof ExternalProperties externalProperties) | ||
craftingRemainder = externalProperties.craftingRemainderItem; | ||
else | ||
craftingRemainder = () -> null; | ||
} | ||
|
||
@Nonnull | ||
public Supplier<Item> getCraftingRemainder() { | ||
return craftingRemainder; | ||
} | ||
|
||
@Override | ||
public boolean hasCraftingRemainingItem(ItemStack stack) { | ||
return super.hasCraftingRemainingItem(stack) || craftingRemainder.get() != null; | ||
} | ||
|
||
@Override | ||
public ItemStack getCraftingRemainingItem(ItemStack itemStack) { | ||
ItemStack remain = super.getCraftingRemainingItem(itemStack); | ||
if (remain == ItemStack.EMPTY && craftingRemainder.get() != null) { | ||
remain = craftingRemainder.get().getDefaultInstance(); | ||
} | ||
return remain; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters