use of net.minecraft.server.v1_13_R2.TileEntityMobSpawner in project SilkSpawners by timbru31.
the class NMSHandler method setMobNameOfSpawner.
@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
// Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.UPPER_CAMEL, mobID.replace(" ", "_"));
final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
try {
final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
tile.getSpawner().setMobName(safeMobID);
return true;
} catch (IllegalArgumentException | IllegalAccessException e) {
Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
e.printStackTrace();
}
return false;
}
use of net.minecraft.server.v1_13_R2.TileEntityMobSpawner in project SilkSpawners by timbru31.
the class NMSHandler method setMobNameOfSpawner.
@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
// Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
try {
final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
tile.getSpawner().setMobName(IRegistry.ENTITY_TYPE.get(new MinecraftKey(safeMobID)));
return true;
} catch (IllegalArgumentException | IllegalAccessException e) {
Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
e.printStackTrace();
}
return false;
}
use of net.minecraft.server.v1_13_R2.TileEntityMobSpawner in project SilkSpawners by timbru31.
the class NMSHandler method setMobNameOfSpawner.
@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
// Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.UPPER_CAMEL, mobID.replace(" ", "_"));
final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
try {
final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
tile.getSpawner().setMobName(safeMobID);
return true;
} catch (IllegalArgumentException | IllegalAccessException e) {
Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
e.printStackTrace();
}
return false;
}
use of net.minecraft.server.v1_13_R2.TileEntityMobSpawner in project SilkSpawners by timbru31.
the class NMSHandler method setMobNameOfSpawner.
@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
// Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
try {
final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
tile.getSpawner().setMobName(new MinecraftKey(safeMobID));
return true;
} catch (IllegalArgumentException | IllegalAccessException e) {
Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
e.printStackTrace();
}
return false;
}
use of net.minecraft.server.v1_13_R2.TileEntityMobSpawner in project SilkSpawners by timbru31.
the class NMSHandler method setMobNameOfSpawner.
@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
// Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
try {
final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
tile.getSpawner().setMobName(IRegistry.ENTITY_TYPE.get(new MinecraftKey(safeMobID)));
return true;
} catch (IllegalArgumentException | IllegalAccessException e) {
Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
e.printStackTrace();
}
return false;
}
Aggregations