Skip to content

Commit

Permalink
Merge pull request #9 from CasualChampionships/1.21.4
Browse files Browse the repository at this point in the history
Update to 1.21.4
  • Loading branch information
senseiwells authored Dec 4, 2024
2 parents db4a92a + 879faac commit f6d3852
Show file tree
Hide file tree
Showing 47 changed files with 190 additions and 128 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repositories {
}

dependencies {
include(modImplementation("net.casual-championships:arcade:0.3.1-alpha.45+1.21.3")!!)
include(modImplementation("net.casual-championships:arcade:0.3.1-alpha.47+1.21.4")!!)
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.casual.arcade.datagen.utils

import net.casual.arcade.resources.font.spacing.SpacingFontResources
import net.casual.arcade.resources.lang.LanguageEntry
import net.casual.arcade.utils.ComponentUtils
import net.casual.arcade.utils.ComponentUtils.getTranslationKeyOf
import net.minecraft.client.gui.Font
import net.minecraft.network.chat.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(CommonPlayerSpawnInfo.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.players.PlayerList;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.WorldOptions;
Expand All @@ -23,8 +22,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.function.Supplier;

@Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level {
@Shadow @Final private ServerLevelData serverLevelData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
Expand All @@ -23,8 +22,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.function.Supplier;

@Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level {
@Shadow @Nullable private EndDragonFight dragonFight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.WorldGenRegion
import net.minecraft.util.random.WeightedRandomList
import net.minecraft.world.entity.MobCategory
import net.minecraft.world.level.LevelHeightAccessor
import net.minecraft.world.level.NoiseColumn
import net.minecraft.world.level.StructureManager
import net.minecraft.world.level.WorldGenLevel
import net.minecraft.world.level.*
import net.minecraft.world.level.biome.*
import net.minecraft.world.level.chunk.ChunkAccess
import net.minecraft.world.level.chunk.ChunkGenerator
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState
import net.minecraft.world.level.levelgen.GenerationStep
import net.minecraft.world.level.levelgen.Heightmap
import net.minecraft.world.level.levelgen.RandomState
import net.minecraft.world.level.levelgen.blending.Blender
Expand Down Expand Up @@ -90,8 +86,8 @@ public class VoidChunkGenerator(biome: BiomeSource): ChunkGenerator(biome) {
return WeightedRandomList.create()
}

override fun createStructures(registryAccess: RegistryAccess, structureState: ChunkGeneratorStructureState, structureManager: StructureManager, chunk: ChunkAccess, structureTemplateManager: StructureTemplateManager) {

override fun createStructures(registryAccess: RegistryAccess, structureState: ChunkGeneratorStructureState, structureManager: StructureManager, chunk: ChunkAccess, structureTemplateManager: StructureTemplateManager, dimension: ResourceKey<Level>) {
super.createStructures(registryAccess, structureState, structureManager, chunk, structureTemplateManager, dimension)
}

override fun createReferences(level: WorldGenLevel, structureManager: StructureManager, chunk: ChunkAccess) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.casual.arcade.events.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import net.casual.arcade.events.GlobalEventHandler;
import net.casual.arcade.events.block.CommandBlockExecuteEvent;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.world.level.BaseCommandBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(BaseCommandBlock.class)
public class BaseCommandBlockMixin {
@WrapWithCondition(
method = "performCommand",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/commands/Commands;performPrefixedCommand(Lnet/minecraft/commands/CommandSourceStack;Ljava/lang/String;)V"
)
)
private boolean onPerformCommand(Commands instance, CommandSourceStack source, String command) {
CommandBlockExecuteEvent event = new CommandBlockExecuteEvent(
source.getLevel(),
(BaseCommandBlock) (Object) this,
source,
command
);
GlobalEventHandler.broadcast(event);
return !event.isCancelled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package net.casual.arcade.events.mixins;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.serialization.Decoder;
import net.casual.arcade.events.GlobalEventHandler;
import net.casual.arcade.events.registry.RegistryEventHandler;
import net.casual.arcade.events.registry.RegistryLoadedFromResourcesEvent;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.WritableRegistry;
import net.minecraft.resources.RegistryDataLoader;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.packs.resources.ResourceManager;
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.CallbackInfoReturnable;

import java.util.Map;

@Mixin(RegistryDataLoader.class)
public class RegistryDataLoaderMixin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.llamalad7.mixinextras.sugar.Cancellable;
import com.mojang.authlib.GameProfile;
import net.casual.arcade.events.GlobalEventHandler;
import net.casual.arcade.events.core.CancellableEvent;
import net.casual.arcade.events.network.ClientboundPacketEvent;
import net.casual.arcade.events.network.PlayerDisconnectEvent;
import net.casual.arcade.events.player.PlayerClientboundPacketEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ private void onChangeDimension(
}

@Inject(
method = "doCheckFallDamage",
method = "checkFallDamage",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/player/Player;checkFallDamage(DZLnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V"
)
)
private void onFall(double movementX, double movementY, double movementZ, boolean onGround, CallbackInfo ci) {
PlayerFallEvent event = new PlayerFallEvent((ServerPlayer) (Object) this, movementY, onGround);
private void onFall(double y, boolean onGround, BlockState state, BlockPos pos, CallbackInfo ci) {
PlayerFallEvent event = new PlayerFallEvent((ServerPlayer) (Object) this, y, onGround);
GlobalEventHandler.broadcast(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,6 @@ public object GlobalEventHandler {
this.recursion = true
}

internal fun suppressNextEvent(type: Class<out Event>) {
if (!this.suppressed.add(type)) {
this.logger.warn("Adding suppressed event (type: {}) twice", type)
}
}

private fun checkRecursive(type: Class<out Event>): Boolean {
val count = this.stack.getInt(type)
if (count >= MAX_RECURSIONS) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.casual.arcade.events.block

import net.casual.arcade.events.core.CancellableEvent
import net.casual.arcade.events.level.LocatedLevelEvent
import net.minecraft.commands.CommandSourceStack
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.level.BaseCommandBlock

public data class CommandBlockExecuteEvent(
override val level: ServerLevel,
val commandBlock: BaseCommandBlock,
val source: CommandSourceStack,
val command: String
): CancellableEvent.Default(), LocatedLevelEvent {
override val pos: BlockPos
get() = BlockPos.containing(this.commandBlock.position)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.Fluid
import net.minecraft.world.level.material.FluidState

public class LevelFluidTrySpreadEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.casual.arcade.events.player

import com.mojang.authlib.GameProfile
import net.casual.arcade.events.core.CancellableEvent
import net.casual.arcade.events.core.Event
import net.minecraft.network.chat.Component
import net.minecraft.server.MinecraftServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package net.casual.arcade.events.registry

import com.google.common.collect.HashMultimap
import net.casual.arcade.events.BuiltInEventPhases.DEFAULT
import net.casual.arcade.events.EventListener
import net.casual.arcade.events.GlobalEventHandler
import net.casual.arcade.events.ListenerProvider
import net.casual.arcade.events.core.Event
import net.minecraft.core.Registry
import net.minecraft.resources.ResourceKey
import org.jetbrains.annotations.ApiStatus.Internal
import java.util.function.Consumer

public object RegistryEventHandler: EventListener<RegistryLoadedFromResourcesEvent<*>>, ListenerProvider {
private val listeners = HashMultimap.create<ResourceKey<*>, EventListener<*>>()
Expand Down
1 change: 1 addition & 0 deletions arcade-events/src/main/resources/arcade-events.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"package": "net.casual.arcade.events.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BaseCommandBlockMixin",
"BlockItemMixin",
"BrewingStandBlockEntityAccessor",
"BrewingStandBlockEntityMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void onHandleVehicleMovement(ServerboundMoveVehiclePacket packet, Callba
ci.cancel();
Entity entity = this.player.getRootVehicle();
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
this.send(new ClientboundMoveVehiclePacket(entity));
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.casual.arcade.minigame.mixins.bugfixes;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.datafixers.util.Either;
import net.minecraft.core.BlockPos;
Expand All @@ -12,27 +14,27 @@
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;

import java.util.Optional;

@Mixin(Leashable.class)
public interface LeashableMixin {
@Inject(
@WrapOperation(
method = "readLeashData",
at = @At("HEAD"),
cancellable = true
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/Leashable;readLeashDataInternal(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/entity/Leashable$LeashData;"
)
)
private void onReadLeashData(CompoundTag compound, CallbackInfoReturnable<Leashable.LeashData> cir) {
private Leashable.LeashData onReadLeashData(CompoundTag compound, Operation<Leashable.LeashData> original) {
if (this instanceof Entity entity && compound.contains("LeashRelative", CompoundTag.TAG_INT_ARRAY)) {
Optional<BlockPos> optional = NbtUtils.readBlockPos(compound, "LeashRelative");
if (optional.isEmpty()) {
return;
if (optional.isPresent()) {
BlockPos position = entity.blockPosition().offset(optional.get());
return LeashDataInvoker.construct(Either.right(position));
}

BlockPos position = entity.blockPosition().offset(optional.get());
cir.setReturnValue(LeashDataInvoker.construct(Either.right(position)));
}
return original.call(compound);
}

@Inject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import net.casual.arcade.minigame.gamemode.ExtendedGameMode;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -30,11 +32,11 @@ private void shouldBroadcastTo(ServerPlayer player, CallbackInfoReturnable<Boole
}

@Inject(
method = "doCheckFallDamage",
method = "checkFallDamage",
at = @At("HEAD"),
cancellable = true
)
private void onCheckFallDamage(double movementX, double movementY, double movementZ, boolean onGround, CallbackInfo ci) {
private void onCheckFallDamage(double y, boolean onGround, BlockState state, BlockPos pos, CallbackInfo ci) {
// Prevent fall damage particles if in AdventureSpectator
if (getExtendedGameMode((ServerPlayer) (Object) this) == ExtendedGameMode.AdventureSpectator) {
ci.cancel();
Expand Down
Loading

0 comments on commit f6d3852

Please sign in to comment.