Revert "Fix ingredients being "empty" when playing multiplayer"

This reverts commit f56884705a.
This commit is contained in:
DBotThePony 2023-08-19 01:13:32 +07:00
parent 260be58951
commit e88c29be57
Signed by: DBot
GPG Key ID: DCC23B5715498507
5 changed files with 7 additions and 34 deletions

View File

@ -7,7 +7,6 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.TagsUpdatedEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
@ -152,10 +151,6 @@ public final class OverdriveThatMatters {
ToolsConfig.INSTANCE.register();
}
private void tagsUpdated(TagsUpdatedEvent event) {
Ingredient.invalidateAll();
}
private void setup(final FMLCommonSetupEvent event) {
EVENT_BUS.addListener(EventPriority.NORMAL, DrivePool.INSTANCE::onWorldSave);
@ -205,8 +200,6 @@ public final class OverdriveThatMatters {
EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged);
EVENT_BUS.addListener(EventPriority.NORMAL, this::tagsUpdated);
MatteryPlayerNetworkChannel.INSTANCE.register();
MenuNetworkChannel.INSTANCE.register();
WeaponNetworkChannel.INSTANCE.register();

View File

@ -1,19 +0,0 @@
package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Ingredient.class)
public abstract class IngredientMixin {
@Inject(
method = "getItems()[Lnet/minecraft/world/item/ItemStack;",
at = @At("HEAD")
)
public void getItemsPatch(CallbackInfoReturnable<ItemStack[]> info) {
((Ingredient) (Object) this).checkInvalidation();
}
}

View File

@ -1,6 +1,5 @@
package ru.dbotthepony.mc.otm.data
import com.google.gson.JsonParseException
import com.google.gson.JsonSyntaxException
import com.mojang.datafixers.util.Pair
import com.mojang.serialization.Codec
@ -15,12 +14,10 @@ object IngredientCodec : Codec<Ingredient> {
}
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<Ingredient, T>> {
return try {
DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
try {
return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
} catch (err: JsonSyntaxException) {
DataResult.error { "Error decoding Ingredient: ${err.message}" }
} catch (err: JsonParseException) {
DataResult.error { "Error decoding Ingredient: ${err.message}" }
return DataResult.error { "Error decoding Ingredient: ${err.message}" }
}
}
}

View File

@ -56,6 +56,9 @@ class PlatePressRecipe(
}
override fun getIngredients(): NonNullList<Ingredient> {
if (isIncomplete)
return super.getIngredients()
return NonNullList.of(Ingredient.EMPTY, input)
}

View File

@ -15,8 +15,7 @@
"MixinAbstractHurtingProjectile",
"SimpleCriterionTriggerMixin",
"InventoryChangeTriggerMixin",
"MixinPlayer",
"IngredientMixin"
"MixinPlayer"
],
"client": [
"MixinGameRenderer",