Skip to content

Commit

Permalink
Helper event for setting up ShellEntry models
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 committed Dec 19, 2023
1 parent 3e0c039 commit d990e50
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 1 addition & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
architectury {
common(rootProject.enabled_platforms.split(",")) {
it.platformPackage("neoforge", "forge")
}
common(rootProject.enabled_platforms.split(","))
}

loom {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package whocraft.tardis_refined.api.event;

import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -13,9 +14,6 @@
import whocraft.tardis_refined.common.tardis.TardisNavLocation;
import whocraft.tardis_refined.common.tardis.control.Control;

import java.util.List;
import java.util.function.Function;

public class TardisEvents {

public static final Event<TakeOff> TAKE_OFF = new Event<>(TakeOff.class, listeners -> (tardisLevelOperator, level, pos) -> Event.result(listeners, takeOff -> takeOff.onTakeOff(tardisLevelOperator, level, pos)));
Expand Down Expand Up @@ -62,13 +60,25 @@ public class TardisEvents {
}
}));

public static final Event<SetupModels> SHELLENTRY_MODELS_SETUP = new Event<>(SetupModels.class, listeners -> (EntityModelSet context) -> {
for(SetupModels listener : listeners) {
listener.setUpShellAndInteriorModels(context);
}
});


/**
* Represents an event that allows checking whether player control can be used.
*/
public static final Event<CanControlBeUsed> PLAYER_CONTROL_INTERACT = new Event<>(CanControlBeUsed.class, listeners -> (tardisLevelOperator, control, controlEntity) -> Event.result(listeners, takeOff -> takeOff.canControlBeUsed(tardisLevelOperator, control, controlEntity)));


@FunctionalInterface
public interface SetupModels {
void setUpShellAndInteriorModels(EntityModelSet context);
}


/**
* Functional interface to define the conditions for using player control.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.resources.ResourceLocation;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.api.event.TardisEvents;
import whocraft.tardis_refined.client.ModelRegistry;
import whocraft.tardis_refined.client.model.blockentity.door.interior.*;
import whocraft.tardis_refined.client.model.blockentity.shell.shells.*;
Expand Down Expand Up @@ -67,6 +69,8 @@ public void registerModels(EntityModelSet context){
hieroglyphDoorModel = new HieroglyphShellDoor(context.bakeLayer((ModelRegistry.HIEROGLYPH_DOOR)));
castleDoorModel = new CastleShellDoorModel(context.bakeLayer((ModelRegistry.CASTLE_DOOR)));

TardisEvents.SHELLENTRY_MODELS_SETUP.invoker().setUpShellAndInteriorModels(context);

registerShellEntry(ShellTheme.FACTORY.get(), factoryShellModel, factoryDoorModel);
registerShellEntry(ShellTheme.POLICE_BOX.get(), policeBoxModel, policeBoxDoorModel);
registerShellEntry(ShellTheme.PHONE_BOOTH.get(), phoneBoothModel, phoneBoothDoorModel);
Expand Down
Empty file.

0 comments on commit d990e50

Please sign in to comment.