Properly obtain read/write methods for tile entities

This commit is contained in:
Dan Mulloy 2015-06-19 22:17:34 -04:00
parent e0f7c72e18
commit 9fe5df3cfe
3 changed files with 9 additions and 10 deletions

View File

@ -13,7 +13,8 @@
* 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
* 02111-1307 USA
*/package com.comphenix.protocol.compat.netty.shaded;
*/
package com.comphenix.protocol.compat.netty.shaded;
import java.io.IOException;
import java.io.ObjectInputStream;

View File

@ -13,7 +13,8 @@
* 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
* 02111-1307 USA
*/package com.comphenix.protocol.compat.netty.shaded;
*/
package com.comphenix.protocol.compat.netty.shaded;
import java.io.DataInputStream;
import java.io.DataOutputStream;

View File

@ -46,16 +46,14 @@ class TileEntityAccessor<T extends BlockState> {
private boolean writeDetected;
private boolean readDetected;
private TileEntityAccessor() {
public TileEntityAccessor() {
// Do nothing
}
/**
* Construct a new tile entity accessor.
* @param tileEntityField - the tile entity field.
* @param tileEntity - the tile entity.
* @param tile - the block state.
* @throws IOException Cannot read tile entity.
* @param state - the block state.
*/
private TileEntityAccessor(FieldAccessor tileEntityField, T state) {
if (tileEntityField != null) {
@ -64,7 +62,7 @@ class TileEntityAccessor<T extends BlockState> {
// Possible read/write methods
try {
findMethodsUsingASM(type);
findMethodsUsingASM();
} catch (IOException ex1) {
try {
// Much slower though
@ -84,12 +82,11 @@ class TileEntityAccessor<T extends BlockState> {
/**
* 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.
*/
private void findMethodsUsingASM(final Class<?> tileEntityClass) throws IOException {
private void findMethodsUsingASM() throws IOException {
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
final Class<?> tileEntityClass = MinecraftReflection.getTileEntityClass();
final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName());
final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());