Skip to content

Commit

Permalink
added rule "fixedTickMemoriesEntityAI"
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana committed Sep 8, 2024
1 parent ac734fb commit 32b3784
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
// dependencies

// library mods
include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version)))
// include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version)))
include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${project.conditionalmixin_version}"))
include(annotationProcessor(implementation("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}")))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

package com.vulpeus.vulpeus_carpet;

import static carpet.api.settings.RuleCategory.COMMAND;
import static carpet.api.settings.RuleCategory.OPTIMIZATION;
import static carpet.api.settings.RuleCategory.SURVIVAL;
import static carpet.api.settings.RuleCategory.*;

import carpet.api.settings.Rule;

Expand All @@ -48,6 +46,12 @@ public class VulpeusCarpetSettings {
@Rule(categories = {VULPEUS})
public static boolean disableSOECrash = false;

//#if MC<=12001
//$$ @Rule(categories = {BUGFIX, VULPEUS})
//#endif
public static boolean fixedTickMemoriesEntityAI = false;

@Rule(categories = {OPTIMIZATION, VULPEUS})
public static boolean optimizedDragonRespawn = false;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This file is part of the VulpeusCarpet project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 VulpeusServer and contributors
*
* VulpeusCarpet is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VulpeusCarpet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VulpeusCarpet. If not, see <https://www.gnu.org/licenses/>.
*/

package com.vulpeus.vulpeus_carpet.mixins.fixedTickMemoriesEntityAI;

import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import net.minecraft.entity.ai.brain.Memory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Restriction(require = @Condition(value = "minecraft", versionPredicates = "<=1.20.1"))
@Mixin(Memory.class)
public abstract class MixinMemory {

@Unique
private boolean tickFlag = false;

@Shadow
public abstract void tick();

@Inject(method = "isExpired", at = @At(value = "HEAD", target = "Lnet/minecraft/entity/ai/brain/Brain;tickMemories()V"))
public void isExpired(CallbackInfoReturnable<Boolean> cir) {
if (VulpeusCarpetSettings.fixedTickMemoriesEntityAI) {
this.tickFlag = true;
tick();
}
}

@Inject(method = "tick", at = @At(value = "HEAD", target = "Lnet/minecraft/entity/ai/brain/Brain;tickMemories()V"), cancellable = true)
public void tick(CallbackInfo ci) {
if (VulpeusCarpetSettings.fixedTickMemoriesEntityAI && this.tickFlag) {
this.tickFlag = false;
ci.cancel();
}
}

}
24 changes: 24 additions & 0 deletions src/main/java/com/vulpeus/vulpeus_carpet/utils/DummyClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* This file is part of the VulpeusCarpet project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 VulpeusServer and contributors
*
* VulpeusCarpet is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VulpeusCarpet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VulpeusCarpet. If not, see <https://www.gnu.org/licenses/>.
*/

package com.vulpeus.vulpeus_carpet.utils;

public class DummyClass {
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/vulpeus_carpet/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ carpet:
disableSOECrash:
desc: yeet the server crash caused by StackOverflowError.

fixedTickMemoriesEntityAI:
desc: fixed MC-254100

optimizedDragonRespawn:
desc: Optimize dragon respawn method. Ported from carpet AMS addition.
1 change: 1 addition & 0 deletions src/main/resources/vulpeus_carpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"mixins": [
"commandSit.MixinArmorStandEntity",
"disableCrash.MixinMinecraftServer",
"fixedTickMemoriesEntityAI.MixinMemory",
"optimizedDragonRespawn.IMixinBlockPatternTestTransform",
"optimizedDragonRespawn.MixinEnderDragonFight",
"playerActions.PlayerCommandMixin",
Expand Down
6 changes: 3 additions & 3 deletions versions/1.20.1/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Fabric Properties
# check these on https://fallen-breath.github.io/fabric-versions/?&version=1.20.1
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
yarn_mappings=1.20.1+build.2

# Fabric Mod Metadata
minecraft_dependency=>=1.20.1
minecraft_dependency=>=1.20

# Build Information
# The target mc versions for the mod during mod publishing, separated with \n
game_versions=1.20\n1.20.1

# Dependencies
fabric_api_version=0.92.2+1.20.1
carpet_version=1.20.2-1.4.118+v230921
carpet_version=1.20-1.4.112+v230608

0 comments on commit 32b3784

Please sign in to comment.