Fixed potential Pattern crash when loading Minecraft. Fixes #3176
Fixes a NPE when using "level" later on in the pattern factory Normally, this shouldn't be an issue because there is a hasTag() guard (and MC preloads tooltips of items where tag = null) But for some reason, there is an environment where MC loads the Pattern tooltip (at startup) with a NBT tag
This commit is contained in:
@@ -10,6 +10,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed all Refined Storage advancements being granted when joining a world.
|
- Fixed all Refined Storage advancements being granted when joining a world.
|
||||||
|
- Fixed potential Pattern crash when loading Minecraft.
|
||||||
|
|
||||||
## [v1.10.0-beta.1] - 2021-12-15
|
## [v1.10.0-beta.1] - 2021-12-15
|
||||||
|
|
||||||
|
@@ -219,7 +219,7 @@ public class PatternItem extends Item implements ICraftingPatternProvider, IItem
|
|||||||
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) {
|
||||||
super.appendHoverText(stack, level, tooltip, flag);
|
super.appendHoverText(stack, level, tooltip, flag);
|
||||||
|
|
||||||
if (!stack.hasTag()) {
|
if (!stack.hasTag() || level == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ public class PatternItemBlockEntityRenderer extends BlockEntityWithoutLevelRende
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderByItem(ItemStack stack, ItemTransforms.TransformType transformType, PoseStack poseStack, MultiBufferSource renderTypeBuffer, int combinedLight, int combinedOverlay) {
|
public void renderByItem(ItemStack stack, ItemTransforms.TransformType transformType, PoseStack poseStack, MultiBufferSource renderTypeBuffer, int combinedLight, int combinedOverlay) {
|
||||||
ICraftingPattern pattern = PatternItem.fromCache(null, stack);
|
ICraftingPattern pattern = PatternItem.fromCache(Minecraft.getInstance().level, stack);
|
||||||
|
|
||||||
ItemStack outputStack = pattern.getOutputs().get(0);
|
ItemStack outputStack = pattern.getOutputs().get(0);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user