Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkage origins mod #1179

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a311e4d
Conditional on adding origin (empty method)
gengyoubo Nov 1, 2024
e0e3e1e
Merge branch 'LtxProgrammer:master' into 1.18.2
gengyoubo Nov 1, 2024
9cffea7
Conditional on adding origin
gengyoubo Nov 2, 2024
f2d1e1b
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 2, 2024
63f8205
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 2, 2024
efa6a4e
Adding Config Files
gengyoubo Nov 3, 2024
ab11211
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 5, 2024
855ab81
Adding Files
gengyoubo Nov 5, 2024
35c31a4
Adding Files
gengyoubo Nov 5, 2024
4c3ecf4
Adding Files
gengyoubo Nov 5, 2024
ee9c779
Adding Files
gengyoubo Nov 5, 2024
5fdb042
Adding Files
gengyoubo Nov 6, 2024
7cb3be6
Adding Files
gengyoubo Nov 6, 2024
bfa768f
Adding Files
gengyoubo Nov 6, 2024
c377c1f
Adding Files
gengyoubo Nov 6, 2024
0c6feec
Update PatienceCompatibility.java
gengyoubo Nov 6, 2024
97cc55a
Update CommandTransfur.java
gengyoubo Nov 6, 2024
cc90ea2
Update Changed.java
gengyoubo Nov 6, 2024
2e0283f
Update ChangedConfig.java
gengyoubo Nov 6, 2024
0e3332c
Update ChangedConfig.java
gengyoubo Nov 6, 2024
97f1cbc
Update ChangedConfig.java
gengyoubo Nov 7, 2024
1ec5b17
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 7, 2024
e194d9a
update Files
gengyoubo Nov 7, 2024
eb5275d
Merge branch 'LtxProgrammer:master' into 1.18.2
gengyoubo Nov 7, 2024
7f15ffd
update Files
gengyoubo Nov 8, 2024
f5878e9
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 8, 2024
b6e453d
update Files
gengyoubo Nov 9, 2024
fdfccf4
update Files
gengyoubo Nov 9, 2024
acd3303
update Files
gengyoubo Nov 9, 2024
ef048bc
update Files
gengyoubo Nov 9, 2024
203fa23
update Files
gengyoubo Nov 9, 2024
0a4d6ef
update Files
gengyoubo Nov 9, 2024
fb88dc9
update Files
gengyoubo Nov 9, 2024
d367822
update Files
gengyoubo Nov 9, 2024
0b7ec5f
Merge branch 'LtxProgrammer:master' into 1.18.2
gengyoubo Nov 11, 2024
06c0cd8
update Files
gengyoubo Nov 11, 2024
0f51ba1
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 11, 2024
ba76ca4
update Files
gengyoubo Nov 11, 2024
11d56d1
update Files
gengyoubo Nov 11, 2024
fd75b18
Merge branch 'LtxProgrammer:master' into 1.18.2
gengyoubo Nov 20, 2024
254f367
update Files
gengyoubo Nov 21, 2024
f4d0495
Merge remote-tracking branch 'origin/1.18.2' into 1.18.2
gengyoubo Nov 21, 2024
885ced5
update Files
gengyoubo Nov 22, 2024
f195b42
update Files
gengyoubo Nov 23, 2024
9145eec
Merge branch 'master' into 1.18.2
gengyoubo Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ repositories {
name = "ModMaven"
url = "https://modmaven.dev"
}
maven {
url "https://cursemaven.com"
}
maven { url "https://maven.shedaniel.me" }
}

Expand All @@ -191,7 +194,7 @@ dependencies {
implementation fg.deobf('me.lucko:spark-1.9.11-forge:1.9.11') // Spark
implementation fg.deobf('org.embeddedt:modernfix-forge-5.2.5+mc1.18.2:5.2.5') // ModernFix
implementation fg.deobf('me.jellysquid.mods:rubidium-0.5.6:0.5.6') // Rubidium
implementation fg.deobf('net.coderbot:oculus-mc1.18.2-1.6.4:1.6.4') // Oculus
compileOnly fg.deobf('net.coderbot:oculus-mc1.18.2-1.6.4:1.6.4') // Oculus
implementation fg.deobf('org:vivecraft-1.18.2-0.0.15-forge:0.0.15') // Vivecraft
//implementation fg.deobf("com.simibubi.create:create-1.18.2:0.5.1.c-298") // Create

Expand Down Expand Up @@ -229,6 +232,12 @@ dependencies {
compileOnly fg.deobf("mod:ChiselsBits-forge-1.18.2:1.2.116-universal")
//runtimeOnly fg.deobf("com.corosus:coroutil-forge-1.18.2:1.3.6")
compileOnly fg.deobf("com.corosus:watut-forge-1.18.2:1.0.14")
//origin_mod
implementation fg.deobf("curse.maven:originsforge-474438:5179273")
runtimeOnly fg.deobf("curse.maven:configured-457570:4462832")
runtimeOnly fg.deobf("curse.maven:survive-367337:4665174")
runtimeOnly fg.deobf("curse.maven:caelus-308989:3650485")
runtimeOnly fg.deobf("curse.maven:unionlib-367806:4729780")

// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false

modVersion = v0.14b
minecraftVersion = 1.18.2
forgeVersion = 40.2.0
forgeVersion = 40.2.4
jeiVersion = 9.7.0.192
reiVersion = 8.3.649
clothVersion = 6.5.102
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/ltxprogrammer/changed/Changed.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.ltxprogrammer.changed.entity.HairStyle;
import net.ltxprogrammer.changed.entity.PlayerMover;
import net.ltxprogrammer.changed.init.*;
import net.ltxprogrammer.changed.latexvariant.origins.LatexPhantom;
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
import net.ltxprogrammer.changed.network.ChangedPackets;
import net.ltxprogrammer.changed.network.packet.ChangedPacket;
import net.ltxprogrammer.changed.util.PatreonBenefits;
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/net/ltxprogrammer/changed/ChangedConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,6 +59,7 @@ public static class Client implements AdditionalData {
public final ForgeConfigSpec.ConfigValue<Boolean> fastAndCheapLatexBlocks;
public final ForgeConfigSpec.ConfigValue<TransfurProgressOverlay.Position> transfurMeterPosition;


public final BasicPlayerInfo basicPlayerInfo = new BasicPlayerInfo();

public Client(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -109,6 +108,8 @@ public static class Server {
public final ForgeConfigSpec.ConfigValue<Boolean> playerControllingAbilities;
public final ForgeConfigSpec.ConfigValue<Boolean> isGrabEnabled;
public final ForgeConfigSpec.ConfigValue<Double> bpiSizeTolerance;
public final ForgeConfigSpec.ConfigValue<Boolean> enableTransfurringOrigins;


public Server(ForgeConfigSpec.Builder builder) {
builder.comment("Should transfurred players have a nametag");
Expand All @@ -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<RegistryElementPredicate<Block>> getBlacklistedCoverBlocks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.latexvariant.CheckCondition;
import net.ltxprogrammer.changed.entity.ChangedEntity;
import net.ltxprogrammer.changed.entity.TransfurCause;
import net.ltxprogrammer.changed.entity.TransfurContext;
Expand Down Expand Up @@ -145,23 +146,30 @@ private static int transfurPlayer(CommandSourceStack source, ServerPlayer player
throw NOT_CAUSE.create();
}

CheckCondition compatibility = new CheckCondition(player);
compatibility.checkOriginCondition(source.getServer());

if ((compatibility.isConditionMet())) {
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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.ltxprogrammer.changed.latexvariant;
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved

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 int varianttypenumber = 0;
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
public CheckCondition(ServerPlayer player) {
this.player = player;
}
private void applyVariantLogic() {
switch (variantType) {
case ORIGINS -> {
conditionValue = true;
}
default -> {
conditionValue = false;
}
}
}
public boolean isConditionMet() {
return conditionValue;
}
public int VariantTypeNumber() {
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
return varianttypenumber;
}
public void checkOriginCondition(MinecraftServer server) {
if ((ModList.get().isLoaded("origins"))) {
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)
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
.map(container -> Objects.equals(container.getOrigin(layer), origin))
.orElse(false);
if(nowHuman){
varianttypenumber = 0;
}else{
varianttypenumber = 1;
}
if (!(Changed.config.server.enableTransfurringOrigins.get())) {
if (nowHuman) {
variantType = VariantType.DEFAULT;
} else {
variantType = VariantType.ORIGINS;
}
applyVariantLogic();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.ltxprogrammer.changed.latexvariant;

public enum VariantType {
ORIGINS, DEFAULT
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package net.ltxprogrammer.changed.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;

@Mod.EventBusSubscriber
public class LatexPhantom {
private final ServerPlayer player;
private boolean nowphantom = false;
private static final Map<ServerPlayer, Long> playerCooldown = new HashMap<>();
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
public LatexPhantom(ServerPlayer player) {
this.player = player;
}
public void nowPhantom(MinecraftServer server) {
OriginLayer layer = OriginsAPI.getLayersRegistry(server).get(new ResourceLocation("origins:origin"));
Origin origin = OriginsAPI.getOriginsRegistry(server).get(new ResourceLocation("origins:phantom"));
nowphantom = IOriginContainer.get(player)
.map(container -> {
assert layer != null;
return Objects.equals(container.getOrigin(layer), origin);
})
.orElse(false);
}
/**
* Handles the player's tick event to simulate burning in daylight for players with the Phantom origin.
* This method will check if the player is a Phantom, if they can see the sky, and if it's daytime in the game.
* If the conditions are met, the player will burn for a specified duration every 5 seconds (100 ticks).
* @param event The PlayerTickEvent triggered on each tick of the player.
* This event contains the player and the current phase of the tick (START or END).
* The event is used to check if the conditions are met for the player to be set on fire.
*/
@SubscribeEvent
public static void burn_in_daylight(TickEvent.PlayerTickEvent event) {
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
// 确保在适当的 Tick 阶段执行
if (event.phase == TickEvent.Phase.END && ModList.get().isLoaded("origins")) {
Player player = event.player;
if (player instanceof ServerPlayer serverPlayer) {
LatexPhantom phantomPlayer = new LatexPhantom(serverPlayer);
phantomPlayer.nowPhantom(serverPlayer.level.getServer());
if (phantomPlayer.nowphantom && serverPlayer.level.canSeeSky(serverPlayer.blockPosition())
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
&& !ProcessTransfur.isPlayerPermTransfurred(serverPlayer)) {
IOriginContainer originContainer = IOriginContainer.get(serverPlayer).orElse(null);
Origin phantomizeOverlayOrigin = OriginsAPI.getOriginsRegistry(Objects.requireNonNull(serverPlayer.level.getServer()))
.get(new ResourceLocation("origins", "phantomize_overlay"));
if (originContainer.getOrigin(Objects.requireNonNull(OriginsAPI.getLayersRegistry(serverPlayer.level.getServer())
.get(new ResourceLocation("origins:origin")))) == phantomizeOverlayOrigin) {
if (serverPlayer.level.isDay()) {
long currentTime = serverPlayer.level.getGameTime();
if (!playerCooldown.containsKey(serverPlayer) || currentTime - playerCooldown.get(serverPlayer) >= 100) {
serverPlayer.setSecondsOnFire(5);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to track cooldowns. Repeatedly setting ticks on fire has less overhead cost than checking a map to see if the player should be set on fire.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you want me to do?

playerCooldown.put(serverPlayer, currentTime);
}
}
} else {
playerCooldown.remove(serverPlayer);
serverPlayer.setSecondsOnFire(0);
}
}
}
}
}
@SubscribeEvent
public static void onPlayerDeath(LivingDeathEvent event) {
if (event.getEntity() instanceof ServerPlayer serverPlayer) {
playerCooldown.remove(serverPlayer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.latexvariant.CheckCondition;
import net.ltxprogrammer.changed.ability.IAbstractChangedEntity;
import net.ltxprogrammer.changed.entity.*;
import net.ltxprogrammer.changed.entity.beast.SpecialLatex;
Expand Down Expand Up @@ -688,7 +687,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.isConditionMet()))
gengyoubo marked this conversation as resolved.
Show resolved Hide resolved
return;
}
if (level.getGameRules().getBoolean(RULE_KEEP_BRAIN))
keepConscious = true;
else if (entity instanceof Player player) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ description='''Gooey transfur mod inspired by Dragon Snow's Changed.'''
versionRange="[1.18.2]"
ordering="NONE"
side="BOTH"

[[dependencies.changed]]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this now a dependency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mandatory=false

modId="origins"
mandatory=false
versionRange="[*,]"
ordering="BEFORE"
side="BOTH"
8 changes: 6 additions & 2 deletions src/main/resources/assets/changed/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.latextype.name": "latex type",
"power.origins.latextype.description": "Certain powers will be strengthened or weakened if and when you are transfured! Or you will have certain powers or lose certain powers!"
}
7 changes: 5 additions & 2 deletions src/main/resources/assets/changed/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.latextype.name": "胶性",
"power.origins.latextype.description": "如果你被兽化时,某些能力将会被强化或者削弱!或者你会拥有某些能力或者失去某些能力!"
}
18 changes: 18 additions & 0 deletions src/main/resources/data/origins/origins/phantom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"powers": [
"origins:burn_in_daylight",
"origins:latextype",
"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
}
9 changes: 9 additions & 0 deletions src/main/resources/data/origins/powers/burn_in_daylight.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "origins:prevent_sleep",
"block_condition": {
"type": "origins:height",
"comparison": "<",
"compare_to": -2147483647
},
"message": "origins.avian_sleep_fail"
}
Loading