Skip to content

Commit

Permalink
rename mixins, and start on time dilation effect
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 19, 2025
1 parent b253cca commit f466b6e
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package dev.cammiescorner.arcanuscontinuum.mixin.common;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import dev.cammiescorner.arcanuscontinuum.common.entities.magic.MagicProjectileEntity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(AbstractArrow.class)
public class AbstractArrowMixin {
@WrapOperation(method = "tick", at = @At(
public abstract class AbstractArrowMixin extends Projectile {
public AbstractArrowMixin(EntityType<? extends Projectile> entityType, Level world) {
super(entityType, world);
}

@ModifyExpressionValue(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/projectile/AbstractArrow;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;"
target = "Lnet/minecraft/world/entity/player/Player;canHarmPlayer(Lnet/minecraft/world/entity/player/Player;)Z"
))
private Vec3 pleaseWork(AbstractArrow instance, Operation<Vec3> original) {
return original.call(instance).scale(0.5);
private boolean ignorePvpFlag(boolean original) {
return original || ((Object) this) instanceof MagicProjectileEntity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ArmorStand.class)
public abstract class ArmorStandEntityMixin extends LivingEntity {
public abstract class ArmorStandMixin extends LivingEntity {
@Shadow protected abstract EquipmentSlot getClickedSlot(Vec3 hitPos);

protected ArmorStandEntityMixin(EntityType<? extends LivingEntity> entityType, Level world) {
protected ArmorStandMixin(EntityType<? extends LivingEntity> entityType, Level world) {
super(entityType, world);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BlockBehaviour.BlockStateBase.class)
public class AbstractBlockStateMixin {
public class BlockStateBaseMixin {
@Inject(method = "getDestroyProgress", at = @At("HEAD"), cancellable = true)
private void arcanuscontinuum$wardedBlockBreakStatus(Player player, BlockGetter world, BlockPos pos, CallbackInfoReturnable<Float> info) {
if(ArcanusComponents.isBlockWarded((Level) world, pos))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.List;

@Mixin(EntityGetter.class)
public interface EntityViewMixin {
public interface EntityGetterMixin {
@Inject(method = "getEntityCollisions", at = @At("HEAD"))
private void arcanuscontinuum$collidesWithHead(@Nullable Entity entity, AABB box, CallbackInfoReturnable<List<VoxelShape>> info) {
ManaShieldEntity.COLLIDING_ENTITY.set(entity);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
package dev.cammiescorner.arcanuscontinuum.mixin.common;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(Entity.class)
public class EntityMixin {
@Shadow private Vec3 deltaMovement;
private Entity self = (Entity) (Object) this;

@ModifyVariable(method = "move", at = @At("HEAD"), argsOnly = true)
private Vec3 modifyMotion(Vec3 value) {
return value.scale(0.5);
@ModifyVariable(method = "playSound(Lnet/minecraft/sounds/SoundEvent;FF)V", at = @At("HEAD"), argsOnly = true, ordinal = 1)
private float pitchDown(float pitch) {
return pitch * 0.5f; // TODO tie to being in a time dilation entity
}

// @WrapOperation(method = "saveWithoutId", at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;"
// ))
// private Vec3 saveDeltaMovementField(Entity instance, Operation<Vec3> original) {
// return deltaMovement;
// }
//
// @ModifyReturnValue(method = "isNoGravity", at = @At("RETURN"))
// private boolean noGrav(boolean original) {
// return !(self instanceof Player);
// }
//
// @ModifyReturnValue(method = "getDeltaMovement", at = @At("RETURN"))
// private Vec3 slowMovement(Vec3 original) {
// return self instanceof Player ? original : original.scale(0.5);
// }
//
// @WrapOperation(method = "addDeltaMovement", at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;"
// ))
// private Vec3 painPainPain(Entity instance, Operation<Vec3> original) {
// return deltaMovement;
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.spongepowered.asm.mixin.injection.At;

@Mixin(FoodData.class)
public class HungerManagerMixin {
public class FoodDataMixin {
@WrapOperation(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/GameRules;getBoolean(Lnet/minecraft/world/level/GameRules$Key;)Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@SuppressWarnings("ConstantValue")
@Mixin(Level.class)
public abstract class WorldMixin {
public abstract class LevelMixin {
@Shadow public abstract BlockState getBlockState(BlockPos pos);

@Inject(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(MenuType.class)
public class ScreenHandlerTypeMixin {
public class MenuTypeMixin {
@Inject(method = "register(Ljava/lang/String;Lnet/minecraft/world/inventory/MenuType$MenuSupplier;)Lnet/minecraft/world/inventory/MenuType;", at = @At("HEAD"), cancellable = true)
private static void arcanuscontinuum$register(String id, MenuType.MenuSupplier<AbstractContainerMenu> factory, CallbackInfoReturnable<MenuType<AbstractContainerMenu>> info) {
if("lectern".equals(id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Mob.class)
public abstract class MobEntityMixin extends LivingEntity {
protected MobEntityMixin(EntityType<? extends LivingEntity> entityType, Level world) {
public abstract class MobMixin extends LivingEntity {
protected MobMixin(EntityType<? extends LivingEntity> entityType, Level world) {
super(entityType, world);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PistonBaseBlock.class)
public class PistonBlockMixin {
public class PistonBaseBlockMixin {
@Inject(method = "isPushable", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;isAir()Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.function.Predicate;

@Mixin(PlayerList.class)
public class PlayerManagerMixin {
public class PlayerListMixin {
@Shadow @Final private LayeredRegistryAccess<RegistryLayer> registries;

@ModifyReceiver(method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V", at = @At(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.spongepowered.asm.mixin.injection.At;

@Mixin(Player.class)
public abstract class PlayerEntityMixin extends LivingEntity {
protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, Level world) {
public abstract class PlayerMixin extends LivingEntity {
protected PlayerMixin(EntityType<? extends LivingEntity> entityType, Level world) {
super(entityType, world);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.cammiescorner.arcanuscontinuum.mixin.common;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.WritableLevelData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import java.util.function.Consumer;
import java.util.function.Supplier;

@Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level {
protected ServerLevelMixin(WritableLevelData levelData, ResourceKey<Level> dimension, RegistryAccess registryAccess, Holder<DimensionType> dimensionTypeRegistration, Supplier<ProfilerFiller> profiler, boolean isClientSide, boolean isDebug, long biomeZoomSeed, int maxChainedNeighborUpdates) { super(levelData, dimension, registryAccess, dimensionTypeRegistration, profiler, isClientSide, isDebug, biomeZoomSeed, maxChainedNeighborUpdates); }

@WrapWithCondition(method = "method_31420", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;guardEntityTick(Ljava/util/function/Consumer;Lnet/minecraft/world/entity/Entity;)V"
))
private boolean slowTime(ServerLevel instance, Consumer<?> consumer, Entity entity) {
// TODO tie to being in a time dilation entity
if(getGameTime() % 2 == 0) {
entity.setOldPosAndRot();
return false;
}

return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(ThrowableProjectile.class)
public abstract class ThrownEntityMixin extends Projectile {
public ThrownEntityMixin(EntityType<? extends Projectile> entityType, Level world) {
public abstract class ThrowableProjectileMixin extends Projectile {
public ThrowableProjectileMixin(EntityType<? extends Projectile> entityType, Level world) {
super(entityType, world);
}

Expand Down
25 changes: 12 additions & 13 deletions src/main/resources/arcanuscontinuum.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@
"compatibilityLevel": "JAVA_${java_version}",
"mixins": [
"common.AbstractArrowMixin",
"common.AbstractBlockStateMixin",
"common.ArmorStandEntityMixin",
"common.ArmorStandMixin",
"common.BlockStateBaseMixin",
"common.EnderDragonPartMixin",
"common.EntityGetterMixin",
"common.EntityMixin",
"common.EntityViewMixin",
"common.ExplosionMixin",
"common.FallingBlockMixin",
"common.HungerManagerMixin",
"common.FoodDataMixin",
"common.ItemEntityMixin",
"common.ItemStackMixin",
"common.LecternBlockEntityMixin",
"common.LevelMixin",
"common.LivingEntityMixin",
"common.MenuTypeMixin",
"common.MilkBucketItemMixin",
"common.MobEntityMixin",
"common.PersistentProjectileEntityMixin",
"common.PistonBlockMixin",
"common.PlayerEntityMixin",
"common.PlayerManagerMixin",
"common.ScreenHandlerTypeMixin",
"common.ServerWorldMixin",
"common.ThrownEntityMixin",
"common.WorldMixin",
"common.MobMixin",
"common.PistonBaseBlockMixin",
"common.PlayerListMixin",
"common.PlayerMixin",
"common.ServerLevelMixin",
"common.ThrowableProjectileMixin",
"compat.pehkui.LivingEntityMixin",
"datagen.AdvancementBuilderMixin",
"datagen.FabricDynamicRegistryProviderEntriesMixin",
Expand Down

0 comments on commit f466b6e

Please sign in to comment.