Compare commits

..

10 Commits

Author SHA1 Message Date
IzzelAliz
fded76e5ac Release 1.0.12
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
2024-02-28 22:49:35 +08:00
IzzelAliz
14bf4dc941 Release 1.0.11 2024-01-26 21:35:37 +08:00
IzzelAliz
976e874c78 Update download mirrors (#1200) 2024-01-26 21:35:08 +08:00
IzzelAliz
033f7507e6
Release 1.0.10 2023-12-02 19:55:41 +08:00
IzzelAliz
072483cf95
Update to forge 40.2.14
Update mirrors
2023-12-02 19:55:15 +08:00
IzzelAliz
7a0a194619
Release 1.0.9 2023-08-05 23:47:15 +08:00
IzzelAliz
c743dbdb58
Update to forge 40.2.10 2023-08-05 13:36:09 +08:00
sandtechnology
473aa47edb
Fix #583, Update dragonPhase dynamically (#869)
* #583 Update dragonPhase dynamically

* Remove author annotation

* Fix build

* Formatting
2023-08-05 13:09:25 +08:00
IzzelAliz
87c9caa8ed
Fix NPE in runCommand (#969) 2023-05-15 09:55:45 +08:00
IzzelAliz
ef1854ccb2
Fix mobs ignore player (#986) 2023-05-11 10:32:17 +08:00
11 changed files with 73 additions and 31 deletions

View File

@ -0,0 +1,42 @@
package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.api.EnumHelper;
import io.izzel.arclight.common.mod.ArclightMod;
import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase;
import org.bukkit.craftbukkit.v.entity.CraftEnderDragon;
import org.bukkit.entity.EnderDragon;
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.CallbackInfoReturnable;
import java.util.ArrayList;
import java.util.List;
@Mixin(value = CraftEnderDragon.class, remap = false)
public class CraftEnderDragonMixin {
@Inject(method = "getPhase", at = @At("HEAD"))
public void arclight$getPhase(CallbackInfoReturnable<EnderDragon.Phase> cir) {
checkAndUpdateDragonPhase();
}
@Inject(method = "getBukkitPhase", at = @At("HEAD"))
private static void arclight$getBukkitPhase(EnderDragonPhase phase, CallbackInfoReturnable<EnderDragon.Phase> cir) {
checkAndUpdateDragonPhase();
}
private static void checkAndUpdateDragonPhase() {
var forgeCount = EnderDragonPhase.getCount();
if (EnderDragon.Phase.values().length != forgeCount) {
var newTypes = new ArrayList<EnderDragon.Phase>();
for (var id = EnderDragon.Phase.values().length; id < forgeCount; id++) {
var name = "MOD_PHASE_" + id;
var newPhase = EnumHelper.makeEnum(EnderDragon.Phase.class, name, id, List.of(), List.of());
newTypes.add(newPhase);
ArclightMod.LOGGER.debug("Registered {} as ender dragon phase {}", name, newPhase);
}
EnumHelper.addEnums(EnderDragon.Phase.class, newTypes);
}
}
}

View File

@ -1207,7 +1207,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
// CraftBukkit end
InteractionResult enuminteractionresult = interaction.run(player, entity, hand);
if (ForgeHooks.onInteractEntityAt(player, entity, entity.position(), hand) != null) return;
// if (ForgeHooks.onInteractEntityAt(player, entity, entity.position(), hand) != null) return;
// CraftBukkit start
if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
@ -1233,7 +1233,11 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
@Override
public void onInteraction(InteractionHand hand, Vec3 vec) {
this.performInteraction(hand, (player, e, h) -> e.interactAt(player, vec, h),
this.performInteraction(hand, (player, e, h) -> {
var interactionResult = ForgeHooks.onInteractEntityAt(player, entity, vec, hand);
if (interactionResult != null) return interactionResult;
return e.interactAt(player, vec, h);
},
new PlayerInteractAtEntityEvent(getCraftPlayer(), ((EntityBridge) entity).bridge$getBukkitEntity(),
new org.bukkit.util.Vector(vec.x, vec.y, vec.z), (hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND));
}

View File

@ -48,7 +48,7 @@ public abstract class DedicatedServerMixin extends MinecraftServerMixin {
BukkitRegistry.lockRegistries();
}
@Inject(method = "initServer", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/server/rcon/thread/RconThread;create(Lnet/minecraft/server/ServerInterface;)Lnet/minecraft/server/rcon/thread/RconThread;"))
@Inject(method = "initServer", at = @At(value = "FIELD", target = "Lnet/minecraft/server/dedicated/DedicatedServerProperties;enableRcon:Z"))
public void arclight$setRcon(CallbackInfoReturnable<Boolean> cir) {
this.remoteConsole = new CraftRemoteConsoleCommandSender(this.rconConsoleSource);
}

View File

@ -49,8 +49,6 @@ public abstract class EntityTypeMixin<T extends Entity> implements EntityTypeBri
public T spawn(ServerLevel worldIn, @Nullable CompoundTag compound, @Nullable Component customName, @Nullable Player playerIn, BlockPos pos, MobSpawnType reason, boolean p_220342_7_, boolean p_220342_8_, CreatureSpawnEvent.SpawnReason spawnReason) {
T t = this.create(worldIn, compound, customName, playerIn, pos, reason, p_220342_7_, p_220342_8_);
if (t != null) {
if (t instanceof net.minecraft.world.entity.Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.world.entity.Mob) t, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, reason))
return null;
((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(spawnReason);
worldIn.addFreshEntityWithPassengers(t);
return t.isRemoved() ? null : t;

View File

@ -137,7 +137,7 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri
}
}
var changeTargetEvent = ForgeHooks.onLivingChangeTarget((Mob) (Object) this, livingEntity, LivingChangeTargetEvent.LivingTargetType.MOB_TARGET);
if (changeTargetEvent.isCanceled()) {
if (!changeTargetEvent.isCanceled()) {
this.target = changeTargetEvent.getNewTarget();
// noinspection removal
ForgeHooks.onLivingSetAttackTarget((Mob) (Object) this, this.target);

View File

@ -35,7 +35,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public abstract class BucketItemMixin {
// @formatter:off
@Shadow public abstract boolean emptyContents(@javax.annotation.Nullable Player player, Level worldIn, BlockPos posIn, @javax.annotation.Nullable BlockHitResult rayTrace);
@Shadow(remap = false) public abstract boolean emptyContents(@javax.annotation.Nullable Player player, Level worldIn, BlockPos posIn, @javax.annotation.Nullable BlockHitResult rayTrace, ItemStack stack);
// @formatter:on
@Inject(method = "use", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/BucketPickup;pickupBlock(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack;"))
@ -54,11 +54,10 @@ public abstract class BucketItemMixin {
}
}
@Inject(method = "use", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/BucketItem;emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;)Z"))
@Inject(method = "use", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraft/world/item/BucketItem;emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;Lnet/minecraft/world/item/ItemStack;)Z"))
private void arclight$capture(Level worldIn, Player playerIn, InteractionHand handIn, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir, ItemStack stack, BlockHitResult result) {
arclight$direction = result.getDirection();
arclight$click = result.getBlockPos();
arclight$stack = stack;
}
@Inject(method = "use", at = @At("RETURN"))
@ -66,7 +65,6 @@ public abstract class BucketItemMixin {
arclight$captureItem = null;
arclight$direction = null;
arclight$click = null;
arclight$stack = null;
}
private transient org.bukkit.inventory.@Nullable ItemStack arclight$captureItem;
@ -79,25 +77,22 @@ public abstract class BucketItemMixin {
public boolean emptyContents(Player entity, Level world, BlockPos pos, @Nullable BlockHitResult result, Direction direction, BlockPos clicked, ItemStack itemstack) {
arclight$direction = direction;
arclight$click = clicked;
arclight$stack = itemstack;
try {
return this.emptyContents(entity, world, pos, result);
return this.emptyContents(entity, world, pos, result, itemstack);
} finally {
arclight$direction = null;
arclight$click = null;
arclight$stack = null;
}
}
private transient Direction arclight$direction;
private transient BlockPos arclight$click;
private transient ItemStack arclight$stack;
@Inject(method = "emptyContents", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/dimension/DimensionType;ultraWarm()Z"))
private void arclight$bucketEmpty(Player player, Level worldIn, BlockPos posIn, BlockHitResult rayTrace, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;Lnet/minecraft/world/item/ItemStack;)Z", remap = false, cancellable = true, at = @At(value = "INVOKE", remap = true, target = "Lnet/minecraft/world/level/dimension/DimensionType;ultraWarm()Z"))
private void arclight$bucketEmpty(Player player, Level worldIn, BlockPos posIn, BlockHitResult rayTrace, ItemStack itemStack, CallbackInfoReturnable<Boolean> cir) {
if (!DistValidate.isValid(worldIn)) return;
if (player != null) {
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerLevel) worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack);
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerLevel) worldIn, player, posIn, arclight$click, arclight$direction, itemStack);
if (event.isCancelled()) {
((ServerPlayer) player).connection.send(new ClientboundBlockUpdatePacket(worldIn, posIn));
((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().updateInventory();

View File

@ -18,6 +18,7 @@
"CraftBlockStateMixin",
"CraftConsoleCommandSenderMixin",
"CraftCreativeCategoryMixin",
"CraftEnderDragonMixin",
"CraftEntityMixin",
"CraftEventFactoryMixin",
"CraftHumanEntityMixin",

View File

@ -1,6 +1,6 @@
allprojects {
group 'io.izzel.arclight'
version '1.0.9-SNAPSHOT'
version '1.0.12'
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
@ -14,7 +14,7 @@ allprojects {
ext {
agpVersion = '1.23'
minecraftVersion = '1.18.2'
forgeVersion = '40.2.1'
forgeVersion = '40.2.14'
apiVersion = '1.4.0'
toolsVersion = '1.3.+'
mixinVersion = '0.8.5'

View File

@ -92,7 +92,9 @@ public class ForgeInstaller {
builder.command(file.getCanonicalPath(), "-Djava.net.useSystemProxies=true", "-jar", futures[0].join().toString(), "--installServer", ".", "--debug");
builder.inheritIO();
Process process = builder.start();
process.waitFor();
if (process.waitFor() > 0) {
throw new Exception("Forge installation failed");
}
} catch (IOException e) {
try (URLClassLoader loader = new URLClassLoader(
new URL[]{new File(String.format("forge-%s-%s-installer.jar", installInfo.installer.minecraft, installInfo.installer.forge)).toURI().toURL()},

View File

@ -5,15 +5,10 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.StringJoiner;
import java.util.function.Function;
import java.util.function.Supplier;
public class MavenDownloader implements Supplier<Path> {
private static final Function<String, String> FORGE_TO_BMCLAPI =
s -> s.replace("https://files.minecraftforge.net/maven/", "https://download.mcbbs.net/maven/")
.replace("https://maven.minecraftforge.net/", "https://download.mcbbs.net/maven/");
private final LinkedList<String> urls;
private final String coord;
private final String target;
@ -33,8 +28,11 @@ public class MavenDownloader implements Supplier<Path> {
public MavenDownloader(String[] repos, String coord, String target, String hash, String sourceUrl) {
this(repos, coord, target, hash);
if (sourceUrl != null && !this.urls.contains(sourceUrl)) {
if (Mirrors.isMirrorUrl(sourceUrl)) {
this.urls.addFirst(sourceUrl);
this.urls.addFirst(FORGE_TO_BMCLAPI.apply(sourceUrl));
} else {
this.urls.addLast(sourceUrl);
}
}
}

View File

@ -8,14 +8,12 @@ import java.util.stream.Collectors;
public class Mirrors {
private static final String[] MAVEN_REPO = {
"https://arclight.mcxk.net/",
"https://download.mcbbs.net/maven/",
"https://arclight.hypertention.cn/",
"https://repo.spongepowered.org/maven/"
};
private static final String[] MOJANG_MIRROR = {
"https://download.mcbbs.net",
"https://bmclapi2.bangbang93.com",
"https://mojmirror.hypertention.cn",
"https://piston-meta.mojang.com"
};
@ -39,4 +37,8 @@ public class Mirrors {
.replace("https://piston-meta.mojang.com", mirror)
.replace("https://piston-data.mojang.com", mirror);
}
public static boolean isMirrorUrl(String url) {
return url.startsWith(MOJANG_MIRROR[0]);
}
}