mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Add 1.16 support, drop 1.14 (#141)
This commit is contained in:
parent
1228fc2de2
commit
201a3578bf
7 changed files with 160 additions and 176 deletions
|
@ -152,7 +152,7 @@ The final file is `target/OpenInv.jar`
|
||||||
|
|
||||||
## License
|
## License
|
||||||
```
|
```
|
||||||
Copyright (C) 2011-2019 lishid. All rights reserved.
|
Copyright (C) 2011-2020 lishid. All rights reserved.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
<id>all</id>
|
<id>all</id>
|
||||||
<modules>
|
<modules>
|
||||||
<module>v1_8_R3</module>
|
<module>v1_8_R3</module>
|
||||||
<module>v1_14_R1</module>
|
|
||||||
<module>v1_15_R1</module>
|
<module>v1_15_R1</module>
|
||||||
|
<module>v1_16_R1</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@
|
||||||
<version>4.1.2-SNAPSHOT</version>
|
<version>4.1.2-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>openinvadapter1_14_R1</artifactId>
|
<artifactId>openinvadapter1_16_R1</artifactId>
|
||||||
<name>OpenInvAdapter1_14_R1</name>
|
<name>OpenInvAdapter1_16_R1</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.14.3-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
|
@ -14,40 +14,40 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_14_R1;
|
package com.lishid.openinv.internal.v1_16_R1;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import net.minecraft.server.v1_14_R1.Block;
|
import net.minecraft.server.v1_16_R1.Block;
|
||||||
import net.minecraft.server.v1_14_R1.BlockBarrel;
|
import net.minecraft.server.v1_16_R1.BlockBarrel;
|
||||||
import net.minecraft.server.v1_14_R1.BlockChest;
|
import net.minecraft.server.v1_16_R1.BlockChest;
|
||||||
import net.minecraft.server.v1_14_R1.BlockChestTrapped;
|
import net.minecraft.server.v1_16_R1.BlockChestTrapped;
|
||||||
import net.minecraft.server.v1_14_R1.BlockEnderChest;
|
import net.minecraft.server.v1_16_R1.BlockEnderChest;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPropertyChestType;
|
import net.minecraft.server.v1_16_R1.BlockPropertyChestType;
|
||||||
import net.minecraft.server.v1_14_R1.BlockShulkerBox;
|
import net.minecraft.server.v1_16_R1.BlockShulkerBox;
|
||||||
import net.minecraft.server.v1_14_R1.ChatMessage;
|
import net.minecraft.server.v1_16_R1.ChatMessage;
|
||||||
import net.minecraft.server.v1_14_R1.Container;
|
import net.minecraft.server.v1_16_R1.Container;
|
||||||
import net.minecraft.server.v1_14_R1.ContainerChest;
|
import net.minecraft.server.v1_16_R1.ContainerChest;
|
||||||
import net.minecraft.server.v1_14_R1.Containers;
|
import net.minecraft.server.v1_16_R1.Containers;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_14_R1.EnumChatFormat;
|
import net.minecraft.server.v1_16_R1.EnumChatFormat;
|
||||||
import net.minecraft.server.v1_14_R1.EnumGamemode;
|
import net.minecraft.server.v1_16_R1.EnumGamemode;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.IChatBaseComponent;
|
import net.minecraft.server.v1_16_R1.IChatBaseComponent;
|
||||||
import net.minecraft.server.v1_14_R1.ITileInventory;
|
import net.minecraft.server.v1_16_R1.ITileInventory;
|
||||||
import net.minecraft.server.v1_14_R1.InventoryEnderChest;
|
import net.minecraft.server.v1_16_R1.InventoryEnderChest;
|
||||||
import net.minecraft.server.v1_14_R1.InventoryLargeChest;
|
import net.minecraft.server.v1_16_R1.InventoryLargeChest;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerInteractManager;
|
import net.minecraft.server.v1_16_R1.PlayerInteractManager;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerInventory;
|
import net.minecraft.server.v1_16_R1.PlayerInventory;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntity;
|
import net.minecraft.server.v1_16_R1.TileEntity;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntityChest;
|
import net.minecraft.server.v1_16_R1.TileEntityChest;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntityEnderChest;
|
import net.minecraft.server.v1_16_R1.TileEntityEnderChest;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntityLootable;
|
import net.minecraft.server.v1_16_R1.TileEntityLootable;
|
||||||
import net.minecraft.server.v1_14_R1.TileInventory;
|
import net.minecraft.server.v1_16_R1.TileInventory;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
import net.minecraft.server.v1_16_R1.World;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.block.Barrel;
|
import org.bukkit.block.Barrel;
|
||||||
|
@ -216,7 +216,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return new ContainerChest(containers, containerCounter, playerInventory, enderChest, rows);
|
return new ContainerChest(containers, containerCounter, playerInventory, enderChest, rows);
|
||||||
}, BlockEnderChest.d));
|
}, BlockEnderChest.e));
|
||||||
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
|
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -231,16 +231,16 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||||
|
|
||||||
if (block instanceof BlockChest) {
|
if (block instanceof BlockChest) {
|
||||||
|
|
||||||
BlockPropertyChestType chestType = blockData.get(BlockChest.b);
|
BlockPropertyChestType chestType = blockData.get(BlockChest.c);
|
||||||
|
|
||||||
if (chestType != BlockPropertyChestType.SINGLE) {
|
if (chestType != BlockPropertyChestType.SINGLE) {
|
||||||
|
|
||||||
BlockPosition adjacentBlockPosition = blockPosition.shift(BlockChest.j(blockData));
|
BlockPosition adjacentBlockPosition = blockPosition.shift(BlockChest.h(blockData));
|
||||||
IBlockData adjacentBlockData = world.getType(adjacentBlockPosition);
|
IBlockData adjacentBlockData = world.getType(adjacentBlockPosition);
|
||||||
|
|
||||||
if (adjacentBlockData.getBlock() == block) {
|
if (adjacentBlockData.getBlock() == block) {
|
||||||
|
|
||||||
BlockPropertyChestType adjacentChestType = adjacentBlockData.get(BlockChest.b);
|
BlockPropertyChestType adjacentChestType = adjacentBlockData.get(BlockChest.c);
|
||||||
|
|
||||||
if (adjacentChestType != BlockPropertyChestType.SINGLE && chestType != adjacentChestType
|
if (adjacentChestType != BlockPropertyChestType.SINGLE && chestType != adjacentChestType
|
||||||
&& adjacentBlockData.get(BlockChest.FACING) == blockData.get(BlockChest.FACING)) {
|
&& adjacentBlockData.get(BlockChest.FACING) == blockData.get(BlockChest.FACING)) {
|
|
@ -14,7 +14,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_14_R1;
|
package com.lishid.openinv.internal.v1_16_R1;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IPlayerDataManager;
|
import com.lishid.openinv.internal.IPlayerDataManager;
|
||||||
|
@ -23,30 +23,32 @@ import com.mojang.authlib.GameProfile;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import net.minecraft.server.v1_14_R1.ChatComponentText;
|
import net.minecraft.server.v1_16_R1.ChatComponentText;
|
||||||
import net.minecraft.server.v1_14_R1.ChatMessageType;
|
import net.minecraft.server.v1_16_R1.ChatMessageType;
|
||||||
import net.minecraft.server.v1_14_R1.Container;
|
import net.minecraft.server.v1_16_R1.Container;
|
||||||
import net.minecraft.server.v1_14_R1.Containers;
|
import net.minecraft.server.v1_16_R1.Containers;
|
||||||
import net.minecraft.server.v1_14_R1.DimensionManager;
|
import net.minecraft.server.v1_16_R1.Entity;
|
||||||
import net.minecraft.server.v1_14_R1.Entity;
|
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_14_R1.MinecraftServer;
|
import net.minecraft.server.v1_16_R1.NBTCompressedStreamTools;
|
||||||
import net.minecraft.server.v1_14_R1.NBTCompressedStreamTools;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.PacketPlayOutChat;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutChat;
|
import net.minecraft.server.v1_16_R1.PacketPlayOutOpenWindow;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutOpenWindow;
|
import net.minecraft.server.v1_16_R1.PlayerInteractManager;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerInteractManager;
|
import net.minecraft.server.v1_16_R1.PlayerInventory;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerInventory;
|
import net.minecraft.server.v1_16_R1.SystemUtils;
|
||||||
import net.minecraft.server.v1_14_R1.WorldNBTStorage;
|
import net.minecraft.server.v1_16_R1.World;
|
||||||
|
import net.minecraft.server.v1_16_R1.WorldNBTStorage;
|
||||||
|
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_16_R1.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftContainer;
|
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
@ -57,7 +59,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class PlayerDataManager implements IPlayerDataManager {
|
public class PlayerDataManager implements IPlayerDataManager {
|
||||||
|
|
||||||
private Field bukkitEntity;
|
private @Nullable Field bukkitEntity;
|
||||||
|
|
||||||
public PlayerDataManager() {
|
public PlayerDataManager() {
|
||||||
try {
|
try {
|
||||||
|
@ -90,6 +92,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
||||||
return nmsPlayer;
|
return nmsPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Player loadPlayer(@NotNull final OfflinePlayer offline) {
|
public Player loadPlayer(@NotNull final OfflinePlayer offline) {
|
||||||
// Ensure player has data
|
// Ensure player has data
|
||||||
|
@ -98,11 +101,17 @@ public class PlayerDataManager implements IPlayerDataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a profile and entity to load the player data
|
// Create a profile and entity to load the player data
|
||||||
|
// See net.minecraft.server.PlayerList#attemptLogin
|
||||||
GameProfile profile = new GameProfile(offline.getUniqueId(),
|
GameProfile profile = new GameProfile(offline.getUniqueId(),
|
||||||
offline.getName() != null ? offline.getName() : offline.getUniqueId().toString());
|
offline.getName() != null ? offline.getName() : offline.getUniqueId().toString());
|
||||||
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(DimensionManager.OVERWORLD), profile,
|
WorldServer worldServer = server.getWorldServer(World.OVERWORLD);
|
||||||
new PlayerInteractManager(server.getWorldServer(DimensionManager.OVERWORLD)));
|
|
||||||
|
if (worldServer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityPlayer entity = new EntityPlayer(server, worldServer, profile, new PlayerInteractManager(worldServer));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
injectPlayer(entity);
|
injectPlayer(entity);
|
||||||
|
@ -133,7 +142,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
||||||
super.saveData();
|
super.saveData();
|
||||||
// See net.minecraft.server.WorldNBTStorage#save(EntityPlayer)
|
// See net.minecraft.server.WorldNBTStorage#save(EntityPlayer)
|
||||||
try {
|
try {
|
||||||
WorldNBTStorage worldNBTStorage = (WorldNBTStorage) player.server.getPlayerList().playerFileData;
|
WorldNBTStorage worldNBTStorage = player.server.getPlayerList().playerFileData;
|
||||||
|
|
||||||
NBTTagCompound playerData = player.save(new NBTTagCompound());
|
NBTTagCompound playerData = player.save(new NBTTagCompound());
|
||||||
|
|
||||||
|
@ -280,7 +289,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
||||||
|
|
||||||
// For action bar chat, color codes are still supported but JSON text color is not allowed. Do not convert text.
|
// For action bar chat, color codes are still supported but JSON text color is not allowed. Do not convert text.
|
||||||
if (nmsPlayer.playerConnection != null) {
|
if (nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(new PacketPlayOutChat(new ChatComponentText(message), ChatMessageType.GAME_INFO));
|
nmsPlayer.playerConnection.sendPacket(new PacketPlayOutChat(new ChatComponentText(message), ChatMessageType.GAME_INFO, SystemUtils.b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,25 +14,26 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_14_R1;
|
package com.lishid.openinv.internal.v1_16_R1;
|
||||||
|
|
||||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.server.v1_14_R1.AutoRecipeStackManager;
|
import net.minecraft.server.v1_16_R1.AutoRecipeStackManager;
|
||||||
import net.minecraft.server.v1_14_R1.ContainerUtil;
|
import net.minecraft.server.v1_16_R1.ContainerUtil;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_14_R1.IInventoryListener;
|
import net.minecraft.server.v1_16_R1.IInventoryListener;
|
||||||
import net.minecraft.server.v1_14_R1.InventoryEnderChest;
|
import net.minecraft.server.v1_16_R1.InventoryEnderChest;
|
||||||
import net.minecraft.server.v1_14_R1.ItemStack;
|
import net.minecraft.server.v1_16_R1.ItemStack;
|
||||||
import net.minecraft.server.v1_14_R1.NonNullList;
|
import net.minecraft.server.v1_16_R1.NonNullList;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEnderChest {
|
public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEnderChest {
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public @Nullable Location getLocation() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(int i) {
|
public ItemStack getItem(int i) {
|
||||||
return i >= 0 && i < this.items.size() ? this.items.get(i) : ItemStack.a;
|
return i >= 0 && i < this.items.size() ? this.items.get(i) : ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -153,7 +154,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
|
||||||
if (itemstack2.isEmpty()) {
|
if (itemstack2.isEmpty()) {
|
||||||
this.setItem(i, itemstack1);
|
this.setItem(i, itemstack1);
|
||||||
this.update();
|
this.update();
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ItemStack.c(itemstack2, itemstack1)) {
|
if (ItemStack.c(itemstack2, itemstack1)) {
|
||||||
|
@ -164,7 +165,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
|
||||||
itemstack1.subtract(k);
|
itemstack1.subtract(k);
|
||||||
if (itemstack1.isEmpty()) {
|
if (itemstack1.isEmpty()) {
|
||||||
this.update();
|
this.update();
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,9 +182,9 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
|
||||||
public ItemStack splitWithoutUpdate(int i) {
|
public ItemStack splitWithoutUpdate(int i) {
|
||||||
ItemStack itemstack = this.items.get(i);
|
ItemStack itemstack = this.items.get(i);
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
} else {
|
} else {
|
||||||
this.items.set(i, ItemStack.a);
|
this.items.set(i, ItemStack.b);
|
||||||
return itemstack;
|
return itemstack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNotEmpty() {
|
public boolean isEmpty() {
|
||||||
|
|
||||||
for (ItemStack itemstack : this.items) {
|
for (ItemStack itemstack : this.items) {
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
|
@ -14,7 +14,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_14_R1;
|
package com.lishid.openinv.internal.v1_16_R1;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
||||||
|
@ -22,29 +22,31 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import net.minecraft.server.v1_14_R1.AutoRecipeStackManager;
|
import net.minecraft.server.v1_16_R1.AutoRecipeStackManager;
|
||||||
import net.minecraft.server.v1_14_R1.ChatMessage;
|
import net.minecraft.server.v1_16_R1.ChatMessage;
|
||||||
import net.minecraft.server.v1_14_R1.ContainerUtil;
|
import net.minecraft.server.v1_16_R1.ContainerUtil;
|
||||||
import net.minecraft.server.v1_14_R1.CrashReport;
|
import net.minecraft.server.v1_16_R1.CrashReport;
|
||||||
import net.minecraft.server.v1_14_R1.CrashReportSystemDetails;
|
import net.minecraft.server.v1_16_R1.CrashReportSystemDetails;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
import net.minecraft.server.v1_16_R1.DamageSource;
|
||||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_14_R1.EnumItemSlot;
|
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_16_R1.EnumItemSlot;
|
||||||
import net.minecraft.server.v1_14_R1.IChatBaseComponent;
|
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.Item;
|
import net.minecraft.server.v1_16_R1.IChatBaseComponent;
|
||||||
import net.minecraft.server.v1_14_R1.ItemArmor;
|
import net.minecraft.server.v1_16_R1.IInventory;
|
||||||
import net.minecraft.server.v1_14_R1.ItemStack;
|
import net.minecraft.server.v1_16_R1.Item;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R1.ItemArmor;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagList;
|
import net.minecraft.server.v1_16_R1.ItemStack;
|
||||||
import net.minecraft.server.v1_14_R1.NonNullList;
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutSetSlot;
|
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerInventory;
|
import net.minecraft.server.v1_16_R1.NonNullList;
|
||||||
import net.minecraft.server.v1_14_R1.ReportedException;
|
import net.minecraft.server.v1_16_R1.PacketPlayOutSetSlot;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
import net.minecraft.server.v1_16_R1.PlayerInventory;
|
||||||
|
import net.minecraft.server.v1_16_R1.ReportedException;
|
||||||
|
import net.minecraft.server.v1_16_R1.World;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
@ -117,7 +119,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= list.size()) {
|
if (i >= list.size()) {
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.get(i);
|
return list.get(i);
|
||||||
|
@ -133,7 +135,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
i -= next.size();
|
i -= next.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list == null ? ItemStack.a : list.get(i);
|
return list == null ? ItemStack.b : list.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -229,10 +231,10 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= list.size()) {
|
if (i >= list.size()) {
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
|
return list.get(i).isEmpty() ? ItemStack.b : ContainerUtil.a(list, i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -254,17 +256,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= list.size()) {
|
if (i >= list.size()) {
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!list.get(i).isEmpty()) {
|
if (!list.get(i).isEmpty()) {
|
||||||
ItemStack itemstack = list.get(i);
|
ItemStack itemstack = list.get(i);
|
||||||
|
|
||||||
list.set(i, ItemStack.a);
|
list.set(i, ItemStack.b);
|
||||||
return itemstack;
|
return itemstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ItemStack.a;
|
return ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -304,10 +306,10 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInHand() {
|
public ItemStack getItemInHand() {
|
||||||
return d(this.itemInHandIndex) ? this.items.get(this.itemInHandIndex) : ItemStack.a;
|
return d(this.itemInHandIndex) ? this.items.get(this.itemInHandIndex) : ItemStack.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean a(ItemStack itemstack, ItemStack itemstack1) {
|
private boolean isSimilarAndNotFull(ItemStack itemstack, ItemStack itemstack1) {
|
||||||
return !itemstack.isEmpty() && this.b(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize();
|
return !itemstack.isEmpty() && this.b(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,8 +327,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
return itemstack.getCount();
|
return itemstack.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.a(itemstack, itemstack1)) {
|
if (!this.isSimilarAndNotFull(itemstack, itemstack1)) {
|
||||||
remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
|
remains -= Math.min(itemstack1.getMaxStackSize(), this.getMaxStackSize()) - itemstack1.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remains <= 0) {
|
if (remains <= 0) {
|
||||||
|
@ -334,6 +336,11 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size());
|
||||||
|
if (this.isSimilarAndNotFull(offhandItemStack, itemstack)) {
|
||||||
|
remains -= Math.min(offhandItemStack.getMaxStackSize(), this.getMaxStackSize()) - offhandItemStack.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
return itemstack.getCount() - remains;
|
return itemstack.getCount() - remains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,41 +397,14 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int a(Predicate<ItemStack> predicate, int i) {
|
public int a(Predicate<ItemStack> predicate, int i, IInventory iinventory) {
|
||||||
int j = 0;
|
byte b0 = 0;
|
||||||
|
boolean flag = i == 0;
|
||||||
int k;
|
int j = b0 + ContainerUtil.a(this, predicate, i - b0, flag);
|
||||||
for (k = 0; k < this.getSize(); ++k) {
|
j += ContainerUtil.a(iinventory, predicate, i - j, flag);
|
||||||
ItemStack itemstack = this.getItem(k);
|
j += ContainerUtil.a(this.getCarried(), predicate, i - j, flag);
|
||||||
if (!itemstack.isEmpty() && predicate.test(itemstack)) {
|
if (this.getCarried().isEmpty()) {
|
||||||
int l = i <= 0 ? itemstack.getCount() : Math.min(i - j, itemstack.getCount());
|
this.setCarried(ItemStack.b);
|
||||||
j += l;
|
|
||||||
if (i != 0) {
|
|
||||||
itemstack.subtract(l);
|
|
||||||
if (itemstack.isEmpty()) {
|
|
||||||
this.setItem(k, ItemStack.a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i > 0 && j >= i) {
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.getCarried().isEmpty() && predicate.test(this.getCarried())) {
|
|
||||||
k = i <= 0 ? this.getCarried().getCount() : Math.min(i - j, this.getCarried().getCount());
|
|
||||||
j += k;
|
|
||||||
if (i != 0) {
|
|
||||||
this.getCarried().subtract(k);
|
|
||||||
if (this.getCarried().isEmpty()) {
|
|
||||||
this.setCarried(ItemStack.a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i > 0 && j >= i) {
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return j;
|
return j;
|
||||||
|
@ -445,8 +425,9 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
ItemStack itemstack1 = this.getItem(i);
|
ItemStack itemstack1 = this.getItem(i);
|
||||||
if (itemstack1.isEmpty()) {
|
if (itemstack1.isEmpty()) {
|
||||||
itemstack1 = new ItemStack(item, 0);
|
itemstack1 = new ItemStack(item, 0);
|
||||||
if (itemstack.hasTag()) {
|
NBTTagCompound tag = itemstack.getTag();
|
||||||
itemstack1.setTag(itemstack.getTag().clone());
|
if (tag != null) {
|
||||||
|
itemstack1.setTag(tag.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setItem(i, itemstack1);
|
this.setItem(i, itemstack1);
|
||||||
|
@ -461,25 +442,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
k = this.getMaxStackSize() - itemstack1.getCount();
|
k = this.getMaxStackSize() - itemstack1.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k == 0) {
|
if (k != 0) {
|
||||||
return j;
|
|
||||||
} else {
|
|
||||||
j -= k;
|
j -= k;
|
||||||
itemstack1.add(k);
|
itemstack1.add(k);
|
||||||
itemstack1.d(5);
|
itemstack1.d(5);
|
||||||
return j;
|
|
||||||
}
|
}
|
||||||
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int firstPartial(ItemStack itemstack) {
|
public int firstPartial(ItemStack itemstack) {
|
||||||
if (this.a(this.getItem(this.itemInHandIndex), itemstack)) {
|
if (this.isSimilarAndNotFull(this.getItem(this.itemInHandIndex), itemstack)) {
|
||||||
return this.itemInHandIndex;
|
return this.itemInHandIndex;
|
||||||
} else if (this.a(this.getItem(40), itemstack)) {
|
} else if (this.isSimilarAndNotFull(this.getItem(40), itemstack)) {
|
||||||
return 40;
|
return 40;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < this.items.size(); ++i) {
|
for (int i = 0; i < this.items.size(); ++i) {
|
||||||
if (this.a(this.items.get(i), itemstack)) {
|
if (this.isSimilarAndNotFull(this.items.get(i), itemstack)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,7 +565,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
for (List<ItemStack> list : this.f) {
|
for (List<ItemStack> list : this.f) {
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
if (list.get(i) == itemstack) {
|
if (list.get(i) == itemstack) {
|
||||||
list.set(i, ItemStack.a);
|
list.set(i, ItemStack.b);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -656,12 +635,12 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNotEmpty() {
|
public boolean isEmpty() {
|
||||||
Iterator iterator = this.items.iterator();
|
Iterator<ItemStack> iterator = this.items.iterator();
|
||||||
|
|
||||||
ItemStack itemstack;
|
ItemStack itemstack;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
itemstack = (ItemStack)iterator.next();
|
itemstack = iterator.next();
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +649,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
iterator = this.armor.iterator();
|
iterator = this.armor.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
itemstack = (ItemStack)iterator.next();
|
itemstack = iterator.next();
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -679,7 +658,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
iterator = this.extraSlots.iterator();
|
iterator = this.extraSlots.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
itemstack = (ItemStack)iterator.next();
|
itemstack = iterator.next();
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -695,12 +674,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean b(IBlockData iblockdata) {
|
public void a(DamageSource damagesource, float f) {
|
||||||
return this.getItem(this.itemInHandIndex).b(iblockdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void a(float f) {
|
|
||||||
if (f > 0.0F) {
|
if (f > 0.0F) {
|
||||||
f /= 4.0F;
|
f /= 4.0F;
|
||||||
if (f < 1.0F) {
|
if (f < 1.0F) {
|
||||||
|
@ -710,8 +684,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
for (int i = 0; i < this.armor.size(); ++i) {
|
for (int i = 0; i < this.armor.size(); ++i) {
|
||||||
ItemStack itemstack = this.armor.get(0);
|
ItemStack itemstack = this.armor.get(0);
|
||||||
int index = i;
|
int index = i;
|
||||||
if (itemstack.getItem() instanceof ItemArmor) {
|
if ((!damagesource.isFire() || !itemstack.getItem().u()) && itemstack.getItem() instanceof ItemArmor) {
|
||||||
itemstack.damage((int) f, this.player, (entityhuman) -> entityhuman.c(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, index)));
|
itemstack.damage((int) f, this.player, (entityHuman) -> entityHuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, index)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -723,7 +697,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
||||||
for (int i = 0; i < itemStacks.size(); ++i) {
|
for (int i = 0; i < itemStacks.size(); ++i) {
|
||||||
ItemStack itemstack = itemStacks.get(i);
|
ItemStack itemstack = itemStacks.get(i);
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
itemStacks.set(i, ItemStack.a);
|
itemStacks.set(i, ItemStack.b);
|
||||||
this.player.a(itemstack, true, false);
|
this.player.a(itemstack, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue