コード例 #1
0
 @Test
 public void materialStaticInitialisationTest() {
   EngineFaker.setupEngine();
   try {
     new Stone("Test Stone", 87945);
     VanillaMaterials.initialize();
     for (Field field : VanillaMaterials.class.getFields()) {
       try {
         if (field == null
             || ((field.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC))
                 != (Modifier.STATIC | Modifier.PUBLIC))
             || !VanillaMaterial.class.isAssignableFrom(field.getType())) {
           continue;
         }
         VanillaMaterial material = (VanillaMaterial) field.get(null);
         if (material == null) {
           fail("invalid material: VanillaMaterials field '" + field.getName() + "' is null");
         }
       } catch (NoClassDefFoundError ex) {
         staticInitFail(ex);
       } catch (Throwable t) {
         t.printStackTrace();
         fail(
             "invalid material: An exception occurred while loading/reading VanillaMaterials field '"
                 + field.getName()
                 + "'");
       }
     }
   } catch (NoClassDefFoundError t) {
     staticInitFail(t);
   }
 }
コード例 #2
0
 @EventHandler
 public Message onBlockAction(BlockActionEvent event) {
   int id = VanillaMaterials.getMinecraftId(event.getMaterial());
   if (id == -1) {
     return null;
   } else {
     return new BlockActionMessage(
         event.getBlock(), (short) id, event.getData1(), event.getData2());
   }
 }
コード例 #3
0
 public static Material popMaterial(String argName, CommandArguments args)
     throws ArgumentParseException {
   String arg = args.currentArgument(argName);
   Material mat;
   try {
     mat = VanillaMaterials.getMaterial((short) Integer.parseInt(arg));
   } catch (NumberFormatException ex) {
     mat = MaterialRegistry.get(arg);
   }
   if (mat == null) {
     throw args.failure(argName, "Unknown material: " + arg, false);
   }
   return args.success(argName, mat);
 }
コード例 #4
0
ファイル: BreakBlockEffect.java プロジェクト: NikoMix/Vanilla
 public void play(List<Player> players, Point position, BlockMaterial material) {
   int id = VanillaMaterials.getMinecraftId(material);
   if (id != -1) {
     this.play(players, position, id);
   }
 }