Update upstream
This commit is contained in:
parent
4b7ac41bdc
commit
f681dd0456
@ -1,6 +1,8 @@
|
||||
package io.izzel.arclight.common.mixin.core.server.commands;
|
||||
|
||||
import io.izzel.arclight.common.bridge.core.world.server.ServerWorldBridge;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.commands.TimeCommand;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -9,9 +11,21 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(TimeCommand.class)
|
||||
public class TimeCommandMixin {
|
||||
|
||||
@Redirect(method = "setTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getAllLevels()Ljava/lang/Iterable;"))
|
||||
private static Iterable<ServerLevel> arclight$useSourceLevel1(MinecraftServer server, CommandSourceStack source) {
|
||||
return List.of(source.getLevel());
|
||||
}
|
||||
|
||||
@Redirect(method = "addTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getAllLevels()Ljava/lang/Iterable;"))
|
||||
private static Iterable<ServerLevel> arclight$useSourceLevel2(MinecraftServer server, CommandSourceStack source) {
|
||||
return List.of(source.getLevel());
|
||||
}
|
||||
|
||||
@Redirect(method = "addTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setDayTime(J)V"))
|
||||
private static void arclight$addTimeEvent(ServerLevel serverWorld, long time) {
|
||||
TimeSkipEvent event = new TimeSkipEvent(((ServerWorldBridge) serverWorld).bridge$getWorld(), TimeSkipEvent.SkipReason.COMMAND, time - serverWorld.getDayTime());
|
||||
|
||||
@ -214,6 +214,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||
@Shadow public abstract void gameEvent(GameEvent p_146853_, @org.jetbrains.annotations.Nullable Entity p_146854_);
|
||||
@Shadow public abstract void setTicksFrozen(int p_146918_);
|
||||
@Shadow public abstract void setSharedFlagOnFire(boolean p_146869_);
|
||||
@Shadow public abstract int getMaxAirSupply();
|
||||
// @formatter:on
|
||||
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
@ -224,6 +225,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||
public boolean forceExplosionKnockback; // SPIGOT-949
|
||||
public boolean persistentInvisibility = false;
|
||||
public BlockPos lastLavaContact;
|
||||
public int maxAirTicks = getDefaultMaxAirSupply();
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
@ -272,6 +274,15 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||
return isChunkLoaded();
|
||||
}
|
||||
|
||||
public int getDefaultMaxAirSupply() {
|
||||
return Entity.TOTAL_AIR_SUPPLY;
|
||||
}
|
||||
|
||||
@Inject(method = "getMaxAirSupply", cancellable = true, at = @At("RETURN"))
|
||||
private void arclight$useBukkitMaxAir(CallbackInfoReturnable<Integer> cir) {
|
||||
cir.setReturnValue(this.maxAirTicks);
|
||||
}
|
||||
|
||||
@Inject(method = "setPose", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/syncher/SynchedEntityData;set(Lnet/minecraft/network/syncher/EntityDataAccessor;Ljava/lang/Object;)V"))
|
||||
public void arclight$setPose$EntityPoseChangeEvent(Pose poseIn, CallbackInfo callbackInfo) {
|
||||
if (poseIn == this.getPose()) {
|
||||
@ -523,6 +534,9 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||
if (this.persistentInvisibility) {
|
||||
compound.putBoolean("Bukkit.invisible", this.persistentInvisibility);
|
||||
}
|
||||
if (maxAirTicks != getDefaultMaxAirSupply()) {
|
||||
compound.putInt("Bukkit.MaxAirSupply", getMaxAirSupply());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "saveWithoutId", at = @At(value = "RETURN"))
|
||||
@ -578,6 +592,9 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||
this.setInvisible(bukkitInvisible);
|
||||
this.persistentInvisibility = bukkitInvisible;
|
||||
}
|
||||
if (compound.contains("Bukkit.MaxAirSupply")) {
|
||||
maxAirTicks = compound.getInt("Bukkit.MaxAirSupply");
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
@ -920,7 +937,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||
return null;
|
||||
}
|
||||
ServerLevel worldFinal = world = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||
blockpos1 = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
blockpos1 = worldFinal.getWorldBorder().clampToBounds(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
|
||||
return this.getExitPortal(world, blockpos1, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((result) -> {
|
||||
BlockState blockstate = this.level.getBlockState(this.portalEntrancePos);
|
||||
|
||||
@ -185,7 +185,6 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
||||
// @formatter:on
|
||||
|
||||
public int expToDrop;
|
||||
public int maxAirTicks;
|
||||
public boolean forceDrops;
|
||||
public CraftAttributeMap craftAttributes;
|
||||
public boolean collides;
|
||||
@ -199,7 +198,6 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void arclight$init(EntityType<? extends LivingEntity> type, Level worldIn, CallbackInfo ci) {
|
||||
this.maxAirTicks = 300;
|
||||
this.collides = true;
|
||||
this.craftAttributes = new CraftAttributeMap(this.attributes);
|
||||
this.entityData.set(DATA_HEALTH_ID, (float) this.getAttributeValue(Attributes.MAX_HEALTH));
|
||||
|
||||
@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import io.izzel.arclight.common.mixin.core.world.entity.PathfinderMobMixin;
|
||||
import net.minecraft.world.entity.animal.Dolphin;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Dolphin.class)
|
||||
public abstract class DolphinMixin extends PathfinderMobMixin {
|
||||
@ -18,4 +19,14 @@ public abstract class DolphinMixin extends PathfinderMobMixin {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getMaxAirSupply", cancellable = true, at = @At("RETURN"))
|
||||
private void arclight$useBukkitMaxAir(CallbackInfoReturnable<Integer> cir) {
|
||||
cir.setReturnValue(this.maxAirTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultMaxAirSupply() {
|
||||
return Dolphin.TOTAL_AIR_SUPPLY;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package io.izzel.arclight.common.mixin.core.world.entity.animal.axolotl;
|
||||
|
||||
import io.izzel.arclight.common.bridge.core.entity.MobEntityBridge;
|
||||
import io.izzel.arclight.common.mixin.core.world.entity.animal.AnimalMixin;
|
||||
import net.minecraft.world.entity.animal.Dolphin;
|
||||
import net.minecraft.world.entity.animal.axolotl.Axolotl;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Axolotl.class)
|
||||
public abstract class AxolotlMixin extends AnimalMixin {
|
||||
|
||||
@Shadow @Final private static int AXOLOTL_TOTAL_AIR_SUPPLY;
|
||||
|
||||
@Inject(method = "getMaxAirSupply", cancellable = true, at = @At("RETURN"))
|
||||
private void arclight$useBukkitMaxAir(CallbackInfoReturnable<Integer> cir) {
|
||||
cir.setReturnValue(this.maxAirTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultMaxAirSupply() {
|
||||
return AXOLOTL_TOTAL_AIR_SUPPLY;
|
||||
}
|
||||
|
||||
@Inject(method = "applySupportingEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;addEffect(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z"))
|
||||
private void arclight$cause(Player player, CallbackInfo ci) {
|
||||
((MobEntityBridge) player).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.AXOLOTL);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package io.izzel.arclight.common.mixin.core.world.entity.monster;
|
||||
|
||||
import io.izzel.arclight.common.bridge.core.world.WorldBridge;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.monster.Evoker;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
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;
|
||||
|
||||
@Mixin(targets = "net.minecraft.world.entity.monster.Evoker$EvokerSummonSpellGoal")
|
||||
public class Evoker_EvokerSummonSpellGoalMixin {
|
||||
|
||||
@Inject(method = "performSpellCasting", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"))
|
||||
private void arclight$reason(CallbackInfo ci, ServerLevel level) {
|
||||
((WorldBridge) level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SPELL);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package io.izzel.arclight.common.mixin.core.world.level.levelgen.structure.templatesystem;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer;
|
||||
import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataTypeRegistry;
|
||||
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;
|
||||
|
||||
@Mixin(StructureTemplate.class)
|
||||
public class StructureTemplateMixin {
|
||||
|
||||
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
||||
public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||
|
||||
@Inject(method = "save", at = @At("RETURN"))
|
||||
private void arclight$savePdc(CompoundTag tag, CallbackInfoReturnable<CompoundTag> cir) {
|
||||
if (!this.persistentDataContainer.isEmpty()) {
|
||||
tag.put("BukkitValues", this.persistentDataContainer.toTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "load", at = @At("RETURN"))
|
||||
private void arclight$loadPdc(CompoundTag tag, CallbackInfo ci) {
|
||||
var base = tag.get("BukkitValues");
|
||||
if (base instanceof CompoundTag compoundTag) {
|
||||
this.persistentDataContainer.putAll(compoundTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,8 @@ public net.minecraft.server.level.PlayerRespawnLogic m_183928_(Lnet/minecraft/se
|
||||
public net.minecraft.world.entity.npc.Villager m_35524_()V # releaseAllPois
|
||||
public net.minecraft.world.entity.Entity f_19861_ # onGround
|
||||
public net.minecraft.world.level.block.ChestBlock$2$1
|
||||
public net.minecraft.world.entity.animal.horse.SkeletonHorse f_30892_ # trapTime
|
||||
public net.minecraft.world.entity.monster.Vindicator f_34071_ # Here's Johnny!
|
||||
# Arclight 1.17
|
||||
public net.minecraft.world.entity.Entity f_19851_
|
||||
public net.minecraft.world.entity.raid.Raider$HoldGroundAttackGoal
|
||||
|
||||
@ -150,6 +150,7 @@
|
||||
"world.entity.animal.Turtle_LayEggGoalMixin",
|
||||
"world.entity.animal.TurtleMixin",
|
||||
"world.entity.animal.WolfMixin",
|
||||
"world.entity.animal.axolotl.AxolotlMixin",
|
||||
"world.entity.animal.horse.AbstractHorseMixin",
|
||||
"world.entity.animal.horse.LlamaMixin",
|
||||
"world.entity.animal.horse.TraderLlamaEntity_FollowTraderGoalMixin",
|
||||
@ -171,6 +172,7 @@
|
||||
"world.entity.monster.EnderMan_EndermanLeaveBlockGoalMixin",
|
||||
"world.entity.monster.EnderMan_EndermanTakeBlockGoalMixin",
|
||||
"world.entity.monster.EnderManMixin",
|
||||
"world.entity.monster.Evoker_EvokerSummonSpellGoalMixin",
|
||||
"world.entity.monster.Ghast_GhastShootFireballGoalMixin",
|
||||
"world.entity.monster.HuskMixin",
|
||||
"world.entity.monster.Illusioner_BlindnessSpellGoalMixin",
|
||||
@ -431,6 +433,7 @@
|
||||
"world.level.entity.PersistentEntitySectionManagerMixin",
|
||||
"world.level.gameevent.vibrations.VibrationListenerMixin",
|
||||
"world.level.levelgen.ChunkGeneratorMixin",
|
||||
"world.level.levelgen.structure.templatesystem.StructureTemplateMixin",
|
||||
"world.level.portal.PortalForcerMixin",
|
||||
"world.level.saveddata.maps.MapDataMixin",
|
||||
"world.level.saveddata.maps.MapItemSavedData_HoldingPlayerMixin",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user