use of com.minecolonies.api.colony.colonyEvents.IColonyEvent in project minecolonies by Minecolonies.
the class CommandKillRaider method onExecute.
/**
* What happens when the command is executed
*
* @param context the context of the command execution
*/
@Override
public int onExecute(final CommandContext<CommandSource> context) {
entitiesKilled = 0;
context.getSource().getLevel().getEntities().forEach(entity -> {
if (entity instanceof AbstractEntityMinecoloniesMob) {
final AbstractEntityMinecoloniesMob mob = (AbstractEntityMinecoloniesMob) entity;
mob.die(new DamageSource("despawn"));
mob.remove();
final IColonyEvent event = mob.getColony().getEventManager().getEventByID(mob.getEventID());
if (event != null) {
event.setStatus(EventStatus.DONE);
}
entitiesKilled++;
}
});
context.getSource().sendSuccess(new StringTextComponent(entitiesKilled + " entities killed"), true);
return 1;
}
use of com.minecolonies.api.colony.colonyEvents.IColonyEvent in project minecolonies by ldtteam.
the class EventManager method registerEntity.
/**
* Registers an entity with the given event.
*
* @param entity the entity to register.
* @param eventID the event id to register it to.
*/
@Override
public void registerEntity(@NotNull final Entity entity, final int eventID) {
final IColonyEvent event = events.get(eventID);
if (!(event instanceof IColonyEntitySpawnEvent)) {
entity.remove();
return;
}
((IColonyEntitySpawnEvent) event).registerEntity(entity);
}
use of com.minecolonies.api.colony.colonyEvents.IColonyEvent in project minecolonies by ldtteam.
the class EventManager method writeToNBT.
@Override
public void writeToNBT(@NotNull final CompoundNBT compound) {
final CompoundNBT eventManagerNBT = new CompoundNBT();
final ListNBT eventListNBT = new ListNBT();
for (final IColonyEvent event : events.values()) {
final CompoundNBT eventNBT = event.serializeNBT();
eventNBT.putString(TAG_NAME, event.getEventTypeID().getPath());
eventListNBT.add(eventNBT);
}
eventManagerNBT.putInt(TAG_EVENT_ID, currentEventID);
eventManagerNBT.put(TAG_EVENT_LIST, eventListNBT);
compound.put(TAG_EVENT_MANAGER, eventManagerNBT);
structureManager.writeToNBT(compound);
}
use of com.minecolonies.api.colony.colonyEvents.IColonyEvent in project minecolonies by ldtteam.
the class CommandKillRaider method onExecute.
/**
* What happens when the command is executed
*
* @param context the context of the command execution
*/
@Override
public int onExecute(final CommandContext<CommandSource> context) {
entitiesKilled = 0;
context.getSource().getLevel().getEntities().forEach(entity -> {
if (entity instanceof AbstractEntityMinecoloniesMob) {
final AbstractEntityMinecoloniesMob mob = (AbstractEntityMinecoloniesMob) entity;
mob.die(new DamageSource("despawn"));
mob.remove();
final IColonyEvent event = mob.getColony().getEventManager().getEventByID(mob.getEventID());
if (event != null) {
event.setStatus(EventStatus.DONE);
}
entitiesKilled++;
}
});
context.getSource().sendSuccess(new StringTextComponent(entitiesKilled + " entities killed"), true);
return 1;
}
Aggregations