SHARE
TWEET

Untitled

a guest May 21st, 2016 19 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.klein5.TowerDefense.datawatcher;
  2.  
  3. import java.io.IOException;
  4. import java.lang.reflect.InvocationTargetException;
  5. import java.lang.reflect.Method;
  6. import java.util.List;
  7.  
  8. import net.minecraft.server.v1_9_R2.DataWatcher;
  9. import net.minecraft.server.v1_9_R2.DataWatcher.Item;
  10. import net.minecraft.server.v1_9_R2.DataWatcherObject;
  11. import net.minecraft.server.v1_9_R2.PacketDataSerializer;
  12.  
  13. public class NullDataWatcher {
  14.    
  15.     private final DataWatcher dataWatcher;
  16.    
  17.     public NullDataWatcher() {
  18.         this.dataWatcher = new DataWatcher(null);
  19.        
  20.     }
  21.    
  22.     public NullDataWatcher add(EnumDataWatcherObjects dataWatcherObjects, Object value){
  23.  
  24.         try {
  25.             Method f = this.dataWatcher.getClass().getDeclaredMethod("registerObject", new Class[]{DataWatcherObject.class,Object.class});
  26.             f.setAccessible(true);
  27.             f.invoke(this.dataWatcher, dataWatcherObjects.getObject(),value);
  28.         } catch (IllegalAccessException e) {
  29.             e.printStackTrace();
  30.         } catch (IllegalArgumentException e) {
  31.             e.printStackTrace();
  32.         } catch (InvocationTargetException e) {
  33.             e.printStackTrace();
  34.         } catch (NoSuchMethodException e) {
  35.             e.printStackTrace();
  36.         } catch (SecurityException e) {
  37.             e.printStackTrace();
  38.         }
  39.        
  40.         return this;
  41.     }
  42.     @SuppressWarnings("static-access")
  43.     public void update(EnumDataWatcherObjects dataWatcherObjects, PacketDataSerializer value){
  44.        
  45.         List<Item<?>> item = this.dataWatcher.c();
  46.        
  47.         try {
  48.             this.dataWatcher.a(item, value);
  49.         } catch (IOException e) {
  50.             e.printStackTrace();
  51.         }
  52.        
  53.        
  54.     }
  55.     public DataWatcher toNMS(){
  56.         return this.dataWatcher;
  57.     }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top