-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent special mob spawning and other miscellaneous features
resolves #30
- Loading branch information
Showing
12 changed files
with
212 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/main/java/me/drex/vanish/mixin/ExperienceOrbMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/main/java/me/drex/vanish/mixin/interaction/AbstractMinecartMixin.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/main/java/me/drex/vanish/mixin/interaction/BoatMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/java/me/drex/vanish/mixin/interaction/EntitySelectorMixin.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/me/drex/vanish/mixin/interaction/LivingEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.drex.vanish.mixin.interaction; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import me.drex.vanish.api.VanishAPI; | ||
import me.drex.vanish.config.ConfigManager; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class LivingEntityMixin { | ||
|
||
@WrapOperation( | ||
method = "isPushable", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/entity/LivingEntity;isSpectator()Z" | ||
) | ||
) | ||
public boolean vanish_preventPushing(LivingEntity entity, Operation<Boolean> original) { | ||
return original.call(entity) || (ConfigManager.vanish().interaction.entityCollisions && VanishAPI.isVanished(entity)); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
src/main/java/me/drex/vanish/mixin/interaction/VanishEntitySelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package me.drex.vanish.mixin.interaction; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import me.drex.vanish.VanishMod; | ||
import me.drex.vanish.api.VanishAPI; | ||
import me.drex.vanish.config.ConfigManager; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntitySelector; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.entity.vehicle.AbstractMinecart; | ||
import net.minecraft.world.item.ArmorItem; | ||
import net.minecraft.world.level.EntityGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.BeehiveBlock; | ||
import net.minecraft.world.phys.AABB; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.util.List; | ||
import java.util.function.Predicate; | ||
|
||
public class VanishEntitySelector { | ||
|
||
/** | ||
* This class is a collection of mixins that (conditionally) replace some {@link EntitySelector#NO_SPECTATORS} with {@link VanishMod#NO_SPECTATORS_AND_NO_VANISH} | ||
*/ | ||
|
||
@Mixin(EntityGetter.class) | ||
public interface EntityGetterMixin { | ||
|
||
@WrapOperation( | ||
method = "hasNearbyAlivePlayer", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/entity/EntitySelector;NO_SPECTATORS:Ljava/util/function/Predicate;" | ||
) | ||
) | ||
default Predicate<Entity> vanish_preventMobSpawning(Operation<Predicate<Entity>> original) { | ||
return ConfigManager.vanish().interaction.mobSpawning ? VanishMod.NO_SPECTATORS_AND_NO_VANISH : original.call(); | ||
} | ||
|
||
@WrapOperation( | ||
method = "getNearestPlayer(DDDDZ)Lnet/minecraft/world/entity/player/Player;", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/entity/EntitySelector;NO_SPECTATORS:Ljava/util/function/Predicate;" | ||
) | ||
) | ||
default Predicate<Entity> vanish_preventMobSpawning2(Operation<Predicate<Entity>> original) { | ||
return ConfigManager.vanish().interaction.mobSpawning ? VanishMod.NO_SPECTATORS_AND_NO_VANISH : original.call(); | ||
} | ||
|
||
@WrapOperation( | ||
method = "getEntityCollisions", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/entity/EntitySelector;NO_SPECTATORS:Ljava/util/function/Predicate;" | ||
) | ||
) | ||
default Predicate<Entity> vanish_preventEntityCollisions(Operation<Predicate<Entity>> original) { | ||
return ConfigManager.vanish().interaction.entityCollisions ? VanishMod.NO_SPECTATORS_AND_NO_VANISH : original.call(); | ||
} | ||
|
||
@WrapOperation( | ||
method = "getEntityCollisions", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/entity/EntitySelector;CAN_BE_COLLIDED_WITH:Ljava/util/function/Predicate;" | ||
) | ||
) | ||
default Predicate<Entity> vanish_preventEntityCollisions2(Operation<Predicate<Entity>> original) { | ||
return ConfigManager.vanish().interaction.entityCollisions ? VanishMod.CAN_BE_COLLIDED_WITH_AND_NO_VANISH : original.call(); | ||
} | ||
} | ||
|
||
@Mixin(EntitySelector.class) | ||
public abstract static class EntitySelectorMixin { | ||
|
||
@WrapOperation( | ||
method = "pushableBy", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/entity/EntitySelector;NO_SPECTATORS:Ljava/util/function/Predicate;" | ||
) | ||
) | ||
private static Predicate<Entity> vanish_preventEntityCollision(Operation<Predicate<Entity>> original, Entity entity) { | ||
return ConfigManager.vanish().interaction.entityCollisions ? VanishMod.NO_SPECTATORS_AND_NO_VANISH.and(entity1 -> !VanishAPI.isVanished(entity)) : original.call(); | ||
} | ||
} | ||
|
||
@Mixin(ArmorItem.class) | ||
public abstract static class ArmorItemMixin { | ||
|
||
@WrapOperation( | ||
method = "dispenseArmor", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/world/entity/EntitySelector;NO_SPECTATORS:Ljava/util/function/Predicate;" | ||
) | ||
) | ||
private static Predicate<Entity> vanish_preventArmorItemEquip(Operation<Predicate<Entity>> original) { | ||
return ConfigManager.vanish().interaction.entityPickup ? VanishMod.NO_SPECTATORS_AND_NO_VANISH : original.call(); | ||
} | ||
} | ||
|
||
@Mixin(AbstractMinecart.class) | ||
public abstract static class AbstractMinecartMixin { | ||
|
||
@WrapOperation( | ||
method = "tick", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;" | ||
) | ||
) | ||
private List<Entity> vanish_preventMinecartColision(Level instance, Entity entity, AABB aABB, Operation<List<Entity>> original) { | ||
return true ? instance.getEntities(entity, aABB, VanishMod.NO_SPECTATORS_AND_NO_VANISH) : original.call(instance, entity, aABB); | ||
} | ||
|
||
} | ||
|
||
@Mixin(Player.class) | ||
public abstract static class PlayerMixin { | ||
|
||
@Redirect( | ||
method = "attack", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/Level;getEntitiesOfClass(Ljava/lang/Class;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;" | ||
) | ||
) | ||
private List<LivingEntity> vanish_preventSweepingEdge(Level instance, Class<LivingEntity> aClass, AABB aabb) { | ||
return instance.getEntitiesOfClass(aClass, aabb, VanishMod.NO_SPECTATORS_AND_NO_VANISH); | ||
} | ||
} | ||
|
||
@Mixin(BeehiveBlock.class) | ||
public abstract static class BeehiveBlockMixin { | ||
|
||
@Redirect( | ||
method = "angerNearbyBees", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/Level;getEntitiesOfClass(Ljava/lang/Class;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;" | ||
) | ||
) | ||
private List<LivingEntity> vanish_preventBeeAnger(Level instance, Class<LivingEntity> aClass, AABB aabb) { | ||
return instance.getEntitiesOfClass(aClass, aabb, VanishMod.NO_SPECTATORS_AND_NO_VANISH); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.