1.16: loots and more

This commit is contained in:
IzzelAliz 2020-08-26 18:02:44 +08:00
parent d18632c55c
commit ca23b4b854
21 changed files with 348 additions and 248 deletions

View File

@ -0,0 +1,13 @@
package io.izzel.arclight.common.bridge.util.text;
import net.minecraft.util.text.ITextComponent;
import java.util.Iterator;
import java.util.stream.Stream;
public interface ITextComponentBridge {
Stream<ITextComponent> bridge$stream();
Iterator<ITextComponent> bridge$iterator();
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.bridge.world.storage.loot;
import net.minecraft.inventory.IInventory;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.loot.LootContext;
public interface LootTableBridge {

View File

@ -3,7 +3,7 @@ package io.izzel.arclight.common.mixin.core.fluid;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.FlowingFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState;
import net.minecraft.fluid.FluidState;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
@ -28,11 +28,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public abstract class FlowingFluidMixin {
// @formatter:off
@Shadow protected abstract boolean canFlow(IBlockReader worldIn, BlockPos fromPos, BlockState fromBlockState, Direction direction, BlockPos toPos, BlockState toBlockState, IFluidState toFluidState, Fluid fluidIn);
@Shadow protected abstract boolean canFlow(IBlockReader worldIn, BlockPos fromPos, BlockState fromBlockState, Direction direction, BlockPos toPos, BlockState toBlockState, FluidState toFluidState, Fluid fluidIn);
// @formatter:on
@Inject(method = "flowAround", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FlowingFluid;flowInto(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/Direction;Lnet/minecraft/fluid/IFluidState;)V"))
public void arclight$flowInto(IWorld worldIn, BlockPos pos, IFluidState stateIn, CallbackInfo ci) {
@Inject(method = "flowAround", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FlowingFluid;flowInto(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/Direction;Lnet/minecraft/fluid/FluidState;)V"))
public void arclight$flowInto(IWorld worldIn, BlockPos pos, FluidState stateIn, CallbackInfo ci) {
Block source = CraftBlock.at(worldIn, pos);
BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
Bukkit.getPluginManager().callEvent(event);
@ -41,8 +41,8 @@ public abstract class FlowingFluidMixin {
}
}
@Redirect(method = "func_207937_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FlowingFluid;canFlow(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/Direction;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/fluid/IFluidState;Lnet/minecraft/fluid/Fluid;)Z"))
public boolean arclight$flowInto(FlowingFluid flowingFluid, IBlockReader worldIn, BlockPos fromPos, BlockState fromBlockState, Direction direction, BlockPos toPos, BlockState toBlockState, IFluidState toFluidState, Fluid fluidIn) {
@Redirect(method = "func_207937_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FlowingFluid;canFlow(Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/Direction;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/fluid/FluidState;Lnet/minecraft/fluid/Fluid;)Z"))
public boolean arclight$flowInto(FlowingFluid flowingFluid, IBlockReader worldIn, BlockPos fromPos, BlockState fromBlockState, Direction direction, BlockPos toPos, BlockState toBlockState, FluidState toFluidState, Fluid fluidIn) {
if (this.canFlow(worldIn, fromPos, fromBlockState, direction, toPos, toBlockState, toFluidState, fluidIn)) {
Block source = CraftBlock.at(((World) worldIn), fromPos);
BlockFromToEvent event = new BlockFromToEvent(source, CraftBlock.notchToBlockFace(direction));

View File

@ -1,10 +1,11 @@
package io.izzel.arclight.common.mixin.core.fluid;
import io.izzel.arclight.common.bridge.world.IWorldBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.fluid.IFluidState;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.LavaFluid;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.IWorld;
@ -16,8 +17,6 @@ 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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@ -35,7 +34,7 @@ public abstract class LavaFluidMixin {
* @reason
*/
@Overwrite
public void randomTick(World world, BlockPos pos, IFluidState state, Random random) {
public void randomTick(World world, BlockPos pos, FluidState state, Random random) {
if (world.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) {
int i = random.nextInt(3);
if (i > 0) {
@ -84,15 +83,13 @@ public abstract class LavaFluidMixin {
}
}
@Inject(method = "flowInto", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/IWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$returnIfFail(IWorld worldIn, BlockPos pos, BlockState blockStateIn, Direction direction, IFluidState fluidStateIn, CallbackInfo ci) {
if (!arclight$success) ci.cancel();
}
private transient boolean arclight$success;
@Redirect(method = "flowInto", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean arclight$blockFromTo(IWorld iWorld, BlockPos pos, BlockState newState, int flags) {
return arclight$success = CraftEventFactory.handleBlockFormEvent(iWorld.getWorld(), pos, newState, flags);
@Eject(method = "flowInto", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean arclight$blockFromTo(IWorld world, BlockPos pos, BlockState newState, int flags, CallbackInfo ci) {
if (!CraftEventFactory.handleBlockFormEvent(((IWorldBridge) world).bridge$getMinecraftWorld(), pos, newState, flags)) {
ci.cancel();
return false;
} else {
return true;
}
}
}

View File

@ -0,0 +1,25 @@
package io.izzel.arclight.common.mixin.core.loot;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import net.minecraft.loot.LootEntry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(LootEntry.Serializer.class)
public abstract class LootEntry_SerializerMixin<T extends LootEntry> {
// @formatter:off
@Shadow public abstract void func_230424_a_(JsonObject p_230424_1_, T p_230424_2_, JsonSerializationContext p_230424_3_);
@Shadow public abstract T func_230423_a_(JsonObject p_230423_1_, JsonDeserializationContext p_230423_2_);
// @formatter:on
public final void a(JsonObject object, T t0, JsonSerializationContext context) {
this.func_230424_a_(object, t0, context);
}
public final T a(JsonObject object, JsonDeserializationContext context) {
return this.func_230423_a_(object, context);
}
}

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.mixin.core.world.storage.loot;
package io.izzel.arclight.common.mixin.core.loot;
import io.izzel.arclight.common.mod.ArclightConstants;
import net.minecraft.world.storage.loot.LootParameter;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraft.loot.LootParameter;
import net.minecraft.loot.LootParameters;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(LootParameters.class)

View File

@ -1,12 +1,12 @@
package io.izzel.arclight.common.mixin.core.world.storage.loot;
package io.izzel.arclight.common.mixin.core.loot;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonObject;
import net.minecraft.profiler.IProfiler;
import net.minecraft.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraft.world.storage.loot.LootTableManager;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTableManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -1,10 +1,11 @@
package io.izzel.arclight.common.mixin.core.world.storage.loot;
package io.izzel.arclight.common.mixin.core.loot;
import io.izzel.arclight.common.bridge.world.storage.loot.LootTableBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootTable;
import org.apache.logging.log4j.Logger;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
@ -12,6 +13,8 @@ import org.bukkit.event.world.LootGenerateEvent;
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.callback.CallbackInfo;
import java.util.List;
import java.util.Random;
@ -27,6 +30,18 @@ public abstract class LootTableMixin implements LootTableBridge {
@Shadow protected abstract void shuffleItems(List<ItemStack> stacks, int p_186463_2_, Random rand);
// @formatter:on
@Eject(method = "fillInventory", at = @At(value = "INVOKE", target = "Lnet/minecraft/loot/LootTable;generate(Lnet/minecraft/loot/LootContext;)Ljava/util/List;"))
private List<ItemStack> arclight$nonPluginEvent(LootTable lootTable, LootContext context, CallbackInfo ci, IInventory inv) {
List<ItemStack> list = lootTable.generate(context);
LootGenerateEvent event = CraftEventFactory.callLootGenerateEvent(inv, (LootTable) (Object) this, context, list, false);
if (event.isCancelled()) {
ci.cancel();
return null;
} else {
return event.getLoot().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList());
}
}
public void fillInventory(IInventory inv, LootContext context, boolean plugin) {
List<ItemStack> list = this.generate(context);
Random random = context.getRandom();

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.mixin.core.world.storage.loot.conditions;
package io.izzel.arclight.common.mixin.core.loot.conditions;
import io.izzel.arclight.common.mod.ArclightConstants;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.conditions.RandomChanceWithLooting;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.conditions.RandomChanceWithLooting;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.mixin.core.world.storage.loot.conditions;
package io.izzel.arclight.common.mixin.core.loot.conditions;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraft.world.storage.loot.conditions.SurvivesExplosion;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.loot.conditions.SurvivesExplosion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

View File

@ -1,12 +1,12 @@
package io.izzel.arclight.common.mixin.core.world.storage.loot.functions;
package io.izzel.arclight.common.mixin.core.loot.functions;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraft.world.storage.loot.RandomValueRange;
import net.minecraft.world.storage.loot.functions.LootingEnchantBonus;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.loot.RandomValueRange;
import net.minecraft.loot.functions.LootingEnchantBonus;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

View File

@ -14,6 +14,7 @@ import net.minecraft.network.login.server.SDisconnectLoginPacket;
import net.minecraft.network.status.ServerStatusNetHandler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.SharedConstants;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.apache.logging.log4j.LogManager;
@ -36,8 +37,11 @@ public class ServerHandshakeNetHandlerMixin {
private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<>();
private static int throttleCounter = 0;
// @formatter:off
@Shadow @Final private NetworkManager networkManager;
@Shadow @Final private MinecraftServer server;
@Shadow @Final private static ITextComponent field_241169_a_;
// @formatter:on
/**
* @author IzzelAliz
@ -112,8 +116,12 @@ public class ServerHandshakeNetHandlerMixin {
break;
}
case STATUS: {
this.networkManager.setConnectionState(ProtocolType.STATUS);
this.networkManager.setNetHandler(new ServerStatusNetHandler(this.server, this.networkManager));
if (this.server.func_230541_aj_()) {
this.networkManager.setConnectionState(ProtocolType.STATUS);
this.networkManager.setNetHandler(new ServerStatusNetHandler(this.server, this.networkManager));
} else {
this.networkManager.closeChannel(field_241169_a_);
}
break;
}
default: {

View File

@ -0,0 +1,21 @@
package io.izzel.arclight.common.mixin.core.server;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.resources.ResourcePackList;
import net.minecraft.server.Main;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.datafix.codec.DatapackCodec;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Main.class)
public class MainMixin {
@Redirect(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;func_240772_a_(Lnet/minecraft/resources/ResourcePackList;Lnet/minecraft/util/datafix/codec/DatapackCodec;Z)Lnet/minecraft/util/datafix/codec/DatapackCodec;"))
private static DatapackCodec arclight$captureDatapackCodec(ResourcePackList p_240772_0_, DatapackCodec p_240772_1_, boolean p_240772_2_) {
DatapackCodec datapackCodec = MinecraftServer.func_240772_a_(p_240772_0_, p_240772_1_, p_240772_2_);
ArclightCaptures.captureDatapackConfig(datapackCodec);
return datapackCodec;
}
}

View File

@ -1,17 +1,14 @@
package io.izzel.arclight.common.mixin.core.server;
import com.google.common.io.Files;
import com.google.gson.JsonElement;
import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.datafixers.DataFixer;
import io.izzel.arclight.common.bridge.command.ICommandSourceBridge;
import io.izzel.arclight.common.bridge.server.MinecraftServerBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import io.izzel.arclight.common.mod.ArclightConstants;
import io.izzel.arclight.common.mod.server.BukkitRegistry;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import io.izzel.arclight.common.mod.util.BukkitOptionParser;
import it.unimi.dsi.fastutil.longs.LongIterator;
import joptsimple.OptionParser;
@ -21,31 +18,37 @@ import net.minecraft.command.Commands;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.ReportedException;
import net.minecraft.network.ServerStatusResponse;
import net.minecraft.profiler.DebugProfiler;
import net.minecraft.profiler.IProfiler;
import net.minecraft.profiler.LongTickDetector;
import net.minecraft.resources.DataPackRegistries;
import net.minecraft.resources.ResourcePackList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerProfileCache;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.SharedConstants;
import net.minecraft.util.Unit;
import net.minecraft.util.Util;
import net.minecraft.util.concurrent.RecursiveEventLoop;
import net.minecraft.util.concurrent.TickDelayedTask;
import net.minecraft.util.datafix.codec.DatapackCodec;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.registry.DynamicRegistries;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.ForcedChunksSaveData;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldType;
import net.minecraft.world.World;
import net.minecraft.world.border.WorldBorder;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.chunk.listener.IChunkStatusListenerFactory;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.server.TicketType;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.fml.StartupQuery;
import net.minecraft.world.storage.IServerConfiguration;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraft.world.storage.SaveFormat;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.BrandingControl;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
@ -58,6 +61,7 @@ import org.bukkit.event.server.ServerLoadEvent;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.plugin.PluginLoadOrder;
import org.spigotmc.WatchdogThread;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -67,14 +71,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.net.Proxy;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
@ -90,12 +92,11 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
@Shadow protected long serverTime;
@Shadow @Final private ServerStatusResponse statusResponse;
@Shadow @Nullable private String motd;
@Shadow public abstract void applyServerIconToResponse(ServerStatusResponse response);
@Shadow protected abstract void applyServerIconToResponse(ServerStatusResponse response);
@Shadow private volatile boolean serverRunning;
@Shadow private long timeOfLastWarning;
@Shadow @Final private static Logger LOGGER;
@Shadow private boolean startProfiling;
@Shadow @Final private DebugProfiler profiler;
@Shadow protected abstract void tick(BooleanSupplier hasTimeLeft);
@Shadow protected abstract boolean isAheadOfTime();
@Shadow private boolean isRunningScheduledTasks;
@ -109,15 +110,22 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
@Shadow protected abstract void stopServer();
@Shadow protected abstract void systemExitNow();
@Shadow public abstract Commands getCommandManager();
@Shadow protected abstract void applyDebugWorldInfo(WorldInfo worldInfoIn);
@Shadow protected abstract void setUserMessage(ITextComponent userMessageIn);
@Shadow public abstract ServerWorld getWorld(DimensionType dimension);
@Shadow protected abstract void func_240773_a_(@org.jetbrains.annotations.Nullable LongTickDetector p_240773_1_);
@Shadow private IProfiler profiler;
@Shadow protected abstract void func_240795_b_(@org.jetbrains.annotations.Nullable LongTickDetector p_240795_1_);
@Shadow protected abstract void func_240794_aZ_();
@Shadow public abstract ServerWorld func_241755_D_();
@Shadow @Final public Map<RegistryKey<World>, ServerWorld> worlds;
@Shadow protected abstract void func_240778_a_(IServerConfiguration p_240778_1_);
@Shadow protected IServerConfiguration field_240768_i_;
@Shadow private static void func_240786_a_(ServerWorld p_240786_0_, IServerWorldInfo p_240786_1_, boolean hasBonusChest, boolean p_240786_3_, boolean p_240786_4_) { }
// @formatter:on
public MinecraftServerMixin(String name) {
super(name);
}
public DatapackCodec datapackconfiguration;
private boolean forceTicks;
public CraftServer server;
public OptionSet options;
@ -125,7 +133,6 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
public RemoteConsoleCommandSender remoteConsole;
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<>();
public int autosavePeriod;
public File bukkitDataPackFolder;
private boolean hasStopped = false;
private final Object stopLock = new Object();
@ -147,7 +154,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
}
@Inject(method = "<init>", at = @At("RETURN"))
public void arclight$loadOptions(File file, Proxy proxy, DataFixer dataFixerIn, Commands commands, YggdrasilAuthenticationService authenticationService, MinecraftSessionService sessionService, GameProfileRepository profileRepository, PlayerProfileCache playerProfileCache, IChunkStatusListenerFactory listenerFactory, String string, CallbackInfo ci) {
public void arclight$loadOptions(Thread p_i232576_1_, DynamicRegistries.Impl p_i232576_2_, SaveFormat.LevelSave p_i232576_3_, IServerConfiguration p_i232576_4_, ResourcePackList p_i232576_5_, Proxy p_i232576_6_, DataFixer p_i232576_7_, DataPackRegistries p_i232576_8_, MinecraftSessionService p_i232576_9_, GameProfileRepository p_i232576_10_, PlayerProfileCache p_i232576_11_, IChunkStatusListenerFactory p_i232576_12_, CallbackInfo ci) {
String[] arguments = ManagementFactory.getRuntimeMXBean().getInputArguments().toArray(new String[0]);
OptionParser parser = new BukkitOptionParser();
try {
@ -155,6 +162,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
} catch (Exception e) {
e.printStackTrace();
}
this.datapackconfiguration = ArclightCaptures.getDatapackConfig();
}
/**
@ -162,7 +170,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
* @reason
*/
@Overwrite
public void run() {
protected void func_240802_v_() {
try {
if (this.init()) {
ServerLifecycleHooks.handleServerStarted((MinecraftServer) (Object) this);
@ -198,11 +206,8 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
currentTick = (int) (System.currentTimeMillis() / 50);
this.serverTime += 50L;
if (this.startProfiling) {
this.startProfiling = false;
this.profiler.getFixedProfiler().enable();
}
LongTickDetector longtickdetector = LongTickDetector.func_233524_a_("Server");
this.func_240773_a_(longtickdetector);
this.profiler.startTick();
this.profiler.startSection("tick");
this.tick(this::isAheadOfTime);
@ -212,6 +217,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
this.runScheduledTasks();
this.profiler.endSection();
this.profiler.endTick();
this.func_240795_b_(longtickdetector);
this.serverIsRunning = true;
}
ServerLifecycleHooks.handleServerStopping((MinecraftServer) (Object) this);
@ -220,11 +226,13 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions
this.finalTick(null);
}
} catch (StartupQuery.AbortedException e) {
// ignore silently
ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions
} catch (Throwable throwable1) {
LOGGER.error("Encountered an unexpected exception", throwable1);
if (throwable1.getCause() != null) {
LOGGER.error("\tCause of unexpected exception was", throwable1.getCause());
}
CrashReport crashreport;
if (throwable1 instanceof ReportedException) {
crashreport = this.addServerInfoToCrashReport(((ReportedException) throwable1).getCrashReport());
@ -248,6 +256,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
} catch (Throwable throwable) {
LOGGER.error("Exception stopping the server", throwable);
} finally {
WatchdogThread.doStop();
ServerLifecycleHooks.handleServerStopped((MinecraftServer) (Object) this);
this.systemExitNow();
}
@ -276,73 +285,14 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
}
}
@Inject(method = "loadAllWorlds", at = @At("RETURN"))
public void arclight$enablePlugins(String saveName, String worldNameIn, long seed, WorldType type, JsonElement generatorOptions, CallbackInfo ci) {
@Inject(method = "func_240787_a_", at = @At("RETURN"))
public void arclight$enablePlugins(IChunkStatusListener p_240787_1_, CallbackInfo ci) {
BukkitRegistry.unlockRegistries();
this.server.enablePlugins(PluginLoadOrder.POSTWORLD);
BukkitRegistry.lockRegistries();
this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
}
public void initWorld(ServerWorld serverWorld, WorldInfo worldInfo, WorldSettings worldSettings) {
serverWorld.getWorldBorder().copyFrom(worldInfo);
if (((WorldBridge) serverWorld).bridge$getGenerator() != null) {
((WorldBridge) serverWorld).bridge$getWorld().getPopulators().addAll(
((WorldBridge) serverWorld).bridge$getGenerator().getDefaultPopulators(
((WorldBridge) serverWorld).bridge$getWorld()));
}
if (!worldInfo.isInitialized()) {
try {
serverWorld.createSpawnPosition(worldSettings);
if (worldInfo.getGenerator() == WorldType.DEBUG_ALL_BLOCK_STATES) {
this.applyDebugWorldInfo(worldInfo);
}
worldInfo.setInitialized(true);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception initializing level");
try {
serverWorld.fillCrashReport(crashreport);
} catch (Throwable ignored) {}
throw new ReportedException(crashreport);
}
worldInfo.setInitialized(true);
}
}
public void loadSpawn(IChunkStatusListener listener, ServerWorld serverWorld) {
if (!((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
return;
}
this.setUserMessage(new TranslationTextComponent("menu.generatingTerrain"));
this.forceTicks = true;
LOGGER.info("Preparing start region for dimension '{}'/{}", serverWorld.getWorldInfo().getWorldName(), DimensionType.getKey(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType()));
BlockPos pos = serverWorld.getSpawnPoint();
listener.start(new ChunkPos(pos));
ServerChunkProvider chunkProvider = serverWorld.getChunkProvider();
chunkProvider.getLightManager().func_215598_a(500);
this.serverTime = Util.milliTime();
chunkProvider.registerTicket(TicketType.START, new ChunkPos(pos), 11, Unit.INSTANCE);
while (chunkProvider.getLoadedChunksCount() != 441) {
this.executeModerately();
}
this.executeModerately();
DimensionType type = serverWorld.dimension.getType();
ForcedChunksSaveData chunks = serverWorld.getSavedData().get(ForcedChunksSaveData::new, "chunks");
if (chunks != null) {
ServerWorld world = this.getWorld(type);
LongIterator iterator = chunks.getChunks().iterator();
while (iterator.hasNext()) {
long i = iterator.nextLong();
ChunkPos chunkPos = new ChunkPos(i);
world.getChunkProvider().forceChunk(chunkPos, true);
}
}
this.executeModerately();
listener.stop();
chunkProvider.getLightManager().func_215598_a(5);
this.forceTicks = false;
}
private void executeModerately() {
this.drainTasks();
java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
@ -353,22 +303,18 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
if (this.forceTicks) cir.setReturnValue(true);
}
@Inject(method = "loadWorlds", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraftforge/common/DimensionManager;fireRegister()V", remap = false))
private void arclight$registerEnv(SaveHandler saveHandlerIn, WorldInfo info, WorldSettings worldSettingsIn, IChunkStatusListener chunkStatusListenerIn, CallbackInfo ci) {
@Inject(method = "func_240787_a_", at = @At("HEAD"))
private void arclight$registerEnv(IChunkStatusListener p_240787_1_, CallbackInfo ci) {
BukkitRegistry.registerEnvironments();
}
@Inject(method = "loadWorlds", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/server/MinecraftServer;func_213204_a(Lnet/minecraft/world/storage/DimensionSavedDataManager;)V"))
private void arclight$worldInit(SaveHandler p_213194_1_, WorldInfo info, WorldSettings p_213194_3_, IChunkStatusListener p_213194_4_, CallbackInfo ci, ServerWorld serverWorld) {
if (((CraftServer) Bukkit.getServer()).scoreboardManager == null) {
((CraftServer) Bukkit.getServer()).scoreboardManager = new CraftScoreboardManager((MinecraftServer) (Object) this, serverWorld.getScoreboard());
}
}
@Redirect(method = "loadWorlds", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
@Redirect(method = "func_240787_a_", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
private Object arclight$worldInit(Map<Object, Object> map, Object key, Object value) {
Object ret = map.put(key, value);
ServerWorld serverWorld = (ServerWorld) value;
if (((CraftServer) Bukkit.getServer()).scoreboardManager == null) {
((CraftServer) Bukkit.getServer()).scoreboardManager = new CraftScoreboardManager((MinecraftServer) (Object) this, serverWorld.getScoreboard());
}
if (((WorldBridge) serverWorld).bridge$getGenerator() != null) {
((WorldBridge) serverWorld).bridge$getWorld().getPopulators().addAll(
((WorldBridge) serverWorld).bridge$getGenerator().getDefaultPopulators(
@ -384,10 +330,9 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
*/
@Overwrite
public void loadInitialChunks(IChunkStatusListener listener) {
this.setUserMessage(new TranslationTextComponent("menu.generatingTerrain"));
ServerWorld serverworld = this.getWorld(DimensionType.OVERWORLD);
ServerWorld serverworld = this.func_241755_D_();
this.forceTicks = true;
LOGGER.info("Preparing start region for dimension " + DimensionType.getKey(serverworld.dimension.getType()));
LOGGER.info("Preparing start region for dimension {}", serverworld.getDimensionKey().func_240901_a_());
BlockPos blockpos = serverworld.getSpawnPoint();
listener.start(new ChunkPos(blockpos));
ServerChunkProvider serverchunkprovider = serverworld.getChunkProvider();
@ -401,8 +346,7 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
this.executeModerately();
for (DimensionType dimensiontype : DimensionType.getAll()) {
ServerWorld serverWorld = this.getWorld(dimensiontype);
for (ServerWorld serverWorld : this.worlds.values()) {
if (((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
ForcedChunksSaveData forcedchunkssavedata = serverWorld.getSavedData().get(ForcedChunksSaveData::new, "chunks");
if (forcedchunkssavedata != null) {
@ -421,6 +365,74 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
this.executeModerately();
listener.stop();
serverchunkprovider.getLightManager().func_215598_a(5);
this.func_240794_aZ_();
this.forceTicks = false;
}
// bukkit methods
public void initWorld(ServerWorld serverWorld, IServerWorldInfo worldInfo, IServerConfiguration saveData, DimensionGeneratorSettings generatorSettings) {
boolean flag = generatorSettings.func_236227_h_();
if (((WorldBridge) serverWorld).bridge$getGenerator() != null) {
((WorldBridge) serverWorld).bridge$getWorld().getPopulators().addAll(
((WorldBridge) serverWorld).bridge$getGenerator().getDefaultPopulators(
((WorldBridge) serverWorld).bridge$getWorld()));
}
WorldBorder worldborder = serverWorld.getWorldBorder();
worldborder.deserialize(worldInfo.getWorldBorderSerializer());
if (!worldInfo.isInitialized()) {
try {
func_240786_a_(serverWorld, worldInfo, generatorSettings.hasBonusChest(), flag, true);
worldInfo.setInitialized(true);
if (flag) {
this.func_240778_a_(this.field_240768_i_);
}
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception initializing level");
try {
serverWorld.fillCrashReport(crashreport);
} catch (Throwable throwable2) {
// empty catch block
}
throw new ReportedException(crashreport);
}
worldInfo.setInitialized(true);
}
}
// bukkit methods
public void loadSpawn(IChunkStatusListener listener, ServerWorld serverWorld) {
MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(serverWorld));
if (!((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
return;
}
LOGGER.info("Preparing start region for dimension {}", serverWorld.getDimensionKey().func_240901_a_());
BlockPos blockpos = serverWorld.getSpawnPoint();
listener.start(new ChunkPos(blockpos));
ServerChunkProvider serverchunkprovider = serverWorld.getChunkProvider();
serverchunkprovider.getLightManager().func_215598_a(500);
this.serverTime = Util.milliTime();
serverchunkprovider.registerTicket(TicketType.START, new ChunkPos(blockpos), 11, Unit.INSTANCE);
while (serverchunkprovider.getLoadedChunksCount() != 441) {
this.executeModerately();
}
this.executeModerately();
ForcedChunksSaveData forcedchunkssavedata = serverWorld.getSavedData().get(ForcedChunksSaveData::new, "chunks");
if (forcedchunkssavedata != null) {
LongIterator longiterator = forcedchunkssavedata.getChunks().iterator();
while (longiterator.hasNext()) {
long i = longiterator.nextLong();
ChunkPos chunkpos = new ChunkPos(i);
serverWorld.getChunkProvider().forceChunk(chunkpos, true);
}
}
this.executeModerately();
listener.stop();
serverchunkprovider.getLightManager().func_215598_a(5);
this.func_240794_aZ_();
this.forceTicks = false;
}
@ -433,18 +445,13 @@ public abstract class MinecraftServerMixin extends RecursiveEventLoop<TickDelaye
}
}
@Inject(method = "loadDataPacks(Ljava/io/File;Lnet/minecraft/world/storage/WorldInfo;)V", at = @At("HEAD"))
private void arclight$bukkitDatapack(File file, WorldInfo p_195560_2_, CallbackInfo ci) {
this.bukkitDataPackFolder = new File(new File(file, "datapacks"), "bukkit");
if (!this.bukkitDataPackFolder.exists()) {
this.bukkitDataPackFolder.mkdirs();
}
final File mcMeta = new File(this.bukkitDataPackFolder, "pack.mcmeta");
try {
Files.write("{\n \"pack\": {\n \"description\": \"Data pack for resources provided by Bukkit plugins\",\n \"pack_format\": " + SharedConstants.getVersion().getPackVersion() + "\n" + " }\n" + "}\n", mcMeta, StandardCharsets.UTF_8);
} catch (IOException ex) {
throw new RuntimeException("Could not initialize Bukkit datapack", ex);
}
/**
* @author IzzelAliz
* @reason our branding, no one should fuck this up
*/
@Overwrite
public String getServerModName() {
return BrandingControl.getServerBranding() + " arclight";
}
@Override

View File

@ -0,0 +1,39 @@
package io.izzel.arclight.common.mixin.core.util.text;
import com.google.common.collect.Streams;
import io.izzel.arclight.common.bridge.util.text.ITextComponentBridge;
import net.minecraft.util.text.ITextComponent;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
@Mixin(ITextComponent.class)
public interface ITextComponentMixin extends ITextComponentBridge, Iterable<ITextComponent> {
// @formatter:off
@Shadow List<ITextComponent> getSiblings();
// @formatter:on
default Stream<ITextComponent> stream() {
return Streams.concat(Stream.of((ITextComponent) this), this.getSiblings().stream().flatMap(it -> ((ITextComponentBridge) it).bridge$stream()));
}
@Override
default @NotNull Iterator<ITextComponent> iterator() {
return this.stream().iterator();
}
@Override
default Stream<ITextComponent> bridge$stream() {
return stream();
}
@Override
default Iterator<ITextComponent> bridge$iterator() {
return iterator();
}
}

View File

@ -7,18 +7,19 @@ import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.ExplosionBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.enchantment.ProtectionEnchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.FallingBlockEntity;
import net.minecraft.entity.item.TNTEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.DamagingProjectileEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
@ -27,12 +28,11 @@ import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.Explosion;
import net.minecraft.world.ExplosionContext;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
@ -49,10 +49,10 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
@ -69,7 +69,7 @@ public abstract class ExplosionMixin implements ExplosionBridge {
@Shadow @Final private double z;
@Shadow @Final public Entity exploder;
@Shadow public abstract DamageSource getDamageSource();
@Shadow @Final private Map<PlayerEntity, Vec3d> playerKnockbackMap;
@Shadow @Final private Map<PlayerEntity, Vector3d> playerKnockbackMap;
@Accessor("exploder") public abstract Entity bridge$getExploder();
@Accessor("size") public abstract float bridge$getSize();
@Accessor("size") public abstract void bridge$setSize(float size);
@ -79,6 +79,8 @@ public abstract class ExplosionMixin implements ExplosionBridge {
@Shadow private static void func_229976_a_(ObjectArrayList<Pair<ItemStack, BlockPos>> p_229976_0_, ItemStack p_229976_1_, BlockPos p_229976_2_) { }
// @formatter:on
@Shadow @Final private ExplosionContext field_234893_k_;
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;DDDFZLnet/minecraft/world/Explosion$Mode;)V",
at = @At("RETURN"))
public void arclight$adjustSize(World worldIn, Entity exploderIn, double xIn, double yIn, double zIn, float sizeIn, boolean causesFireIn, Explosion.Mode modeIn, CallbackInfo ci) {
@ -91,6 +93,9 @@ public abstract class ExplosionMixin implements ExplosionBridge {
*/
@Overwrite
public void doExplosionA() {
if (this.size < 0.1F) {
return;
}
Set<BlockPos> set = Sets.newHashSet();
int i = 16;
@ -113,17 +118,13 @@ public abstract class ExplosionMixin implements ExplosionBridge {
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
BlockPos blockpos = new BlockPos(d4, d6, d8);
BlockState blockstate = this.world.getBlockState(blockpos);
IFluidState ifluidstate = this.world.getFluidState(blockpos);
if (!blockstate.isAir(this.world, blockpos) || !ifluidstate.isEmpty()) {
float f2 = Math.max(blockstate.getExplosionResistance(this.world, blockpos, exploder, (Explosion) (Object) this), ifluidstate.getExplosionResistance(this.world, blockpos, exploder, (Explosion) (Object) this));
if (this.exploder != null) {
f2 = this.exploder.getExplosionResistance((Explosion) (Object) this, this.world, blockpos, blockstate, ifluidstate, f2);
}
f -= (f2 + 0.3F) * 0.3F;
FluidState fluidstate = this.world.getFluidState(blockpos);
Optional<Float> optional = this.field_234893_k_.getExplosionResistance((Explosion) (Object) this, this.world, blockpos, blockstate, fluidstate);
if (optional.isPresent()) {
f -= (optional.get() + 0.3F) * 0.3F;
}
if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock((Explosion) (Object) this, this.world, blockpos, blockstate, f))) {
if (f > 0.0F && this.field_234893_k_.canExplosionDestroyBlock((Explosion) (Object) this, this.world, blockpos, blockstate, f)) {
set.add(blockpos);
}
@ -146,15 +147,15 @@ public abstract class ExplosionMixin implements ExplosionBridge {
int j1 = MathHelper.floor(this.z + (double) f3 + 1.0D);
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this.exploder, new AxisAlignedBB(k1, i2, j2, l1, i1, j1));
net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, (Explosion) (Object) this, list, f3);
Vec3d vec3d = new Vec3d(this.x, this.y, this.z);
Vector3d vec3d = new Vector3d(this.x, this.y, this.z);
for (Entity entity : list) {
if (!entity.isImmuneToExplosions()) {
double d12 = MathHelper.sqrt(entity.getDistanceSq(vec3d)) / f3;
if (d12 <= 1.0D) {
double d5 = entity.posX - this.x;
double d5 = entity.getPosX() - this.x;
double d7 = entity.getPosYEye() - this.y;
double d9 = entity.posZ - this.z;
double d9 = entity.getPosZ() - this.z;
double d13 = MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
if (d13 != 0.0D) {
d5 = d5 / d13;
@ -180,7 +181,7 @@ public abstract class ExplosionMixin implements ExplosionBridge {
if (entity instanceof PlayerEntity) {
PlayerEntity playerentity = (PlayerEntity) entity;
if (!playerentity.isSpectator() && (!playerentity.isCreative() || !playerentity.abilities.isFlying)) {
this.playerKnockbackMap.put(playerentity, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
this.playerKnockbackMap.put(playerentity, new Vector3d(d5 * d10, d7 * d10, d9 * d10));
}
}
}
@ -235,7 +236,7 @@ public abstract class ExplosionMixin implements ExplosionBridge {
this.world.getProfiler().startSection("explosion_blocks");
if (blockstate.canDropFromExplosion(this.world, blockpos, (Explosion) (Object) this) && this.world instanceof ServerWorld) {
TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockpos) : null;
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.POSITION, blockpos).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity).withNullableParameter(LootParameters.THIS_ENTITY, this.exploder);
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld)this.world)).withRandom(this.world.rand).withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(blockpos)).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity).withNullableParameter(LootParameters.THIS_ENTITY, this.exploder);
if (this.mode == Explosion.Mode.DESTROY || yield < 1.0F) {
lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, 1.0F / yield);
}
@ -260,7 +261,7 @@ public abstract class ExplosionMixin implements ExplosionBridge {
if (this.random.nextInt(3) == 0 && this.world.getBlockState(blockpos2).isAir() && this.world.getBlockState(blockpos2.down()).isOpaqueCube(this.world, blockpos2.down())) {
BlockIgniteEvent event = CraftEventFactory.callBlockIgniteEvent(this.world, blockpos2.getX(), blockpos2.getY(), blockpos2.getZ(), (Explosion) (Object) this);
if (!event.isCancelled()) {
this.world.setBlockState(blockpos2, Blocks.FIRE.getDefaultState());
this.world.setBlockState(blockpos2, AbstractFireBlock.getFireForPlacement(this.world, blockpos2));
}
}
}
@ -311,24 +312,4 @@ public abstract class ExplosionMixin implements ExplosionBridge {
}
return cancelled ? Float.NaN : yield;
}
/**
* @author IzzelAliz
* @reason add shooting entity track
*/
@Nullable
@Overwrite
public LivingEntity getExplosivePlacedBy() {
if (this.exploder == null) {
return null;
} else if (this.exploder instanceof TNTEntity) {
return ((TNTEntity) this.exploder).getTntPlacedBy();
} else if (this.exploder instanceof LivingEntity) {
return (LivingEntity) this.exploder;
} else if (this.exploder instanceof DamagingProjectileEntity) {
return ((DamagingProjectileEntity) this.exploder).shootingEntity;
} else {
return null;
}
}
}

View File

@ -2,12 +2,12 @@ package io.izzel.arclight.common.mixin.core.world;
import io.izzel.arclight.common.bridge.world.IBlockReaderBridge;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.IFluidState;
import net.minecraft.fluid.FluidState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -19,15 +19,15 @@ public interface IBlockReaderMixin extends IBlockReaderBridge {
// @formatter:off
@Shadow BlockState getBlockState(BlockPos pos);
@Shadow IFluidState getFluidState(BlockPos pos);
@Shadow @Nullable BlockRayTraceResult rayTraceBlocks(Vec3d p_217296_1_, Vec3d p_217296_2_, BlockPos p_217296_3_, VoxelShape p_217296_4_, BlockState p_217296_5_);
@Shadow FluidState getFluidState(BlockPos pos);
@Shadow @Nullable BlockRayTraceResult rayTraceBlocks(Vector3d p_217296_1_, Vector3d p_217296_2_, BlockPos p_217296_3_, VoxelShape p_217296_4_, BlockState p_217296_5_);
// @formatter:on
default BlockRayTraceResult rayTraceBlock(RayTraceContext context, BlockPos pos) {
BlockState blockstate = this.getBlockState(pos);
IFluidState ifluidstate = this.getFluidState(pos);
Vec3d vec3d = context.getStartVec();
Vec3d vec3d1 = context.getStartVec();
FluidState ifluidstate = this.getFluidState(pos);
Vector3d vec3d = context.getStartVec();
Vector3d vec3d1 = context.getStartVec();
VoxelShape voxelshape = context.getBlockShape(blockstate, (IBlockReader) this, pos);
BlockRayTraceResult blockraytraceresult = this.rayTraceBlocks(vec3d, vec3d1, pos, voxelshape, blockstate);
VoxelShape voxelshape1 = context.getFluidShape(ifluidstate, (IBlockReader) this, pos);

View File

@ -1,17 +0,0 @@
package io.izzel.arclight.common.mixin.core.world.chunk.storage;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import net.minecraft.world.chunk.storage.ChunkLoader;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(ChunkLoader.class)
public class ChunkLoaderMixin {
@ModifyArg(method = "updateChunkData", index = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/gen/feature/structure/LegacyStructureDataUtil;func_215130_a(Lnet/minecraft/world/dimension/DimensionType;Lnet/minecraft/world/storage/DimensionSavedDataManager;)Lnet/minecraft/world/gen/feature/structure/LegacyStructureDataUtil;"))
private DimensionType arclight$dimType(DimensionType dim) {
return ((DimensionTypeBridge) dim).bridge$getType();
}
}

View File

@ -5,7 +5,7 @@ import io.izzel.arclight.api.EnumHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Unit;
import net.minecraft.world.server.TicketType;
import net.minecraft.world.storage.loot.LootParameter;
import net.minecraft.loot.LootParameter;
import org.bukkit.TreeType;
import org.bukkit.plugin.Plugin;

View File

@ -7,6 +7,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.Container;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.datafix.codec.DatapackCodec;
import net.minecraft.util.math.BlockPos;
import org.bukkit.TreeType;
import org.bukkit.block.BlockState;
@ -219,6 +220,20 @@ public class ArclightCaptures {
}
}
private static transient DatapackCodec datapackCodec;
public static void captureDatapackConfig(DatapackCodec codec) {
datapackCodec = codec;
}
public static DatapackCodec getDatapackConfig() {
try {
return datapackCodec;
} finally {
datapackCodec = null;
}
}
private static void recapture(String type) {
throw new IllegalStateException("Recapturing " + type);
}

View File

@ -132,7 +132,6 @@
"entity.ai.brain.task.InteractWithDoorTaskMixin",
"entity.ai.goal.BreakBlockGoalMixin",
"entity.ai.goal.BreakDoorGoalMixin",
"entity.ai.goal.BreedGoalMixin",
"entity.ai.goal.DefendVillageTargetGoalMixin",
"entity.ai.goal.EatGrassGoalMixin",
"entity.ai.goal.FollowOwnerGoalMixin",
@ -154,7 +153,6 @@
"entity.item.ExperienceBottleEntityMixin",
"entity.item.ExperienceOrbEntityMixin",
"entity.item.FallingBlockEntityMixin",
"entity.item.FireworkRocketEntityMixin",
"entity.item.HangingEntityMixin",
"entity.item.ItemEntityMixin",
"entity.item.ItemFrameEntityMixin",
@ -162,8 +160,8 @@
"entity.item.PaintingEntityMixin",
"entity.item.TNTEntityMixin",
"entity.item.minecart.AbstractMinecartEntityMixin",
"entity.item.minecart.ContainerMinecartEntityMixin",
"entity.item.minecart.CommandBlockMinecartEntity_MinecartCommandLogicMixin",
"entity.item.minecart.ContainerMinecartEntityMixin",
"entity.merchant.IMerchantMixin",
"entity.merchant.villager.AbstractVillagerEntityMixin",
"entity.merchant.villager.VillagerEntityMixin",
@ -188,21 +186,18 @@
"entity.monster.SilverfishEntity_SummonSilverfishGoalMixin",
"entity.monster.SlimeEntityMixin",
"entity.monster.SpellcastingIllagerEntity_UseSpellGoalMixin",
"entity.monster.SpellcastingIllagerEntityMixin",
"entity.monster.SpiderEntityMixin",
"entity.monster.VexEntity_CopyOwnerTargetGoalMixin",
"entity.monster.WitchEntityMixin",
"entity.monster.WitherSkeletonEntityMixin",
"entity.monster.ZombieEntityMixin",
"entity.monster.ZombiePigmanEntity_HurtByAggressorGoalMixin",
"entity.monster.ZombifiedPiglinEntityMixin",
"entity.monster.ZombieVillagerEntityMixin",
"entity.monster.ZombifiedPiglinEntityMixin",
"entity.passive.AnimalEntityMixin",
"entity.passive.BatEntityMixin",
"entity.passive.BeeEntity_AngerGoalMixin",
"entity.passive.BeeEntity_FindPollinationTargetGoalMixin",
"entity.passive.BeeEntityMixin",
"entity.passive.CatEntityMixin",
"entity.passive.ChickenEntityMixin",
"entity.passive.CowEntityMixin",
"entity.passive.DolphinEntity_SwimWithPlayerGoalMixin",
@ -243,7 +238,6 @@
"entity.projectile.FireballEntityMixin",
"entity.projectile.FireworkRocketEntityMixin",
"entity.projectile.FishingBobberEntityMixin",
"entity.projectile.LlamaSpitEntityMixin",
"entity.projectile.PotionEntityMixin",
"entity.projectile.ProjectileEntityMixin",
"entity.projectile.ProjectileItemEntityMixin",
@ -331,6 +325,13 @@
"item.crafting.SmokingRecipeMixin",
"item.crafting.SpecialRecipeMixin",
"item.crafting.StonecuttingRecipeMixin",
"loot.LootEntry_SerializerMixin",
"loot.LootParametersMixin",
"loot.LootTableManagerMixin",
"loot.LootTableMixin",
"loot.conditions.RandomChanceWithLootingMixin",
"loot.conditions.SurvivesExplosionMixin",
"loot.functions.LootingEnchantBonusMixin",
"network.NetworkManagerMixin",
"network.PacketThreadUtilMixin",
"network.datasync.EntityDataManagerMixin",
@ -348,6 +349,7 @@
"network.status.ServerStatusNetHandlerMixin",
"potion.EffectMixin",
"server.CustomServerBossInfoMixin",
"server.MainMixin",
"server.MinecraftServerMixin",
"server.dedicated.DedicatedServerMixin",
"server.management.BanEntryMixin",
@ -383,6 +385,7 @@
"util.IndirectEntityDamageSourceMixin",
"util.IWorldPosCallableMixin",
"util.text.ColorMixin",
"util.text.ITextComponentMixin",
"util.text.StyleMixin",
"village.VillageSiegeMixin",
"world.ExplosionMixin",
@ -395,7 +398,6 @@
"world.biome.BiomeContainerMixin",
"world.border.WorldBorderMixin",
"world.chunk.ChunkMixin",
"world.chunk.storage.ChunkLoaderMixin",
"world.chunk.storage.RegionFileCacheMixin",
"world.dimension.DimensionMixin",
"world.dimension.DimensionTypeMixin",
@ -422,12 +424,6 @@
"world.storage.MapDataMixin",
"world.storage.SaveFormatMixin",
"world.storage.SaveHandlerMixin",
"world.storage.WorldInfoMixin",
"world.storage.loot.LootParametersMixin",
"world.storage.loot.LootTableManagerMixin",
"world.storage.loot.LootTableMixin",
"world.storage.loot.conditions.RandomChanceWithLootingMixin",
"world.storage.loot.conditions.SurvivesExplosionMixin",
"world.storage.loot.functions.LootingEnchantBonusMixin"
"world.storage.WorldInfoMixin"
]
}