diff --git a/build.gradle b/build.gradle index 39f9f28a2..f90395f32 100644 --- a/build.gradle +++ b/build.gradle @@ -188,6 +188,7 @@ dependencies { annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' + implementation fg.deobf("curse.maven:presence-footsteps-forge-433068:4328018") // Forge 1.18.2 v1.5.1 implementation fg.deobf("curse.maven:spark-361579:4505375") // Forge 1.18.2 v1.10.38 implementation fg.deobf("curse.maven:modernfix-790626:5399365") // Forge 1.18.2 v5.18.0 @@ -235,7 +236,6 @@ dependencies { compileOnly fg.deobf("curse.maven:originsforge-474438:5179273") // Forge 1.18.2 v1.5.0.2 //runtimeOnly fg.deobf("curse.maven:caelus-308989:3650485") - // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html diff --git a/src/main/java/net/ltxprogrammer/changed/ChangedConfig.java b/src/main/java/net/ltxprogrammer/changed/ChangedConfig.java index 641163e8e..41099ec6b 100644 --- a/src/main/java/net/ltxprogrammer/changed/ChangedConfig.java +++ b/src/main/java/net/ltxprogrammer/changed/ChangedConfig.java @@ -4,19 +4,17 @@ import net.ltxprogrammer.changed.client.gui.TransfurProgressOverlay; import net.ltxprogrammer.changed.data.RegistryElementPredicate; import net.ltxprogrammer.changed.entity.BasicPlayerInfo; -import net.minecraft.core.Registry; + import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.config.ConfigTracker; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.server.ServerLifecycleHooks; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -61,6 +59,7 @@ public static class Client implements AdditionalData { public final ForgeConfigSpec.ConfigValue fastAndCheapLatexBlocks; public final ForgeConfigSpec.ConfigValue transfurMeterPosition; + public final BasicPlayerInfo basicPlayerInfo = new BasicPlayerInfo(); public Client(ForgeConfigSpec.Builder builder) { @@ -109,6 +108,8 @@ public static class Server { public final ForgeConfigSpec.ConfigValue playerControllingAbilities; public final ForgeConfigSpec.ConfigValue isGrabEnabled; public final ForgeConfigSpec.ConfigValue bpiSizeTolerance; + public final ForgeConfigSpec.ConfigValue enableTransfurringOrigins; + public Server(ForgeConfigSpec.Builder builder) { builder.comment("Should transfurred players have a nametag"); @@ -123,6 +124,12 @@ public Server(ForgeConfigSpec.Builder builder) { isGrabEnabled = builder.define("isGrabEnabled", true); builder.comment("Acceptable model scaling through BPI (Default: +/- 5%)"); bpiSizeTolerance = builder.defineInRange("bpiSizeTolerance", 0.05, 0.01, 0.95); + if(ModList.get().isLoaded("origins")) { + builder.comment("Enabling this config will allow you to have both origin and latex variants. (default is false)"); + enableTransfurringOrigins = builder.define("enableTransfurringOrigins", true); + }else{ + enableTransfurringOrigins = null; + } } public Stream> getBlacklistedCoverBlocks() { diff --git a/src/main/java/net/ltxprogrammer/changed/command/CommandTransfur.java b/src/main/java/net/ltxprogrammer/changed/command/CommandTransfur.java index 4e1659aac..fb9d0ff86 100644 --- a/src/main/java/net/ltxprogrammer/changed/command/CommandTransfur.java +++ b/src/main/java/net/ltxprogrammer/changed/command/CommandTransfur.java @@ -7,6 +7,7 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.SuggestionProvider; import net.ltxprogrammer.changed.Changed; +import net.ltxprogrammer.changed.extension.latexvariant.CheckCondition; import net.ltxprogrammer.changed.entity.ChangedEntity; import net.ltxprogrammer.changed.entity.TransfurCause; import net.ltxprogrammer.changed.entity.TransfurContext; @@ -145,23 +146,30 @@ private static int transfurPlayer(CommandSourceStack source, ServerPlayer player throw NOT_CAUSE.create(); } + CheckCondition compatibility = new CheckCondition(player); + compatibility.checkOriginCondition(); + + if ((compatibility.getConditionMet())) { + throw NOT_LATEX_FORM.create(); + } + if (ChangedCompatibility.isPlayerUsedByOtherMod(player)) throw USED_BY_OTHER_MOD.create(); if (TransfurVariant.getPublicTransfurVariants().map(TransfurVariant::getRegistryName).anyMatch(form::equals)) { ProcessTransfur.transfur(player, source.getLevel(), ChangedRegistry.TRANSFUR_VARIANT.get().getValue(form), true, TransfurContext.hazard(transfurCause)); - } - else if (form.equals(TransfurVariant.SPECIAL_LATEX)) { + } else if (form.equals(TransfurVariant.SPECIAL_LATEX)) { ResourceLocation key = Changed.modResource("special/form_" + player.getUUID()); if (!ChangedRegistry.TRANSFUR_VARIANT.get().containsKey(key)) throw NO_SPECIAL_FORM.create(); ProcessTransfur.transfur(player, source.getLevel(), ChangedRegistry.TRANSFUR_VARIANT.get().getValue(key), true, TransfurContext.hazard(transfurCause)); - } - else + } else { throw NOT_LATEX_FORM.create(); + } + return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/net/ltxprogrammer/changed/extension/latexvariant/CheckCondition.java b/src/main/java/net/ltxprogrammer/changed/extension/latexvariant/CheckCondition.java new file mode 100644 index 000000000..c6cb0bd76 --- /dev/null +++ b/src/main/java/net/ltxprogrammer/changed/extension/latexvariant/CheckCondition.java @@ -0,0 +1,68 @@ +package net.ltxprogrammer.changed.extension.latexvariant; + +import io.github.edwinmindcraft.origins.api.OriginsAPI; +import io.github.edwinmindcraft.origins.api.capabilities.IOriginContainer; +import io.github.edwinmindcraft.origins.api.origin.Origin; +import io.github.edwinmindcraft.origins.api.origin.OriginLayer; +import net.ltxprogrammer.changed.Changed; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.fml.ModList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Objects; + +public class CheckCondition { + private final ServerPlayer player; + private boolean conditionValue = false; + public VariantType variantType = VariantType.DEFAULT; + public static final Logger LOGGER = LogManager.getLogger(Changed.class); + public CheckCondition(ServerPlayer player) { + this.player = player; + checkOriginCondition(); + } + private void applyVariantLogic() { + switch (variantType) { + case ORIGINS -> { + conditionValue = true; + } + default -> { + conditionValue = false; + } + } + } + public boolean getConditionMet() { + return conditionValue; + } + public void checkOriginCondition() { + if ((ModList.get().isLoaded("origins"))) { + MinecraftServer server=this.player.getServer(); + OriginLayer layer = OriginsAPI.getLayersRegistry(server).get(new ResourceLocation("origins:origin")); + Origin origin = OriginsAPI.getOriginsRegistry(server).get(new ResourceLocation("origins:human")); + boolean nowHuman = IOriginContainer.get(player) + .map(container -> Objects.equals(container.getOrigin(layer), origin)) + .orElse(false); + if(!(Changed.config.server.enableTransfurringOrigins.get())) { + if (nowHuman) { + variantType = VariantType.DEFAULT; + } else { + variantType = VariantType.ORIGINS; + } + applyVariantLogic(); + } + } + } +} +enum VariantType { + DEFAULT(0), + ORIGINS(1); + private final int varianttypenumber; + VariantType(int varianttypenumber) { + this.varianttypenumber = varianttypenumber; + } + public int getVariantTypeNumber() { + return this.varianttypenumber; + } +} \ No newline at end of file diff --git a/src/main/java/net/ltxprogrammer/changed/extension/latexvariant/origins/LatexPhantom.java b/src/main/java/net/ltxprogrammer/changed/extension/latexvariant/origins/LatexPhantom.java new file mode 100644 index 000000000..23de3b613 --- /dev/null +++ b/src/main/java/net/ltxprogrammer/changed/extension/latexvariant/origins/LatexPhantom.java @@ -0,0 +1,76 @@ +package net.ltxprogrammer.changed.extension.latexvariant.origins; + +import io.github.edwinmindcraft.origins.api.OriginsAPI; +import io.github.edwinmindcraft.origins.api.capabilities.IOriginContainer; +import io.github.edwinmindcraft.origins.api.origin.Origin; +import io.github.edwinmindcraft.origins.api.origin.OriginLayer; +import net.ltxprogrammer.changed.process.ProcessTransfur; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.event.TickEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.common.Mod; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +@Mod.EventBusSubscriber +public class LatexPhantom { + private static final Map playerCooldown = new HashMap<>(); + + /** + * Checks if the player has Phantom origins. + * + * @param player Player object + * @param server Minecraft server + * @return Returns true if the player is a Phantom, false otherwise. + */ + public static boolean isPhantom(ServerPlayer player, MinecraftServer server) { + OriginLayer layer = OriginsAPI.getLayersRegistry(server).get(new ResourceLocation("origins:origin")); + Origin origin = OriginsAPI.getOriginsRegistry(server).get(new ResourceLocation("origins:phantom")); + return IOriginContainer.get(player) + .map(container -> layer != null && Objects.equals(container.getOrigin(layer), origin)) + .orElse(false); + } + @SubscribeEvent + public static void burnInDaylight(TickEvent.PlayerTickEvent event) { + if (event.phase == TickEvent.Phase.END && ModList.get().isLoaded("origins")) { + Player player = event.player; + if (player instanceof ServerPlayer serverPlayer) { + MinecraftServer server = serverPlayer.level.getServer(); + if (isPhantom(serverPlayer, server) && serverPlayer.level.canSeeSky(serverPlayer.blockPosition()) + && !ProcessTransfur.isPlayerPermTransfurred(serverPlayer)) { + OriginLayer layer = OriginsAPI.getLayersRegistry(server).get(new ResourceLocation("origins:origin")); + Origin phantomizeOverlayOrigin = OriginsAPI.getOriginsRegistry(server) + .get(new ResourceLocation("origins", "phantomize_overlay")); + IOriginContainer originContainer = IOriginContainer.get(serverPlayer).orElse(null); + if (originContainer != null && layer != null && Objects.equals(originContainer.getOrigin(layer), phantomizeOverlayOrigin)) { + if (serverPlayer.level.isDay()) { + long currentTime = serverPlayer.level.getGameTime(); + UUID playerUUID = serverPlayer.getUUID(); + if (!playerCooldown.containsKey(playerUUID) || currentTime - playerCooldown.get(playerUUID) >= 100) { + serverPlayer.setSecondsOnFire(5); + playerCooldown.put(playerUUID, currentTime); + } + } + } else { + playerCooldown.remove(serverPlayer.getUUID()); + serverPlayer.setSecondsOnFire(0); + } + } + } + } + } + @SubscribeEvent + public static void onPlayerDeath(LivingDeathEvent event) { + if (event.getEntity() instanceof ServerPlayer serverPlayer) { + playerCooldown.remove(serverPlayer.getUUID()); + } + } +} diff --git a/src/main/java/net/ltxprogrammer/changed/process/ProcessTransfur.java b/src/main/java/net/ltxprogrammer/changed/process/ProcessTransfur.java index ca045c413..e1b0332fb 100644 --- a/src/main/java/net/ltxprogrammer/changed/process/ProcessTransfur.java +++ b/src/main/java/net/ltxprogrammer/changed/process/ProcessTransfur.java @@ -2,8 +2,7 @@ import com.mojang.logging.LogUtils; import net.ltxprogrammer.changed.Changed; -import net.ltxprogrammer.changed.ability.AbstractAbility; -import net.ltxprogrammer.changed.ability.GrabEntityAbilityInstance; +import net.ltxprogrammer.changed.extension.latexvariant.CheckCondition; import net.ltxprogrammer.changed.ability.IAbstractChangedEntity; import net.ltxprogrammer.changed.entity.*; import net.ltxprogrammer.changed.entity.beast.SpecialLatex; @@ -685,7 +684,13 @@ public static void transfur(LivingEntity entity, Level level, TransfurVariant if (entity == null) return; if (entity.isDeadOrDying()) - return; // To prevent most bugs, entity has to be alive to transfur + return;// + // To prevent most bugs, entity has to be alive to transfur + if(entity instanceof ServerPlayer player){ + CheckCondition compatibility = new CheckCondition(player); + if ((compatibility.getConditionMet())) + return; + } if (level.getGameRules().getBoolean(RULE_KEEP_BRAIN)) keepConscious = true; else if (entity instanceof Player player) { diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ef31cae8d..40506a7e0 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -26,3 +26,10 @@ description='''Gooey transfur mod inspired by Dragon Snow's Changed.''' versionRange="[1.18.2]" ordering="NONE" side="BOTH" + +[[dependencies.changed]] + modId="origins" + mandatory=false + versionRange="[*,]" + ordering="BEFORE" + side="BOTH" \ No newline at end of file diff --git a/src/main/resources/assets/changed/lang/en_us.json b/src/main/resources/assets/changed/lang/en_us.json index afc62e10f..95666152b 100644 --- a/src/main/resources/assets/changed/lang/en_us.json +++ b/src/main/resources/assets/changed/lang/en_us.json @@ -605,5 +605,9 @@ "changed.config.bpi.size": "Model Size", "changed.config.bpi.size.value": "Size: %s%%", "changed.config.bpi.override_dl_iris": "Override Iris Color on Dark Latex Variants", - "changed.config.bpi.override_all_eye_styles": "Override All Eye Styles to Match" -} + "changed.config.bpi.override_all_eye_styles": "Override All Eye Styles to Match", + + + "power.origins.latex_type.name": "latex type", + "power.origins.latex_type.description": "Certain powers will be strengthened or weakened if and when you are transfured! Or you will have certain powers or lose certain powers!" +} \ No newline at end of file diff --git a/src/main/resources/assets/changed/lang/zh_cn.json b/src/main/resources/assets/changed/lang/zh_cn.json index 18fb6154a..9d6689b3a 100644 --- a/src/main/resources/assets/changed/lang/zh_cn.json +++ b/src/main/resources/assets/changed/lang/zh_cn.json @@ -610,5 +610,8 @@ "changed.config.bpi.size": "型号尺寸", "changed.config.bpi.size.value": "尺寸:%s%%", "changed.config.bpi.override_dl_iris": "覆盖黑胶兽的眼睛颜色", - "changed.config.bpi.override_all_eye_styles": "覆盖所有眼睛样式以匹配" -} + "changed.config.bpi.override_all_eye_styles": "覆盖所有眼睛样式以匹配", + + "power.origins.latex_type.name": "胶性", + "power.origins.latex_type.description": "如果你被兽化时,某些能力将会被强化或者削弱!或者你会拥有某些能力或者失去某些能力!" +} \ No newline at end of file diff --git a/src/main/resources/data/origins/origins/phantom.json b/src/main/resources/data/origins/origins/phantom.json new file mode 100644 index 000000000..625c63679 --- /dev/null +++ b/src/main/resources/data/origins/origins/phantom.json @@ -0,0 +1,18 @@ +{ + "powers": [ + "origins:burn_in_daylight", + "origins:latex_type", + "origins:phantomize", + "origins:translucent", + "origins:phasing", + "origins:invisibility", + "origins:hunger_over_time", + "origins:fragile", + "origins:phantomize_overlay" + ], + "icon": { + "item": "minecraft:phantom_membrane" + }, + "order": 2, + "impact": 3 +} \ No newline at end of file diff --git a/src/main/resources/data/origins/powers/burn_in_daylight.json b/src/main/resources/data/origins/powers/burn_in_daylight.json new file mode 100644 index 000000000..208768931 --- /dev/null +++ b/src/main/resources/data/origins/powers/burn_in_daylight.json @@ -0,0 +1,9 @@ +{ + "type": "origins:prevent_sleep", + "block_condition": { + "type": "origins:height", + "comparison": "<", + "compare_to": -2147483647 + }, + "message": "origins.avian_sleep_fail" +} \ No newline at end of file diff --git a/src/main/resources/data/origins/powers/latex_type.json b/src/main/resources/data/origins/powers/latex_type.json new file mode 100644 index 000000000..208768931 --- /dev/null +++ b/src/main/resources/data/origins/powers/latex_type.json @@ -0,0 +1,9 @@ +{ + "type": "origins:prevent_sleep", + "block_condition": { + "type": "origins:height", + "comparison": "<", + "compare_to": -2147483647 + }, + "message": "origins.avian_sleep_fail" +} \ No newline at end of file diff --git a/src/main/resources/data/origins/powers/readme.md b/src/main/resources/data/origins/powers/readme.md new file mode 100644 index 000000000..441c3436e --- /dev/null +++ b/src/main/resources/data/origins/powers/readme.md @@ -0,0 +1,2 @@ +These json are all placeholders for the methods used in order to write in java, +if you want to write in java with the ability to do so. \ No newline at end of file