Update upstream

This commit is contained in:
IzzelAliz 2023-09-02 16:59:53 +08:00
parent 5d09bb89fe
commit 2606ff93b7
4 changed files with 27 additions and 33 deletions

View File

@ -68,14 +68,14 @@ public abstract class VineBlockMixin extends BlockMixin {
}
}
} else if (isAcceptableNeighbour(worldIn, blockpos4, direction)) {
worldIn.setBlock(pos, state.setValue(getPropertyForFace(direction), Boolean.TRUE), 2);
CraftEventFactory.handleBlockGrowEvent(worldIn, pos, state.setValue(getPropertyForFace(direction), Boolean.TRUE), 2);
}
}
} else {
if (direction == Direction.UP && pos.getY() < worldIn.getMaxBuildHeight() - 1) {
if (this.canSupportAtFace(worldIn, pos, direction)) {
worldIn.setBlock(pos, state.setValue(UP, Boolean.TRUE), 2);
CraftEventFactory.handleBlockGrowEvent(worldIn, pos, state.setValue(UP, Boolean.TRUE), 2);
return;
}

View File

@ -2,14 +2,13 @@ package io.izzel.arclight.common.mixin.core.world.level.gameevent;
import io.izzel.arclight.common.bridge.core.entity.EntityBridge;
import io.izzel.arclight.common.bridge.core.world.WorldBridge;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.gameevent.GameEventDispatcher;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.v.CraftGameEvent;
import org.bukkit.event.world.GenericGameEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -19,8 +18,6 @@ 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.Objects;
@Mixin(GameEventDispatcher.class)
public class GameEventDispatcherMixin {
@ -32,7 +29,7 @@ public class GameEventDispatcherMixin {
private void arclight$gameEvent(GameEvent gameEvent, Vec3 vec3, GameEvent.Context context, CallbackInfo ci) {
var entity = context.sourceEntity();
var i = gameEvent.getNotificationRadius();
GenericGameEvent event = new GenericGameEvent(Objects.requireNonNull(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameEvent)))),
GenericGameEvent event = new GenericGameEvent(CraftGameEvent.minecraftToBukkit(gameEvent),
new Location(((WorldBridge) this.level).bridge$getWorld(), vec3.x(), vec3.y(), vec3.z()), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), i, !Bukkit.isPrimaryThread());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@ -2,7 +2,6 @@ package io.izzel.arclight.common.mixin.core.world.level.gameevent.vibrations;
import io.izzel.arclight.common.bridge.core.entity.EntityBridge;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
@ -10,8 +9,8 @@ import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.gameevent.vibrations.VibrationSystem;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.CraftGameEvent;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.util.CraftNamespacedKey;
import org.bukkit.event.block.BlockReceiveGameEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -52,7 +51,7 @@ public abstract class VibrationListenerMixin {
// CraftBukkit start
boolean defaultCancel = !vibrationsystem_d.canReceiveVibration(worldserver, BlockPos.containing(vec3d), gameevent, gameevent_a);
Entity entity = gameevent_a.sourceEntity();
BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, BlockPos.containing(vec3d1)), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity());
BlockReceiveGameEvent event = new BlockReceiveGameEvent(CraftGameEvent.minecraftToBukkit(gameevent), CraftBlock.at(worldserver, BlockPos.containing(vec3d1)), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity());
event.setCancelled(defaultCancel);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@ -1,6 +1,10 @@
package io.izzel.arclight.common.mod.server;
import com.google.common.collect.*;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.izzel.arclight.api.ArclightVersion;
import io.izzel.arclight.api.EnumHelper;
import io.izzel.arclight.api.Unsafe;
@ -39,7 +43,11 @@ import net.minecraftforge.fml.CrashReportCallables;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import org.bukkit.*;
import org.bukkit.Art;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v.CraftCrashReport;
import org.bukkit.craftbukkit.v.CraftStatistic;
@ -49,13 +57,22 @@ import org.bukkit.craftbukkit.v.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.v.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.v.util.CraftSpawnCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.SpawnCategory;
import org.bukkit.entity.Villager;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@SuppressWarnings({"ConstantConditions", "deprecation"})
public class BukkitRegistry {
@ -96,7 +113,6 @@ public class BukkitRegistry {
loadEndDragonPhase();
loadCookingBookCategory();
loadFluids();
loadGameEvents();
try {
for (var field : org.bukkit.Registry.class.getFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.get(null) instanceof org.bukkit.Registry.SimpleRegistry<?> registry) {
@ -107,24 +123,6 @@ public class BukkitRegistry {
}
}
private static void loadGameEvents() {
try {
var constructor = GameEvent.class.getDeclaredConstructor(NamespacedKey.class);
constructor.setAccessible(true);
var handle = Unsafe.lookup().unreflectConstructor(constructor);
for (var gameEvent : BuiltInRegistries.GAME_EVENT) {
var key = BuiltInRegistries.GAME_EVENT.getKey(gameEvent);
var bukkit = GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(key));
if (bukkit == null) {
bukkit = (GameEvent) handle.invoke(CraftNamespacedKey.fromMinecraft(key));
ArclightMod.LOGGER.debug("Registered {} as game event {}", key, bukkit);
}
}
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
private static void loadFluids() {
var id = org.bukkit.Fluid.values().length;
var newTypes = new ArrayList<org.bukkit.Fluid>();