use of net.minecraft.server.v1_16_R1.Item in project SilkSpawners by timbru31.
the class NMSHandler method setSpawnersUnstackable.
@Override
public void setSpawnersUnstackable() {
try {
final Item spawner = IRegistry.ITEM.get(new MinecraftKey(NAMESPACED_SPAWNER_ID));
final Field maxStackSize = Item.class.getDeclaredField("maxStackSize");
maxStackSize.setAccessible(true);
maxStackSize.set(spawner, 1);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_16_R1.Item in project SilkSpawners by timbru31.
the class NMSHandler method setSpawnersUnstackable.
@Override
public void setSpawnersUnstackable() {
try {
final Item spawner = IRegistry.ITEM.get(new MinecraftKey(NAMESPACED_SPAWNER_ID));
final Field maxStackSize = Item.class.getDeclaredField("maxStackSize");
maxStackSize.setAccessible(true);
maxStackSize.set(spawner, 1);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_16_R1.Item in project PaperDev by Kamillaova.
the class MaterialTest method verifyMapping.
@Test
public void verifyMapping() {
Map<Integer, Material> materials = Maps.newHashMap();
for (Material material : Material.values()) {
if (INVALIDATED_MATERIALS.contains(material)) {
continue;
}
materials.put(material.getId(), material);
}
Iterator<Item> items = Item.REGISTRY.iterator();
while (items.hasNext()) {
Item item = items.next();
if (item == null)
continue;
int id = CraftMagicNumbers.getId(item);
String name = item.getName();
Material material = materials.remove(id);
assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue())));
}
assertThat(materials, is(Collections.EMPTY_MAP));
}
use of net.minecraft.server.v1_16_R1.Item in project PaperDev by Kamillaova.
the class CraftStatistic method getMaterialFromStatistic.
public static Material getMaterialFromStatistic(net.minecraft.server.v1_12_R1.Statistic statistic) {
String statisticString = statistic.name;
String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
if (item != null) {
return Material.getMaterial(Item.getId(item));
}
Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
if (block != null) {
return Material.getMaterial(Block.getId(block));
}
try {
return Material.getMaterial(Integer.parseInt(val));
} catch (NumberFormatException e) {
return null;
}
}
Aggregations