Skip to content

Commit

Permalink
Update to forge 48.0.49
Browse files Browse the repository at this point in the history
Update mirrors
  • Loading branch information
IzzelAliz committed Dec 2, 2023
1 parent e76bbea commit 06b3ed2
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Bukkit server implementation utilizing Mixin.

| Release | Forge | Status | Build |
|:--------------------:|:-------:|:------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Net (1.20.2) | 48.0.40 | ACTIVE | [![1.20.2 Status](https://img.shields.io/github/actions/workflow/status/IzzelAliz/Arclight/gradle.yml?branch=Net&style=flat-square)](https://github.com/IzzelAliz/Arclight/actions?query=branch%3ANet) |
| Net (1.20.2) | 48.0.49 | ACTIVE | [![1.20.2 Status](https://img.shields.io/github/actions/workflow/status/IzzelAliz/Arclight/gradle.yml?branch=Net&style=flat-square)](https://github.com/IzzelAliz/Arclight/actions?query=branch%3ANet) |
| Trials (1.20-1.20.1) | 47.2.0 | LTS | [![1.20.1 Status](https://img.shields.io/github/actions/workflow/status/IzzelAliz/Arclight/gradle.yml?branch=Trials&style=flat-square)](https://github.com/IzzelAliz/Arclight/actions?query=branch%3ATrials) |
| Horn (1.19-1.19.2) | 43.3.2 | LTS | [![Horn Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-19?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-19) |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public interface EntityBridge extends ICommandSourceBridge {

void bridge$setValid(boolean valid);

boolean bridge$isInWorld();

void bridge$setInWorld(boolean inWorld);

ProjectileSource bridge$getProjectileSource();

void bridge$setProjectileSource(ProjectileSource projectileSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class ServerLevel_EntityCallbacksMixin {

@Shadow(aliases = {"f_143351_", "this$0"}) private ServerLevel outerThis;

@Inject(method = "onCreated(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"))
private void arclight$addedToWorld(Entity entity, CallbackInfo ci) {
((EntityBridge) entity).bridge$setInWorld(true);
}

@Inject(method = "onTrackingStart(Lnet/minecraft/world/entity/Entity;)V", at = @At("RETURN"))
private void arclight$valid(Entity entity, CallbackInfo ci) {
((EntityBridge) entity).bridge$setValid(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
Expand Down Expand Up @@ -232,18 +233,23 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
@Shadow protected abstract void setLevel(Level p_285201_);
@Shadow protected abstract void lerpPositionAndRotationStep(int p_298722_, double p_297490_, double p_300716_, double p_298684_, double p_300659_, double p_298926_);
@Shadow protected abstract void reapplyPosition();
@Shadow protected abstract void addAdditionalSaveData(CompoundTag p_20139_);
@Shadow public abstract CompoundTag saveWithoutId(CompoundTag p_20241_);
@Shadow public abstract boolean saveAsPassenger(CompoundTag p_20087_);
// @formatter:on

private static final int CURRENT_LEVEL = 2;
public boolean persist = true;
public boolean generation;
public boolean valid;
public boolean inWorld = false;
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean lastDamageCancelled; // SPIGOT-949
public boolean persistentInvisibility = false;
public BlockPos lastLavaContact;
public int maxAirTicks = getDefaultMaxAirSupply();
public boolean visibleByDefault = true;
public boolean pluginRemoved = false;

private CraftEntity bukkitEntity;

Expand Down Expand Up @@ -308,6 +314,16 @@ public SoundEvent getSwimHighSpeedSplashSound0() {
return getSwimHighSpeedSplashSound();
}

@Override
public boolean bridge$isInWorld() {
return inWorld;
}

@Override
public void bridge$setInWorld(boolean inWorld) {
this.inWorld = inWorld;
}

@Inject(method = "getMaxAirSupply", cancellable = true, at = @At("RETURN"))
private void arclight$useBukkitMaxAir(CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(this.maxAirTicks);
Expand Down Expand Up @@ -487,7 +503,7 @@ public void setSecondsOnFire(int seconds, boolean callEvent) {
}

@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;onGround()Z"),
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;updateEntityAfterFallOn(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;)V")))
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;updateEntityAfterFallOn(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;)V")))
private void arclight$move$blockCollide(MoverType typeIn, Vec3 pos, CallbackInfo ci) {
if (horizontalCollision && this.bridge$getBukkitEntity() instanceof Vehicle vehicle) {
org.bukkit.block.Block block = ((WorldBridge) this.level()).bridge$getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ()));
Expand Down Expand Up @@ -524,6 +540,37 @@ public boolean canCollideWith(Entity entity) {
return canCollideWith(entity);
}

@Unique protected transient boolean arclight$saveNotIncludeAll = false;

protected void addAdditionalSaveData(CompoundTag tag, boolean includeAll) {
var old = arclight$saveNotIncludeAll;
arclight$saveNotIncludeAll = !includeAll;
try {
addAdditionalSaveData(tag);
} finally {
arclight$saveNotIncludeAll = old;
}
}

public CompoundTag saveWithoutId(CompoundTag tag, boolean includeAll) {
var old = arclight$saveNotIncludeAll;
arclight$saveNotIncludeAll = !includeAll;
try {
return this.saveWithoutId(tag);
} finally {
arclight$saveNotIncludeAll = old;
}
}

public boolean saveAsPassenger(CompoundTag tag, boolean includeAll) {
arclight$saveNotIncludeAll = !includeAll;
try {
return this.saveAsPassenger(tag);
} finally {
arclight$saveNotIncludeAll = false;
}
}

@Inject(method = "saveAsPassenger", cancellable = true, at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/entity/Entity;getEncodeId()Ljava/lang/String;"))
public void arclight$writeUnlessRemoved$persistCheck(CompoundTag compound, CallbackInfoReturnable<Boolean> cir) {
if (!this.persist)
Expand Down Expand Up @@ -567,6 +614,10 @@ public boolean canCollideWith(Entity entity) {
if (this.bukkitEntity != null) {
this.bukkitEntity.storeBukkitValues(compound);
}
if (this.arclight$saveNotIncludeAll) {
compound.remove("Pos");
compound.remove("UUID");
}
}

private static boolean isLevelAtLeast(CompoundTag tag, int level) {
Expand Down Expand Up @@ -632,8 +683,8 @@ private static boolean isLevelAtLeast(CompoundTag tag, int level) {
}

@Inject(method = "spawnAtLocation(Lnet/minecraft/world/item/ItemStack;F)Lnet/minecraft/world/entity/item/ItemEntity;",
cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"))
cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"))
public void arclight$entityDropItem(ItemStack stack, float offsetY, CallbackInfoReturnable<ItemEntity> cir, ItemEntity itementity) {
EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) ((EntityBridge) itementity).bridge$getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
Expand Down Expand Up @@ -677,8 +728,8 @@ public boolean addPassenger(Entity entity) {
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent(
(Vehicle) getBukkitEntity(),
((EntityBridge) entity).bridge$getBukkitEntity()
(Vehicle) getBukkitEntity(),
((EntityBridge) entity).bridge$getBukkitEntity()
);
// Suppress during worldgen
if (this.valid) {
Expand Down Expand Up @@ -734,8 +785,8 @@ public boolean removePassenger(Entity entity) { // CraftBukkit
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent(
(Vehicle) getBukkitEntity(),
(org.bukkit.entity.LivingEntity) ((EntityBridge) entity).bridge$getBukkitEntity()
(Vehicle) getBukkitEntity(),
(org.bukkit.entity.LivingEntity) ((EntityBridge) entity).bridge$getBukkitEntity()
);
// Suppress during worldgen
if (this.valid) {
Expand All @@ -762,7 +813,7 @@ public boolean removePassenger(Entity entity) { // CraftBukkit
this.passengers = ImmutableList.of();
} else {
this.passengers = this.passengers.stream().filter((entity1) -> entity1 != entity)
.collect(ImmutableList.toImmutableList());
.collect(ImmutableList.toImmutableList());
}

entity.boardingCooldown = 60;
Expand Down Expand Up @@ -889,7 +940,7 @@ public Entity changeDimension(ServerLevel server, net.minecraftforge.common.util
var bukkitPos = arclight$tpPos;
arclight$tpPos = null;
PortalInfo portalinfo = bukkitPos == null ? teleporter.getPortalInfo((Entity) (Object) this, server, this::findDimensionEntryPoint)
: new PortalInfo(new Vec3(bukkitPos.x(), bukkitPos.y(), bukkitPos.z()), Vec3.ZERO, this.yRot, this.xRot);
: new PortalInfo(new Vec3(bukkitPos.x(), bukkitPos.y(), bukkitPos.z()), Vec3.ZERO, this.yRot, this.xRot);
if (portalinfo == null) {
return null;
} else {
Expand All @@ -907,10 +958,12 @@ public Entity changeDimension(ServerLevel server, net.minecraftforge.common.util
entity.restoreFrom((Entity) (Object) this);
entity.moveTo(portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.yRot, entity.getXRot());
entity.setDeltaMovement(portalinfo.speed);
world.addDuringTeleport(entity);
if (((WorldBridge) world).bridge$getTypeKey() == LevelStem.END) {
ArclightCaptures.captureEndPortalEntity((Entity) (Object) this, spawnPortal);
ServerLevel.makeObsidianPlatform(world);
if (this.inWorld) {
world.addDuringTeleport(entity);
if (((WorldBridge) world).bridge$getTypeKey() == LevelStem.END) {
ArclightCaptures.captureEndPortalEntity((Entity) (Object) this, spawnPortal);
ServerLevel.makeObsidianPlatform(world);
}
}
}
return entity;
Expand All @@ -928,6 +981,13 @@ public Entity changeDimension(ServerLevel server, net.minecraftforge.common.util
}
}

@Redirect(method = "teleportTo(Lnet/minecraft/server/level/ServerLevel;DDDLjava/util/Set;FF)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addDuringTeleport(Lnet/minecraft/world/entity/Entity;)V"))
private void arclight$skipIfNotInWorld(ServerLevel instance, Entity entity) {
if (this.inWorld) {
instance.addDuringTeleport(entity);
}
}

@Inject(method = "restoreFrom", at = @At("HEAD"))
private void arclight$forwardHandle(Entity entityIn, CallbackInfo ci) {
((InternalEntityBridge) entityIn).internal$getBukkitEntity().setHandle((Entity) (Object) this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.EntityTransformEvent;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
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.ModifyArg;
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 Expand Up @@ -176,6 +178,11 @@ public boolean setTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReas
arclight$fireEvent = fireEvent;
}

@Redirect(method = "addAdditionalSaveData", at = @At(value = "FIELD", ordinal = 0, opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/world/entity/Mob;leashHolder:Lnet/minecraft/world/entity/Entity;"))
private Entity arclight$skipLeaseSave(Mob instance) {
return this.pluginRemoved ? null : instance.getLeashHolder();
}

@Inject(method = "addAdditionalSaveData", at = @At("HEAD"))
private void arclight$setAware(CompoundTag compound, CallbackInfo ci) {
compound.putBoolean("Bukkit.Aware", this.aware);
Expand Down Expand Up @@ -278,6 +285,11 @@ public ItemStack equipItemIfPossible(ItemStack stack) {
EntityUnleashEvent.UnleashReason.HOLDER_GONE : EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH));
}

@ModifyArg(method = "tickLeash", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;dropLeash(ZZ)V"))
private boolean arclight$skipOnPluginRemove(boolean b) {
return !this.pluginRemoved;
}

@Inject(method = "dropLeash", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Mob;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;"))
public void arclight$leashDropPost(boolean sendPacket, boolean dropLead, CallbackInfo ci) {
this.forceDrops = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.world.entity.animal;

import io.izzel.arclight.common.bridge.core.entity.LivingEntityBridge;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.animal.Bee;
Expand All @@ -10,6 +11,7 @@
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(Bee.class)
Expand All @@ -19,6 +21,14 @@ public abstract class BeeMixin extends AnimalMixin {
@Shadow Bee.BeePollinateGoal beePollinateGoal;
// @formatter:on

@Inject(method = "addAdditionalSaveData", at = @At("RETURN"))
private void arclight$removePos(CompoundTag tag, CallbackInfo ci) {
if (this.arclight$saveNotIncludeAll) {
tag.remove("HivePos");
tag.remove("FlowerPos");
}
}

@Inject(method = "doHurtTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;addEffect(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z"))
private void arclight$sting(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
((LivingEntityBridge) entityIn).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.ATTACK);
Expand All @@ -33,7 +43,6 @@ public boolean hurt(DamageSource source, float amount) {
if (this.isInvulnerableTo(source)) {
return false;
} else {
Entity entity = source.getEntity();
boolean ret = super.hurt(source, amount);
if (ret && !this.level().isClientSide) {
this.beePollinateGoal.stopPollinating();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.izzel.arclight.common.mixin.core.world.entity.EntityMixin;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
Expand All @@ -29,6 +30,13 @@ public abstract class HangingEntityMixin extends EntityMixin {
@Shadow public BlockPos pos;
// @formatter:on

@Inject(method = "addAdditionalSaveData", cancellable = true, at = @At("HEAD"))
private void arclight$skipSave(CompoundTag p_31736_, CallbackInfo ci) {
if (this.arclight$saveNotIncludeAll) {
ci.cancel();
}
}

@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/decoration/HangingEntity;discard()V"))
private void arclight$hangingBreak(CallbackInfo ci) {
var state = this.level().getBlockState(new BlockPos(this.blockPosition()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void onHit(final HitResult result) {
}
if (hatching) {
for (int i = 0; i < b0; ++i) {
Entity entity = ((WorldBridge) this.level()).bridge$getWorld().createEntity(new Location(((WorldBridge) this.level()).bridge$getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0f), hatchingType.getEntityClass());
Entity entity = ((WorldBridge) this.level()).bridge$getWorld().makeEntity(new Location(((WorldBridge) this.level()).bridge$getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0f), hatchingType.getEntityClass());
if (entity != null) {
if (((EntityBridge) entity).bridge$getBukkitEntity() instanceof Ageable) {
((Ageable) ((EntityBridge) entity).bridge$getBukkitEntity()).setBaby();
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
allprojects {
group 'io.izzel.arclight'
version '1.0.0'
version '1.0.1-SNAPSHOT'

def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
Expand All @@ -14,7 +14,7 @@ allprojects {
ext {
agpVersion = '1.23'
minecraftVersion = '1.20.2'
forgeVersion = '48.0.40'
forgeVersion = '48.0.49'
apiVersion = '1.5.5'
toolsVersion = '1.3.0'
mixinVersion = '0.8.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class Mirrors {

private static final String[] MAVEN_REPO = {
"https://arclight.mcxk.net/",
"https://arclight.hypertention.cn/",
"https://download.mcbbs.net/maven/",
"https://repo.spongepowered.org/maven/"
};
Expand Down

0 comments on commit 06b3ed2

Please sign in to comment.