Skip to content

Commit

Permalink
24w37a
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Sep 12, 2024
1 parent 8be3635 commit e18549c
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.BaseText;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.thread.TaskExecutor;
import net.minecraft.util.thread.TaskQueue;
import net.minecraft.world.chunk.light.LightingProvider;

import java.util.List;

//#if MC >= 12102
//$$ import net.minecraft.class_10209;
//#endif

public class LightThreadSynchronizer
{
private static final Translator translator = new Translator("rule.synchronizedLightThread");
Expand All @@ -49,7 +54,14 @@ private static boolean isSafeToWait(boolean synchronizedLightThread, CarpetTISAd

public static void waitForLightThread(ServerWorld serverWorld)
{
serverWorld.getProfiler().push(SECTION_NAME);
Profiler profiler =
//#if MC >= 12102
//$$ class_10209.method_64146();
//#else
serverWorld.getProfiler();
//#endif

profiler.push(SECTION_NAME);
CarpetProfiler.ProfilerToken token = CarpetProfiler.start_section(serverWorld, SECTION_NAME, CarpetProfiler.TYPE.GENERAL);

LightingProvider lightingProvider =
Expand Down Expand Up @@ -81,7 +93,7 @@ public static void waitForLightThread(ServerWorld serverWorld)
}
}

serverWorld.getProfiler().pop();
profiler.pop();
CarpetProfiler.end_current_section(token);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@

import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget;
import carpettisaddition.commands.lifetime.spawning.LiteralSpawningReason;
import carpettisaddition.utils.ModIds;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import net.minecraft.entity.Entity;
import net.minecraft.server.PlayerManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = "<=1.21.1"))
@Mixin(PlayerManager.class)
public abstract class PlayerManagerMixin
{
@ModifyReturnValue(
// The lambda function argument for EntityType.loadEntityWithPassengers
method = "method_18241", // lambda method in onPlayerConnect
at = @At("TAIL")
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of the Carpet TIS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* Carpet TIS Addition 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.
*
* Carpet TIS Addition 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 Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package carpettisaddition.mixins.command.lifetime.spawning.playerlogin;

import carpettisaddition.utils.ModIds;
import carpettisaddition.utils.compat.DummyClass;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import org.spongepowered.asm.mixin.Mixin;

/**
* See {@link PlayerManagerMixin} for impl for this mc version
*/
@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = ">1.21.1"))
@Mixin(DummyClass.class)
public abstract class ServerPlayerEntityMixin
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
package carpettisaddition.mixins.logger.microtiming.api;

import carpettisaddition.logging.loggers.microtiming.MicroTimingLoggerManager;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Iterator;
import java.util.function.BooleanSupplier;

@Mixin(MinecraftServer.class)
Expand All @@ -40,13 +39,13 @@ public abstract class MinecraftServerMixin
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;tick(Ljava/util/function/BooleanSupplier;)V"
),
locals = LocalCapture.CAPTURE_FAILHARD
)
)
private void beforeTickingWorld(BooleanSupplier shouldKeepTicking, CallbackInfo ci, Iterator<ServerWorld> iter, ServerWorld serverWorld)
private void beforeTickingWorld(BooleanSupplier shouldKeepTicking, CallbackInfo ci, @Local ServerWorld serverWorld)
{
MicroTimingLoggerManager.setCurrentWorld(serverWorld);
}

@Inject(
method = "tickWorlds",
at = @At(
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/carpet-tis-addition.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"command.lifetime.spawning.natural.ZombieSiegeManagerMixin",
"command.lifetime.spawning.placeblock.EndermanEntityMixin",
"command.lifetime.spawning.playerlogin.PlayerManagerMixin",
"command.lifetime.spawning.playerlogin.ServerPlayerEntityMixin",
"command.lifetime.spawning.portalpigman.NetherPortalBlockMixin",
"command.lifetime.spawning.raid.RaidMixin",
"command.lifetime.spawning.slime.SlimeEntityMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected MobEntityMixin(EntityType<? extends LivingEntity> entityType, World wo
at = @At(
value = "INVOKE",
//#if MC >= 12102
//$$ target = "Lnet/minecraft/server/world/ServerWorld;spawnEntityAndPassengers(Lnet/minecraft/entity/Entity;)V"
//$$ target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
//#else
target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected MobEntityMixin(EntityType<? extends LivingEntity> entityType, World wo
at = @At(
value = "INVOKE",
//#if MC >= 12102
//$$ target = "Lnet/minecraft/server/world/ServerWorld;spawnEntityAndPassengers(Lnet/minecraft/entity/Entity;)V"
//$$ target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
//#else
target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
//#endif
Expand Down
10 changes: 5 additions & 5 deletions versions/future/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fallen-breath.github.io/fabric-versions/?&version=24w36a
minecraft_version=24w36a
yarn_mappings=24w36a+build.6
# check these on https://fallen-breath.github.io/fabric-versions/?&version=24w37a
minecraft_version=24w37a
yarn_mappings=24w37a+build.2

# Fabric Mod Metadata
carpet_dependency=>=1.4.147
Expand All @@ -10,12 +10,12 @@

# Build Information
# The target mc versions for the mod during mod publishing, separated with \n
game_versions=24w36a
game_versions=24w37a

# Mod Dependency
# check available versions on maven for the given minecraft version you are using
# https://masa.dy.fi/maven/carpet/fabric-carpet/
carpet_core_version=24w36a-1.4.151+v240904
carpet_core_version=24w37a-1.4.152+v240911

# Lithium mc1.21.1-0.13.0
# https://www.curseforge.com/minecraft/mc-mods/lithium/files/5618760
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of the Carpet TIS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* Carpet TIS Addition 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.
*
* Carpet TIS Addition 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 Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package carpettisaddition.mixins.command.lifetime.spawning.playerlogin;

import carpettisaddition.utils.ModIds;
import carpettisaddition.utils.compat.DummyClass;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import org.spongepowered.asm.mixin.Mixin;

/**
* See {@link ServerPlayerEntityMixin} for impl for this mc version
*/
@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = "<=1.21.1"))
@Mixin(DummyClass.class)
public abstract class PlayerManagerMixin
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This file is part of the Carpet TIS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* Carpet TIS Addition 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.
*
* Carpet TIS Addition 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 Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package carpettisaddition.mixins.command.lifetime.spawning.playerlogin;

import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget;
import carpettisaddition.commands.lifetime.spawning.LiteralSpawningReason;
import carpettisaddition.utils.ModIds;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import net.minecraft.entity.Entity;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = ">1.21.1"))
@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin
{
@ModifyReturnValue(
// The lambda function argument for EntityType.loadEntityWithPassengers
method = {
"method_64132", // in method readRootVehicle
"method_64129" // in method readEnderPearls
},
at = @At("TAIL")
)
private static Entity lifetimeTracker_recordSpawning_playerLogin(Entity entity)
{
if (entity != null)
{
((LifetimeTrackerTarget)entity).recordSpawning(LiteralSpawningReason.PLAYER_LOGIN);
}
return entity;
}
}

0 comments on commit e18549c

Please sign in to comment.