Port to 1.16_combat-6

This commit is contained in:
SKBotNL committed 2025-10-10 00:16:31 +02:00
1 parent ac254ddb73
commit 8f007a30a4
19 files changed
+96 -131

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
[submodule "SpongeAPI"]
path = SpongeAPI
url = https://github.com/SpongePowered/SpongeAPI.git
url = https://github.com/SKBotNL/SpongeAPI-CTS.git
branch = api-8
+2 -2
View File
@@ -5,7 +5,7 @@ plugins {
`maven-publish`
`java-library`
eclipse
id("org.spongepowered.gradle.vanilla")
id("nl.skbotnl.sponge.gradle.vanilla")
id("com.github.johnrengelman.shadow")
id("org.spongepowered.gradle.sponge.dev") apply false // for version json generation
id("net.kyori.indra.licenser.spotless")
@@ -250,7 +250,7 @@ allprojects {
archivesBaseName = name.toLowerCase(Locale.ENGLISH)
}
plugins.withId("org.spongepowered.gradle.vanilla") {
plugins.withId("nl.skbotnl.sponge.gradle.vanilla") {
val quiltflowerVersion: String by project
minecraft {
version(minecraftVersion)
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id("org.spongepowered.gradle.vanilla")
id("nl.skbotnl.sponge.gradle.vanilla")
}
val apiVersion: String by project
+1 -1
View File
@@ -12,7 +12,7 @@ mixinConfigs=mixins.sponge.accessors.json,mixins.sponge.api.json,mixins.sponge.c
mixins.sponge.tracker.json,mixins.sponge.ipforward.json,mixins.sponge.optimization.json
superClassChanges=common.superclasschange
minecraftVersion=1.16.5
minecraftVersion=1.16_combat-6
recommendedVersion=1-SNAPSHOT
asmVersion=9.4
log4jVersion=2.17.1
+3 -2
View File
@@ -2,6 +2,7 @@ import org.spongepowered.gradle.vanilla.repository.MinecraftRepositoryExtension
pluginManagement {
repositories {
mavenLocal()
maven("https://repo.spongepowered.org/repository/maven-public/") {
name = "sponge"
}
@@ -9,7 +10,7 @@ pluginManagement {
plugins {
// Default plugin versions
id("org.spongepowered.gradle.vanilla") version "0.2.1-SNAPSHOT"
id("nl.skbotnl.sponge.gradle.vanilla") version "0.2.1-SNAPSHOT"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("org.spongepowered.gradle.sponge.dev") version "2.1.1"
id("net.kyori.indra.licenser.spotless") version "3.0.1"
@@ -20,7 +21,7 @@ pluginManagement {
}
plugins {
id("org.spongepowered.gradle.vanilla")
id("nl.skbotnl.sponge.gradle.vanilla")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.3.0")
}
@@ -311,7 +311,7 @@ public final class HumanEntity extends PathfinderMob implements TeamMember, Rang
float f = (float) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue();
int i = 0;
f += EnchantmentHelper.getDamageBonus(this.getItemInHand(InteractionHand.MAIN_HAND), this.getMobType());
f += EnchantmentHelper.getDamageBonus(this.getItemInHand(InteractionHand.MAIN_HAND), this);
i += EnchantmentHelper.getKnockbackBonus(this);
final boolean flag = entityIn.hurt(DamageSource.mobAttack(this), f);
@@ -34,7 +34,7 @@ public interface ItemHooks {
default void setCapabilitiesFromSpongeBuilder(final ItemStack stack, final CompoundTag compound) { }
default boolean canEnchantmentBeAppliedToItem(final Enchantment enchantment, final ItemStack stack) {
return enchantment.canEnchant(stack);
return enchantment.canEnchant(stack, false);
}
default void writeItemStackCapabilitiesToDataView(final DataContainer container, final ItemStack stack) { }
@@ -29,14 +29,13 @@ import net.minecraft.core.Registry;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.CombatRules;
import net.minecraft.world.CombatRules;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.EntityDamageSource;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.enchantment.Enchantment;
@@ -221,7 +220,7 @@ public final class DamageEventUtil {
}
public static List<DamageFunction> createAttackEnchantmentFunction(final net.minecraft.world.item.ItemStack heldItem,
final MobType creatureAttribute, final float attackStrength) {
final LivingEntity creature, final float attackStrength) {
if (heldItem.isEmpty()) {
return Collections.emptyList();
}
@@ -258,7 +257,7 @@ public final class DamageEventUtil {
final DoubleUnaryOperator enchantmentFunction = (damage) -> {
double totalDamage = 0;
for (final int level : enchantment.getValue()) {
totalDamage += (double) enchantment.getKey().getDamageBonus(level, creatureAttribute) * attackStrength;
totalDamage += (double) enchantment.getKey().getDamageBonus(level, creature) * attackStrength;
}
return totalDamage;
};
@@ -0,0 +1,44 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.item;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import org.spongepowered.api.data.Keys;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(CrossbowItem.class)
public abstract class ThrowableInaccurateCrossbowItemMixin {
@ModifyConstant(method = "use", constant = @Constant(floatValue = 0.25F, ordinal = 0))
public float impl$configureInaccuracy(final float inaccuracy, final Level level, final Player player, final InteractionHand hand) {
final ItemStack handItem = player.getItemInHand(hand);
return ((org.spongepowered.api.item.inventory.ItemStack) (Object) handItem).getOrElse(Keys.INACCURACY, (double) inaccuracy).floatValue();
}
}
@@ -26,19 +26,14 @@ package org.spongepowered.common.mixin.core.item;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CrossbowItem;
import net.minecraft.world.item.EggItem;
import net.minecraft.world.item.EnderpearlItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SnowballItem;
import net.minecraft.world.item.ThrowablePotionItem;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import org.spongepowered.api.data.Keys;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin({EggItem.class, CrossbowItem.class, EnderpearlItem.class, SnowballItem.class, ThrowablePotionItem.class})
@Mixin({EggItem.class, EnderpearlItem.class, SnowballItem.class, ThrowablePotionItem.class})
public abstract class ThrowableInaccurateItemMixin {
@ModifyConstant(method = "use", constant = @Constant(floatValue = 1.0F, ordinal = 0))
@@ -43,21 +43,7 @@ import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketUtils;
import net.minecraft.network.protocol.game.ClientboundBlockBreakAckPacket;
import net.minecraft.network.protocol.game.ClientboundCommandSuggestionsPacket;
import net.minecraft.network.protocol.game.ClientboundMoveVehiclePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
import net.minecraft.network.protocol.game.ClientboundResourcePackPacket;
import net.minecraft.network.protocol.game.ServerGamePacketListener;
import net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket;
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.network.protocol.game.ServerboundResourcePackPacket;
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
import net.minecraft.network.protocol.game.*;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayerGameMode;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
@@ -97,9 +83,7 @@ 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.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.common.SpongeCommon;
@@ -118,27 +102,18 @@ import org.spongepowered.common.entity.player.tab.SpongeTabList;
import org.spongepowered.common.event.ShouldFire;
import org.spongepowered.common.event.SpongeCommonEventFactory;
import org.spongepowered.common.event.tracking.PhaseTracker;
import org.spongepowered.common.event.tracking.phase.packet.BasicPacketContext;
import org.spongepowered.common.event.tracking.phase.packet.PacketPhase;
import org.spongepowered.common.hooks.PlatformHooks;
import org.spongepowered.common.item.util.ItemStackUtil;
import org.spongepowered.common.util.CommandUtil;
import org.spongepowered.common.util.VecHelper;
import org.spongepowered.math.vector.Vector3d;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.*;
@Mixin(ServerGamePacketListenerImpl.class)
public abstract class ServerGamePacketListenerImplMixin implements ServerGamePacketListenerImplBridge, ConnectionHolderBridge {
private static final String[] IMPL$ZERO_LENGTH_STRING_ARRAY = new String[0];
// @formatter:off
@Shadow @Final public Connection connection;
@Shadow public net.minecraft.server.level.ServerPlayer player;
@@ -152,7 +127,7 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerGamePac
@Shadow private int chatSpamTickCount;
@Shadow public abstract void shadow$teleport(double x, double y, double z, float yaw, float pitch, Set<ClientboundPlayerPositionPacket.RelativeArgument> relativeArguments);
@Shadow protected abstract void shadow$filterTextPacket(List<String> p_244537_1_, Consumer<List<String>> p_244537_2_);
// @Shadow protected abstract void shadow$filterTextPacket(List<String> p_244537_1_, Consumer<List<String>> p_244537_2_);
// @formatter:on
private int impl$ignorePackets;
@@ -225,13 +200,13 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerGamePac
/**
* Specifically hooks the reach distance to use the forge hook.
*/
@ModifyConstant(
method = "handleInteract",
constant = @Constant(doubleValue = 36.0D)
)
private double impl$getPlatformReach(final double thirtySix, final ServerboundInteractPacket p_147340_1_) {
return PlatformHooks.INSTANCE.getGeneralHooks().getEntityReachDistanceSq(this.player, p_147340_1_.getTarget(this.player.level));
}
// @ModifyConstant(
// method = "handleInteract",
// constant = @Constant(doubleValue = 36.0D)
// )
// private double impl$getPlatformReach(final double thirtySix, final ServerboundInteractPacket p_147340_1_) {
// return PlatformHooks.INSTANCE.getGeneralHooks().getEntityReachDistanceSq(this.player, p_147340_1_.getTarget(this.player.level));
// }
@Inject(method = "handleMovePlayer",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;isPassenger()Z"),
@@ -513,25 +488,14 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerGamePac
((ServerPlayerBridge) this.player).bridge$getWorldBorderListener().onPlayerDisconnect();
}
@Redirect(method = "handleSignUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;filterTextPacket(Ljava/util/List;Ljava/util/function/Consumer;)V"))
private void impl$switchToSignPhaseState(final ServerGamePacketListenerImpl serverPlayNetHandler, final List<String> p_244537_1_, final Consumer<List<String>> p_244537_2_) {
try (final BasicPacketContext context = PacketPhase.General.UPDATE_SIGN.createPhaseContext(PhaseTracker.getInstance())
.packetPlayer(this.player)
.buildAndSwitch()
) {
this.shadow$filterTextPacket(p_244537_1_, p_244537_2_);
}
}
@Redirect(method = "updateSignText", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/List;size()I"))
private int impl$callChangeSignEvent(final List<String> list, final ServerboundSignUpdatePacket p_244542_1_, final List<String> p_244542_2_) {
final SignBlockEntity blockEntity = (SignBlockEntity) this.player.level.getBlockEntity(p_244542_1_.getPos());
@Redirect(method = "handleSignUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ServerboundSignUpdatePacket;getLines()[Ljava/lang/String;"))
private String[] impl$callChangeSignEvent(final ServerboundSignUpdatePacket packet) {
final SignBlockEntity blockEntity = (SignBlockEntity) this.player.level.getBlockEntity(packet.getPos());
final ListValue<Component> originalLinesValue = ((Sign) blockEntity).getValue(Keys.SIGN_LINES)
.orElseGet(() -> new ImmutableSpongeListValue<>(Keys.SIGN_LINES, ImmutableList.of()));
final List<Component> newLines = new ArrayList<>();
for (final String line : list) {
for (final String line : packet.getLines()) {
// Sponge Start - While Vanilla does some strip formatting, it doesn't catch everything. This patches an exploit that allows color
// signs to be created.
newLines.add(Component.text(SharedConstants.filterText(line)));
@@ -547,17 +511,17 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerGamePac
((Sign) blockEntity).offer(toApply);
}
return 0;
return IMPL$ZERO_LENGTH_STRING_ARRAY;
}
@Redirect(method = "handleChat(Ljava/lang/String;)V",
@Redirect(method = "handleChat(Lnet/minecraft/network/protocol/game/ServerboundChatPacket;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/players/PlayerList;broadcastMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V") )
private void impl$postChatMessageEventAndSend(final PlayerList playerList, final net.minecraft.network.chat.Component component, final ChatType chatType, final UUID playerUUID, final String initialMessage) {
private void impl$postChatMessageEventAndSend(final PlayerList playerList, final net.minecraft.network.chat.Component component, final ChatType chatType, final UUID playerUUID, final ServerboundChatPacket packet) {
final ServerPlayer player = (ServerPlayer) this.player;
final PlayerChatFormatter chatFormatter = player.chatFormatter();
Component currentMessage = Component.text(initialMessage);
Component currentMessage = Component.text(packet.getMessage());
if (component instanceof TranslatableComponent && ((TranslatableComponent) component).getArgs().length == 2) {
if (((TranslatableComponent) component).getArgs()[1] instanceof net.minecraft.network.chat.Component) {
currentMessage = SpongeAdventure.asAdventure((net.minecraft.network.chat.Component) ((TranslatableComponent) component).getArgs()[1]);
@@ -79,7 +79,6 @@ public abstract class MobMixin extends LivingEntityMixin {
@Shadow @Nullable private LivingEntity target;
@Shadow @Nullable public abstract net.minecraft.world.entity.Entity shadow$getLeashHolder();
@Shadow protected abstract void shadow$registerGoals();
@Shadow protected abstract void shadow$maybeDisableShield(Player p_233655_1_, ItemStack p_233655_2_, ItemStack p_233655_3_);
// @formatter:on
@@ -217,7 +216,7 @@ public abstract class MobMixin extends LivingEntityMixin {
if (targetEntity instanceof LivingEntity) {
// Sponge Start - Gather modifiers
originalFunctions.addAll(DamageEventUtil
.createAttackEnchantmentFunction(this.shadow$getMainHandItem(), ((LivingEntity) targetEntity).getMobType(), 1.0F)); // 1.0F is for full attack strength since mobs don't have the concept
.createAttackEnchantmentFunction(this.shadow$getMainHandItem(), ((LivingEntity) targetEntity), 1.0F)); // 1.0F is for full attack strength since mobs don't have the concept
// baseDamage += EnchantmentHelper.getModifierForCreature(this.getHeldItem(), ((EntityLivingBase) targetEntity).getCreatureAttribute());
knockbackModifier += EnchantmentHelper.getKnockbackBonus((Mob) (Object) this);
}
@@ -253,7 +252,6 @@ public abstract class MobMixin extends LivingEntityMixin {
final Player playerentity = (Player) targetEntity;
final ItemStack mainHandItem = this.shadow$getMainHandItem();
final ItemStack useItem = playerentity.isUsingItem() ? playerentity.getUseItem() : ItemStack.EMPTY;
this.shadow$maybeDisableShield(playerentity, mainHandItem, useItem);
}
this.shadow$doEnchantDamageEffects((Mob) (Object) this, targetEntity);
@@ -36,7 +36,6 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.player.Player;
@@ -85,9 +84,7 @@ public abstract class PlayerMixin_Attack_Impl extends LivingEntityMixin {
//@formatter:off
@Shadow @Final public InventoryMenu inventoryMenu;
@Shadow public abstract float shadow$getAttackStrengthScale(float p_184825_1_);
@Shadow public abstract void shadow$resetAttackStrengthTicker();
@Shadow public abstract float shadow$getSpeed();
@Shadow public abstract void shadow$sweepAttack();
@Shadow public abstract void shadow$crit(Entity p_71009_1_);
@Shadow public abstract void shadow$magicCrit(Entity p_71047_1_);
@Shadow public abstract void shadow$awardStat(ResourceLocation stat, int amount);
@@ -151,11 +148,9 @@ public abstract class PlayerMixin_Attack_Impl extends LivingEntityMixin {
final List<DamageFunction> originalFunctions = new ArrayList<>();
final MobType creatureAttribute = targetEntity instanceof LivingEntity
? ((LivingEntity) targetEntity).getMobType()
: MobType.UNDEFINED;
if (!(targetEntity instanceof LivingEntity)) return;
final List<DamageFunction> enchantmentModifierFunctions = DamageEventUtil
.createAttackEnchantmentFunction(this.shadow$getMainHandItem(), creatureAttribute, attackStrength);
.createAttackEnchantmentFunction(this.shadow$getMainHandItem(), (LivingEntity) targetEntity, attackStrength);
// This is kept for the post-damage event handling
final List<DamageModifier> enchantmentModifiers = enchantmentModifierFunctions.stream()
.map(ModifierFunction::modifier)
@@ -172,7 +167,6 @@ public abstract class PlayerMixin_Attack_Impl extends LivingEntityMixin {
DamageEventUtil.provideCooldownAttackStrengthFunction((net.minecraft.world.entity.player.Player) (Object) this, attackStrength));
damage = damage * (0.2F + attackStrength * attackStrength * 0.8F);
enchantmentDamage = enchantmentDamage * attackStrength;
this.shadow$resetAttackStrengthTicker();
if (damage > 0.0F || enchantmentDamage > 0.0F) {
final boolean isStrongAttack = attackStrength > 0.9F;
@@ -320,7 +314,6 @@ public abstract class PlayerMixin_Attack_Impl extends LivingEntityMixin {
SoundEvents.PLAYER_ATTACK_SWEEP, this.shadow$getSoundSource(), 1.0F, 1.0F
);
}
this.shadow$sweepAttack();
}
if (targetEntity instanceof ServerPlayer && targetEntity.hurtMarked) {
@@ -41,7 +41,6 @@ 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.Surrogate;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import org.spongepowered.common.SpongeCommon;
@@ -81,13 +80,7 @@ public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityBri
}
@Inject(method = "cook", locals = LocalCapture.CAPTURE_FAILEXCEPTION, at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/Containers;dropItemStack(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V"))
private void impl$assembleCampfireResult(final CallbackInfo ci, final int i, final ItemStack itemStack, final int j,
final Container iInventory, final ItemStack itemStack1, final BlockPos blockPos) {
this.impl$assembleCampfireResult(ci, i, itemStack, iInventory, itemStack1, blockPos);
}
@Surrogate
target = "Lnet/minecraft/world/Containers;dropItemStack(Lnet/minecraft/world/level/Level;DDD Lnet/minecraft/world/item/ItemStack;)V"))
private void impl$assembleCampfireResult(final CallbackInfo ci, final int i, final ItemStack itemStack,
final Container iInventory, final ItemStack itemStack1, final BlockPos blockPos) {
final Cause cause = PhaseTracker.getCauseStackManager().currentCause();
+2 -2
View File
@@ -2,7 +2,7 @@ import org.jetbrains.gradle.ext.TaskTriggersConfig
import org.spongepowered.gradle.impl.GenerateResourceTemplates
plugins {
id("org.spongepowered.gradle.vanilla")
id("nl.skbotnl.sponge.gradle.vanilla")
id("com.github.johnrengelman.shadow")
id("implementation-structure")
id("templated-resources")
@@ -170,7 +170,7 @@ minecraft {
.firstOrNull()
// The mixin agent initializes logging too early, which prevents jansi from properly stripping escape codes in Eclipse.
val base = if (!org.spongepowered.gradle.vanilla.internal.util.IdeConfigurer.isEclipseImport() && mixinJar != null) {
val base = if (!nl.skbotnl.sponge.gradle.vanilla.internal.util.IdeConfigurer.isEclipseImport() && mixinJar != null) {
listOf("-javaagent:$mixinJar")
} else {
emptyList()
@@ -25,30 +25,23 @@
package org.spongepowered.vanilla.installer;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import net.minecraftforge.fart.api.Renamer;
import net.minecraftforge.fart.api.SignatureStripperConfig;
import net.minecraftforge.fart.api.SourceFixerConfig;
import net.minecraftforge.fart.api.Transformer;
import net.minecraftforge.srgutils.IMappingFile;
import org.spongepowered.vanilla.installer.model.mojang.Version;
import org.spongepowered.vanilla.installer.model.mojang.VersionManifest;
import org.tinylog.Logger;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.AccessDeniedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -166,30 +159,13 @@ public final class InstallerMain {
private Version downloadMinecraftManifest() throws IOException {
Logger.info("Downloading the Minecraft versions manifest...");
VersionManifest.Version foundVersionManifest = null;
final Gson gson = new Gson();
final URLConnection conn = new URL(Constants.Libraries.MINECRAFT_MANIFEST_URL)
.openConnection();
conn.setConnectTimeout(5 /* seconds */ * 1000);
try (final JsonReader reader = new JsonReader(new InputStreamReader(conn.getInputStream()))) {
final VersionManifest manifest = gson.fromJson(reader, VersionManifest.class);
for (final VersionManifest.Version version : manifest.versions) {
if (Constants.Libraries.MINECRAFT_VERSION_TARGET.equals(version.id)) {
foundVersionManifest = version;
break;
}
}
}
if (foundVersionManifest == null) {
throw new IOException(String.format("Failed to find version manifest for '%s'!", Constants.Libraries.MINECRAFT_VERSION_TARGET));
}
final Version version;
try (final JsonReader reader = new JsonReader(new InputStreamReader(foundVersionManifest.url.openStream()))) {
try (InputStreamReader reader = new InputStreamReader(
Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("1_16_combat-6.json")))) {
version = gson.fromJson(reader, Version.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (version == null) {
@@ -0,0 +1 @@
{"arguments": {"game": ["--username", "${auth_player_name}", "--version", "${version_name}", "--gameDir", "${game_directory}", "--assetsDir", "${assets_root}", "--assetIndex", "${assets_index_name}", "--uuid", "${auth_uuid}", "--accessToken", "${auth_access_token}", "--userType", "${user_type}", "--versionType", "${version_type}", {"rules": [{"action": "allow", "features": {"is_demo_user": true}}], "value": "--demo"}, {"rules": [{"action": "allow", "features": {"has_custom_resolution": true}}], "value": ["--width", "${resolution_width}", "--height", "${resolution_height}"]}], "jvm": [{"rules": [{"action": "allow", "os": {"name": "osx"}}], "value": ["-XstartOnFirstThread"]}, {"rules": [{"action": "allow", "os": {"name": "windows"}}], "value": "-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"}, {"rules": [{"action": "allow", "os": {"name": "windows", "version": "^10\\."}}], "value": ["-Dos.name=Windows 10", "-Dos.version=10.0"]}, {"rules": [{"action": "allow", "os": {"arch": "x86"}}], "value": "-Xss1M"}, "-Djava.library.path=${natives_directory}", "-Dminecraft.launcher.brand=${launcher_name}", "-Dminecraft.launcher.version=${launcher_version}", "-cp", "${classpath}"]}, "assetIndex": {"id": "1.16", "sha1": "bdb68de96a44ec1e9ed6d9cfcd2ee973be618c3a", "size": 295417, "totalSize": 329202599, "url": "https://launchermeta.mojang.com/v1/packages/bdb68de96a44ec1e9ed6d9cfcd2ee973be618c3a/1.16.json"}, "assets": "1.16", "downloads": {"client": {"sha1": "177472ace3ff5d98fbd63b4bcd5bbef5b035a018", "size": 17523426, "url": "https://launcher.mojang.com/v1/objects/177472ace3ff5d98fbd63b4bcd5bbef5b035a018/client.jar"}, "client_mappings": {"sha1": "5ea38a7b8d58837c97214f2a46e5e12151d51f83", "size": 5729201, "url": "https://launcher.mojang.com/v1/objects/5ea38a7b8d58837c97214f2a46e5e12151d51f83/client.txt"}, "server": {"sha1": "b707c44ac1503ad179fde86c78d41aa4d0cc78a5", "size": 37945325, "url": "https://launcher.mojang.com/v1/objects/b707c44ac1503ad179fde86c78d41aa4d0cc78a5/server.jar"}, "server_mappings": {"sha1": "d89f9e0eb8fbe6f2c91e749e8b59391cd0dd96d4", "size": 4397606, "url": "https://launcher.mojang.com/v1/objects/d89f9e0eb8fbe6f2c91e749e8b59391cd0dd96d4/server.txt"}}, "id": "1.16_combat-6", "libraries": [{"downloads": {"artifact": {"path": "com/mojang/patchy/1.1/patchy-1.1.jar", "sha1": "aef610b34a1be37fa851825f12372b78424d8903", "size": 15817, "url": "https://libraries.minecraft.net/com/mojang/patchy/1.1/patchy-1.1.jar"}}, "name": "com.mojang:patchy:1.1"}, {"downloads": {"artifact": {"path": "oshi-project/oshi-core/1.1/oshi-core-1.1.jar", "sha1": "9ddf7b048a8d701be231c0f4f95fd986198fd2d8", "size": 30973, "url": "https://libraries.minecraft.net/oshi-project/oshi-core/1.1/oshi-core-1.1.jar"}}, "name": "oshi-project:oshi-core:1.1"}, {"downloads": {"artifact": {"path": "net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar", "sha1": "cb208278274bf12ebdb56c61bd7407e6f774d65a", "size": 1091208, "url": "https://libraries.minecraft.net/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar"}}, "name": "net.java.dev.jna:jna:4.4.0"}, {"downloads": {"artifact": {"path": "net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar", "sha1": "e3f70017be8100d3d6923f50b3d2ee17714e9c13", "size": 913436, "url": "https://libraries.minecraft.net/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar"}}, "name": "net.java.dev.jna:platform:3.4.0"}, {"downloads": {"artifact": {"path": "com/ibm/icu/icu4j/66.1/icu4j-66.1.jar", "sha1": "72c7519b6d91f7a1f993bd44a99fe95d67211b27", "size": 12935630, "url": "https://libraries.minecraft.net/com/ibm/icu/icu4j/66.1/icu4j-66.1.jar"}}, "name": "com.ibm.icu:icu4j:66.1"}, {"downloads": {"artifact": {"path": "com/mojang/javabridge/1.0.22/javabridge-1.0.22.jar", "sha1": "6aa6453aa99a52a5cd91749da1af6ab70e082ab3", "size": 5111, "url": "https://libraries.minecraft.net/com/mojang/javabridge/1.0.22/javabridge-1.0.22.jar"}}, "name": "com.mojang:javabridge:1.0.22"}, {"downloads": {"artifact": {"path": "net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar", "sha1": "cdd846cfc4e0f7eefafc02c0f5dce32b9303aa2a", "size": 78175, "url": "https://libraries.minecraft.net/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar"}}, "name": "net.sf.jopt-simple:jopt-simple:5.0.3"}, {"downloads": {"artifact": {"path": "io/netty/netty-all/4.1.25.Final/netty-all-4.1.25.Final.jar", "sha1": "d0626cd3108294d1d58c05859add27b4ef21f83b", "size": 3823147, "url": "https://libraries.minecraft.net/io/netty/netty-all/4.1.25.Final/netty-all-4.1.25.Final.jar"}}, "name": "io.netty:netty-all:4.1.25.Final"}, {"downloads": {"artifact": {"path": "com/google/guava/guava/21.0/guava-21.0.jar", "sha1": "3a3d111be1be1b745edfa7d91678a12d7ed38709", "size": 2521113, "url": "https://libraries.minecraft.net/com/google/guava/guava/21.0/guava-21.0.jar"}}, "name": "com.google.guava:guava:21.0"}, {"downloads": {"artifact": {"path": "org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar", "sha1": "6c6c702c89bfff3cd9e80b04d668c5e190d588c6", "sizeLine truncated
@@ -26,6 +26,7 @@ package org.spongepowered.vanilla.mixin.core.server.network;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.protocol.game.ServerGamePacketListener;
import net.minecraft.network.protocol.game.ServerboundChatPacket;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
@@ -71,17 +72,17 @@ public abstract class ServerGamePacketListenerImplMixin_Vanilla implements Serve
this.server.execute(() -> channelRegistry.handlePlayPayload((EngineConnection) this, packet));
}
@Inject(method = "handleChat(Ljava/lang/String;)V",
@Inject(method = "handleChat(Lnet/minecraft/network/protocol/game/ServerboundChatPacket;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/players/PlayerList;broadcastMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V"),
locals = LocalCapture.CAPTURE_FAILHARD)
private void vanilla$onProcessChatMessage(final String var1, final CallbackInfo ci, final net.minecraft.network.chat.Component component) {
private void vanilla$onProcessChatMessage(final ServerboundChatPacket param0, final CallbackInfo ci, final String var0, final net.minecraft.network.chat.Component component) {
ChatFormatter.formatChatComponent((TranslatableComponent) component);
}
@SuppressWarnings({"unchecked", "rawtypes"})
@Redirect(method = "lambda$handlePlaceRecipe$10",
@Redirect(method = "lambda$handlePlaceRecipe$5",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/RecipeBookMenu;handlePlacement(ZLnet/minecraft/world/item/crafting/Recipe;Lnet/minecraft/server/level/ServerPlayer;)V"))
private void vanilla$onPlaceRecipe(final RecipeBookMenu recipeBookMenu, final boolean shift, final Recipe<?> recipe, final net.minecraft.server.level.ServerPlayer player) {
final PhaseContext<@NonNull ?> context = PhaseTracker.SERVER.getPhaseContext();