Properly obtain read/write methods for tile entities
Dieser Commit ist enthalten in:
Ursprung
e0f7c72e18
Commit
9fe5df3cfe
@ -13,7 +13,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with this program;
|
* You should have received a copy of the GNU General Public License along with this program;
|
||||||
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/package com.comphenix.protocol.compat.netty.shaded;
|
*/
|
||||||
|
package com.comphenix.protocol.compat.netty.shaded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with this program;
|
* You should have received a copy of the GNU General Public License along with this program;
|
||||||
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/package com.comphenix.protocol.compat.netty.shaded;
|
*/
|
||||||
|
package com.comphenix.protocol.compat.netty.shaded;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
@ -46,16 +46,14 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
private boolean writeDetected;
|
private boolean writeDetected;
|
||||||
private boolean readDetected;
|
private boolean readDetected;
|
||||||
|
|
||||||
private TileEntityAccessor() {
|
public TileEntityAccessor() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new tile entity accessor.
|
* Construct a new tile entity accessor.
|
||||||
* @param tileEntityField - the tile entity field.
|
* @param tileEntityField - the tile entity field.
|
||||||
* @param tileEntity - the tile entity.
|
* @param state - the block state.
|
||||||
* @param tile - the block state.
|
|
||||||
* @throws IOException Cannot read tile entity.
|
|
||||||
*/
|
*/
|
||||||
private TileEntityAccessor(FieldAccessor tileEntityField, T state) {
|
private TileEntityAccessor(FieldAccessor tileEntityField, T state) {
|
||||||
if (tileEntityField != null) {
|
if (tileEntityField != null) {
|
||||||
@ -64,7 +62,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
|
|
||||||
// Possible read/write methods
|
// Possible read/write methods
|
||||||
try {
|
try {
|
||||||
findMethodsUsingASM(type);
|
findMethodsUsingASM();
|
||||||
} catch (IOException ex1) {
|
} catch (IOException ex1) {
|
||||||
try {
|
try {
|
||||||
// Much slower though
|
// Much slower though
|
||||||
@ -84,12 +82,11 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the read/write methods in TileEntity.
|
* Find the read/write methods in TileEntity.
|
||||||
* @param tileEntityClass - the tile entity class.
|
|
||||||
* @param nbtCompoundClass - the compound clas.
|
|
||||||
* @throws IOException If we cannot find these methods.
|
* @throws IOException If we cannot find these methods.
|
||||||
*/
|
*/
|
||||||
private void findMethodsUsingASM(final Class<?> tileEntityClass) throws IOException {
|
private void findMethodsUsingASM() throws IOException {
|
||||||
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
|
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
|
||||||
|
final Class<?> tileEntityClass = MinecraftReflection.getTileEntityClass();
|
||||||
final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName());
|
final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName());
|
||||||
|
|
||||||
final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());
|
final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren