mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Deprecate Item.onUsingTick, as vanilla provides the same function in Item.onUseTick now. Closes #9342
This commit is contained in:
8 files changed
+53
-15
No files matched your search
@@ -519,25 +519,37 @@
|
||||
if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) {
|
||||
flag = true;
|
||||
int i = this.f_20937_ + 1;
|
||||
@@ -2786,8 +_,16 @@
|
||||
@@ -2786,8 +_,11 @@
|
||||
|
||||
private void m_21329_() {
|
||||
if (this.m_6117_()) {
|
||||
- if (ItemStack.m_41746_(this.m_21120_(this.m_7655_()), this.f_20935_)) {
|
||||
- this.f_20935_ = this.m_21120_(this.m_7655_());
|
||||
+ ItemStack itemStack = this.m_21120_(this.m_7655_());
|
||||
+ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.f_20935_, itemStack)) this.f_20935_ = itemStack;
|
||||
+ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.f_20935_, itemStack)) {
|
||||
+ this.f_20935_ = itemStack;
|
||||
+ }
|
||||
+ if (itemStack == this.f_20935_) {
|
||||
+
|
||||
+ if (!this.f_20935_.m_41619_()) {
|
||||
+ f_20936_ = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, f_20935_, f_20936_);
|
||||
+ if (f_20936_ > 0)
|
||||
+ f_20935_.onUsingTick(this, f_20936_);
|
||||
+ }
|
||||
+
|
||||
this.m_142106_(this.f_20935_);
|
||||
} else {
|
||||
this.m_5810_();
|
||||
@@ -2797,12 +_,15 @@
|
||||
}
|
||||
|
||||
protected void m_142106_(ItemStack p_147201_) {
|
||||
+ if (!p_147201_.m_41619_())
|
||||
+ this.f_20936_ = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, p_147201_, this.m_21212_());
|
||||
+ if (this.m_21212_() > 0)
|
||||
p_147201_.m_41731_(this.f_19853_, this, this.m_21212_());
|
||||
if (this.m_21332_()) {
|
||||
this.m_21137_(p_147201_, 5);
|
||||
}
|
||||
|
||||
- if (--this.f_20936_ == 0 && !this.f_19853_.f_46443_ && !p_147201_.m_41781_()) {
|
||||
+ if (--this.f_20936_ <= 0 && !this.f_19853_.f_46443_ && !p_147201_.m_41781_()) {
|
||||
this.m_8095_();
|
||||
}
|
||||
|
||||
@@ -2810,7 +_,7 @@
|
||||
|
||||
private boolean m_21332_() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/item/BrushItem.java
|
||||
+++ b/net/minecraft/world/item/BrushItem.java
|
||||
@@ -76,6 +_,7 @@
|
||||
} else {
|
||||
p_273619_.m_21253_();
|
||||
}
|
||||
+ super.m_5929_(p_273467_, p_273619_, p_273316_, p_273101_); //TODO: Remove in 1.20, this is only here to trigger Forge's old onUseingTick method
|
||||
}
|
||||
|
||||
public void m_271895_(Level p_272701_, BlockHitResult p_273758_, BlockState p_272753_, Vec3 p_272912_) {
|
||||
@@ -8,3 +8,11 @@
|
||||
List<ItemStack> list = m_40941_(p_40891_);
|
||||
float[] afloat = m_220023_(p_40889_.m_217043_());
|
||||
|
||||
@@ -304,6 +_,7 @@
|
||||
p_40910_.m_6263_((Player)null, p_40911_.m_20185_(), p_40911_.m_20186_(), p_40911_.m_20189_(), soundevent1, SoundSource.PLAYERS, 0.5F, 1.0F);
|
||||
}
|
||||
}
|
||||
+ super.m_5929_(p_40910_, p_40911_, p_40912_, p_40913_); //TODO: Remove in 1.20, this is only here to trigger Forge's old onUseingTick method
|
||||
|
||||
}
|
||||
|
||||
@@ -22,13 +22,16 @@
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -108,6 +_,8 @@
|
||||
return this.f_204113_;
|
||||
@@ -109,8 +_,11 @@
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Use damage source sensitive version */
|
||||
+ @Deprecated
|
||||
public void m_5929_(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) {
|
||||
+ p_41430_.onUsingTick(p_41429_, p_41431_);
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: {@link net.minecraftforge.common.extensions.IForgeItem#onDestroyed(ItemEntity, DamageSource) Use damage source sensitive version} */
|
||||
+ @Deprecated
|
||||
public void m_142023_(ItemEntity p_150887_) {
|
||||
}
|
||||
|
||||
@@ -134,9 +_,9 @@
|
||||
|
||||
@@ -248,7 +248,7 @@
|
||||
this.m_41720_().m_5929_(p_41732_, p_41733_, this, p_41734_);
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Use damage source sensitive version */
|
||||
+ /** @deprecated Forge: {@link net.minecraftforge.common.extensions.IForgeItemStack#onDestroyed(ItemEntity, DamageSource) Use damage source sensitive version} */
|
||||
+ @Deprecated
|
||||
public void m_150924_(ItemEntity p_150925_) {
|
||||
this.m_41720_().m_142023_(p_150925_);
|
||||
|
||||
@@ -196,7 +196,9 @@ public interface IForgeItem
|
||||
* @param player The Player using the item
|
||||
* @param count The amount of time in tick the item has been used for
|
||||
* continuously
|
||||
* @deprecated {@link net.minecraft.world.item.Item#onUseTick(Level, LivingEntity, ItemStack, int) Implement Vanilla's Version}
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
default void onUsingTick(ItemStack stack, LivingEntity player, int count)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -249,7 +249,10 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
|
||||
* @param player The Player using the item
|
||||
* @param count The amount of time in tick the item has been used for
|
||||
* continuously
|
||||
*
|
||||
* @deprecated {@link net.minecraft.world.item.ItemStack#onUseTick(Level, LivingEntity, int) Use Vanilla's Version}
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
default void onUsingTick(LivingEntity player, int count)
|
||||
{
|
||||
self().getItem().onUsingTick(self(), player, count);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class LivingEntityUseItemEvent extends LivingEvent
|
||||
/**
|
||||
* Fired every tick that a player is 'using' an item, see {@link Start} for info.
|
||||
*
|
||||
* Cancel the event, or set the duration or {@literal <=} 0 to cause the player to stop using the item.
|
||||
* Cancel the event, or set the duration to {@literal <=} 0 to cause the player to stop using the item.
|
||||
*
|
||||
*/
|
||||
@Cancelable
|
||||
|
||||
Reference in new issue
Block a user