update for 0.3.4
All checks were successful
/ Auto-Build-App (push) Successful in 15m35s

This commit is contained in:
pietru 2024-11-02 12:45:41 +01:00
parent 4156949e7d
commit 795204e41b
4 changed files with 112 additions and 62 deletions

View file

@ -1,16 +1,14 @@
plugins { plugins {
id "application" id "java-library"
id "maven-publish" id "maven-publish"
} }
repositories { repositories {
ivy { ivy {
name "Cosmic Reach" name "Cosmic Reach"
url "https://github.com/CRModders/CosmicArchive/raw/main/versions/pre-alpha" url "https://github.com/CRModders/CosmicArchive/raw/main/versions"
patternLayout { patternLayout {
//artifact "/Cosmic Reach-[revision].jar" artifact "[classifier]/[revision]/client/Cosmic-Reach-[revision].jar"
artifact "/[revision]/[classifier]/Cosmic Reach-[revision].jar"
artifact "/[revision]/[classifier]/Cosmic Reach-Server-[revision].jar"
} }
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory // This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
metadataSources { metadataSources {
@ -22,6 +20,23 @@ repositories {
} }
} }
ivy {
name "Cosmic Reach"
url "https://github.com/CRModders/CosmicArchive/raw/main/versions"
patternLayout {
artifact "[classifier]/[revision]/server/Cosmic-Reach-Server-[revision].jar"
}
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
metadataSources {
artifact()
}
content {
includeModule "finalforeach", "cosmicreach-server"
}
}
maven { maven {
name "crmReleases" name "crmReleases"
url "https://maven.crmodders.dev/releases" url "https://maven.crmodders.dev/releases"
@ -59,20 +74,39 @@ repositories {
configurations { configurations {
cosmicreach // Config to provide the Cosmic Reach project // Config to provide the Cosmic Reach project
compileOnly.extendsFrom(cosmicreach) // Allows cosmic reach to be used in the codebase cosmicreach
// Config to provide the Cosmic Reach project
cosmicreachServer
// Allows cosmic reach to be used in the codebase
compileOnly.extendsFrom(cosmicreach)
compileOnly.extendsFrom(cosmicreachServer)
internal {
visible = false
canBeConsumed = false
canBeResolved = false
}
compileClasspath.extendsFrom(internal)
runtimeClasspath.extendsFrom(internal)
testCompileClasspath.extendsFrom(internal)
testRuntimeClasspath.extendsFrom(internal)
quiltMod // Config to be able to load Quilt Mods
implementation.extendsFrom(quiltMod)
} }
dependencies { dependencies {
// Cosmic Reach jar // Cosmic Reach jar
cosmicreach "finalforeach:cosmicreach:${cosmic_reach_version}:${jar_type}" cosmicreach "finalforeach:cosmicreach:${cosmic_reach_version}:pre-alpha"
cosmicreachServer "finalforeach:cosmicreach-server:${cosmic_reach_server_version? cosmic_reach_server_version: cosmic_reach_version}:pre-alpha"
// Cosmic Quilt // Cosmic Quilt
implementation "org.codeberg.CRModders:cosmic-quilt:${cosmic_quilt_version}" internal "org.codeberg.CRModders:cosmic-quilt:${cosmic_quilt_version}"
// Modmenu
// internal "org.codeberg.CRModders:modmenu:${modmenu_version}"
//quiltMod "quilt-mod:fluxapi:0.5.8r2" //quiltMod "quilt-mod:fluxapi:0.5.8r2"
//quiltMod "dev.crmodders:fluxapi:${fluxapi_version}"//0.5.5 //quiltMod "dev.crmodders:fluxapi:${fluxapi_version}"//0.5.5
@ -105,7 +139,7 @@ dependencies {
processResources { processResources {
def resourceTargets = [ // Locations of where to inject the properties def resourceTargets = [ // Locations of where to inject the properties
"quilt.mod.json" "quilt.mod.json"
] ]
// Left item is the name in the target, right is the varuable name // Left item is the name in the target, right is the varuable name
@ -125,46 +159,53 @@ processResources {
} }
application { tasks.register("runClient", JavaExec) {
// As Quilt is our loader, use its main class at: // We need to build the jar before we can actually run
mainClass = "org.quiltmc.loader.impl.launch.knot.KnotClient"
}
// Sets up all the Quilt Mods
//def String getQuiltModLocations(Configuration config) {
// StringBuilder sb = new StringBuilder()
// for (obj in config.allDependencies) {
// sb.append(File.pathSeparator + config.files(obj)[0])
// }
// return sb.toString()
//}
applicationDefaultJvmArgs = [
//"-Dloader.skipMcProvider=true", // Stops Quilt from attempting to find mappings, and all the other Minecraft stuff
"-Dloader.development=true", // Allows stuff to be found through the classpath
"-Dloader.gameJarPath=" + configurations.cosmicreach.asPath, // Defines path to Cosmic Reach
// "-Dloader.addMods=" +
// jar.archiveFile.get().asFile + // Add the jar of this project
// getQuiltModLocations(configurations.quiltMod) // Adds the jars of any Quilt mods added
]
run {
// To run this project in the game, depend on the creation of jar task
dependsOn "jar" dependsOn "jar"
// We need to use Quilt's main class so that we can actually modify the game
mainClass = "dev.crmodders.cosmicquilt.loader.knot.KnotClient"
// Tells this task the dependencies needed for it to run properly.
classpath sourceSets.main.runtimeClasspath
// Allows stuff to be found through the classpath
jvmArgs "-Dloader.development=true"
// Tells the loader where the game jar is located
jvmArgs "-Dloader.gameJarPath=" + configurations.cosmicreach.asPath
// Change the run directory // Change the run directory
File runningDir = new File("run/") File runningDir = new File("run/")
if (!runningDir.exists()) if (!runningDir.exists())
runningDir.mkdirs() runningDir.mkdirs()
tasks.run.workingDir = runningDir workingDir = runningDir
}
tasks.register("runServer", JavaExec) {
// We need to build the jar before we can actually run
dependsOn "jar"
standardInput = System.in
// We need to use Quilt's main class so that we can actually modify the game
mainClass = "dev.crmodders.cosmicquilt.loader.knot.KnotServer"
// Tells this task the dependencies needed for it to run properly.
classpath sourceSets.main.runtimeClasspath
// Allows stuff to be found through the classpath
jvmArgs "-Dloader.development=true"
// Tells the loader where the game jar is located
jvmArgs "-Dloader.gameJarPath=" + configurations.cosmicreachServer.asPath
// Change the run directory
File runningDir = new File("run/")
if (!runningDir.exists())
runningDir.mkdirs()
workingDir = runningDir
} }
java { java {
withSourcesJar() withSourcesJar()
// withJavadocJar() // If docs are included with the project, this line can be un-commented // withJavadocJar() // If docs are included with the project, this line can be un-commented
// Sets the Java version // Sets the Java version
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
@ -177,7 +218,7 @@ publishing {
groupId = group groupId = group
artifactId = id artifactId = id
from components.java from components.java
} }
} }

View file

@ -9,8 +9,9 @@ group=net.pietru
id=omni_power id=omni_power
# Dependency Versions # Dependency Versions
cosmic_reach_version=0.3.2-pre2 cosmic_reach_version=0.3.4
cosmic_quilt_version=2.0.2 # If unspecified, will use the version above
jar_type=client cosmic_reach_server_version=0.3.4
cosmic_quilt_version=2.3.1
#fluxapi_version=0.6.0 # modmenu_version=1.0.7

View file

@ -2,6 +2,8 @@ package net.pietru.omni_power.blockevents;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import finalforeach.cosmicreach.blockentities.BlockEntity; import finalforeach.cosmicreach.blockentities.BlockEntity;
import finalforeach.cosmicreach.blockevents.BlockEventArgs;
import finalforeach.cosmicreach.blockevents.ScheduledTrigger;
import finalforeach.cosmicreach.blockevents.actions.ActionId; import finalforeach.cosmicreach.blockevents.actions.ActionId;
import finalforeach.cosmicreach.blockevents.actions.IBlockAction; import finalforeach.cosmicreach.blockevents.actions.IBlockAction;
import finalforeach.cosmicreach.blocks.BlockPosition; import finalforeach.cosmicreach.blocks.BlockPosition;
@ -11,6 +13,7 @@ import finalforeach.cosmicreach.world.Zone;
import net.pietru.omni_power.OmniPower; import net.pietru.omni_power.OmniPower;
import net.pietru.omni_power.api.IPowerClient; import net.pietru.omni_power.api.IPowerClient;
import net.pietru.omni_power.api.IPowerProducer; import net.pietru.omni_power.api.IPowerProducer;
import org.spongepowered.asm.mixin.Shadow;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -28,11 +31,9 @@ public class Power implements IBlockAction {
} }
@Override @Override
public void act(BlockState blockState, BlockEventTrigger blockEventTrigger, Zone zone, Map<String, Object> args) { public void act(BlockEventArgs args) {
this.act(zone, (BlockPosition)args.get("blockPos")); Zone zone = args.zone;
} BlockPosition sourcePos = args.blockPos;
public void act(Zone zone, BlockPosition sourcePos) {
boolean source_be = false; boolean source_be = false;
BlockEntity source_entity = null; BlockEntity source_entity = null;
if (block_entities){ if (block_entities){
@ -56,7 +57,7 @@ public class Power implements IBlockAction {
continue; continue;
} }
if (to_check!=sourcePos || this.self_run){ if (to_check!=sourcePos || this.self_run){
runTrigger(this.triggerId,to_check,zone); runTrigger(this.triggerId,to_check,args);
} }
if (block_entities && source_be){ if (block_entities && source_be){
BlockEntity target_entity = to_check.chunk.getBlockEntity(to_check.localX,to_check.localY,to_check.localZ); BlockEntity target_entity = to_check.chunk.getBlockEntity(to_check.localX,to_check.localY,to_check.localZ);
@ -72,7 +73,9 @@ public class Power implements IBlockAction {
} }
} }
private void runTrigger(String triggerId, BlockPosition triggerPos, Zone zone) { private void runTrigger(String triggerId, BlockPosition triggerPos, BlockEventArgs args) {
Zone zone = args.zone;
if (triggerPos != null) { if (triggerPos != null) {
BlockState targetBlockState = triggerPos.getBlockState(); BlockState targetBlockState = triggerPos.getBlockState();
if (targetBlockState == null) { if (targetBlockState == null) {
@ -84,11 +87,14 @@ public class Power implements IBlockAction {
return; return;
} }
Map<String, Object> args = new HashMap<>(); BlockEventArgs newArgs = new BlockEventArgs();
args.put("blockPos", triggerPos); newArgs.blockPos = triggerPos;
newArgs.zone = zone;
newArgs.srcBlockState = targetBlockState;
newArgs.srcIdentity = args.srcIdentity;
for (BlockEventTrigger t : customTrigger) { for (BlockEventTrigger t : customTrigger) {
t.act(targetBlockState, zone, args); t.act(newArgs);
} }
} }
} }

View file

@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.utils.JsonValue; import com.badlogic.gdx.utils.JsonValue;
import finalforeach.cosmicreach.GameAssetLoader; import finalforeach.cosmicreach.GameAssetLoader;
import finalforeach.cosmicreach.gamestates.InGame; import finalforeach.cosmicreach.gamestates.InGame;
import finalforeach.cosmicreach.items.ISlotContainerParent;
import finalforeach.cosmicreach.items.ItemSlot; import finalforeach.cosmicreach.items.ItemSlot;
import finalforeach.cosmicreach.items.containers.SlotContainer; import finalforeach.cosmicreach.items.containers.SlotContainer;
import finalforeach.cosmicreach.items.screens.BaseItemScreen; import finalforeach.cosmicreach.items.screens.BaseItemScreen;
@ -28,7 +29,8 @@ public class CustomScreen extends BaseItemScreen {
SlotContainer container; SlotContainer container;
CustomUIBlockEntity blockEntity; CustomUIBlockEntity blockEntity;
public CustomScreen(final CustomUIBlockEntity be, final String ui_id) { public CustomScreen(ISlotContainerParent parent,final CustomUIBlockEntity be, final String ui_id) {
super(parent);
if (!OmniPower.uis.containsKey(ui_id)) { if (!OmniPower.uis.containsKey(ui_id)) {
System.out.println("Omni Power [ERROR] Tried accessing/opening non existent ui data."); System.out.println("Omni Power [ERROR] Tried accessing/opening non existent ui data.");
@ -51,7 +53,7 @@ public class CustomScreen extends BaseItemScreen {
for (int i = 0; i<slotWidgets.length;i++){ for (int i = 0; i<slotWidgets.length;i++){
if (slotWidgets[i]==null) if (slotWidgets[i]==null)
slotWidgets[i]=new ItemSlotWidget(container,container.getSlot(i)); slotWidgets[i]=new ItemSlotWidget(parent,container,i);
} }
@ -83,13 +85,13 @@ public class CustomScreen extends BaseItemScreen {
slot.setOutputOnly(is_output); slot.setOutputOnly(is_output);
ItemSlotWidget slotWidget; ItemSlotWidget slotWidget;
if (slot.isOutputOnly()) if (slot.isOutputOnly())
slotWidget = new ItemSlotWidget(screen.container, slot, slotWidget = new ItemSlotWidget(screen.parent, screen.container, slot.getSlotId(),
new NinePatchDrawable(UI.containerOutput9Patch), new NinePatchDrawable(UI.containerOutput9Patch),
new NinePatchDrawable(UI.containerOutput9PatchHovered), new NinePatchDrawable(UI.containerOutput9PatchHovered),
new NinePatchDrawable(UI.containerSelected9Patch) new NinePatchDrawable(UI.containerSelected9Patch)
); );
else else
slotWidget = new ItemSlotWidget(screen.container, slot); slotWidget = new ItemSlotWidget(screen.parent,screen.container, slot.getSlotId());
screen.slotWidgets[n] = slotWidget; screen.slotWidgets[n] = slotWidget;
table.add(slotWidget); table.add(slotWidget);
} }
@ -103,7 +105,7 @@ public class CustomScreen extends BaseItemScreen {
if (!UI.openContainers.contains(container, true)) { if (!UI.openContainers.contains(container, true)) {
UI.itemCatalog.show(); UI.itemCatalog.show();
UI.openContainers.add(container); UI.openContainers.add(container);
final CustomScreen screen = new CustomScreen(be, ui_id); final CustomScreen screen = new CustomScreen(be, be, ui_id);
InGame.IN_GAME.openedMainItemScreen = screen; InGame.IN_GAME.openedMainItemScreen = screen;
InGame.IN_GAME.addBaseItemScreen(screen); InGame.IN_GAME.addBaseItemScreen(screen);
Action perFrameAct = new Action() { Action perFrameAct = new Action() {