diff --git a/build.gradle b/build.gradle index 776bf84a29c..2d4c2bd0f5c 100644 --- a/build.gradle +++ b/build.gradle @@ -161,6 +161,8 @@ dependencies { exclude(group: "net.fabricmc.fabric-api") } + modCompileOnly("curse.maven:diet-443570:4813902") + // Sodium // modImplementation "maven.modrinth:sodium:mc1.20.1-0.5.2" // modImplementation("maven.modrinth:indium:1.0.25+mc1.20.1") diff --git a/gradle.properties b/gradle.properties index b5a59a240e9..6ca800f536c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ loader_version=0.14.21 parchment_version=2023.03.12 # Build Dependencies -mantle_version=1.9.264 +mantle_version=1.9.267 mantle_range=[1.9.264,) milk_lib_version=1.2.58 dripstone_fluid_lib_version=3.0.1 diff --git a/src/main/java/slimeknights/tconstruct/TConstruct.java b/src/main/java/slimeknights/tconstruct/TConstruct.java index f3a501ea20c..823cf14d651 100644 --- a/src/main/java/slimeknights/tconstruct/TConstruct.java +++ b/src/main/java/slimeknights/tconstruct/TConstruct.java @@ -4,6 +4,7 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; @@ -123,7 +124,7 @@ public void onInitialize() { // if (modList.isLoaded("jsonthings")) { // JsonThingsPlugin.onConstruct(); // } - if (modList.isLoaded("diet")) { + if (FabricLoader.getInstance().isModLoaded("diet")) { DietPlugin.onConstruct(); } diff --git a/src/main/java/slimeknights/tconstruct/common/config/Config.java b/src/main/java/slimeknights/tconstruct/common/config/Config.java index 3a78479d4bf..2ad3f265e0a 100644 --- a/src/main/java/slimeknights/tconstruct/common/config/Config.java +++ b/src/main/java/slimeknights/tconstruct/common/config/Config.java @@ -1,19 +1,17 @@ package slimeknights.tconstruct.common.config; import com.google.common.collect.ImmutableList; +import io.github.fabricators_of_create.porting_lib.config.ConfigRegistry; +import io.github.fabricators_of_create.porting_lib.config.ConfigType; +import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; +import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.BooleanValue; +import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.ConfigValue; +import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.DoubleValue; +import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.EnumValue; +import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.IntValue; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; -import net.minecraftforge.common.ForgeConfigSpec.EnumValue; -import net.minecraftforge.common.ForgeConfigSpec.IntValue; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; import slimeknights.tconstruct.TConstruct; import slimeknights.tconstruct.library.recipe.melting.IMeltingContainer.IOreRate; @@ -281,7 +279,7 @@ public enum LogInvalidToolStack { STACKTRACE, WARNING, IGNORED }; * Client specific configuration - only loaded clientside from tconstruct-client.toml */ public static class Client { - //public final ForgeConfigSpec.BooleanValue temperatureInCelsius; +// public final ModConfigSpec.BooleanValue temperatureInCelsius; public final ModConfigSpec.BooleanValue tankFluidModel; public final ModConfigSpec.BooleanValue extraToolTips; // TODO: do we even need this config option? who would turn it off? public final ModConfigSpec.BooleanValue logMissingMaterialTextures; diff --git a/src/main/java/slimeknights/tconstruct/library/client/book/content/ContentModifier.java b/src/main/java/slimeknights/tconstruct/library/client/book/content/ContentModifier.java index 8c82eaa6da4..7a81ddc6f7a 100644 --- a/src/main/java/slimeknights/tconstruct/library/client/book/content/ContentModifier.java +++ b/src/main/java/slimeknights/tconstruct/library/client/book/content/ContentModifier.java @@ -2,14 +2,15 @@ import com.google.common.collect.Lists; import com.google.gson.annotations.SerializedName; +import io.github.fabricators_of_create.porting_lib.util.ForgeI18n; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.language.I18n; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.common.ForgeI18n; import slimeknights.mantle.client.book.data.BookData; import slimeknights.mantle.client.book.data.content.PageContent; import slimeknights.mantle.client.book.data.element.ImageData; @@ -109,7 +110,7 @@ public TagKey getToolFilterTag() { return null; } if (this.toolFilterTag == null) { - this.toolFilterTag = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(toolFilter)); + this.toolFilterTag = TagKey.create(Registries.ITEM, new ResourceLocation(toolFilter)); } return this.toolFilterTag; } diff --git a/src/main/java/slimeknights/tconstruct/library/client/data/material/GeneratorPartTextureJsonGenerator.java b/src/main/java/slimeknights/tconstruct/library/client/data/material/GeneratorPartTextureJsonGenerator.java index 89b3a772b2a..297e840d259 100644 --- a/src/main/java/slimeknights/tconstruct/library/client/data/material/GeneratorPartTextureJsonGenerator.java +++ b/src/main/java/slimeknights/tconstruct/library/client/data/material/GeneratorPartTextureJsonGenerator.java @@ -18,11 +18,14 @@ import slimeknights.tconstruct.library.materials.stats.MaterialStatsId; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.CompletableFuture; /** Generates the file that tells the part generator command which parts are needed for your tools */ public class GeneratorPartTextureJsonGenerator extends GenericDataProvider { @@ -39,10 +42,10 @@ public class GeneratorPartTextureJsonGenerator extends GenericDataProvider { private final StatOverride overrides; public GeneratorPartTextureJsonGenerator(FabricDataOutput output, String modId, AbstractPartSpriteProvider spriteProvider) { - this(generator, modId, spriteProvider, StatOverride.EMPTY); + this(output, modId, spriteProvider, StatOverride.EMPTY); } - public GeneratorPartTextureJsonGenerator(DataGenerator generator, String modId, AbstractPartSpriteProvider spriteProvider, StatOverride overrides) { + public GeneratorPartTextureJsonGenerator(FabricDataOutput output, String modId, AbstractPartSpriteProvider spriteProvider, StatOverride overrides) { super(output, PackType.CLIENT_RESOURCES, "tinkering", GSON); this.modId = modId; this.spriteProvider = spriteProvider; diff --git a/src/main/java/slimeknights/tconstruct/library/client/data/material/MaterialPartTextureGenerator.java b/src/main/java/slimeknights/tconstruct/library/client/data/material/MaterialPartTextureGenerator.java index 4384a10dbf0..5c416eda0c3 100644 --- a/src/main/java/slimeknights/tconstruct/library/client/data/material/MaterialPartTextureGenerator.java +++ b/src/main/java/slimeknights/tconstruct/library/client/data/material/MaterialPartTextureGenerator.java @@ -44,10 +44,10 @@ public class MaterialPartTextureGenerator extends GenericTextureGenerator { private final StatOverride overrides; public MaterialPartTextureGenerator(FabricDataOutput output, ExistingFileHelper existingFileHelper, AbstractPartSpriteProvider spriteProvider, AbstractMaterialSpriteProvider... materialProviders) { - this(generator, existingFileHelper, spriteProvider, StatOverride.EMPTY, materialProviders); + this(output, existingFileHelper, spriteProvider, StatOverride.EMPTY, materialProviders); } - public MaterialPartTextureGenerator(DataGenerator generator, ExistingFileHelper existingFileHelper, AbstractPartSpriteProvider spriteProvider, StatOverride overrides, AbstractMaterialSpriteProvider... materialProviders) { + public MaterialPartTextureGenerator(FabricDataOutput output, ExistingFileHelper existingFileHelper, AbstractPartSpriteProvider spriteProvider, StatOverride overrides, AbstractMaterialSpriteProvider... materialProviders) { super(output, FOLDER); this.spriteReader = new DataGenSpriteReader(existingFileHelper, FOLDER); this.existingFileHelper = existingFileHelper; diff --git a/src/main/java/slimeknights/tconstruct/library/json/predicate/RegistrySetLoader.java b/src/main/java/slimeknights/tconstruct/library/json/predicate/RegistrySetLoader.java index d47c439ad06..53fe7e5eb7b 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/predicate/RegistrySetLoader.java +++ b/src/main/java/slimeknights/tconstruct/library/json/predicate/RegistrySetLoader.java @@ -4,10 +4,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; +import net.minecraft.core.Registry; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.data.GenericLoaderRegistry.IHaveLoader; import slimeknights.mantle.util.JsonHelper; @@ -21,13 +20,13 @@ * @param Registry type * @param Loader object type */ -public record RegistrySetLoader, T extends IHaveLoader>(IForgeRegistry registry, Function, T> constructor, Function> getter, String name) implements IGenericLoader { +public record RegistrySetLoader>(Registry registry, Function, T> constructor, Function> getter, String name) implements IGenericLoader { @Override public T deserialize(JsonObject json) { Set set = ImmutableSet.copyOf(JsonHelper.parseList(json, name, (element, jsonKey) -> { ResourceLocation objectKey = JsonHelper.convertToResourceLocation(element, jsonKey); if (registry.containsKey(objectKey)) { - return registry.getValue(objectKey); + return registry.get(objectKey); } throw new JsonSyntaxException("Unknown " + name + " '" + objectKey + "'"); })); @@ -38,7 +37,7 @@ public T deserialize(JsonObject json) { public void serialize(T object, JsonObject json) { JsonArray array = new JsonArray(); for (R entry : getter.apply(object)) { - array.add(Objects.requireNonNull(entry.getRegistryName()).toString()); + array.add(Objects.requireNonNull(registry.getKey(entry)).toString()); } json.add(name, array); } @@ -48,7 +47,7 @@ public T fromNetwork(FriendlyByteBuf buffer) { ImmutableSet.Builder builder = ImmutableSet.builder(); int max = buffer.readVarInt(); for (int i = 0; i < max; i++) { - builder.add(buffer.readRegistryIdUnsafe(registry)); + builder.add(registry.byId(buffer.readVarInt())); } return constructor.apply(builder.build()); } @@ -58,7 +57,7 @@ public void toNetwork(T object, FriendlyByteBuf buffer) { Set set = getter.apply(object); buffer.writeVarInt(set.size()); for (R entry : set) { - buffer.writeRegistryIdUnsafe(registry, entry); + buffer.writeVarInt(registry.getId(entry)); } } } diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/entity/EntityLightVariable.java b/src/main/java/slimeknights/tconstruct/library/json/variable/entity/EntityLightVariable.java index 8322df254c7..561edd0b2e9 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/entity/EntityLightVariable.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/entity/EntityLightVariable.java @@ -11,7 +11,7 @@ public record EntityLightVariable(LightLayer lightLayer) implements EntityVariab @Override public float getValue(LivingEntity entity) { - return entity.level.getBrightness(lightLayer, entity.blockPosition()); + return entity.level().getBrightness(lightLayer, entity.blockPosition()); } @Override diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockLightVariable.java b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockLightVariable.java index 44c25ea8257..1d37405f755 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockLightVariable.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockLightVariable.java @@ -6,7 +6,7 @@ import net.minecraft.util.GsonHelper; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.LightLayer; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.util.JsonHelper; import slimeknights.tconstruct.library.tools.nbt.IToolStackView; diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockMiningSpeedVariable.java b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockMiningSpeedVariable.java index be3d63b90b7..351e890e6ec 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockMiningSpeedVariable.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/BlockMiningSpeedVariable.java @@ -2,7 +2,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.tconstruct.library.json.variable.NestedFallbackLoader; import slimeknights.tconstruct.library.json.variable.NestedFallbackLoader.NestedFallback; diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/EntityMiningSpeedVariable.java b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/EntityMiningSpeedVariable.java index 187f85bd459..92c734892c3 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/EntityMiningSpeedVariable.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/EntityMiningSpeedVariable.java @@ -2,7 +2,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.tconstruct.library.json.variable.NestedFallbackLoader; import slimeknights.tconstruct.library.json.variable.NestedFallbackLoader.NestedFallback; diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedFormula.java b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedFormula.java index a3d266af1b0..02aba9ec8fb 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedFormula.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedFormula.java @@ -4,7 +4,7 @@ import net.minecraft.core.Direction; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry; import slimeknights.tconstruct.library.json.math.ModifierFormula; import slimeknights.tconstruct.library.json.variable.VariableFormula; diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedVariable.java b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedVariable.java index 2d54b00d8df..867a9d4f25b 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedVariable.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/MiningSpeedVariable.java @@ -2,7 +2,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.data.GenericLoaderRegistry.IHaveLoader; diff --git a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/ToolMiningSpeedVariable.java b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/ToolMiningSpeedVariable.java index 42c89187af3..ea49bf508af 100644 --- a/src/main/java/slimeknights/tconstruct/library/json/variable/mining/ToolMiningSpeedVariable.java +++ b/src/main/java/slimeknights/tconstruct/library/json/variable/mining/ToolMiningSpeedVariable.java @@ -2,7 +2,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.data.loader.NestedLoader; import slimeknights.tconstruct.library.json.variable.tool.ToolVariable; diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/ModifierId.java b/src/main/java/slimeknights/tconstruct/library/modifiers/ModifierId.java index 200910f990a..5a0dfd80a37 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/ModifierId.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/ModifierId.java @@ -2,6 +2,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import slimeknights.tconstruct.library.utils.IdParser; diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/DamageTakenModifierHook.java b/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/DamageTakenModifierHook.java index 12e057914f1..2057a055419 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/DamageTakenModifierHook.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/DamageTakenModifierHook.java @@ -1,7 +1,6 @@ package slimeknights.tconstruct.library.modifiers.hook.combat; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import slimeknights.tconstruct.library.modifiers.ModifierEntry; diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/ProtectionModifierHook.java b/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/ProtectionModifierHook.java index eb4bb8df28e..6c3371cab31 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/ProtectionModifierHook.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/hook/combat/ProtectionModifierHook.java @@ -2,7 +2,6 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraftforge.common.util.LazyOptional; import slimeknights.tconstruct.library.modifiers.ModifierEntry; import slimeknights.tconstruct.library.tools.capability.TinkerDataCapability; import slimeknights.tconstruct.library.tools.capability.TinkerDataKeys; @@ -10,6 +9,7 @@ import slimeknights.tconstruct.library.tools.nbt.IToolStackView; import java.util.Collection; +import java.util.Optional; /** * Hook for increasing or decreasing protection from a given damage source. @@ -35,8 +35,8 @@ public interface ProtectionModifierHook { float getProtectionModifier(IToolStackView tool, ModifierEntry modifier, EquipmentContext context, EquipmentSlot slotType, DamageSource source, float modifierValue); /** Gets the maximum protection amount on the given entity */ - static float getProtectionCap(LazyOptional capability) { - return Math.min(20 + capability.resolve().map(data -> data.get(TinkerDataKeys.PROTECTION_CAP)).orElse(0f), 25 * 0.95f); + static float getProtectionCap(Optional capability) { + return Math.min(20 + capability.map(data -> data.get(TinkerDataKeys.PROTECTION_CAP)).orElse(0f), 25 * 0.95f); } /** Merger that combines all values */ diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ProtectionModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ProtectionModule.java index dfb3645ab11..0bf7c45b709 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ProtectionModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ProtectionModule.java @@ -5,10 +5,9 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EquipmentSlot; @@ -16,7 +15,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.registries.ForgeRegistries; import slimeknights.mantle.client.TooltipKey; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.data.predicate.IJsonPredicate; @@ -78,13 +76,13 @@ public float getProtectionModifier(IToolStackView tool, ModifierEntry modifier, public static void addResistanceTooltip(IToolStackView tool, Modifier modifier, float amount, @Nullable Player player, List tooltip) { float cap; if (player != null) { - cap = ProtectionModifierHook.getProtectionCap(player.getCapability(TinkerDataCapability.CAPABILITY)); + cap = ProtectionModifierHook.getProtectionCap(TinkerDataCapability.CAPABILITY.maybeGet(player)); } else { cap = Math.min(20f + tool.getModifierLevel(TinkerModifiers.boundless.getId()) * 2.5f, 20 * 0.95f); } tooltip.add(modifier.applyStyle( - new TextComponent(Util.PERCENT_BOOST_FORMAT.format(Math.min(amount, cap) / 25f)) - .append(" ").append(new TranslatableComponent(modifier.getTranslationKey() + ".resistance")))); + Component.literal(Util.PERCENT_BOOST_FORMAT.format(Math.min(amount, cap) / 25f)) + .append(" ").append(Component.translatable(modifier.getTranslationKey() + ".resistance")))); } @Override @@ -104,7 +102,7 @@ public IGenericLoader getLoader() { public ProtectionModule deserialize(JsonObject json) { Enchantment enchantment = null; if (json.has("subtract_enchantment")) { - enchantment = JsonHelper.getAsEntry(ForgeRegistries.ENCHANTMENTS, json, "subtract_enchantment"); + enchantment = JsonHelper.getAsEntry(BuiltInRegistries.ENCHANTMENT, json, "subtract_enchantment"); } return new ProtectionModule( DamageSourcePredicate.LOADER.getAndDeserialize(json, "damage_source"), @@ -119,7 +117,7 @@ public void serialize(ProtectionModule object, JsonObject json) { json.add("wearing_entity", LivingEntityPredicate.LOADER.serialize(object.entity)); object.amount.serialize(json); if (object.subtract != null) { - json.addProperty("subtract_enchantment", Objects.requireNonNull(object.subtract.getRegistryName()).toString()); + json.addProperty("subtract_enchantment", Objects.requireNonNull(BuiltInRegistries.ENCHANTMENT.getKey(object.subtract)).toString()); } } @@ -127,7 +125,7 @@ public void serialize(ProtectionModule object, JsonObject json) { public ProtectionModule fromNetwork(FriendlyByteBuf buffer) { Enchantment enchantment = null; if (buffer.readBoolean()) { - enchantment = buffer.readRegistryIdUnsafe(ForgeRegistries.ENCHANTMENTS); + enchantment = BuiltInRegistries.ENCHANTMENT.byId(buffer.readVarInt()); } return new ProtectionModule( DamageSourcePredicate.LOADER.fromNetwork(buffer), LivingEntityPredicate.LOADER.fromNetwork(buffer), @@ -138,7 +136,7 @@ public ProtectionModule fromNetwork(FriendlyByteBuf buffer) { public void toNetwork(ProtectionModule object, FriendlyByteBuf buffer) { if (object.subtract != null) { buffer.writeBoolean(true); - buffer.writeRegistryIdUnsafe(ForgeRegistries.ENCHANTMENTS, object.subtract); + buffer.writeVarInt(BuiltInRegistries.ENCHANTMENT.getId(object.subtract)); } else { buffer.writeBoolean(false); } diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ReplaceBlockWalkerModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ReplaceBlockWalkerModule.java index 533c8ca9b52..2fd8e1957b9 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ReplaceBlockWalkerModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ReplaceBlockWalkerModule.java @@ -16,8 +16,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraftforge.common.util.BlockSnapshot; -import net.minecraftforge.event.ForgeEventFactory; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.data.predicate.IJsonPredicate; import slimeknights.mantle.data.predicate.block.BlockPredicate; diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ToolActionWalkerTransformModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ToolActionWalkerTransformModule.java index 8699f4ae2af..b845e9a0f38 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ToolActionWalkerTransformModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/armor/ToolActionWalkerTransformModule.java @@ -1,11 +1,13 @@ package slimeknights.tconstruct.library.modifiers.modules.armor; import com.google.gson.JsonObject; +import io.github.fabricators_of_create.porting_lib.tool.ToolAction; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; @@ -17,9 +19,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; -import net.minecraftforge.common.ToolAction; -import net.minecraftforge.registries.ForgeRegistries; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.util.JsonHelper; import slimeknights.tconstruct.library.json.LevelingValue; @@ -72,7 +71,7 @@ public void onWalk(IToolStackView tool, ModifierEntry modifier, LivingEntity liv @Override public MutableUseOnContext getContext(IToolStackView tool, ModifierEntry modifier, LivingEntity living, BlockPos prevPos, BlockPos newPos) { - return new MutableUseOnContext(living.getLevel(), living instanceof Player p ? p : null, InteractionHand.MAIN_HAND, living.getItemBySlot(EquipmentSlot.FEET), Util.createTraceResult(newPos, Direction.UP, false)); + return new MutableUseOnContext(living.level(), living instanceof Player p ? p : null, InteractionHand.MAIN_HAND, living.getItemBySlot(EquipmentSlot.FEET), Util.createTraceResult(newPos, Direction.UP, false)); } @Override @@ -103,7 +102,7 @@ public IGenericLoader getLoader() { public ToolActionWalkerTransformModule deserialize(JsonObject json) { return new ToolActionWalkerTransformModule( ToolAction.get(GsonHelper.getAsString(json, "tool_action")), - JsonHelper.getAsEntry(ForgeRegistries.SOUND_EVENTS, json, "sound"), + JsonHelper.getAsEntry(BuiltInRegistries.SOUND_EVENT, json, "sound"), LevelingValue.deserialize(GsonHelper.getAsJsonObject(json, "radius")), ModifierModuleCondition.deserializeFrom(json) ); @@ -113,7 +112,7 @@ public ToolActionWalkerTransformModule deserialize(JsonObject json) { public void serialize(ToolActionWalkerTransformModule object, JsonObject json) { object.condition.serializeInto(json); json.addProperty("tool_action", object.action.name()); - json.addProperty("sound", Objects.requireNonNull(object.sound.getRegistryName()).toString()); + json.addProperty("sound", Objects.requireNonNull(BuiltInRegistries.SOUND_EVENT.getKey(object.sound)).toString()); json.add("radius", object.radius.serialize(new JsonObject())); } @@ -121,7 +120,7 @@ public void serialize(ToolActionWalkerTransformModule object, JsonObject json) { public ToolActionWalkerTransformModule fromNetwork(FriendlyByteBuf buffer) { return new ToolActionWalkerTransformModule( ToolAction.get(buffer.readUtf(Short.MAX_VALUE)), - buffer.readRegistryIdUnsafe(ForgeRegistries.SOUND_EVENTS), + BuiltInRegistries.SOUND_EVENT.byId(buffer.readVarInt()), LevelingValue.fromNetwork(buffer), ModifierModuleCondition.fromNetwork(buffer) ); @@ -130,7 +129,7 @@ public ToolActionWalkerTransformModule fromNetwork(FriendlyByteBuf buffer) { @Override public void toNetwork(ToolActionWalkerTransformModule object, FriendlyByteBuf buffer) { buffer.writeUtf(object.action.name()); - buffer.writeRegistryIdUnsafe(ForgeRegistries.SOUND_EVENTS, object.sound); + buffer.writeVarInt(BuiltInRegistries.SOUND_EVENT.getId(object.sound)); object.radius.toNetwork(buffer); object.condition.toNetwork(buffer); } diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/AttributeModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/AttributeModule.java index 7eb8837a410..79e8aef3dd0 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/AttributeModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/AttributeModule.java @@ -3,13 +3,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.util.GsonHelper; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; -import net.minecraftforge.registries.ForgeRegistries; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.util.JsonHelper; import slimeknights.tconstruct.library.json.LevelingValue; @@ -77,7 +77,7 @@ public IGenericLoader getLoader() { public AttributeModule deserialize(JsonObject json) { String unique = GsonHelper.getAsString(json, "unique"); return new AttributeModule(unique, - JsonHelper.getAsEntry(ForgeRegistries.ATTRIBUTES, json, "attribute"), + JsonHelper.getAsEntry(BuiltInRegistries.ATTRIBUTE, json, "attribute"), JsonHelper.getAsEnum(json, "operation", Operation.class), LevelingValue.deserialize(json), slotsToUUIDs(unique, JsonHelper.parseList(json, "slots", SLOT_PARSER)), @@ -89,7 +89,7 @@ public AttributeModule deserialize(JsonObject json) { public void serialize(AttributeModule object, JsonObject json) { object.condition.serializeInto(json); json.addProperty("unique", object.unique); - json.addProperty("attribute", Objects.requireNonNull(object.attribute.getRegistryName()).toString()); + json.addProperty("attribute", Objects.requireNonNull(BuiltInRegistries.ATTRIBUTE.getKey(object.attribute)).toString()); json.addProperty("operation", object.operation.name().toLowerCase(Locale.ROOT)); object.amount.serialize(json); JsonArray array = new JsonArray(); @@ -112,7 +112,7 @@ public AttributeModule fromNetwork(FriendlyByteBuf buffer) { } } return new AttributeModule(name, - buffer.readRegistryIdUnsafe(ForgeRegistries.ATTRIBUTES), + BuiltInRegistries.ATTRIBUTE.byId(buffer.readVarInt()), buffer.readEnum(Operation.class), LevelingValue.fromNetwork(buffer), slotUUIDs, @@ -130,7 +130,7 @@ public void toNetwork(AttributeModule object, FriendlyByteBuf buffer) { } } buffer.writeByte(packed); - buffer.writeRegistryIdUnsafe(ForgeRegistries.ATTRIBUTES, object.attribute); + buffer.writeVarInt(BuiltInRegistries.ATTRIBUTE.getId(object.attribute)); buffer.writeEnum(object.operation); object.amount.toNetwork(buffer); object.condition.toNetwork(buffer); diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ReduceToolDamageModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ReduceToolDamageModule.java index 507dd24f756..da12b7af237 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ReduceToolDamageModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ReduceToolDamageModule.java @@ -1,7 +1,6 @@ package slimeknights.tconstruct.library.modifiers.modules.behavior; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.TooltipFlag; @@ -88,7 +87,7 @@ public int onDamageTool(IToolStackView tool, ModifierEntry modifier, int amount, @Override public void addTooltip(IToolStackView tool, ModifierEntry modifier, @Nullable Player player, List tooltip, TooltipKey tooltipKey, TooltipFlag tooltipFlag) { if (this.condition.matches(tool, modifier)) { - tooltip.add(modifier.getModifier().applyStyle(new TextComponent(Util.PERCENT_FORMAT.format(getPercent(tool, modifier)) + " ").append(modifier.getModifier().getDisplayName()))); + tooltip.add(modifier.getModifier().applyStyle(Component.literal(Util.PERCENT_FORMAT.format(getPercent(tool, modifier)) + " ").append(modifier.getModifier().getDisplayName()))); } } diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ToolActionTransformModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ToolActionTransformModule.java index 80c9f5253a3..8dd0aa11798 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ToolActionTransformModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/behavior/ToolActionTransformModule.java @@ -1,11 +1,13 @@ package slimeknights.tconstruct.library.modifiers.modules.behavior; import com.google.gson.JsonObject; +import io.github.fabricators_of_create.porting_lib.tool.ToolAction; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; @@ -15,9 +17,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; -import net.minecraftforge.common.ToolAction; -import net.minecraftforge.registries.ForgeRegistries; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.util.JsonHelper; import slimeknights.tconstruct.library.modifiers.ModifierEntry; @@ -94,7 +93,7 @@ public IGenericLoader getLoader() { public ToolActionTransformModule deserialize(JsonObject json) { return new ToolActionTransformModule( ToolAction.get(GsonHelper.getAsString(json, "tool_action")), - JsonHelper.getAsEntry(ForgeRegistries.SOUND_EVENTS, json, "sound"), + JsonHelper.getAsEntry(BuiltInRegistries.SOUND_EVENT, json, "sound"), GsonHelper.getAsBoolean(json, "require_ground"), GsonHelper.getAsInt(json, "event_id", -1), ModifierModuleCondition.deserializeFrom(json) @@ -105,7 +104,7 @@ public ToolActionTransformModule deserialize(JsonObject json) { public void serialize(ToolActionTransformModule object, JsonObject json) { object.condition.serializeInto(json); json.addProperty("tool_action", object.action.name()); - json.addProperty("sound", Objects.requireNonNull(object.sound.getRegistryName()).toString()); + json.addProperty("sound", Objects.requireNonNull(BuiltInRegistries.SOUND_EVENT.getKey(object.sound)).toString()); json.addProperty("require_ground", object.requireGround); if (object.eventId != -1) { json.addProperty("event_id", object.eventId); @@ -116,7 +115,7 @@ public void serialize(ToolActionTransformModule object, JsonObject json) { public ToolActionTransformModule fromNetwork(FriendlyByteBuf buffer) { return new ToolActionTransformModule( ToolAction.get(buffer.readUtf(Short.MAX_VALUE)), - buffer.readRegistryIdUnsafe(ForgeRegistries.SOUND_EVENTS), + BuiltInRegistries.SOUND_EVENT.byId(buffer.readVarInt()), buffer.readBoolean(), buffer.readShort(), ModifierModuleCondition.fromNetwork(buffer) @@ -126,7 +125,7 @@ public ToolActionTransformModule fromNetwork(FriendlyByteBuf buffer) { @Override public void toNetwork(ToolActionTransformModule object, FriendlyByteBuf buffer) { buffer.writeUtf(object.action.name()); - buffer.writeRegistryIdUnsafe(ForgeRegistries.SOUND_EVENTS, object.sound); + buffer.writeVarInt(BuiltInRegistries.SOUND_EVENT.getId(object.sound)); buffer.writeBoolean(object.requireGround); buffer.writeShort(object.eventId); object.condition.toNetwork(buffer); diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/build/EnchantmentModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/build/EnchantmentModule.java index 73a560d492f..dac4681c063 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/build/EnchantmentModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/build/EnchantmentModule.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -12,7 +13,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; -import net.minecraftforge.registries.ForgeRegistries; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.util.JsonHelper; import slimeknights.tconstruct.library.modifiers.Modifier; @@ -81,7 +81,7 @@ record Loader(EnchantmentModuleConstructor constructor) implements IGenericLoade @Override public EnchantmentModule deserialize(JsonObject json) { return constructor.apply( - JsonHelper.getAsEntry(ForgeRegistries.ENCHANTMENTS, json, "name"), + JsonHelper.getAsEntry(BuiltInRegistries.ENCHANTMENT, json, "name"), JsonUtils.getIntMin(json, "level", 1), ModifierModuleCondition.deserializeFrom(json)); } @@ -89,21 +89,21 @@ public EnchantmentModule deserialize(JsonObject json) { @Override public void serialize(EnchantmentModule object, JsonObject json) { object.condition().serializeInto(json); - json.addProperty("name", Objects.requireNonNull(object.enchantment().getRegistryName()).toString()); + json.addProperty("name", Objects.requireNonNull(BuiltInRegistries.ENCHANTMENT.getKey(object.enchantment())).toString()); json.addProperty("level", object.level()); } @Override public EnchantmentModule fromNetwork(FriendlyByteBuf buffer) { return constructor.apply( - buffer.readRegistryIdUnsafe(ForgeRegistries.ENCHANTMENTS), + BuiltInRegistries.ENCHANTMENT.byId(buffer.readVarInt()), buffer.readVarInt(), ModifierModuleCondition.fromNetwork(buffer)); } @Override public void toNetwork(EnchantmentModule object, FriendlyByteBuf buffer) { - buffer.writeRegistryIdUnsafe(ForgeRegistries.ENCHANTMENTS, object.enchantment()); + buffer.writeVarInt(BuiltInRegistries.ENCHANTMENT.getId(object.enchantment())); buffer.writeVarInt(object.level()); object.condition().toNetwork(buffer); } @@ -144,7 +144,7 @@ public IGenericLoader getLoader() { * @param enchantment Enchantment to remove */ private static void removeEnchantment(ListTag list, Enchantment enchantment) { - String id = Objects.requireNonNull(enchantment.getRegistryName()).toString(); + String id = Objects.requireNonNull(BuiltInRegistries.ENCHANTMENT.getKey(enchantment)).toString(); Iterator iterator = list.iterator(); while (iterator.hasNext()) { Tag iteratorTag = iterator.next(); @@ -172,7 +172,7 @@ static void setEnchantmentLevel(RestrictedCompoundTag tag, Enchantment enchantme tag.put(ModifierUtil.TAG_ENCHANTMENTS, enchantments); } // add the enchantment - enchantments.add(EnchantmentHelper.storeEnchantment(enchantment.getRegistryName(), level)); + enchantments.add(EnchantmentHelper.storeEnchantment(BuiltInRegistries.ENCHANTMENT.getKey(enchantment), level)); } /** diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankCapacityModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankCapacityModule.java index d2f655b4f3e..b62c433acde 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankCapacityModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankCapacityModule.java @@ -31,11 +31,11 @@ public class TankCapacityModule implements ModifierModule, VolatileDataModifierH /** Volatile NBT integer indicating the tank's max capacity */ private final ResourceLocation capacityKey; /** Max capacity added by this module */ - private final int capacity; + private final long capacity; /** If true, capacity scales with level */ private final boolean scaleCapacity; - public TankCapacityModule(int capacity, boolean scaleCapacity) { + public TankCapacityModule(long capacity, boolean scaleCapacity) { this(DEFAULT_CAPACITY_KEY, capacity, scaleCapacity); } @@ -47,7 +47,7 @@ public int getCapacity(IToolStackView tool) { @Override public void addVolatileData(ToolRebuildContext context, ModifierEntry modifier, ModDataNBT volatileData) { ResourceLocation key = getCapacityKey(); - volatileData.putInt(key, capacity * modifier.getLevel() + volatileData.getInt(key)); + volatileData.putLong(key, capacity * modifier.getLevel() + volatileData.getInt(key)); } @Override @@ -63,7 +63,7 @@ public IGenericLoader getLoader() { public static final IGenericLoader LOADER = new IGenericLoader<>() { @Override public TankCapacityModule deserialize(JsonObject json) { - int capacity = GsonHelper.getAsInt(json, "capacity"); + long capacity = GsonHelper.getAsLong(json, "capacity"); boolean scaleCapacity = GsonHelper.getAsBoolean(json, "scale_capacity"); ResourceLocation capacityKey = JsonHelper.getResourceLocation(json, "capacity_key", DEFAULT_CAPACITY_KEY); return new TankCapacityModule(capacityKey, capacity, scaleCapacity); @@ -81,7 +81,7 @@ public void serialize(TankCapacityModule object, JsonObject json) { @Override public TankCapacityModule fromNetwork(FriendlyByteBuf buffer) { ResourceLocation capacityKey = buffer.readResourceLocation(); - int capacity = buffer.readVarInt(); + long capacity = buffer.readLong(); boolean scaleCapacity = buffer.readBoolean(); return new TankCapacityModule(capacityKey, capacity, scaleCapacity); } @@ -89,7 +89,7 @@ public TankCapacityModule fromNetwork(FriendlyByteBuf buffer) { @Override public void toNetwork(TankCapacityModule object, FriendlyByteBuf buffer) { buffer.writeResourceLocation(object.capacityKey); - buffer.writeVarInt(object.capacity); + buffer.writeLong(object.capacity); buffer.writeBoolean(object.scaleCapacity); } }; diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankModule.java index 0915c55a8c9..703ee565ea5 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/fluid/TankModule.java @@ -1,18 +1,16 @@ package slimeknights.tconstruct.library.modifiers.modules.fluid; import com.google.gson.JsonObject; +import io.github.fabricators_of_create.porting_lib.fluids.FluidStack; import lombok.Getter; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.TooltipFlag; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; import slimeknights.mantle.client.TooltipKey; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.util.JsonHelper; @@ -57,13 +55,13 @@ public class TankModule extends TankCapacityModule implements FluidModifierHook, @Getter private final ResourceLocation fluidKey; - public TankModule(ResourceLocation capacityKey, int capacity, boolean scaleCapacity, ResourceLocation fluidKey, ResourceLocation ownerKey) { + public TankModule(ResourceLocation capacityKey, long capacity, boolean scaleCapacity, ResourceLocation fluidKey, ResourceLocation ownerKey) { super(capacityKey, capacity, scaleCapacity); this.ownerKey = ownerKey; this.fluidKey = fluidKey; } - public TankModule(int capacity, boolean scaleCapacity) { + public TankModule(long capacity, boolean scaleCapacity) { this(DEFAULT_CAPACITY_KEY, capacity, scaleCapacity, DEFAULT_FLUID_KEY, DEFAULT_OWNER_KEY); } @@ -72,9 +70,9 @@ public void addTooltip(IToolStackView tool, ModifierEntry modifier, @Nullable Pl if (isOwner(tool, modifier.getId())) { FluidStack current = getFluid(tool); if (!current.isEmpty()) { - tooltip.add(new TranslatableComponent(FILLED_KEY, current.getAmount(), current.getDisplayName())); + tooltip.add(Component.translatable(FILLED_KEY, current.getAmount(), current.getDisplayName())); } - tooltip.add(new TranslatableComponent(CAPACITY_KEY, getCapacity(tool))); + tooltip.add(Component.translatable(CAPACITY_KEY, getCapacity(tool))); } } @@ -96,7 +94,7 @@ public int getTanks(IToolContext tool, Modifier modifier) { } @Override - public int getTankCapacity(IToolStackView tool, ModifierEntry modifier, int tank) { + public long getTankCapacity(IToolStackView tool, ModifierEntry modifier, int tank) { return isOwner(tool, modifier.getId()) ? getCapacity(tool) : 0; } diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/mining/ConditionalMiningSpeedModule.java b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/mining/ConditionalMiningSpeedModule.java index c338da12ee0..3cadcd4289b 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/modules/mining/ConditionalMiningSpeedModule.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/modules/mining/ConditionalMiningSpeedModule.java @@ -9,7 +9,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; +import io.github.fabricators_of_create.porting_lib.entity.events.PlayerEvents.BreakSpeed; import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader; import slimeknights.mantle.data.predicate.IJsonPredicate; import slimeknights.mantle.data.predicate.block.BlockPredicate; diff --git a/src/main/java/slimeknights/tconstruct/library/modifiers/spilling/effects/SetFreezeSpillingEffect.java b/src/main/java/slimeknights/tconstruct/library/modifiers/spilling/effects/SetFreezeSpillingEffect.java index bb0cf3dd372..b2e4a8d8d54 100644 --- a/src/main/java/slimeknights/tconstruct/library/modifiers/spilling/effects/SetFreezeSpillingEffect.java +++ b/src/main/java/slimeknights/tconstruct/library/modifiers/spilling/effects/SetFreezeSpillingEffect.java @@ -3,10 +3,10 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; +import io.github.fabricators_of_create.porting_lib.fluids.FluidStack; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; import net.minecraft.world.entity.Entity; -import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.TConstruct; import slimeknights.tconstruct.library.modifiers.spilling.ISpillingEffect; import slimeknights.tconstruct.library.tools.context.ToolAttackContext; diff --git a/src/main/java/slimeknights/tconstruct/library/recipe/ingredient/NoContainerIngredient.java b/src/main/java/slimeknights/tconstruct/library/recipe/ingredient/NoContainerIngredient.java index 6416b1d4e1d..0aa806e6e4e 100644 --- a/src/main/java/slimeknights/tconstruct/library/recipe/ingredient/NoContainerIngredient.java +++ b/src/main/java/slimeknights/tconstruct/library/recipe/ingredient/NoContainerIngredient.java @@ -9,9 +9,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; -import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.common.crafting.IIngredientSerializer; -import net.minecraftforge.common.crafting.VanillaIngredientSerializer; import slimeknights.tconstruct.TConstruct; import slimeknights.tconstruct.library.utils.JsonUtils; diff --git a/src/main/java/slimeknights/tconstruct/plugin/DietPlugin.java b/src/main/java/slimeknights/tconstruct/plugin/DietPlugin.java index 5cbdf9482f9..0dfc0d4ecbb 100644 --- a/src/main/java/slimeknights/tconstruct/plugin/DietPlugin.java +++ b/src/main/java/slimeknights/tconstruct/plugin/DietPlugin.java @@ -1,14 +1,14 @@ package slimeknights.tconstruct.plugin; +import com.illusivesoulworks.diet.common.component.DietComponents; import slimeknights.tconstruct.library.tools.helper.ModifierUtil; -import top.theillusivec4.diet.api.DietCapability; /** Plugin to enable compat with the Diet mod */ public class DietPlugin { /** Call on mod construct to enable the compat */ public static void onConstruct() { ModifierUtil.foodConsumer = (player, stack, hunger, saturation) -> { - DietCapability.get(player).ifPresent(cap -> cap.consume(stack, hunger, saturation)); + DietComponents.DIET_TRACKER.maybeGet(player).ifPresent(cap -> cap.consume(stack, hunger, saturation)); }; } } diff --git a/src/main/java/slimeknights/tconstruct/tools/TinkerModifiers.java b/src/main/java/slimeknights/tconstruct/tools/TinkerModifiers.java index 14c1729ab87..e7bf0f84117 100644 --- a/src/main/java/slimeknights/tconstruct/tools/TinkerModifiers.java +++ b/src/main/java/slimeknights/tconstruct/tools/TinkerModifiers.java @@ -1,6 +1,7 @@ package slimeknights.tconstruct.tools; import com.mojang.serialization.Codec; +import io.github.fabricators_of_create.porting_lib.data.ExistingFileHelper; import io.github.fabricators_of_create.porting_lib.tool.ToolAction; import io.github.fabricators_of_create.porting_lib.tool.ToolActions; import io.github.fabricators_of_create.porting_lib.util.RegistryObject; diff --git a/src/main/java/slimeknights/tconstruct/tools/ToolClientEvents.java b/src/main/java/slimeknights/tconstruct/tools/ToolClientEvents.java index fefb430d660..42532ce5bc5 100644 --- a/src/main/java/slimeknights/tconstruct/tools/ToolClientEvents.java +++ b/src/main/java/slimeknights/tconstruct/tools/ToolClientEvents.java @@ -17,6 +17,7 @@ import net.minecraft.client.player.Input; import net.minecraft.client.renderer.entity.ItemEntityRenderer; import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.world.entity.EquipmentSlot; @@ -112,7 +113,7 @@ static void registerModifierModels(ModifierModelRegistrationEvent event) { static void registerRenderers() { EntityRendererRegistry.register(TinkerTools.indestructibleItem.get(), ItemEntityRenderer::new); EntityRendererRegistry.register(TinkerTools.crystalshotEntity.get(), CrystalshotRenderer::new); - event.registerEntityRenderer(TinkerModifiers.fluidSpitEntity.get(), FluidSpitRenderer::new); + EntityRendererRegistry.register(TinkerModifiers.fluidSpitEntity.get(), FluidSpitRenderer::new); } public static void clientSetupEvent() { @@ -166,7 +167,7 @@ public static void clientSetupEvent() { } static void registerParticleFactories() { - ParticleEngine.SpriteParticleRegistration factory = AttackParticle.Factory::new; + ParticleFactoryRegistry.PendingParticleFactory factory = AttackParticle.Factory::new; ParticleFactoryRegistry.getInstance().register(TinkerTools.hammerAttackParticle.get(), factory); ParticleFactoryRegistry.getInstance().register(TinkerTools.axeAttackParticle.get(), factory); ParticleFactoryRegistry.getInstance().register(TinkerTools.bonkAttackParticle.get(), factory); diff --git a/src/main/java/slimeknights/tconstruct/tools/client/FluidSpitRenderer.java b/src/main/java/slimeknights/tconstruct/tools/client/FluidSpitRenderer.java index 3a6d2b4c6c4..92c03721d8b 100644 --- a/src/main/java/slimeknights/tconstruct/tools/client/FluidSpitRenderer.java +++ b/src/main/java/slimeknights/tconstruct/tools/client/FluidSpitRenderer.java @@ -1,7 +1,7 @@ package slimeknights.tconstruct.tools.client; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider.Context; @@ -9,6 +9,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.inventory.InventoryMenu; +import org.joml.Vector3f; import slimeknights.mantle.client.model.fluid.FluidCuboid; import slimeknights.mantle.client.model.fluid.FluidCuboid.FluidFace; import slimeknights.mantle.client.render.FluidRenderer; @@ -45,8 +46,8 @@ public FluidSpitRenderer(Context context) { public void render(FluidSpitEntity pEntity, float pEntityYaw, float pPartialTicks, PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight) { pMatrixStack.pushPose(); pMatrixStack.translate(0.0D, 0.15F, 0.0D); - pMatrixStack.mulPose(Vector3f.YP.rotationDegrees(Mth.lerp(pPartialTicks, pEntity.yRotO, pEntity.getYRot()) - 90.0F)); - pMatrixStack.mulPose(Vector3f.ZP.rotationDegrees(Mth.lerp(pPartialTicks, pEntity.xRotO, pEntity.getXRot()))); + pMatrixStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(pPartialTicks, pEntity.yRotO, pEntity.getYRot()) - 90.0F)); + pMatrixStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(pPartialTicks, pEntity.xRotO, pEntity.getXRot()))); FluidRenderer.renderCuboids(pMatrixStack, pBuffer.getBuffer(MantleRenderTypes.FLUID), fluids, pEntity.getFluid(), pPackedLight); pMatrixStack.popPose(); super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight); diff --git a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/UseFluidOnHitModifier.java b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/UseFluidOnHitModifier.java index 294f57ba7bd..2eb0cae65d6 100644 --- a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/UseFluidOnHitModifier.java +++ b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/UseFluidOnHitModifier.java @@ -1,5 +1,7 @@ package slimeknights.tconstruct.tools.modifiers.ability.armor; +import io.github.fabricators_of_create.porting_lib.fluids.FluidStack; +import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -7,8 +9,6 @@ import net.minecraft.world.entity.EquipmentSlot.Type; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.fluids.FluidAttributes; -import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.library.modifiers.ModifierEntry; import slimeknights.tconstruct.library.modifiers.impl.TankModifier; import slimeknights.tconstruct.library.modifiers.spilling.SpillingFluid; @@ -24,13 +24,13 @@ /** Modifier to handle spilling recipes onto self when attacked */ public abstract class UseFluidOnHitModifier extends TankModifier { public UseFluidOnHitModifier() { - super(FluidAttributes.BUCKET_VOLUME); + super(FluidConstants.BUCKET); } /** Spawns particles at the given entity */ public static void spawnParticles(Entity target, FluidStack fluid) { - if (target.level instanceof ServerLevel) { - ((ServerLevel)target.level).sendParticles(new FluidParticleData(TinkerCommons.fluidParticle.get(), fluid), target.getX(), target.getY(0.5), target.getZ(), 10, 0.1, 0.2, 0.1, 0.2); + if (target.level() instanceof ServerLevel) { + ((ServerLevel)target.level()).sendParticles(new FluidParticleData(TinkerCommons.fluidParticle.get(), fluid), target.getX(), target.getY(0.5), target.getZ(), 10, 0.1, 0.2, 0.1, 0.2); } } diff --git a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/WettingModifier.java b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/WettingModifier.java index 2d244ae7a27..f1bffd2addb 100644 --- a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/WettingModifier.java +++ b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/armor/WettingModifier.java @@ -1,12 +1,12 @@ package slimeknights.tconstruct.tools.modifiers.ability.armor; +import io.github.fabricators_of_create.porting_lib.fluids.FluidStack; import net.minecraft.world.InteractionHand; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.library.modifiers.ModifierEntry; import slimeknights.tconstruct.library.modifiers.TinkerHooks; import slimeknights.tconstruct.library.modifiers.hook.combat.ModifyDamageModifierHook; diff --git a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/fluid/SpittingModifier.java b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/fluid/SpittingModifier.java index c2ff8eb688a..5c3b01a619b 100644 --- a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/fluid/SpittingModifier.java +++ b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/fluid/SpittingModifier.java @@ -1,9 +1,9 @@ package slimeknights.tconstruct.tools.modifiers.ability.fluid; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; +import io.github.fabricators_of_create.porting_lib.fluids.FluidStack; import lombok.Getter; import lombok.Setter; +import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.SynchedEntityData; @@ -20,8 +20,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.fluids.FluidAttributes; -import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.fluids.TinkerFluids; import slimeknights.tconstruct.library.modifiers.Modifier; import slimeknights.tconstruct.library.modifiers.ModifierEntry; @@ -54,7 +52,7 @@ public class SpittingModifier extends Modifier implements GeneralInteractionModi @Override protected void registerHooks(Builder builder) { builder.addHook(this, TinkerHooks.CHARGEABLE_INTERACT); - tank = new TankModule(FluidAttributes.BUCKET_VOLUME, true); + tank = new TankModule(FluidConstants.BUCKET, true); builder.addModule(tank); } @@ -72,7 +70,7 @@ public UseAnim getUseAction(IToolStackView tool, ModifierEntry modifier) { public InteractionResult onToolUse(IToolStackView tool, ModifierEntry modifier, Player player, InteractionHand hand, InteractionSource source) { if (!tool.isBroken() && source == InteractionSource.RIGHT_CLICK) { FluidStack fluid = tank.getFluid(tool); - if (fluid.getAmount() >= (1 + 2 * (modifier.getLevel() - 1)) && SpillingFluidManager.INSTANCE.contains(fluid.getFluid())) { + if (fluid.getAmount() >= (1 + 2L * (modifier.getLevel() - 1)) && SpillingFluidManager.INSTANCE.contains(fluid.getFluid())) { ModifierUtil.startUsingItemWithDrawtime(tool, modifier.getId(), player, hand, 1.5f); return InteractionResult.SUCCESS; } @@ -88,7 +86,7 @@ public void onUsingTick(IToolStackView tool, ModifierEntry modifier, LivingEntit @Override public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, LivingEntity entity, int timeLeft) { ScopeModifier.stopScoping(entity); - if (!entity.level.isClientSide) { + if (!entity.level().isClientSide) { int chargeTime = getUseDuration(tool, modifier) - timeLeft; if (chargeTime > 0) { // find the fluid to spit @@ -104,7 +102,7 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin int level = modifier.getLevel(); // amount is the amount per projectile, total cost is amount times level (every other shot is free) // if its 0, that means we have only a couple mb left - int amount = Math.min(fluid.getAmount(), (int)(recipe.getAmount(fluid) * power) * level) / level; + long amount = Math.min(fluid.getAmount(), (int)(recipe.getAmount(fluid) * power) * level) / level; if (amount > 0) { // other stats now that we know we are shooting // velocity determines how far it goes, does not impact damage unlike bows @@ -116,7 +114,7 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin float startAngle = ModifiableLauncherItem.getAngleStart(shots); int primaryIndex = shots / 2; for (int shotIndex = 0; shotIndex < shots; shotIndex++) { - FluidSpitEntity spit = new FluidSpitEntity(entity.level, entity, new FluidStack(fluid, amount), (int)Math.ceil(power)); + FluidSpitEntity spit = new FluidSpitEntity(entity.level(), entity, new FluidStack(fluid, amount), (int)Math.ceil(power)); // setup projectile target Vector3f targetVector = new Vector3f(entity.getViewVector(1.0f)); @@ -125,7 +123,7 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin spit.shoot(targetVector.x(), targetVector.y(), targetVector.z(), velocity, inaccuracy); // store all modifiers on the spit - spit.getCapability(EntityModifierCapability.CAPABILITY).ifPresent(cap -> cap.setModifiers(tool.getModifiers())); + EntityModifierCapability.CAPABILITY.maybeGet(spit).ifPresent(cap -> cap.setModifiers(tool.getModifiers())); // fetch the persistent data for the arrow as modifiers may want to store data NamespacedNBT arrowData = PersistentDataCapability.getOrWarn(spit); @@ -135,8 +133,8 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin } // finally, fire the projectile - entity.level.addFreshEntity(spit); - entity.level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.LLAMA_SPIT, SoundSource.PLAYERS, 1.0F, 1.0F / (entity.level.getRandom().nextFloat() * 0.4F + 1.2F) + charge * 0.5F + (angle / 10f)); + entity.level().addFreshEntity(spit); + entity.level().playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.LLAMA_SPIT, SoundSource.PLAYERS, 1.0F, 1.0F / (entity.level().getRandom().nextFloat() * 0.4F + 1.2F) + charge * 0.5F + (angle / 10f)); } @@ -185,7 +183,7 @@ public void setFluid(FluidStack fluid) { @Override protected void onHitEntity(EntityHitResult result) { FluidStack fluid = getFluid(); - if (!level.isClientSide && !fluid.isEmpty() && getOwner() instanceof LivingEntity living) { + if (!level().isClientSide && !fluid.isEmpty() && getOwner() instanceof LivingEntity living) { SpillingFluid recipe = SpillingFluidManager.INSTANCE.find(fluid.getFluid()); Entity target = result.getEntity(); if (recipe.hasEffects()) { diff --git a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/sling/WarpingModifier.java b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/sling/WarpingModifier.java index 6e4e1533d50..5d1629d15b6 100644 --- a/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/sling/WarpingModifier.java +++ b/src/main/java/slimeknights/tconstruct/tools/modifiers/ability/sling/WarpingModifier.java @@ -3,9 +3,9 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.common.MinecraftForge; import slimeknights.tconstruct.common.Sounds; import slimeknights.tconstruct.library.events.teleport.SlingModifierTeleportEvent; import slimeknights.tconstruct.library.modifiers.ModifierEntry; @@ -13,19 +13,17 @@ import slimeknights.tconstruct.library.tools.helper.ToolDamageUtil; import slimeknights.tconstruct.library.tools.nbt.IToolStackView; -import java.util.Random; - /** Teleport through blocks in the look direction */ public class WarpingModifier extends SlingModifier { @Override public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, LivingEntity entity, int timeLeft) { super.onStoppedUsing(tool, modifier, entity, timeLeft); - if (!entity.level.isClientSide && entity instanceof ServerPlayer player) { + if (!entity.level().isClientSide && entity instanceof ServerPlayer player) { float f = getForce(tool, modifier, entity, timeLeft, false) * 6; if (f > 0) { Vec3 look = player.getLookAngle(); float inaccuracy = ModifierUtil.getInaccuracy(tool, player, 1) * 0.0075f; - Random random = player.getRandom(); + RandomSource random = player.getRandom(); double offX = (look.x + random.nextGaussian() * inaccuracy) * f; double offY = (look.y + random.nextGaussian() * inaccuracy) * f + 1; // add extra to help with bad collisions double offZ = (look.z + random.nextGaussian() * inaccuracy) * f; @@ -33,15 +31,15 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin // find teleport target BlockPos furthestPos = null; while (Math.abs(offX) > .5 || Math.abs(offY) > .5 || Math.abs(offZ) > .5) { // while not too close to player - BlockPos posAttempt = new BlockPos(player.getX() + offX, player.getY() + offY, player.getZ() + offZ); + BlockPos posAttempt = BlockPos.containing(player.getX() + offX, player.getY() + offY, player.getZ() + offZ); // if we do not have a position yet, see if this one is valid if (furthestPos == null) { - if (player.level.getWorldBorder().isWithinBounds(posAttempt) && !player.level.getBlockState(posAttempt).isSuffocating(player.level, posAttempt)) { + if (player.level().getWorldBorder().isWithinBounds(posAttempt) && !player.level().getBlockState(posAttempt).isSuffocating(player.level(), posAttempt)) { furthestPos = posAttempt; } } else { // if we already have a position, clear if the new one is unbreakable - if (player.level.getBlockState(posAttempt).getDestroySpeed(player.level, posAttempt) == -1) { + if (player.level().getBlockState(posAttempt).getDestroySpeed(player.level(), posAttempt) == -1) { furthestPos = null; } } @@ -61,9 +59,9 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin // particle effect from EnderPearlEntity for (int i = 0; i < 32; ++i) { - entity.level.addParticle(ParticleTypes.PORTAL, player.getX(), player.getY() + entity.level.random.nextDouble() * 2.0D, player.getZ(), entity.level.random.nextGaussian(), 0.0D, entity.level.random.nextGaussian()); + entity.level().addParticle(ParticleTypes.PORTAL, player.getX(), player.getY() + entity.level().random.nextDouble() * 2.0D, player.getZ(), entity.level().random.nextGaussian(), 0.0D, entity.level.random.nextGaussian()); } - entity.level.playSound(null, player.getX(), player.getY(), player.getZ(), Sounds.SLIME_SLING_TELEPORT.getSound(), player.getSoundSource(), 1f, 1f); + entity.level().playSound(null, player.getX(), player.getY(), player.getZ(), Sounds.SLIME_SLING_TELEPORT.getSound(), player.getSoundSource(), 1f, 1f); player.causeFoodExhaustion(0.2F); player.getCooldowns().addCooldown(tool.getItem(), 3); ToolDamageUtil.damageAnimated(tool, 1, entity); @@ -71,7 +69,7 @@ public boolean onStoppedUsing(IToolStackView tool, ModifierEntry modifier, Livin } } } - entity.level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), Sounds.SLIME_SLING_TELEPORT.getSound(), entity.getSoundSource(), 1, 0.5f); + entity.level().playSound(null, entity.getX(), entity.getY(), entity.getZ(), Sounds.SLIME_SLING_TELEPORT.getSound(), entity.getSoundSource(), 1, 0.5f); } return true; } diff --git a/src/main/java/slimeknights/tconstruct/tools/modifiers/traits/general/TastyModifier.java b/src/main/java/slimeknights/tconstruct/tools/modifiers/traits/general/TastyModifier.java index d0a8acecb31..1e75c39445d 100644 --- a/src/main/java/slimeknights/tconstruct/tools/modifiers/traits/general/TastyModifier.java +++ b/src/main/java/slimeknights/tconstruct/tools/modifiers/traits/general/TastyModifier.java @@ -1,5 +1,6 @@ package slimeknights.tconstruct.tools.modifiers.traits.general; +import io.github.fabricators_of_create.porting_lib.common.util.Lazy; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -14,7 +15,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; -import net.minecraftforge.common.util.Lazy; import slimeknights.tconstruct.common.TinkerTags; import slimeknights.tconstruct.library.modifiers.Modifier; import slimeknights.tconstruct.library.modifiers.ModifierEntry; diff --git a/src/main/java/slimeknights/tconstruct/tools/network/FluidDataSerializer.java b/src/main/java/slimeknights/tconstruct/tools/network/FluidDataSerializer.java index a7a51582f93..fc6fbeaef63 100644 --- a/src/main/java/slimeknights/tconstruct/tools/network/FluidDataSerializer.java +++ b/src/main/java/slimeknights/tconstruct/tools/network/FluidDataSerializer.java @@ -1,19 +1,19 @@ package slimeknights.tconstruct.tools.network; +import io.github.fabricators_of_create.porting_lib.fluids.FluidStack; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.syncher.EntityDataSerializer; -import net.minecraftforge.fluids.FluidStack; /** Serializer for fluid stack data in entities */ public class FluidDataSerializer implements EntityDataSerializer { @Override public void write(FriendlyByteBuf buffer, FluidStack stack) { - buffer.writeFluidStack(stack); + stack.writeToPacket(buffer); } @Override public FluidStack read(FriendlyByteBuf buffer) { - return buffer.readFluidStack(); + return FluidStack.readFromPacket(buffer); } @Override diff --git a/src/main/java/slimeknights/tconstruct/world/entity/SkySlimeEntity.java b/src/main/java/slimeknights/tconstruct/world/entity/SkySlimeEntity.java index 6b98ddaec4f..45a2744e304 100644 --- a/src/main/java/slimeknights/tconstruct/world/entity/SkySlimeEntity.java +++ b/src/main/java/slimeknights/tconstruct/world/entity/SkySlimeEntity.java @@ -3,6 +3,7 @@ import io.github.fabricators_of_create.porting_lib.entity.events.LivingEntityEvents; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.tags.TagKey; +import net.minecraft.util.RandomSource; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EntityType; @@ -26,7 +27,6 @@ import slimeknights.tconstruct.world.TinkerWorld; import java.util.List; -import java.util.Random; public class SkySlimeEntity extends ArmoredSlimeEntity { private double bounceAmount = 0f; @@ -80,7 +80,7 @@ public void move(MoverType typeIn, Vec3 pos) { } @Override - protected void populateDefaultEquipmentSlots(RandomSource randomSource, DifficultyInstance difficulty) { + protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) { // sky slime spawns with tinkers armor, high chance of travelers, low chance of plate // vanilla logic but simplified down to just helmets float multiplier = difficulty.getSpecialMultiplier(); @@ -125,7 +125,7 @@ protected void populateDefaultEquipmentSlots(RandomSource randomSource, Difficul } /** Gets a random defense modifier from the tag */ - private static ModifierId randomModifier(Random random, TagKey tag) { + private static ModifierId randomModifier(RandomSource random, TagKey tag) { List options = ModifierManager.getTagValues(tag); return options.get(random.nextInt(options.size())).getId(); }