1.17: blocks, entities

This commit is contained in:
IzzelAliz 2021-07-24 18:53:37 +08:00
parent 368b0cb259
commit e3a2790709
699 changed files with 15930 additions and 15612 deletions

View File

@ -6,6 +6,7 @@ A Bukkit server implementation utilizing Mixin.
| Minecraft | Forge | Status | Build |
| :----: | :----: | :---: | :---: |
| 1.17.x | 37.0.1 | ACTIVE | - |
| 1.16.x | 36.2.0 | ACTIVE | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) |
| 1.15.x | 31.2.48 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.15/1.0.19) | [![1.15 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-15?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-15) |
| 1.14.x | 28.2.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.0.6) | [![1.14 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight) |

View File

@ -1,6 +1,6 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/maven' }
mavenCentral()
maven { url = 'https://maven.izzel.io/releases' }
@ -21,17 +21,17 @@ apply plugin: 'io.izzel.arclight'
arclight {
mcVersion = minecraftVersion
forgeVersion = project.ext.forgeVersion
bukkitVersion = 'v1_16_R3'
bukkitVersion = 'v1_17_R1'
wipeVersion = true
reobfVersion = false
accessTransformer = project.file('bukkit.at')
packageName = 'spigot'
// packageName = 'spigot'
}
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
// sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '11'
minecraft {
mappings channel: 'snapshot', version: "20210215-1.16.3"
mappings channel: 'official', version: minecraftVersion
accessTransformer = project.file('src/main/resources/META-INF/accesstransformer.cfg')
}
@ -48,13 +48,13 @@ dependencies {
minecraft "net.minecraftforge:forge:$minecraftVersion-$forgeVersion"
implementation "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar"
implementation 'org.jetbrains:annotations:19.0.0'
implementation 'org.spongepowered:mixin:0.8.2'
annotationProcessor 'org.spongepowered:mixin:0.8.2:processor'
implementation 'com.github.ArclightTeam:mixin-tools:1.0.0'
annotationProcessor 'com.github.ArclightTeam:mixin-tools:1.0.0'
implementation 'jline:jline:2.12.1'
implementation 'net.md-5:SpecialSource:1.9.0'
implementation 'org.apache.logging.log4j:log4j-jul:2.11.2'
@ -71,12 +71,6 @@ remapSpigotJar {
includes.add('net/minecraft/tileentity/LecternTileEntity$LecternInventory')
}
processMapping {
process { csrg, srg ->
csrg.classes.put('net/minecraft/world/level/ColorResolver', "net/minecraft/server/$bukkitVersion/ColorResolver".toString())
}
}
generateArclightMeta {
doFirst {
throw new StopExecutionException()

View File

@ -1,11 +1,11 @@
package io.izzel.arclight.common.bridge.block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
public interface BlockBridge {
int bridge$getExpDrop(BlockState blockState, ServerWorld world, BlockPos blockPos, ItemStack itemStack);
int bridge$getExpDrop(BlockState blockState, ServerLevel world, BlockPos blockPos, ItemStack itemStack);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.block;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
public interface FireBlockBridge {

View File

@ -1,10 +1,10 @@
package io.izzel.arclight.common.bridge.block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
public interface NoteBlockBridge {
void bridge$play(World worldIn, BlockPos pos, BlockState state);
void bridge$play(Level worldIn, BlockPos pos, BlockState state);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.block;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerLevel;
import org.bukkit.craftbukkit.v.event.CraftPortalEvent;
import org.jetbrains.annotations.Nullable;
@ -10,7 +10,7 @@ public interface PortalInfoBridge {
CraftPortalEvent bridge$getPortalEventInfo();
void bridge$setWorld(ServerWorld world);
void bridge$setWorld(ServerLevel world);
@Nullable ServerWorld bridge$getWorld();
@Nullable ServerLevel bridge$getWorld();
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.bukkit;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
public interface CraftItemStackBridge {

View File

@ -1,11 +1,11 @@
package io.izzel.arclight.common.bridge.bukkit;
import net.minecraft.server.management.PlayerList;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.players.PlayerList;
public interface CraftServerBridge {
void bridge$setPlayerList(PlayerList playerList);
void bridge$removeWorld(ServerWorld world);
void bridge$removeWorld(ServerLevel world);
}

View File

@ -1,12 +1,12 @@
package io.izzel.arclight.common.bridge.bukkit;
import io.izzel.arclight.i18n.conf.EntityPropertySpec;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Location;
import java.util.function.Function;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
public interface EntityTypeBridge {

View File

@ -1,19 +1,18 @@
package io.izzel.arclight.common.bridge.bukkit;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import java.util.Map;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
public interface ItemMetaBridge {
CompoundNBT bridge$getForgeCaps();
CompoundTag bridge$getForgeCaps();
void bridge$setForgeCaps(CompoundNBT nbt);
void bridge$setForgeCaps(CompoundTag nbt);
void bridge$offerUnhandledTags(CompoundNBT nbt);
void bridge$offerUnhandledTags(CompoundTag nbt);
Map<String, INBT> bridge$getUnhandledTags();
Map<String, Tag> bridge$getUnhandledTags();
void bridge$setUnhandledTags(Map<String, INBT> tags);
void bridge$setUnhandledTags(Map<String, Tag> tags);
}

View File

@ -1,15 +1,15 @@
package io.izzel.arclight.common.bridge.bukkit;
import io.izzel.arclight.i18n.conf.MaterialPropertySpec;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.inventory.CraftMetaItem;
import org.bukkit.inventory.meta.ItemMeta;
import javax.annotation.Nullable;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.util.function.Function;
public interface MaterialBridge {

View File

@ -1,9 +1,9 @@
package io.izzel.arclight.common.bridge.command;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import org.bukkit.command.CommandSender;
public interface ICommandSourceBridge {
CommandSender bridge$getBukkitSender(CommandSource wrapper);
CommandSender bridge$getBukkitSender(CommandSourceStack wrapper);
}

View File

@ -2,7 +2,7 @@ package io.izzel.arclight.common.bridge.command.arguments;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.arguments.EntitySelector;
import net.minecraft.commands.arguments.selector.EntitySelector;
public interface EntityArgumentBridge {

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.bridge.command.arguments;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.arguments.EntitySelector;
import net.minecraft.commands.arguments.selector.EntitySelector;
public interface EntitySelectorParserBridge {

View File

@ -1,17 +1,17 @@
package io.izzel.arclight.common.bridge.entity;
import io.izzel.arclight.common.bridge.command.ICommandSourceBridge;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.entity.CraftEntity;
import org.bukkit.projectiles.ProjectileSource;
import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
public interface EntityBridge extends ICommandSourceBridge {
Entity bridge$teleportTo(ServerWorld world, BlockPos blockPos);
Entity bridge$teleportTo(ServerLevel world, BlockPos blockPos);
void bridge$setOnFire(int tick, boolean callEvent);

View File

@ -1,17 +1,17 @@
package io.izzel.arclight.common.bridge.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.event.entity.CreatureSpawnEvent;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.player.Player;
public interface EntityTypeBridge<T extends Entity> {
T bridge$spawnCreature(ServerWorld worldIn, @Nullable CompoundNBT compound, @Nullable ITextComponent customName, @Nullable PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean flag, boolean flag1, CreatureSpawnEvent.SpawnReason spawnReason);
T bridge$spawnCreature(ServerLevel worldIn, @Nullable CompoundTag compound, @Nullable Component customName, @Nullable Player playerIn, BlockPos pos, MobSpawnType reason, boolean flag, boolean flag1, CreatureSpawnEvent.SpawnReason spawnReason);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import org.bukkit.craftbukkit.v.entity.CraftEntity;
public interface InternalEntityBridge {

View File

@ -1,18 +1,18 @@
package io.izzel.arclight.common.bridge.entity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import org.bukkit.craftbukkit.v.entity.CraftLivingEntity;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import java.util.Optional;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
public interface LivingEntityBridge extends EntityBridge {
void bridge$setSlot(EquipmentSlotType slotIn, ItemStack stack, boolean silent);
void bridge$setSlot(EquipmentSlot slotIn, ItemStack stack, boolean silent);
void bridge$playEquipSound(ItemStack stack, boolean silent);
@ -32,9 +32,9 @@ public interface LivingEntityBridge extends EntityBridge {
void bridge$pushEffectCause(EntityPotionEffectEvent.Cause cause);
boolean bridge$addEffect(EffectInstance effect, EntityPotionEffectEvent.Cause cause);
boolean bridge$addEffect(MobEffectInstance effect, EntityPotionEffectEvent.Cause cause);
boolean bridge$removeEffect(Effect effect, EntityPotionEffectEvent.Cause cause);
boolean bridge$removeEffect(MobEffect effect, EntityPotionEffectEvent.Cause cause);
boolean bridge$removeAllEffects(EntityPotionEffectEvent.Cause cause);

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.bridge.entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTransformEvent;
@ -25,9 +25,4 @@ public interface MobEntityBridge extends LivingEntityBridge {
void bridge$setAware(boolean aware);
void bridge$captureItemDrop(ItemEntity itemEntity);
interface Hack {
ResourceLocation getLootTable();
}
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.entity.monster;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
public interface EndermanEntityBridge {

View File

@ -0,0 +1,12 @@
package io.izzel.arclight.common.bridge.entity.monster.piglin;
import net.minecraft.world.item.Item;
import java.util.Set;
public interface PiglinBridge {
Set<Item> bridge$getAllowedBarterItems();
Set<Item> bridge$getInterestItems();
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.bridge.entity.passive;
import net.minecraft.item.ItemStack;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import net.minecraft.world.item.ItemStack;
public interface AnimalEntityBridge extends MobEntityBridge {

View File

@ -2,10 +2,11 @@ package io.izzel.arclight.common.bridge.entity.player;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.entity.player.Player;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
import org.bukkit.event.entity.EntityExhaustionEvent;
public interface PlayerEntityBridge extends LivingEntityBridge {
@ -14,5 +15,7 @@ public interface PlayerEntityBridge extends LivingEntityBridge {
@Override
CraftHumanEntity bridge$getBukkitEntity();
Either<PlayerEntity.SleepResult, Unit> bridge$trySleep(BlockPos at, boolean force);
Either<Player.BedSleepingProblem, Unit> bridge$trySleep(BlockPos at, boolean force);
void bridge$pushExhaustReason(EntityExhaustionEvent.ExhaustionReason reason);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.entity.player;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
public interface PlayerInventoryBridge {

View File

@ -1,9 +1,9 @@
package io.izzel.arclight.common.bridge.entity.player;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.entity.CraftPlayer;
import org.bukkit.event.player.PlayerTeleportEvent;
@ -20,21 +20,21 @@ public interface ServerPlayerEntityBridge extends PlayerEntityBridge {
Optional<PlayerTeleportEvent.TeleportCause> bridge$getTeleportCause();
BlockPos bridge$getSpawnPoint(ServerWorld world);
BlockPos bridge$getSpawnPoint(ServerLevel world);
boolean bridge$isMovementBlocked();
void bridge$setCompassTarget(Location location);
void bridge$sendMessage(ITextComponent[] ichatbasecomponent, UUID uuid);
void bridge$sendMessage(Component[] ichatbasecomponent, UUID uuid);
void bridge$sendMessage(ITextComponent component, UUID uuid);
void bridge$sendMessage(Component component, UUID uuid);
boolean bridge$isJoining();
void bridge$reset();
Entity bridge$changeDimension(ServerWorld world, PlayerTeleportEvent.TeleportCause cause);
Entity bridge$changeDimension(ServerLevel world, PlayerTeleportEvent.TeleportCause cause);
boolean bridge$initialized();
}

View File

@ -1,11 +0,0 @@
package io.izzel.arclight.common.bridge.entity.projectile;
import net.minecraft.item.Item;
public interface ProjectileItemEntityBridge {
interface Hack {
Item getDefaultItem();
}
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.entity.projectile;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
public interface TridentEntityBridge {

View File

@ -1,11 +1,11 @@
package io.izzel.arclight.common.bridge.inventory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;
public interface CraftingInventoryBridge extends IInventoryBridge {
void bridge$setOwner(PlayerEntity owner);
void bridge$setOwner(Player owner);
void bridge$setResultInventory(IInventory resultInventory);
void bridge$setResultInventory(Container resultInventory);
}

View File

@ -2,9 +2,6 @@ package io.izzel.arclight.common.bridge.inventory;
import io.izzel.arclight.common.mod.ArclightMod;
import io.izzel.arclight.common.mod.util.WrappedContents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v.inventory.CraftInventory;
@ -13,13 +10,16 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import java.util.List;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
public interface IInventoryBridge {
int MAX_STACK = 64;
default List<ItemStack> getContents() {
return new WrappedContents((IInventory) this);
return new WrappedContents((Container) this);
}
void onOpen(CraftHumanEntity who);
@ -36,11 +36,11 @@ public interface IInventoryBridge {
Location getLocation();
default IRecipe<?> getCurrentRecipe() {
default Recipe<?> getCurrentRecipe() {
return null;
}
default void setCurrentRecipe(IRecipe<?> recipe) {
default void setCurrentRecipe(Recipe<?> recipe) {
}
default Inventory getOwnerInventory() {
@ -49,7 +49,7 @@ public interface IInventoryBridge {
return owner.getInventory();
} else {
ArclightMod.LOGGER.warn("No owner for inventory {}/{}", this, this.getClass());
return new CraftInventory((IInventory) this);
return new CraftInventory((Container) this);
}
}
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.bridge.inventory.container;
import net.minecraft.inventory.container.Container;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.inventory.AbstractContainerMenu;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
import org.bukkit.inventory.InventoryView;
@ -9,11 +9,11 @@ public interface ContainerBridge {
InventoryView bridge$getBukkitView();
void bridge$transferTo(Container other, CraftHumanEntity player);
void bridge$transferTo(AbstractContainerMenu other, CraftHumanEntity player);
ITextComponent bridge$getTitle();
Component bridge$getTitle();
void bridge$setTitle(ITextComponent title);
void bridge$setTitle(Component title);
boolean bridge$isCheckReachable();
}

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.bridge.inventory.container;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.world.entity.player.Inventory;
public interface LecternContainerBridge {
void bridge$setPlayerInventory(PlayerInventory playerInventory);
void bridge$setPlayerInventory(Inventory playerInventory);
}

View File

@ -1,12 +1,12 @@
package io.izzel.arclight.common.bridge.inventory.container;
import io.izzel.arclight.common.bridge.util.IWorldPosCallableBridge;
import net.minecraft.util.IWorldPosCallable;
import net.minecraft.world.inventory.ContainerLevelAccess;
import org.bukkit.Location;
public interface PosContainerBridge extends ContainerBridge {
IWorldPosCallable bridge$getWorldPos();
ContainerLevelAccess bridge$getWorldPos();
default Location bridge$getWorldLocation() {
return ((IWorldPosCallableBridge) bridge$getWorldPos()).bridge$getLocation();

View File

@ -1,12 +1,12 @@
package io.izzel.arclight.common.bridge.item;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
public interface ItemStackBridge {
void bridge$convertStack(int version);
CompoundNBT bridge$getForgeCaps();
CompoundTag bridge$getForgeCaps();
void bridge$setForgeCaps(CompoundNBT caps);
void bridge$setForgeCaps(CompoundTag caps);
}

View File

@ -1,10 +1,10 @@
package io.izzel.arclight.common.bridge.item.crafting;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.item.crafting.Recipe;
public interface RecipeManagerBridge {
void bridge$addRecipe(IRecipe<?> recipe);
void bridge$addRecipe(Recipe<?> recipe);
void bridge$clearRecipes();
}

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.bridge.network.datasync;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.syncher.EntityDataAccessor;
public interface EntityDataManagerBridge {
<T> void bridge$markDirty(DataParameter<T> key);
<T> void bridge$markDirty(EntityDataAccessor<T> key);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.server;
import net.minecraft.command.Commands;
import net.minecraft.commands.Commands;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.RemoteConsoleCommandSender;
import org.bukkit.craftbukkit.v.CraftServer;

View File

@ -1,23 +1,23 @@
package io.izzel.arclight.common.bridge.server.management;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.login.ServerLoginNetHandler;
import net.minecraft.util.text.ITextComponent;
import org.bukkit.craftbukkit.v.CraftServer;
import java.net.SocketAddress;
import java.util.List;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
public interface PlayerListBridge {
void bridge$setPlayers(List<ServerPlayerEntity> players);
void bridge$setPlayers(List<ServerPlayer> players);
List<ServerPlayerEntity> bridge$getPlayers();
List<ServerPlayer> bridge$getPlayers();
CraftServer bridge$getCraftServer();
ServerPlayerEntity bridge$canPlayerLogin(SocketAddress socketAddress, GameProfile gameProfile, ServerLoginNetHandler handler);
ServerPlayer bridge$canPlayerLogin(SocketAddress socketAddress, GameProfile gameProfile, ServerLoginPacketListenerImpl handler);
void bridge$sendMessage(ITextComponent[] components);
void bridge$sendMessage(Component[] components);
}

View File

@ -1,14 +1,13 @@
package io.izzel.arclight.common.bridge.tileentity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import java.util.List;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
public interface AbstractFurnaceTileEntityBridge {
List<IRecipe<?>> bridge$dropExp(World world, Vector3d pos, PlayerEntity entity, ItemStack itemStack, int amount);
List<Recipe<?>> bridge$dropExp(Level world, Vec3 pos, Player entity, ItemStack itemStack, int amount);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.util;
import net.minecraft.util.DamageSource;
import net.minecraft.world.damagesource.DamageSource;
public interface DamageSourceBridge {

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.bridge.util;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.Player;
public interface FoodStatsBridge {
void bridge$setEntityHuman(PlayerEntity playerEntity);
void bridge$setEntityHuman(Player playerEntity);
}

View File

@ -1,20 +1,20 @@
package io.izzel.arclight.common.bridge.util;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.util.IWorldPosCallable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.level.Level;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.CraftWorld;
public interface IWorldPosCallableBridge {
default World bridge$getWorld() {
return ((IWorldPosCallable) this).apply((a, b) -> a).orElse(null);
default Level bridge$getWorld() {
return ((ContainerLevelAccess) this).evaluate((a, b) -> a).orElse(null);
}
default BlockPos bridge$getPosition() {
return ((IWorldPosCallable) this).apply((a, b) -> b).orElse(null);
return ((ContainerLevelAccess) this).evaluate((a, b) -> b).orElse(null);
}
default Location bridge$getLocation() {

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.util;
import net.minecraft.entity.Entity;
import net.minecraft.world.entity.Entity;
public interface IndirectEntityDamageSourceBridge extends DamageSourceBridge {

View File

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

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.entity.Entity;
import net.minecraft.world.Explosion;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
public interface ExplosionBridge {
@ -11,7 +11,7 @@ public interface ExplosionBridge {
void bridge$setSize(float size);
Explosion.Mode bridge$getMode();
Explosion.BlockInteraction bridge$getMode();
boolean bridge$wasCancelled();
}

View File

@ -1,10 +1,10 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.BlockHitResult;
public interface IBlockReaderBridge {
BlockRayTraceResult bridge$rayTraceBlock(RayTraceContext context, BlockPos pos);
BlockHitResult bridge$rayTraceBlock(ClipContext context, BlockPos pos);
}

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerLevel;
public interface IWorldBridge {
ServerWorld bridge$getMinecraftWorld();
ServerLevel bridge$getMinecraftWorld();
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.entity.Entity;
import net.minecraft.world.entity.Entity;
import org.bukkit.event.entity.CreatureSpawnEvent;
public interface IWorldWriterBridge {

View File

@ -1,15 +1,14 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.TeleportationRepositioner;
import net.minecraft.util.math.BlockPos;
import java.util.Optional;
import net.minecraft.BlockUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity;
public interface TeleporterBridge {
Optional<TeleportationRepositioner.Result> bridge$findPortal(BlockPos pos, int searchRadius);
Optional<BlockUtil.FoundRectangle> bridge$findPortal(BlockPos pos, int searchRadius);
Optional<TeleportationRepositioner.Result> bridge$createPortal(BlockPos pos, Direction.Axis axis, Entity entity, int createRadius);
Optional<BlockUtil.FoundRectangle> bridge$createPortal(BlockPos pos, Direction.Axis axis, Entity entity, int createRadius);
}

View File

@ -1,10 +1,9 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.entity.player.ServerPlayerEntity;
import java.util.Set;
import net.minecraft.server.level.ServerPlayer;
public interface TrackedEntityBridge {
void bridge$setTrackedPlayers(Set<ServerPlayerEntity> trackedPlayers);
void bridge$setTrackedPlayers(Set<ServerPlayer> trackedPlayers);
}

View File

@ -1,9 +1,9 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.dimension.DimensionType;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.generator.ChunkGenerator;
@ -25,7 +25,7 @@ public interface WorldBridge extends IWorldWriterBridge, IWorldBridge {
ChunkGenerator bridge$getGenerator();
TileEntity bridge$getTileEntity(BlockPos pos, boolean validate);
BlockEntity bridge$getTileEntity(BlockPos pos, boolean validate);
SpigotWorldConfig bridge$spigotConfig();
@ -39,5 +39,5 @@ public interface WorldBridge extends IWorldWriterBridge, IWorldBridge {
long bridge$ticksPerWaterAmbientSpawns();
RegistryKey<DimensionType> bridge$getTypeKey();
ResourceKey<DimensionType> bridge$getTypeKey();
}

View File

@ -1,10 +1,10 @@
package io.izzel.arclight.common.bridge.world.border;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
public interface WorldBorderBridge {
World bridge$getWorld();
Level bridge$getWorld();
void bridge$setWorld(World world);
void bridge$setWorld(Level world);
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.bridge.world.chunk;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer;

View File

@ -1,8 +1,7 @@
package io.izzel.arclight.common.bridge.world.chunk.storage;
import net.minecraft.util.math.ChunkPos;
import java.io.IOException;
import net.minecraft.world.level.ChunkPos;
public interface RegionFileCacheBridge {

View File

@ -1,10 +1,9 @@
package io.izzel.arclight.common.bridge.world.raid;
import net.minecraft.entity.monster.AbstractRaiderEntity;
import java.util.Collection;
import net.minecraft.world.entity.raid.Raider;
public interface RaidBridge {
Collection<AbstractRaiderEntity> bridge$getRaiders();
Collection<Raider> bridge$getRaiders();
}

View File

@ -1,10 +1,10 @@
package io.izzel.arclight.common.bridge.world.server;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.level.chunk.LevelChunk;
public interface ChunkHolderBridge {
int bridge$getOldTicketLevel();
Chunk bridge$getFullChunk();
LevelChunk bridge$getFullChunk();
}

View File

@ -1,11 +1,10 @@
package io.izzel.arclight.common.bridge.world.server;
import io.izzel.arclight.common.mod.util.ArclightCallbackExecutor;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.server.ChunkHolder;
import java.util.function.BooleanSupplier;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkGenerator;
public interface ChunkManagerBridge {

View File

@ -1,9 +1,8 @@
package io.izzel.arclight.common.bridge.world.server;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.server.ServerWorldLightManager;
import java.io.IOException;
import net.minecraft.server.level.ThreadedLevelLightEngine;
import net.minecraft.world.level.chunk.ChunkGenerator;
public interface ServerChunkProviderBridge {
@ -15,7 +14,7 @@ public interface ServerChunkProviderBridge {
boolean bridge$isChunkLoaded(int x, int z);
ServerWorldLightManager bridge$getLightManager();
ThreadedLevelLightEngine bridge$getLightManager();
void bridge$setChunkGenerator(ChunkGenerator chunkGenerator);

View File

@ -1,24 +1,24 @@
package io.izzel.arclight.common.bridge.world.server;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.particles.IParticleData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.storage.SaveFormat;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.storage.LevelStorageSource;
public interface ServerWorldBridge extends WorldBridge {
<T extends IParticleData> int bridge$sendParticles(T type, double posX, double posY, double posZ, int particleCount, double xOffset, double yOffset, double zOffset, double speed, boolean force);
<T extends ParticleOptions> int bridge$sendParticles(T type, double posX, double posY, double posZ, int particleCount, double xOffset, double yOffset, double zOffset, double speed, boolean force);
void bridge$pushStrikeLightningCause(LightningStrikeEvent.Cause cause);
void bridge$strikeLightning(LightningBoltEntity entity, LightningStrikeEvent.Cause cause);
void bridge$strikeLightning(LightningBolt entity, LightningStrikeEvent.Cause cause);
TileEntity bridge$getTileEntity(BlockPos blockPos);
BlockEntity bridge$getTileEntity(BlockPos blockPos);
boolean bridge$addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason);
@ -26,10 +26,10 @@ public interface ServerWorldBridge extends WorldBridge {
boolean bridge$addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason);
SaveFormat.LevelSave bridge$getConvertable();
LevelStorageSource.LevelStorageAccess bridge$getConvertable();
interface Hack {
TileEntity getTileEntity(BlockPos blockPos);
BlockEntity getTileEntity(BlockPos blockPos);
}
}

View File

@ -1,8 +1,8 @@
package io.izzel.arclight.common.bridge.world.server;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.server.Ticket;
import net.minecraft.world.server.TicketType;
import net.minecraft.server.level.Ticket;
import net.minecraft.server.level.TicketType;
import net.minecraft.world.level.ChunkPos;
public interface TicketManagerBridge {

View File

@ -1,19 +1,19 @@
package io.izzel.arclight.common.bridge.world.spawner;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.chunk.ChunkAccess;
public interface WorldEntitySpawnerBridge {
interface EntityDensityManagerBridge {
void bridge$updateDensity(MobEntity mobEntity, IChunk chunk);
void bridge$updateDensity(Mob mobEntity, ChunkAccess chunk);
boolean bridge$canSpawn(EntityClassification classification, int limit);
boolean bridge$canSpawn(MobCategory classification, int limit);
boolean bridge$canSpawn(EntityType<?> entityType, BlockPos pos, IChunk chunk);
boolean bridge$canSpawn(EntityType<?> entityType, BlockPos pos, ChunkAccess chunk);
}
}

View File

@ -1,12 +1,12 @@
package io.izzel.arclight.common.bridge.world.storage;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.DimensionType;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.ServerLevelData;
public interface DerivedWorldInfoBridge {
IServerWorldInfo bridge$getDelegate();
ServerLevelData bridge$getDelegate();
void bridge$setDimType(RegistryKey<DimensionType> typeKey);
void bridge$setDimType(ResourceKey<DimensionType> typeKey);
}

View File

@ -1,12 +1,11 @@
package io.izzel.arclight.common.bridge.world.storage;
import net.minecraft.nbt.CompoundNBT;
import java.io.File;
import net.minecraft.nbt.CompoundTag;
public interface PlayerDataBridge {
File bridge$getPlayerDir();
CompoundNBT bridge$getPlayerData(String uuid);
CompoundTag bridge$getPlayerData(String uuid);
}

View File

@ -1,17 +1,16 @@
package io.izzel.arclight.common.bridge.world.storage;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.Dimension;
import net.minecraft.world.storage.SaveFormat;
import java.io.IOException;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.storage.LevelStorageSource;
public interface SaveFormatBridge {
SaveFormat.LevelSave bridge$getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException;
LevelStorageSource.LevelStorageAccess bridge$getLevelSave(String saveName, ResourceKey<LevelStem> world) throws IOException;
interface LevelSaveBridge {
void bridge$setDimType(RegistryKey<Dimension> typeKey);
void bridge$setDimType(ResourceKey<LevelStem> typeKey);
}
}

View File

@ -1,16 +1,16 @@
package io.izzel.arclight.common.bridge.world.storage;
import com.mojang.serialization.Lifecycle;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.LevelSettings;
public interface WorldInfoBridge {
void bridge$setWorld(ServerWorld world);
void bridge$setWorld(ServerLevel world);
ServerWorld bridge$getWorld();
ServerLevel bridge$getWorld();
WorldSettings bridge$getWorldSettings();
LevelSettings bridge$getWorldSettings();
Lifecycle bridge$getLifecycle();
}

View File

@ -1,9 +1,9 @@
package io.izzel.arclight.common.bridge.world.storage.loot;
import net.minecraft.inventory.IInventory;
import net.minecraft.loot.LootContext;
import net.minecraft.world.Container;
import net.minecraft.world.level.storage.loot.LootContext;
public interface LootTableBridge {
void bridge$fillInventory(IInventory inv, LootContext context, boolean plugin);
void bridge$fillInventory(Container inv, LootContext context, boolean plugin);
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.mixin.bukkit;
import net.minecraft.entity.merchant.villager.AbstractVillagerEntity;
import net.minecraft.world.entity.npc.AbstractVillager;
import org.bukkit.craftbukkit.v.entity.CraftAbstractVillager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -13,7 +13,7 @@ public abstract class CraftAbstractVillagerMixin extends CraftEntityMixin {
* @reason
*/
@Overwrite
public AbstractVillagerEntity getHandle() {
return (AbstractVillagerEntity) this.entity;
public AbstractVillager getHandle() {
return (AbstractVillager) this.entity;
}
}

View File

@ -2,7 +2,7 @@ package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.common.bridge.bukkit.MaterialBridge;
import io.izzel.arclight.common.mod.util.ResourceLocationUtil;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.Registry;
import net.minecraftforge.registries.ForgeRegistries;
import org.bukkit.Material;
import org.bukkit.block.Biome;
@ -36,7 +36,7 @@ public abstract class CraftBlockMixin {
* @reason
*/
@Overwrite
public static Biome biomeBaseToBiome(Registry<net.minecraft.world.biome.Biome> registry, net.minecraft.world.biome.Biome base) {
public static Biome biomeBaseToBiome(Registry<net.minecraft.world.level.biome.Biome> registry, net.minecraft.world.level.biome.Biome base) {
return Biome.valueOf(ResourceLocationUtil.standardize(base.getRegistryName()));
}
@ -45,7 +45,7 @@ public abstract class CraftBlockMixin {
* @reason
*/
@Overwrite
public static net.minecraft.world.biome.Biome biomeToBiomeBase(Registry<net.minecraft.world.biome.Biome> registry, Biome bio) {
public static net.minecraft.world.level.biome.Biome biomeToBiomeBase(Registry<net.minecraft.world.level.biome.Biome> registry, Biome bio) {
return ForgeRegistries.BIOMES.getValue(CraftNamespacedKey.toMinecraft(bio.getKey()));
}
}

View File

@ -1,6 +1,6 @@
package io.izzel.arclight.common.mixin.bukkit;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.craftbukkit.v.block.CraftBlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.level.chunk.LevelChunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v.CraftChunk;
import org.bukkit.entity.Entity;
@ -18,7 +18,7 @@ public abstract class CraftChunkMixin {
@Shadow public abstract World getWorld();
@Shadow @Final private int x;
@Shadow @Final private int z;
@Shadow public abstract Chunk getHandle();
@Shadow public abstract LevelChunk getHandle();
// @formatter:on
/**
@ -32,16 +32,16 @@ public abstract class CraftChunkMixin {
}
int count = 0;
int index = 0;
net.minecraft.world.chunk.Chunk chunk = this.getHandle();
net.minecraft.world.level.chunk.LevelChunk chunk = this.getHandle();
for (int i = 0; i < 16; ++i) {
count += chunk.entityLists[i].size();
count += chunk.entitySections[i].size();
}
Entity[] entities = new Entity[count];
for (int j = 0; j < 16; ++j) {
Object[] array;
for (int length = (array = chunk.entityLists[j].toArray()).length, k = 0; k < length; ++k) {
for (int length = (array = chunk.entitySections[j].toArray()).length, k = 0; k < length; ++k) {
Object obj = array[k];
if (obj instanceof net.minecraft.entity.Entity) {
if (obj instanceof net.minecraft.world.entity.Entity) {
entities[index++] = ((EntityBridge) obj).bridge$getBukkitEntity();
}
}

View File

@ -11,20 +11,20 @@ import io.izzel.arclight.common.mod.server.entity.ArclightModMob;
import io.izzel.arclight.common.mod.server.entity.ArclightModProjectile;
import io.izzel.arclight.common.mod.server.entity.ArclightModRaider;
import io.izzel.arclight.common.mod.util.ResourceLocationUtil;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.FlyingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.minecart.ContainerMinecartEntity;
import net.minecraft.entity.monster.AbstractRaiderEntity;
import net.minecraft.entity.passive.GolemEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.horse.AbstractChestedHorseEntity;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.AgableMob;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.FlyingMob;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.animal.AbstractGolem;
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.raid.Raider;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.entity.vehicle.AbstractMinecartContainer;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.registries.ForgeRegistries;
import org.bukkit.craftbukkit.v.CraftServer;
@ -77,50 +77,50 @@ public abstract class CraftEntityMixin implements org.bukkit.entity.Entity {
@Inject(method = "getEntity", cancellable = true, at = @At(value = "NEW", target = "java/lang/AssertionError"))
private static void arclight$modEntity(CraftServer server, Entity entity, CallbackInfoReturnable<CraftEntity> cir) {
if (entity instanceof LivingEntity) {
if (entity instanceof MobEntity) {
if (entity instanceof AgeableEntity) {
if (entity instanceof AbstractHorseEntity) {
if (entity instanceof AbstractChestedHorseEntity) {
cir.setReturnValue(new ArclightModChestedHorse(server, (AbstractChestedHorseEntity) entity));
if (entity instanceof Mob) {
if (entity instanceof AgableMob) {
if (entity instanceof AbstractHorse) {
if (entity instanceof AbstractChestedHorse) {
cir.setReturnValue(new ArclightModChestedHorse(server, (AbstractChestedHorse) entity));
return;
}
cir.setReturnValue(new ArclightModHorse(server, (AbstractHorseEntity) entity));
cir.setReturnValue(new ArclightModHorse(server, (AbstractHorse) entity));
return;
}
if (entity instanceof TameableEntity) {
cir.setReturnValue(new CraftTameableAnimal(server, (TameableEntity) entity));
if (entity instanceof TamableAnimal) {
cir.setReturnValue(new CraftTameableAnimal(server, (TamableAnimal) entity));
return;
}
cir.setReturnValue(new CraftAgeable(server, (AgeableEntity) entity));
cir.setReturnValue(new CraftAgeable(server, (AgableMob) entity));
return;
}
if (entity instanceof FlyingEntity) {
cir.setReturnValue(new CraftFlying(server, (FlyingEntity) entity));
if (entity instanceof FlyingMob) {
cir.setReturnValue(new CraftFlying(server, (FlyingMob) entity));
return;
}
if (entity instanceof AbstractRaiderEntity) {
cir.setReturnValue(new ArclightModRaider(server, (AbstractRaiderEntity) entity));
if (entity instanceof Raider) {
cir.setReturnValue(new ArclightModRaider(server, (Raider) entity));
return;
}
if (entity instanceof GolemEntity) {
cir.setReturnValue(new CraftGolem(server, (GolemEntity) entity));
if (entity instanceof AbstractGolem) {
cir.setReturnValue(new CraftGolem(server, (AbstractGolem) entity));
return;
}
cir.setReturnValue(new ArclightModMob(server, (MobEntity) entity));
cir.setReturnValue(new ArclightModMob(server, (Mob) entity));
return;
}
cir.setReturnValue(new ArclightModLivingEntity(server, (LivingEntity) entity));
return;
}
if (entity instanceof AbstractMinecartEntity) {
if (entity instanceof ContainerMinecartEntity) {
cir.setReturnValue(new ArclightModMinecartContainer(server, (ContainerMinecartEntity) entity));
if (entity instanceof AbstractMinecart) {
if (entity instanceof AbstractMinecartContainer) {
cir.setReturnValue(new ArclightModMinecartContainer(server, (AbstractMinecartContainer) entity));
return;
}
cir.setReturnValue(new ArclightModMinecart(server, (AbstractMinecartEntity) entity));
cir.setReturnValue(new ArclightModMinecart(server, (AbstractMinecart) entity));
return;
}
if (entity instanceof ProjectileEntity) {
if (entity instanceof Projectile) {
cir.setReturnValue(new ArclightModProjectile(server, entity));
return;
}

View File

@ -4,9 +4,6 @@ import com.google.common.base.Function;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.mod.ArclightMod;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.entity.Entity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v.block.CraftBlock;
@ -20,6 +17,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
@Mixin(value = CraftEventFactory.class, remap = false)
public class CraftEventFactoryMixin {
@ -27,33 +27,33 @@ public class CraftEventFactoryMixin {
@Shadow public static Entity entityDamage;
@Shadow public static Block blockDamage;
@Inject(method = "handleEntityDamageEvent(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/DamageSource;Ljava/util/Map;Ljava/util/Map;Z)Lorg/bukkit/event/entity/EntityDamageEvent;", at = @At("HEAD"))
@Inject(method = "handleEntityDamageEvent(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Ljava/util/Map;Ljava/util/Map;Z)Lorg/bukkit/event/entity/EntityDamageEvent;", at = @At("HEAD"))
private static void arclight$captureSource(Entity entity, DamageSource source, Map<EntityDamageEvent.DamageModifier, Double> modifiers, Map<EntityDamageEvent.DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled, CallbackInfoReturnable<EntityDamageEvent> cir) {
Entity damageEventEntity = ArclightCaptures.getDamageEventEntity();
BlockPos damageEventBlock = ArclightCaptures.getDamageEventBlock();
if (damageEventEntity != null && entityDamage == null) {
if (source.damageType.equals(DamageSource.LIGHTNING_BOLT.damageType)) {
if (source.msgId.equals(DamageSource.LIGHTNING_BOLT.msgId)) {
entityDamage = damageEventEntity;
}
}
if (damageEventBlock != null && blockDamage == null) {
if (source.damageType.equals(DamageSource.CACTUS.damageType)
|| source.damageType.equals(DamageSource.SWEET_BERRY_BUSH.damageType)
|| source.damageType.equals(DamageSource.HOT_FLOOR.damageType)) {
blockDamage = CraftBlock.at(entity.getEntityWorld(), damageEventBlock);
if (source.msgId.equals(DamageSource.CACTUS.msgId)
|| source.msgId.equals(DamageSource.SWEET_BERRY_BUSH.msgId)
|| source.msgId.equals(DamageSource.HOT_FLOOR.msgId)) {
blockDamage = CraftBlock.at(entity.getCommandSenderWorld(), damageEventBlock);
}
}
}
@Inject(method = "handleEntityDamageEvent(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/DamageSource;Ljava/util/Map;Ljava/util/Map;Z)Lorg/bukkit/event/entity/EntityDamageEvent;", cancellable = true, at = @At(value = "NEW", target = "java/lang/IllegalStateException"))
@Inject(method = "handleEntityDamageEvent(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Ljava/util/Map;Ljava/util/Map;Z)Lorg/bukkit/event/entity/EntityDamageEvent;", cancellable = true, at = @At(value = "NEW", target = "java/lang/IllegalStateException"))
private static void arclight$unhandledDamage(Entity entity, DamageSource source, Map<EntityDamageEvent.DamageModifier, Double> modifiers, Map<EntityDamageEvent.DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled, CallbackInfoReturnable<EntityDamageEvent> cir) {
// todo blockDamage is lost
EntityDamageEvent event;
if (source.getTrueSource() != null) {
ArclightMod.LOGGER.debug("Unhandled damage of {} by {} from {}", entity, source.getTrueSource(), source.damageType);
event = new EntityDamageByEntityEvent(((EntityBridge) source.getTrueSource()).bridge$getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), EntityDamageEvent.DamageCause.CUSTOM, modifiers, modifierFunctions);
if (source.getEntity() != null) {
ArclightMod.LOGGER.debug("Unhandled damage of {} by {} from {}", entity, source.getEntity(), source.msgId);
event = new EntityDamageByEntityEvent(((EntityBridge) source.getEntity()).bridge$getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), EntityDamageEvent.DamageCause.CUSTOM, modifiers, modifierFunctions);
} else {
ArclightMod.LOGGER.debug("Unhandled damage of {} from {}", entity, source.damageType);
ArclightMod.LOGGER.debug("Unhandled damage of {} from {}", entity, source.msgId);
event = new EntityDamageEvent(((EntityBridge) entity).bridge$getBukkitEntity(), EntityDamageEvent.DamageCause.CUSTOM, modifiers, modifierFunctions);
}
event.setCancelled(cancelled);

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.mixin.bukkit;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.entity.CraftEntity;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
@ -27,7 +27,7 @@ public abstract class CraftHumanEntityMixin extends CraftEntity {
@Override
public void setHandle(Entity entity) {
super.setHandle(entity);
this.inventory = new CraftInventoryPlayer(((PlayerEntity) entity).inventory);
this.enderChest = new CraftInventory(((PlayerEntity) entity).getInventoryEnderChest());
this.inventory = new CraftInventoryPlayer(((Player) entity).inventory);
this.enderChest = new CraftInventory(((Player) entity).getEnderChestInventory());
}
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.mixin.bukkit;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.LecternTileEntity;
import net.minecraft.world.Container;
import net.minecraft.world.level.block.entity.LecternBlockEntity;
import org.bukkit.craftbukkit.v.inventory.CraftInventory;
import org.bukkit.event.inventory.InventoryType;
import org.spongepowered.asm.mixin.Final;
@ -14,11 +14,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = CraftInventory.class, remap = false)
public class CraftInventoryMixin {
@Shadow @Final protected IInventory inventory;
@Shadow @Final protected Container inventory;
@Inject(method = "getType", cancellable = true, at = @At("HEAD"))
private void arclight$lecternType(CallbackInfoReturnable<InventoryType> cir) {
if (inventory.getClass().getDeclaringClass() == LecternTileEntity.class) {
if (inventory.getClass().getDeclaringClass() == LecternBlockEntity.class) {
cir.setReturnValue(InventoryType.LECTERN);
}
}

View File

@ -3,8 +3,6 @@ package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.common.bridge.bukkit.CraftItemStackBridge;
import io.izzel.arclight.common.bridge.bukkit.ItemMetaBridge;
import io.izzel.arclight.common.bridge.item.ItemStackBridge;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v.legacy.CraftLegacy;
@ -17,6 +15,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Objects;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
@Mixin(value = CraftItemStack.class, remap = false)
public abstract class CraftItemStackMixin implements CraftItemStackBridge {
@ -28,11 +28,11 @@ public abstract class CraftItemStackMixin implements CraftItemStackBridge {
@Shadow public abstract boolean hasItemMeta();
// @formatter:on
@Inject(method = "getItemMeta(Lnet/minecraft/item/ItemStack;)Lorg/bukkit/inventory/meta/ItemMeta;", at = @At("RETURN"))
@Inject(method = "getItemMeta(Lnet/minecraft/world/item/ItemStack;)Lorg/bukkit/inventory/meta/ItemMeta;", at = @At("RETURN"))
private static void arclight$offerCaps(ItemStack item, CallbackInfoReturnable<ItemMeta> cir) {
if (item == null) return;
ItemMeta meta = cir.getReturnValue();
CompoundNBT tag = item.getTag();
CompoundTag tag = item.getTag();
if (tag != null) {
((ItemMetaBridge) meta).bridge$offerUnhandledTags(tag);
}
@ -40,9 +40,9 @@ public abstract class CraftItemStackMixin implements CraftItemStackBridge {
}
// check when update
@Inject(method = "setItemMeta(Lnet/minecraft/item/ItemStack;Lorg/bukkit/inventory/meta/ItemMeta;)Z", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/item/ItemStack;func_77973_b()Lnet/minecraft/item/Item;"))
@Inject(method = "setItemMeta(Lnet/minecraft/world/item/ItemStack;Lorg/bukkit/inventory/meta/ItemMeta;)Z", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/item/ItemStack;func_77973_b()Lnet/minecraft/world/item/Item;"))
private static void arclight$setCaps(ItemStack item, ItemMeta itemMeta, CallbackInfoReturnable<Boolean> cir) {
CompoundNBT forgeCaps = ((ItemMetaBridge) itemMeta).bridge$getForgeCaps();
CompoundTag forgeCaps = ((ItemMetaBridge) itemMeta).bridge$getForgeCaps();
if (forgeCaps != null) {
((ItemStackBridge)(Object) item).bridge$setForgeCaps(forgeCaps.copy());
}
@ -82,10 +82,10 @@ public abstract class CraftItemStackMixin implements CraftItemStackBridge {
: !that.hasItemMeta();
}
@Inject(method = "hasItemMeta(Lnet/minecraft/item/ItemStack;)Z", cancellable = true, at = @At("HEAD"))
@Inject(method = "hasItemMeta(Lnet/minecraft/world/item/ItemStack;)Z", cancellable = true, at = @At("HEAD"))
private static void arclight$hasMeta(ItemStack item, CallbackInfoReturnable<Boolean> cir) {
if (item != null) {
CompoundNBT forgeCaps = ((ItemStackBridge) (Object) item).bridge$getForgeCaps();
CompoundTag forgeCaps = ((ItemStackBridge) (Object) item).bridge$getForgeCaps();
if (forgeCaps != null && !forgeCaps.isEmpty()) {
cir.setReturnValue(true);
}

View File

@ -3,9 +3,6 @@ package io.izzel.arclight.common.mixin.bukkit;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.izzel.arclight.common.bridge.bukkit.ItemMetaBridge;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.INBT;
import org.apache.commons.codec.binary.Base64;
import org.apache.logging.log4j.LogManager;
import org.bukkit.craftbukkit.v.inventory.CraftMetaItem;
@ -24,12 +21,15 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.Tag;
@Mixin(value = CraftMetaItem.class, remap = false)
public class CraftMetaItemMixin implements ItemMetaBridge {
// @formatter:off
@Shadow(remap = false) @Final private Map<String, INBT> unhandledTags;
@Shadow(remap = false) @Final private Map<String, Tag> unhandledTags;
// @formatter:on
private static final Set<String> EXTEND_TAGS = ImmutableSet.of(
@ -60,27 +60,27 @@ public class CraftMetaItemMixin implements ItemMetaBridge {
"LodestoneTracked"
);
@ModifyVariable(method = "<init>(Lnet/minecraft/nbt/CompoundNBT;)V", at = @At(value = "INVOKE", target = "Lorg/bukkit/UnsafeValues;getDataVersion()I"))
private CompoundNBT arclight$provideTag(CompoundNBT tag) {
return tag == null ? new CompoundNBT() : tag;
@ModifyVariable(method = "<init>(Lnet/minecraft/nbt/CompoundTag;)V", at = @At(value = "INVOKE", target = "Lorg/bukkit/UnsafeValues;getDataVersion()I"))
private CompoundTag arclight$provideTag(CompoundTag tag) {
return tag == null ? new CompoundTag() : tag;
}
private CompoundNBT forgeCaps;
private CompoundTag forgeCaps;
@Override
public CompoundNBT bridge$getForgeCaps() {
public CompoundTag bridge$getForgeCaps() {
return this.forgeCaps;
}
@Override
public void bridge$setForgeCaps(CompoundNBT nbt) {
public void bridge$setForgeCaps(CompoundTag nbt) {
this.forgeCaps = nbt;
}
@Override
public void bridge$offerUnhandledTags(CompoundNBT nbt) {
public void bridge$offerUnhandledTags(CompoundTag nbt) {
if (getClass().equals(CraftMetaItem.class)) {
for (String s : nbt.keySet()) {
for (String s : nbt.getAllKeys()) {
if (EXTEND_TAGS.contains(s)) {
this.unhandledTags.put(s, nbt.get(s));
}
@ -89,12 +89,12 @@ public class CraftMetaItemMixin implements ItemMetaBridge {
}
@Override
public Map<String, INBT> bridge$getUnhandledTags() {
public Map<String, Tag> bridge$getUnhandledTags() {
return this.unhandledTags;
}
@Override
public void bridge$setUnhandledTags(Map<String, INBT> tags) {
public void bridge$setUnhandledTags(Map<String, Tag> tags) {
this.unhandledTags.putAll(tags);
}
@ -102,7 +102,7 @@ public class CraftMetaItemMixin implements ItemMetaBridge {
private void arclight$serializeForgeCaps(ImmutableMap.Builder<String, Object> builder, CallbackInfoReturnable<ImmutableMap.Builder<String, Object>> cir) throws IOException {
if (this.forgeCaps != null) {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
CompressedStreamTools.writeCompressed(this.forgeCaps, buf);
NbtIo.writeCompressed(this.forgeCaps, buf);
builder.put("forgeCaps", Base64.encodeBase64String(buf.toByteArray()));
}
}
@ -131,7 +131,7 @@ public class CraftMetaItemMixin implements ItemMetaBridge {
@Inject(method = "equalsCommon", cancellable = true, at = @At("HEAD"))
private void arclight$forgeCapsEquals(CraftMetaItem that, CallbackInfoReturnable<Boolean> cir) {
CompoundNBT forgeCaps = ((ItemMetaBridge) that).bridge$getForgeCaps();
CompoundTag forgeCaps = ((ItemMetaBridge) that).bridge$getForgeCaps();
boolean ret;
if (this.forgeCaps == null) {
ret = forgeCaps != null && forgeCaps.size() != 0;
@ -149,7 +149,7 @@ public class CraftMetaItemMixin implements ItemMetaBridge {
Object forgeCaps = map.get("forgeCaps");
try {
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(forgeCaps.toString()));
this.forgeCaps = CompressedStreamTools.readCompressed(buf);
this.forgeCaps = NbtIo.readCompressed(buf);
} catch (IOException e) {
LogManager.getLogger(getClass()).error("Reading forge caps", e);
}
@ -159,7 +159,7 @@ public class CraftMetaItemMixin implements ItemMetaBridge {
@Inject(method = "<init>*", at = @At("RETURN"))
private void arclight$copyForgeCaps(CraftMetaItem meta, CallbackInfo ci) {
if (meta != null) {
CompoundNBT forgeCaps = ((ItemMetaBridge) meta).bridge$getForgeCaps();
CompoundTag forgeCaps = ((ItemMetaBridge) meta).bridge$getForgeCaps();
if (forgeCaps != null) {
this.forgeCaps = forgeCaps.copy();
}

View File

@ -6,11 +6,11 @@ import io.izzel.arclight.common.bridge.bukkit.CraftServerBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.mod.server.ArclightServer;
import jline.console.ConsoleReader;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.dedicated.DedicatedPlayerList;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.management.PlayerList;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.players.PlayerList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.world.WorldEvent;
@ -90,7 +90,7 @@ public abstract class CraftServerMixin implements CraftServerBridge {
this.playerList = (DedicatedPlayerList) playerList;
}
@Inject(method = "unloadWorld(Lorg/bukkit/World;Z)Z", require = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;getChunkProvider()Lnet/minecraft/world/server/ServerChunkProvider;"))
@Inject(method = "unloadWorld(Lorg/bukkit/World;Z)Z", require = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getChunkSource()Lnet/minecraft/server/level/ServerChunkCache;"))
private void arclight$unloadForge(World world, boolean save, CallbackInfoReturnable<Boolean> cir) {
MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(((CraftWorld) world).getHandle()));
this.console.markWorldsDirty();
@ -98,11 +98,11 @@ public abstract class CraftServerMixin implements CraftServerBridge {
@ModifyVariable(method = "dispatchCommand", remap = false, index = 2, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lorg/spigotmc/AsyncCatcher;catchOp(Ljava/lang/String;)V"))
private String arclight$forgeCommandEvent(String commandLine, CommandSender sender) {
CommandSource commandSource;
CommandSourceStack commandSource;
if (sender instanceof CraftEntity) {
commandSource = ((CraftEntity) sender).getHandle().getCommandSource();
commandSource = ((CraftEntity) sender).getHandle().createCommandSourceStack();
} else if (sender == Bukkit.getConsoleSender()) {
commandSource = ArclightServer.getMinecraftServer().getCommandSource();
commandSource = ArclightServer.getMinecraftServer().createCommandSourceStack();
} else if (sender instanceof CraftBlockCommandSender) {
commandSource = ((CraftBlockCommandSender) sender).getWrapper();
} else {
@ -112,7 +112,7 @@ public abstract class CraftServerMixin implements CraftServerBridge {
if (stringreader.canRead() && stringreader.peek() == '/') {
stringreader.skip();
}
ParseResults<CommandSource> parse = ArclightServer.getMinecraftServer().getCommandManager()
ParseResults<CommandSourceStack> parse = ArclightServer.getMinecraftServer().getCommands()
.getDispatcher().parse(stringreader, commandSource);
CommandEvent event = new CommandEvent(parse);
if (MinecraftForge.EVENT_BUS.post(event)) {
@ -133,7 +133,7 @@ public abstract class CraftServerMixin implements CraftServerBridge {
}
@Override
public void bridge$removeWorld(ServerWorld world) {
public void bridge$removeWorld(ServerLevel world) {
if (world == null) {
return;
}

View File

@ -1,7 +1,7 @@
package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.common.mod.util.ResourceLocationUtil;
import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerProfession;
import org.bukkit.craftbukkit.v.entity.CraftVillager;
import org.bukkit.entity.Villager;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -2,7 +2,6 @@ package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.common.bridge.bukkit.EntityTypeBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.entity.Entity;
@ -18,18 +17,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.File;
import java.util.function.Function;
import net.minecraft.server.level.ServerLevel;
@Mixin(value = CraftWorld.class, remap = false)
public abstract class CraftWorldMixin {
// @formatter:off
@Shadow @Final private ServerWorld world;
@Shadow public abstract <T extends Entity> T addEntity(net.minecraft.entity.Entity entity, CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException;
@Shadow @Final private ServerLevel world;
@Shadow public abstract <T extends Entity> T addEntity(net.minecraft.world.entity.Entity entity, CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException;
// @formatter:on
@Inject(method = "spawnEntity", cancellable = true, at = @At("HEAD"))
private void arclight$useFactory(Location loc, EntityType entityType, CallbackInfoReturnable<Entity> cir) {
Function<Location, ? extends net.minecraft.entity.Entity> factory = ((EntityTypeBridge) (Object) entityType).bridge$entityFactory();
Function<Location, ? extends net.minecraft.world.entity.Entity> factory = ((EntityTypeBridge) (Object) entityType).bridge$entityFactory();
if (factory != null) {
cir.setReturnValue(this.addEntity(factory.apply(loc), CreatureSpawnEvent.SpawnReason.CUSTOM));
}
@ -41,6 +41,6 @@ public abstract class CraftWorldMixin {
*/
@Overwrite
public File getWorldFolder() {
return ((ServerWorldBridge) this.world).bridge$getConvertable().getDimensionFolder(this.world.getDimensionKey());
return ((ServerWorldBridge) this.world).bridge$getConvertable().getDimensionPath(this.world.dimension());
}
}

View File

@ -4,8 +4,6 @@ import io.izzel.arclight.common.bridge.bukkit.EntityTypeBridge;
import io.izzel.arclight.common.mod.ArclightMod;
import io.izzel.arclight.i18n.LocalizedException;
import io.izzel.arclight.i18n.conf.EntityPropertySpec;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v.CraftWorld;
@ -18,6 +16,8 @@ import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import java.util.function.Function;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
@Mixin(value = EntityType.class, remap = false)
public class EntityTypeMixin implements EntityTypeBridge {
@ -28,12 +28,12 @@ public class EntityTypeMixin implements EntityTypeBridge {
@Shadow @Final @Mutable private String name;
// @formatter:on
private net.minecraft.entity.EntityType<?> handleType;
private net.minecraft.world.entity.EntityType<?> handleType;
private EntityPropertySpec spec;
private Function<Location, ? extends net.minecraft.entity.Entity> factory;
private Function<Location, ? extends net.minecraft.world.entity.Entity> factory;
@Override
public void bridge$setup(ResourceLocation location, net.minecraft.entity.EntityType<?> entityType, EntityPropertySpec spec) {
public void bridge$setup(ResourceLocation location, net.minecraft.world.entity.EntityType<?> entityType, EntityPropertySpec spec) {
this.key = CraftNamespacedKey.fromMinecraft(location);
this.name = location.toString();
this.handleType = entityType;
@ -60,10 +60,10 @@ public class EntityTypeMixin implements EntityTypeBridge {
}
this.factory = loc -> {
if (loc != null && loc.getWorld() != null) {
ServerWorld world = ((CraftWorld) loc.getWorld()).getHandle();
net.minecraft.entity.Entity entity = handleType.create(world);
ServerLevel world = ((CraftWorld) loc.getWorld()).getHandle();
net.minecraft.world.entity.Entity entity = handleType.create(world);
if (entity != null) {
entity.setPositionAndRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
entity.absMoveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
}
return entity;
} else return null;
@ -71,7 +71,7 @@ public class EntityTypeMixin implements EntityTypeBridge {
}
@Override
public net.minecraft.entity.EntityType<?> bridge$getHandle() {
public net.minecraft.world.entity.EntityType<?> bridge$getHandle() {
return this.handleType;
}
@ -81,12 +81,12 @@ public class EntityTypeMixin implements EntityTypeBridge {
}
@Override
public Function<Location, ? extends net.minecraft.entity.Entity> bridge$entityFactory() {
public Function<Location, ? extends net.minecraft.world.entity.Entity> bridge$entityFactory() {
return factory;
}
@Override
public void bridge$setEntityFactory(Function<Location, ? extends net.minecraft.entity.Entity> function) {
public void bridge$setEntityFactory(Function<Location, ? extends net.minecraft.world.entity.Entity> function) {
this.factory = function;
}
}

View File

@ -7,14 +7,6 @@ import io.izzel.arclight.common.mod.ArclightMod;
import io.izzel.arclight.common.mod.server.block.ArclightTileInventory;
import io.izzel.arclight.i18n.LocalizedException;
import io.izzel.arclight.i18n.conf.MaterialPropertySpec;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FallingBlock;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.BlockState;
@ -54,6 +46,14 @@ import java.lang.reflect.Constructor;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
@Mixin(value = Material.class, remap = false)
public abstract class MaterialMixin implements MaterialBridge {
@ -313,13 +313,13 @@ public abstract class MaterialMixin implements MaterialBridge {
arclight$spec.record = false;
}
if (arclight$spec.solid == null) {
arclight$spec.solid = block != null && block.getDefaultState().isSolid();
arclight$spec.solid = block != null && block.defaultBlockState().canOcclude();
}
if (arclight$spec.air == null) {
arclight$spec.air = block != null && block.getDefaultState().isAir();
arclight$spec.air = block != null && block.defaultBlockState().isAir();
}
if (arclight$spec.transparent == null) {
arclight$spec.transparent = block != null && block.getDefaultState().isTransparent();
arclight$spec.transparent = block != null && block.defaultBlockState().useShapeForLightOcclusion();
}
if (arclight$spec.flammable == null) {
arclight$spec.flammable = block != null && ((FireBlockBridge) Blocks.FIRE).bridge$canBurn(block);
@ -340,7 +340,7 @@ public abstract class MaterialMixin implements MaterialBridge {
arclight$spec.interactable = true;
}
if (arclight$spec.hardness == null) {
arclight$spec.hardness = block != null ? block.getDefaultState().hardness : 0;
arclight$spec.hardness = block != null ? block.defaultBlockState().destroySpeed : 0;
}
if (arclight$spec.blastResistance == null) {
arclight$spec.blastResistance = block != null ? block.getExplosionResistance() : 0;
@ -391,8 +391,8 @@ public abstract class MaterialMixin implements MaterialBridge {
}
if (this.arclight$stateFunc == null) {
this.arclight$stateFunc = b -> {
TileEntity tileEntity = b.getCraftWorld().getHandle().getTileEntity(b.getPosition());
if (tileEntity instanceof IInventory) {
BlockEntity tileEntity = b.getCraftWorld().getHandle().getBlockEntity(b.getPosition());
if (tileEntity instanceof Container) {
return new ArclightTileInventory(b, tileEntity.getClass());
}
return tileEntity == null ? new CraftBlockState(b) : new CraftBlockEntityState<>(b, tileEntity.getClass());

View File

@ -1,9 +1,6 @@
package io.izzel.arclight.common.mixin.bukkit;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.ResourceLocation;
import org.bukkit.craftbukkit.v.inventory.RecipeIterator;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Final;
@ -13,13 +10,15 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Iterator;
import java.util.Map;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeType;
@Mixin(value = RecipeIterator.class, remap = false)
public class RecipeIteratorMixin {
// @formatter:off
@Shadow private Iterator<IRecipe<?>> current;
@Shadow @Final private Iterator<Map.Entry<IRecipeType<?>, Map<ResourceLocation, IRecipe<?>>>> recipes;
@Shadow private Iterator<net.minecraft.world.item.crafting.Recipe<?>> current;
@Shadow @Final private Iterator<Map.Entry<RecipeType<?>, Map<ResourceLocation, net.minecraft.world.item.crafting.Recipe<?>>>> recipes;
// @formatter:on
/**

View File

@ -1,17 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(AbstractBlock.class)
public abstract class AbstractBlockMixin {
// @formatter:off
@Shadow public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { return null; }
// @formatter:on
}

View File

@ -1,25 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.block.AbstractBlock;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(AbstractBlock.AbstractBlockState.class)
public class AbstractBlock_AbstractBlockStateMixin {
@Inject(method = "onEntityCollision", at = @At("HEAD"))
private void arclight$captureBlockCollide(World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
ArclightCaptures.captureDamageEventBlock(pos);
}
@Inject(method = "onEntityCollision", at = @At("RETURN"))
private void arclight$resetBlockCollide(World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
ArclightCaptures.captureDamageEventBlock(null);
}
}

View File

@ -1,22 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(AbstractFireBlock.class)
public class AbstractFireBlockMixin {
@Redirect(method = "onBlockAdded", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public boolean arclight$extinguish2(World world, BlockPos pos, boolean isMoving) {
if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
world.removeBlock(pos, isMoving);
}
return false;
}
}

View File

@ -1,38 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractPressurePlateBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent;
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.Redirect;
@Mixin(AbstractPressurePlateBlock.class)
public abstract class AbstractPressurePlateBlockMixin {
// @formatter:off
@Shadow protected abstract int computeRedstoneStrength(World worldIn, BlockPos pos);
@Shadow @Final protected static AxisAlignedBB PRESSURE_AABB;
// @formatter:on
@Redirect(method = "updateState", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/AbstractPressurePlateBlock;computeRedstoneStrength(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)I"))
public int arclight$blockRedstone(AbstractPressurePlateBlock abstractPressurePlateBlock, World worldIn, BlockPos pos, World world, BlockPos blockPos, BlockState state, int oldRedstoneStrength) {
int newStrength = this.computeRedstoneStrength(worldIn, pos);
boolean flag = oldRedstoneStrength > 0;
boolean flag1 = newStrength > 0;
if (flag != flag1) {
BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(worldIn, blockPos), oldRedstoneStrength, newStrength);
Bukkit.getPluginManager().callEvent(event);
newStrength = event.getNewCurrent();
}
return newStrength;
}
}

View File

@ -1,21 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractTopPlantBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Random;
@Mixin(AbstractTopPlantBlock.class)
public class AbstractTopPlantBlockMixin {
@Redirect(method = "randomTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
private boolean arclight$blockGrow(ServerWorld world, BlockPos to, BlockState state, BlockState state1, ServerWorld worldIn, BlockPos from, Random random) {
return CraftEventFactory.handleBlockSpreadEvent(world, from, to, state);
}
}

View File

@ -1,63 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BambooBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.properties.BambooLeaves;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Random;
@Mixin(BambooBlock.class)
public abstract class BambooBlockMixin extends BlockMixin {
@Shadow @Final public static EnumProperty<BambooLeaves> PROPERTY_BAMBOO_LEAVES;
@Shadow @Final public static IntegerProperty PROPERTY_AGE;
@Shadow @Final public static IntegerProperty PROPERTY_STAGE;
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void grow(BlockState blockStateIn, World worldIn, BlockPos posIn, Random rand, int height) {
BlockState blockstate = worldIn.getBlockState(posIn.down());
BlockPos blockpos = posIn.down(2);
BlockState blockstate1 = worldIn.getBlockState(blockpos);
BambooLeaves bambooleaves = BambooLeaves.NONE;
boolean update = false;
if (height >= 1) {
if (blockstate.isIn(Blocks.BAMBOO) && blockstate.get(PROPERTY_BAMBOO_LEAVES) != BambooLeaves.NONE) {
if (blockstate.isIn(Blocks.BAMBOO) && blockstate.get(PROPERTY_BAMBOO_LEAVES) != BambooLeaves.NONE) {
bambooleaves = BambooLeaves.LARGE;
if (blockstate1.isIn(Blocks.BAMBOO)) {
update = true;
}
}
} else {
bambooleaves = BambooLeaves.SMALL;
}
}
int newAge = blockStateIn.get(PROPERTY_AGE) != 1 && !blockstate1.isIn(Blocks.BAMBOO) ? 0 : 1;
int newState = (height < 11 || !(rand.nextFloat() < 0.25F)) && height != 15 ? 0 : 1;
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, posIn, posIn.up(),
this.getDefaultState().with(PROPERTY_AGE, newAge).with(PROPERTY_BAMBOO_LEAVES, bambooleaves).with(PROPERTY_STAGE, newState), 3)) {
if (update) {
worldIn.setBlockState(posIn.down(), blockstate.with(PROPERTY_BAMBOO_LEAVES, BambooLeaves.SMALL), 3);
worldIn.setBlockState(blockpos, blockstate1.with(PROPERTY_BAMBOO_LEAVES, BambooLeaves.NONE), 3);
}
}
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BambooSaplingBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BambooSaplingBlock.class)
public class BambooSaplingBlockMixin {
@Redirect(method = "growBamboo", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockSpread(World world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockSpreadEvent(world, pos.down(), pos, newState, flags);
}
}

View File

@ -1,85 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.block.BlockBridge;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.extensions.IForgeBlock;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.block.BlockBreakEvent;
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.callback.CallbackInfo;
import javax.annotation.Nullable;
import java.util.List;
@Mixin(Block.class)
public abstract class BlockMixin extends AbstractBlockMixin implements BlockBridge {
// @formatter:off
@Shadow public abstract BlockState getDefaultState();
@Shadow @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) { return null; }
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack) {
if (!worldIn.isRemote && !stack.isEmpty() && worldIn.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) && !worldIn.restoringBlockSnapshots) {
float f = 0.5F;
double d0 = (double) (worldIn.rand.nextFloat() * 0.5F) + 0.25D;
double d1 = (double) (worldIn.rand.nextFloat() * 0.5F) + 0.25D;
double d2 = (double) (worldIn.rand.nextFloat() * 0.5F) + 0.25D;
ItemEntity itemEntity = new ItemEntity(worldIn, (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, stack);
itemEntity.setDefaultPickupDelay();
List<ItemEntity> blockDrops = ArclightCaptures.getBlockDrops();
if (blockDrops == null) {
worldIn.addEntity(itemEntity);
} else {
blockDrops.add(itemEntity);
}
}
}
public int getExpDrop(BlockState blockState, ServerWorld world, BlockPos blockPos, ItemStack itemStack) {
int silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemStack);
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, itemStack);
return ((IForgeBlock) this).getExpDrop(blockState, world, blockPos, fortune, silkTouch);
}
@Override
public int bridge$getExpDrop(BlockState blockState, ServerWorld world, BlockPos blockPos, ItemStack itemStack) {
return getExpDrop(blockState, world, blockPos, itemStack);
}
@Inject(method = "harvestBlock", at = @At("RETURN"))
private void arclight$handleBlockDrops(World worldIn, PlayerEntity player, BlockPos pos, BlockState blockState, TileEntity te, ItemStack stack, CallbackInfo ci) {
List<ItemEntity> blockDrops = ArclightCaptures.getBlockDrops();
org.bukkit.block.BlockState state = ArclightCaptures.getBlockBreakPlayerState();
BlockBreakEvent breakEvent = ArclightCaptures.resetBlockBreakPlayer();
if (player instanceof ServerPlayerEntity && blockDrops != null && (breakEvent == null || breakEvent.isDropItems())) {
CraftBlock craftBlock = CraftBlock.at(((CraftWorld) state.getWorld()).getHandle(), pos);
CraftEventFactory.handleBlockDropItemEvent(craftBlock, state, ((ServerPlayerEntity) player), blockDrops);
}
}
}

View File

@ -1,25 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BushBlock;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BushBlock.class)
public abstract class BushBlockMixin extends BlockMixin {
@Redirect(method = "updatePostPlacement", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getDefaultState()Lnet/minecraft/block/BlockState;"))
public BlockState arclight$blockFade(Block block, BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
if (!CraftEventFactory.callBlockPhysicsEvent(worldIn, currentPos).isCancelled()) {
return block.getDefaultState();
} else {
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
}
}
}

View File

@ -1,28 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.CakeBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.FoodStats;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CakeBlock.class)
public class CakeBlockMixin {
@Redirect(method = "eatSlice", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/FoodStats;addStats(IF)V"))
private void arclight$eatCake(FoodStats foodStats, int foodLevelIn, float foodSaturationModifier, IWorld worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
int old = foodStats.getFoodLevel();
FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(player, old + foodLevelIn);
if (!event.isCancelled()) {
foodStats.addStats(event.getFoodLevel() - old, foodSaturationModifier);
}
((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().sendHealthUpdate();
}
}

View File

@ -1,23 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CampfireBlock;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(CampfireBlock.class)
public class CampfireBlockMixin {
@Inject(method = "onProjectileCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$onFire(World worldIn, BlockState state, BlockRayTraceResult hit, ProjectileEntity projectile, CallbackInfo ci) {
if (CraftEventFactory.callBlockIgniteEvent(worldIn, hit.getPos(), projectile).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,103 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.CauldronBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.CauldronLevelChangeEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CauldronBlock.class)
public class CauldronBlockMixin {
@Inject(method = "onEntityCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;extinguish()V"))
public void arclight$extinguish(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, entityIn, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
ci.cancel();
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;"))
public void arclight$levelChange(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<ActionResultType> cir) {
ItemStack itemStack = player.getHeldItem(handIn);
Item item = itemStack.getItem();
int i = state.get(CauldronBlock.LEVEL);
int newLevel;
CauldronLevelChangeEvent.ChangeReason reason;
if (item == Items.WATER_BUCKET) {
reason = CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY;
newLevel = 3;
} else if (item == Items.BUCKET) {
reason = CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL;
newLevel = 0;
} else if (item == Items.GLASS_BOTTLE) {
reason = CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL;
newLevel = i - 1;
} else if (item == Items.POTION && PotionUtils.getPotionFromItem(itemStack) == Potions.WATER) {
reason = CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY;
newLevel = i + 1;
} else {
reason = null;
newLevel = 0;
}
if (reason != null && !changeLevel(worldIn, pos, state, newLevel, player, reason)) {
cir.setReturnValue(ActionResultType.SUCCESS);
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/IDyeableArmorItem;removeColor(Lnet/minecraft/item/ItemStack;)V"))
public void arclight$removeColor(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<ActionResultType> cir) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, player, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
cir.setReturnValue(ActionResultType.SUCCESS);
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/BannerTileEntity;removeBannerData(Lnet/minecraft/item/ItemStack;)V"))
public void arclight$removeBanner(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<ActionResultType> cir) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, player, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
cir.setReturnValue(ActionResultType.SUCCESS);
}
}
@Inject(method = "fillWithRain", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$fillRain(World worldIn, BlockPos pos, CallbackInfo ci) {
BlockState state = worldIn.getBlockState(pos);
BlockState cycle = state.cycleValue(CauldronBlock.LEVEL);
int newLevel = cycle.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, newLevel, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN)) {
ci.cancel();
}
}
private boolean changeLevel(World world, BlockPos pos, BlockState state, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
int newLevel = MathHelper.clamp(i, 0, 3);
CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
CraftBlock.at(world, pos),
(entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(),
reason, state.get(CauldronBlock.LEVEL), newLevel
);
Bukkit.getPluginManager().callEvent(event);
return !event.isCancelled();
}
}

View File

@ -1,24 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks;
import net.minecraft.inventory.DoubleSidedInventory;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.tileentity.ChestTileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import java.util.Optional;
@Mixin(targets = "net/minecraft/block/ChestBlock$2")
public class ChestBlock2Mixin {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public Optional<INamedContainerProvider> func_225539_a_(final ChestTileEntity p_225539_1_, final ChestTileEntity p_225539_2_) {
final DoubleSidedInventory iinventory = new DoubleSidedInventory(p_225539_1_, p_225539_2_);
return Optional.ofNullable(ChestBlockDoubleInventoryHacks.create(p_225539_1_, p_225539_2_, iinventory));
}
}

View File

@ -1,24 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CocoaBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CocoaBlock.class)
public class CocoaBlockMixin {
@Redirect(method = "randomTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrow1(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
@Redirect(method = "grow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean arclight$blockGrow2(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -1,50 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CommandBlockBlock;
import net.minecraft.tileentity.CommandBlockTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(CommandBlockBlock.class)
public abstract class CommandBlockBlockMixin {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
if (!worldIn.isRemote) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof CommandBlockTileEntity) {
CommandBlockTileEntity commandblocktileentity = (CommandBlockTileEntity) tileentity;
boolean flag = worldIn.isBlockPowered(pos);
boolean flag1 = commandblocktileentity.isPowered();
org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldIn, pos);
int old = flag1 ? 15 : 0;
int current = flag ? 15 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
Bukkit.getPluginManager().callEvent(eventRedstone);
flag = eventRedstone.getNewCurrent() > 0;
commandblocktileentity.setPowered(flag);
if (!flag1 && !commandblocktileentity.isAuto() && commandblocktileentity.getMode() != CommandBlockTileEntity.Mode.SEQUENCE) {
if (flag) {
commandblocktileentity.setConditionMet();
worldIn.getPendingBlockTicks().scheduleTick(pos, (CommandBlockBlock) (Object) this, 1);
}
}
}
}
}
}

View File

@ -1,29 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ComparatorBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ComparatorBlock.class)
public class ComparatorBlockMixin {
@Inject(method = "onStateChange", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$blockRedstone1(World worldIn, BlockPos pos, BlockState state, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) {
ci.cancel();
}
}
@Inject(method = "onStateChange", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$blockRedstone2(World worldIn, BlockPos pos, BlockState state, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) {
ci.cancel();
}
}
}

View File

@ -1,47 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mixin.core.inventory.InventoryMixin;
import net.minecraft.block.BlockState;
import net.minecraft.block.ComposterBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.craftbukkit.v.inventory.CraftBlockInventoryHolder;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(targets = "net.minecraft.block.ComposterBlock$FullInventory")
public abstract class ComposterBlock_FullInventoryMixin extends InventoryMixin {
// @formatter:off
@Shadow @Final private BlockState state;
@Shadow @Final private IWorld world;
@Shadow @Final private BlockPos pos;
@Shadow private boolean extracted;
// @formatter:on
@Inject(method = "<init>(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)V", at = @At("RETURN"))
public void arclight$setOwner(BlockState blockState, IWorld world, BlockPos blockPos, ItemStack itemStack, CallbackInfo ci) {
this.setOwner(new CraftBlockInventoryHolder(world, blockPos, this));
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void markDirty() {
if (this.isEmpty()) {
ComposterBlock.resetFillState(this.state, this.world, this.pos);
this.extracted = true;
} else {
this.world.setBlockState(this.pos, this.state, 3);
this.extracted = false;
}
}
}

View File

@ -1,20 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mixin.core.inventory.InventoryMixin;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.craftbukkit.v.inventory.CraftBlockInventoryHolder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(targets = "net.minecraft.block.ComposterBlock$PartialInventory")
public abstract class ComposterBlock_PartialInventoryMixin extends InventoryMixin {
@Inject(method = "<init>(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;)V", at = @At("RETURN"))
public void arclight$setOwner(BlockState blockState, IWorld world, BlockPos blockPos, CallbackInfo ci) {
this.setOwner(new CraftBlockInventoryHolder(world, blockPos, this));
}
}

View File

@ -1,32 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CoralFinBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(CoralFinBlock.class)
public class CoralFinBlockMixin {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState().with(AbstractCoralPlantBlock.WATERLOGGED, false)).isCancelled()) {
ci.cancel();
}
}
}

Some files were not shown because too many files have changed in this diff Show More