use of org.spongepowered.asm.util.PrettyPrinter in project SpongeCommon by SpongePowered.
the class SpongeGameRegistry method throwRegistryEvent.
@SuppressWarnings("unchecked")
private void throwRegistryEvent(RegistryModule module) {
if (this.phase == RegistrationPhase.INIT && module instanceof AdditionalCatalogRegistryModule && (!(module instanceof SpongeAdditionalCatalogRegistryModule) || ((SpongeAdditionalCatalogRegistryModule) module).allowsApiRegistration()) && module.getClass().getAnnotation(CustomRegistrationPhase.class) == null) {
Class<? extends CatalogType> catalogClass = null;
for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : this.catalogRegistryMap.entrySet()) {
if (entry.getValue() == module) {
catalogClass = entry.getKey();
}
}
if (catalogClass == null) {
// This isn't a valid registered registry
// We should throw an exception or print out an exception, but otherwise, not going to bother at this moment.
new PrettyPrinter(60).centre().add("Unregistered RegistryModule").hr().addWrapped(60, "An unknown registry module was added to the ordered set of modules, but the " + "module itself is not registered with the GameRegistry!").add().add("%s : %s", "Registry Module", module.toString()).add().add(new Exception()).add().add("To fix this, the developer providing the module needs to register the module correctly.").trace();
return;
}
final AdditionalCatalogRegistryModule registryModule = (AdditionalCatalogRegistryModule) module;
SpongeImpl.postEvent(new SpongeGameRegistryRegisterEvent(Sponge.getCauseStackManager().getCurrentCause(), catalogClass, registryModule));
}
}
use of org.spongepowered.asm.util.PrettyPrinter in project SpongeCommon by SpongePowered.
the class MixinWorldServer method triggerExplosion.
@Override
public void triggerExplosion(org.spongepowered.api.world.explosion.Explosion explosion) {
checkNotNull(explosion, "explosion");
Location<org.spongepowered.api.world.World> origin = explosion.getLocation();
checkNotNull(origin, "location");
final PhaseTracker phaseTracker = PhaseTracker.getInstance();
try (final PhaseContext<?> phaseContext = PluginPhase.State.CUSTOM_EXPLOSION.createPhaseContext().explosion(explosion).buildAndSwitch()) {
final Explosion mcExplosion;
try {
// Since we already have the API created implementation Explosion, let's use it.
mcExplosion = (Explosion) explosion;
} catch (Exception e) {
new PrettyPrinter(60).add("Explosion not compatible with this implementation").centre().hr().add("An explosion that was expected to be used for this implementation does not").add("originate from this implementation.").add(e).trace();
return;
}
final double x = mcExplosion.x;
final double y = mcExplosion.y;
final double z = mcExplosion.z;
final boolean damagesTerrain = explosion.shouldBreakBlocks();
final float strength = explosion.getRadius();
// Set up the pre event
final ExplosionEvent.Pre event = SpongeEventFactory.createExplosionEventPre(Sponge.getCauseStackManager().getCurrentCause(), explosion, this);
if (SpongeImpl.postEvent(event)) {
this.processingExplosion = false;
return;
}
// Sponge End
mcExplosion.doExplosionA();
mcExplosion.doExplosionB(false);
if (!damagesTerrain) {
mcExplosion.clearAffectedBlockPositions();
}
for (EntityPlayer entityplayer : this.playerEntities) {
if (entityplayer.getDistanceSq(x, y, z) < 4096.0D) {
((EntityPlayerMP) entityplayer).connection.sendPacket(new SPacketExplosion(x, y, z, strength, mcExplosion.getAffectedBlockPositions(), mcExplosion.getPlayerKnockbackMap().get(entityplayer)));
}
}
// Sponge Start - end processing
this.processingExplosion = false;
}
// Sponge End
}
Aggregations