Fix NPE when feeding wolves and cats (#9074)

This commit is contained in:
Magnus Jensen authored and GitHub committed 2022-10-07 19:55:40 -07:00
1 parent e1017a4c7e
commit e7bd08649f
2 files changed
+9 -4

No files matched your search

@@ -1,11 +1,12 @@
--- a/net/minecraft/world/entity/animal/Cat.java
+++ b/net/minecraft/world/entity/animal/Cat.java
@@ -366,7 +_,7 @@
@@ -365,8 +_,8 @@
if (this.m_21830_(p_28153_)) {
if (!(item instanceof DyeItem)) {
if (item.m_41472_() && this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) {
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
this.m_142075_(p_28153_, p_28154_, itemstack);
- this.m_5634_((float)item.m_41473_().m_38744_());
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
return InteractionResult.CONSUME;
}
@@ -1,11 +1,15 @@
--- a/net/minecraft/world/entity/animal/Wolf.java
+++ b/net/minecraft/world/entity/animal/Wolf.java
@@ -329,7 +_,8 @@
@@ -325,11 +_,12 @@
} else {
if (this.m_21824_()) {
if (this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) {
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
if (!p_30412_.m_150110_().f_35937_) {
itemstack.m_41774_(1);
}
- this.m_5634_((float)item.m_41473_().m_38744_());
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
+ this.m_146852_(GameEvent.f_157806_, this);
return InteractionResult.SUCCESS;
}