Skip to content

Commit

Permalink
Separated into Mod module and API module
Browse files Browse the repository at this point in the history
  • Loading branch information
floral-qua-floral committed Nov 20, 2024
1 parent 40ca890 commit 17ef4d5
Show file tree
Hide file tree
Showing 303 changed files with 68 additions and 25 deletions.
33 changes: 33 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'java'
id 'maven-publish'
}

group = 'com.floralquafloral' // Customize with your mod's group ID
version = '1.0.0' // API version

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
url = uri("https://maven.pkg.github.com/floral-qua-floral/marioQuaMario")
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
7 changes: 7 additions & 0 deletions api/src/main/java/com/floralquafloral/PlayerPooper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.floralquafloral;

import net.minecraft.entity.player.PlayerEntity;

public interface PlayerPooper {
PlayerEntity poopasaur();
}
2 changes: 2 additions & 0 deletions build.gradle → mod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ fabricApi {
}

dependencies {
implementation project(':api')

// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class MarioQuaMario implements ModInitializer {

@Override
public void onInitialize() {
LOGGER.info("MarioQuaMario.java loaded on environment type " + FabricLoader.getInstance().getEnvironmentType());
LOGGER.info("Mario qua Mario initialized!");
MarioDataManager.registerEventListeners();
BumpManager.registerEventListeners();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
import com.floralquafloral.mariodata.MarioClientSideData;
import com.floralquafloral.mariodata.MarioData;
import com.floralquafloral.mariodata.moveable.MarioTravelData;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

/**
* Callback for Mario bumping a block in the world.
* Used on the client and server.
* Callback for Mario bumping a block in the world. Used on the client and server.
* On the client, called before the block is visibly displaced and the attempt is networked to the server.
* On the server, called before the block is given a redstone signal.
* On the server, called before the block is given a redstone signal and the bump is networked to nearby clients.
* Upon return:
* - PASS falls back to further processing.
* - DISPLACE cancels further processing and displaces the block.
Expand All @@ -25,22 +22,6 @@
* if it occurs on the client.
*/
public interface BlockBumpCallback {
Event<BlockBumpCallback> EVENT = EventFactory.createArrayBacked(BlockBumpCallback.class,
listeners -> (marioData, marioClientData, marioTravelData, world, blockPos, blockState, strength, modifier, direction) -> {
for(BlockBumpCallback listener : listeners) {
BlockBumpResult result = listener.bump(
marioData, marioClientData, marioTravelData,
world, blockPos, blockState,
strength, modifier, direction
);
if(result != BlockBumpResult.PASS) return result;
}


return BlockBumpResult.PASS;
}
);

BlockBumpResult bump(
MarioData marioData, @Nullable MarioClientSideData marioClientData, @Nullable MarioTravelData marioTravelData,
World world, BlockPos blockPos, BlockState blockState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.floralquafloral.mariodata.MarioClientSideData;
import com.floralquafloral.mariodata.MarioData;
import com.floralquafloral.mariodata.moveable.MarioTravelData;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.registry.RegistryKeys;
Expand Down Expand Up @@ -35,6 +37,21 @@ public class BlockBumpHandler {

public static final Set<BlockPos> FORCED_SIGNALS = new HashSet<>();
public static final Set<ForcedSignalSpot> FORCED_SIGNALS_DATA = new HashSet<>();
public static final Event<BlockBumpCallback> EVENT = EventFactory.createArrayBacked(BlockBumpCallback.class,
listeners -> (marioData, marioClientData, marioTravelData, world, blockPos, blockState, strength, modifier, direction) -> {
for(BlockBumpCallback listener : listeners) {
BlockBumpResult result = listener.bump(
marioData, marioClientData, marioTravelData,
world, blockPos, blockState,
strength, modifier, direction
);
if(result != BlockBumpResult.PASS) return result;
}


return BlockBumpResult.PASS;
}
);

public static BlockBumpResult processBumpResult(
MarioData marioData, @Nullable MarioClientSideData marioClientData, @Nullable MarioTravelData marioTravelData,
Expand Down Expand Up @@ -72,7 +89,7 @@ private static BlockBumpResult getBumpResult(
World world, BlockPos blockPos, BlockState blockState,
int strength, int modifier, Direction direction
) {
BlockBumpResult result = BlockBumpCallback.EVENT.invoker().bump(
BlockBumpResult result = EVENT.invoker().bump(
marioData, marioClientData, marioTravelData,
world, blockPos, blockState,
strength, modifier, direction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void registerEventListeners() {
}
});

BlockBumpCallback.EVENT.register((
BlockBumpHandler.EVENT.register((
marioData, marioClientData, marioTravelData,
world, blockPos, blockState,
strength, modifier, direction
Expand Down
File renamed without changes.
Loading

0 comments on commit 17ef4d5

Please sign in to comment.