Skip to content

Commit

Permalink
Revert "Update all forge event code, attempt to become loader unaware (
Browse files Browse the repository at this point in the history
…#10397)"

This reverts commit 70c53ba.
  • Loading branch information
Raycoms committed Nov 19, 2024
1 parent 2fa58d4 commit 34e7ec1
Show file tree
Hide file tree
Showing 44 changed files with 542 additions and 688 deletions.
3 changes: 0 additions & 3 deletions src/main/java/com/minecolonies/api/IMinecoloniesAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry;
import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry;
import com.minecolonies.api.equipment.registry.EquipmentTypeEntry;
import com.minecolonies.api.eventbus.EventBus;
import com.minecolonies.api.quests.registries.QuestRegistries;
import com.minecolonies.api.research.IGlobalResearchTree;
import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType;
Expand Down Expand Up @@ -102,6 +101,4 @@ static IMinecoloniesAPI getInstance()
void onRegistryNewRegistry(NewRegistryEvent event);

IForgeRegistry<EquipmentTypeEntry> getEquipmentTypeRegistry();

EventBus getEventBus();
}
9 changes: 1 addition & 8 deletions src/main/java/com/minecolonies/api/MinecoloniesAPIProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry;
import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry;
import com.minecolonies.api.equipment.registry.EquipmentTypeEntry;
import com.minecolonies.api.eventbus.EventBus;
import com.minecolonies.api.quests.registries.QuestRegistries;
import com.minecolonies.api.research.IGlobalResearchTree;
import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType;
Expand All @@ -33,7 +32,7 @@

public final class MinecoloniesAPIProxy implements IMinecoloniesAPI
{
private static final MinecoloniesAPIProxy ourInstance = new MinecoloniesAPIProxy();
private static MinecoloniesAPIProxy ourInstance = new MinecoloniesAPIProxy();

private IMinecoloniesAPI apiInstance;

Expand Down Expand Up @@ -236,10 +235,4 @@ public IForgeRegistry<EquipmentTypeEntry> getEquipmentTypeRegistry()
{
return apiInstance.getEquipmentTypeRegistry();
}

@Override
public EventBus getEventBus()
{
return apiInstance.getEventBus();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.minecolonies.api.eventbus.events.colony.buildings;
package com.minecolonies.api.colony.buildings.event;

import com.minecolonies.api.colony.buildings.IBuilding;
import com.minecolonies.api.eventbus.events.colony.AbstractColonyEvent;
import com.minecolonies.api.colony.event.AbstractColonyEvent;

/**
* Abstract event for building related things.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.minecolonies.api.colony.buildings.event;

import com.minecolonies.api.colony.buildings.IBuilding;
import com.minecolonies.api.colony.workorders.WorkOrderType;

/**
* Event for when a building was built/repaired/removed.
*/
public final class BuildingConstructionEvent extends AbstractBuildingEvent
{
/**
* What happened to the building.
*/
private final EventType eventType;

/**
* Building construction event.
*
* @param building the building the event was for.
* @param eventType what happened to the building.
*/
public BuildingConstructionEvent(final IBuilding building, final EventType eventType)
{
super(building);
this.eventType = eventType;
}

/**
* Get what happened to the building.
*
* @return the event type.
*/
public EventType getEventType()
{
return eventType;
}

/**
* What happened to the building.
*/
public enum EventType
{
BUILT,
UPGRADED,
REPAIRED,
REMOVED;

/**
* Obtain the construction event type from the work order type.
*
* @param workOrderType the work order type.
* @return the construction event type.
*/
public static EventType fromWorkOrderType(final WorkOrderType workOrderType)
{
return switch (workOrderType)
{
case BUILD -> BUILT;
case UPGRADE -> UPGRADED;
case REPAIR -> REPAIRED;
case REMOVE -> REMOVED;
};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.minecolonies.api.eventbus.events.colony.citizens;
package com.minecolonies.api.colony.citizens.event;

import com.minecolonies.api.colony.ICitizen;
import com.minecolonies.api.colony.ICitizenData;
import com.minecolonies.api.eventbus.events.colony.AbstractColonyEvent;
import com.minecolonies.api.colony.event.AbstractColonyEvent;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.minecolonies.api.eventbus.events.colony.citizens;
package com.minecolonies.api.colony.citizens.event;

import com.minecolonies.api.colony.ICitizenData;

/**
* Event for when a citizen was added to the colony.
*/
public final class CitizenAddedEvent extends AbstractCitizenEvent
public class CitizenAddedEvent extends AbstractCitizenEvent
{
/**
* The way the citizen came into the colony.
*/
private final CitizenAddedSource source;
private final Source source;

/**
* Citizen added event.
*
* @param citizen the citizen related to the event.
* @param source the way the citizen came into the colony.
*/
public CitizenAddedEvent(final ICitizenData citizen, final CitizenAddedSource source)
public CitizenAddedEvent(final ICitizenData citizen, final Source source)
{
super(citizen);
this.source = source;
Expand All @@ -29,15 +29,15 @@ public CitizenAddedEvent(final ICitizenData citizen, final CitizenAddedSource so
*
* @return the enum value.
*/
public CitizenAddedSource getSource()
public Source getSource()
{
return source;
}

/**
* How the citizen came into the colony.
*/
public enum CitizenAddedSource
public enum Source
{
/**
* The citizen spawned as part of the {@link com.minecolonies.api.configuration.ServerConfiguration#initialCitizenAmount}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package com.minecolonies.api.eventbus.events.colony.citizens;
package com.minecolonies.api.colony.citizens.event;

import com.minecolonies.api.colony.ICitizenData;
import net.minecraft.world.damagesource.DamageSource;
import org.jetbrains.annotations.NotNull;

/**
* Event for when a citizen died in any colony.
* Event for when a citizen was removed from the colony.
*/
public final class CitizenDiedEvent extends AbstractCitizenEvent
public class CitizenRemovedEvent extends AbstractCitizenEvent
{
/**
* The damage source that caused a citizen to die.
*/
private final @NotNull DamageSource source;

/**
* Citizen died event.
* Citizen removed event.
*
* @param citizen the citizen related to the event.
* @param source the damage source the citizen died from.
* @param source the way the citizen went out of the colony.
*/
public CitizenDiedEvent(final @NotNull ICitizenData citizen, final @NotNull DamageSource source)
public CitizenRemovedEvent(final @NotNull ICitizenData citizen, final @NotNull DamageSource source)
{
super(citizen);
this.source = source;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
package com.minecolonies.api.eventbus.events.colony;

import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.eventbus.events.AbstractEvent;
import org.jetbrains.annotations.NotNull;

/**
* Any colony related event, provides the target colony the event occurred in.
*/
public abstract class AbstractColonyEvent extends AbstractEvent
{
/**
* The colony this event was called in.
*/
@NotNull
private final IColony colony;

/**
* Constructs a colony-based event.
*
* @param colony The colony related to the event.
*/
protected AbstractColonyEvent(@NotNull final IColony colony)
{
this.colony = colony;
}

/**
* Gets the colony related to the event.
*/
@NotNull
public IColony getColony()
{
return colony;
}
}
package com.minecolonies.api.colony.event;

import com.minecolonies.api.colony.IColony;
import net.minecraftforge.eventbus.api.Event;
import org.jetbrains.annotations.NotNull;

/**
* This is a colony-related event in the Forge sense, not in the
* {@link com.minecolonies.api.colony.colonyEvents.IColonyEvent} sense.
*/
public abstract class AbstractColonyEvent extends Event
{
/**
* The colony this event was called in.
*/
@NotNull
private final IColony colony;

/**
* Constructs a colony-based event.
*
* @param colony The colony related to the event.
*/
protected AbstractColonyEvent(@NotNull final IColony colony)
{
this.colony = colony;
}

/**
* Gets the colony related to the event.
*/
@NotNull
public IColony getColony()
{
return colony;
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package com.minecolonies.api.eventbus.events.colony;

import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.eventbus.api.Event;
import org.jetbrains.annotations.NotNull;

/**
* This event is fired client-side after the colony chunk capabilities are synched to the player;
* i.e. there might be an update to which colony claims a particular chunk. This is fired even if
* no colony owns the chunk in question, as that may also be interesting; and even if the data did
* not actually change, as it might still be new to the listener.
*/
public final class ClientChunkUpdatedEvent extends Event
{
private final LevelChunk chunk;

/**
* Constructs a chunk update event.
*
* @param chunk The chunk that was updated.
*/
public ClientChunkUpdatedEvent(@NotNull final LevelChunk chunk)
{
this.chunk = chunk;
}

/**
* Gets the chunk related to the event.
*/
@NotNull
public LevelChunk getChunk()
{
return this.chunk;
}
}
package com.minecolonies.api.colony.event;

import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.eventbus.api.Event;
import org.jetbrains.annotations.NotNull;

/**
* This event is fired client-side after the colony chunk capabilities are synched to the player;
* i.e. there might be an update to which colony claims a particular chunk. This is fired even if
* no colony owns the chunk in question, as that may also be interesting; and even if the data did
* not actually change, as it might still be new to the listener.
*/
public class ClientChunkUpdatedEvent extends Event
{
private final LevelChunk chunk;

/**
* Constructs a chunk update event.
*
* @param chunk The chunk that was updated.
*/
public ClientChunkUpdatedEvent(@NotNull final LevelChunk chunk)
{
this.chunk = chunk;
}

/**
* Gets the chunk related to the event.
*/
@NotNull
public LevelChunk getChunk()
{
return this.chunk;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.minecolonies.api.eventbus.events.colony;
package com.minecolonies.api.colony.event;

import com.minecolonies.api.colony.IColony;
import org.jetbrains.annotations.NotNull;

/**
* Colony created event.
*/
public final class ColonyCreatedEvent extends AbstractColonyEvent
public class ColonyCreatedEvent extends AbstractColonyEvent
{
/**
* Constructs a colony created event.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.minecolonies.api.eventbus.events.colony;
package com.minecolonies.api.colony.event;

import com.minecolonies.api.colony.IColony;
import org.jetbrains.annotations.NotNull;

/**
* Colony deleted event.
*/
public final class ColonyDeletedEvent extends AbstractColonyEvent
public class ColonyDeletedEvent extends AbstractColonyEvent
{
/**
* Constructs a colony deleted event.
Expand Down
Loading

0 comments on commit 34e7ec1

Please sign in to comment.