-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more reload listeners + Rocket and RocketPart structs
- Loading branch information
Juniper Primavera
committed
Sep 20, 2023
1 parent
8a2001d
commit 8227d3d
Showing
10 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/main/generated/.cache/b6572f28e8fc69d06bbdd0d02604d6271b1dffaf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// 1.20.1 2023-09-20T18:39:15.494323252 Propulsive/Advancements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/io/github/teampropulsive/data/GasReloadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.github.teampropulsive.data; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import io.github.teampropulsive.Items; | ||
import io.github.teampropulsive.Propulsive; | ||
import io.github.teampropulsive.types.Gas; | ||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; | ||
import net.minecraft.resource.Resource; | ||
import net.minecraft.resource.ResourceManager; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Map; | ||
|
||
public class GasReloadListener implements SimpleSynchronousResourceReloadListener { | ||
@Override | ||
public Identifier getFabricId() { | ||
return Propulsive.id("gas"); | ||
} | ||
|
||
@Override | ||
public void reload(ResourceManager manager) { | ||
// Clear caches here | ||
|
||
for (Map.Entry<Identifier, Resource> entry : manager.findResources("gases", path -> path.getPath().endsWith(".json")).entrySet()) { | ||
Identifier id = entry.getKey(); | ||
Resource resource = entry.getValue(); | ||
try (InputStream stream = resource.getInputStream()) { // Pretty sure this works, just gotta register it somehow (?) | ||
Gas new_gas = new Gson().fromJson(new String(stream.readAllBytes(), StandardCharsets.UTF_8), Gas.class); | ||
|
||
} catch (Exception e) { | ||
Propulsive.LOGGER.error("Error occurred while loading gas " + id.toString(), e); | ||
} | ||
} | ||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/teampropulsive/data/PlanetReloadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.teampropulsive.data; | ||
|
||
import com.google.gson.Gson; | ||
import io.github.teampropulsive.Propulsive; | ||
import io.github.teampropulsive.types.Gas; | ||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; | ||
import net.minecraft.resource.Resource; | ||
import net.minecraft.resource.ResourceManager; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Map; | ||
|
||
public class PlanetReloadListener implements SimpleSynchronousResourceReloadListener { | ||
@Override | ||
public Identifier getFabricId() { | ||
return Propulsive.id("gas"); | ||
} | ||
|
||
@Override | ||
public void reload(ResourceManager manager) { | ||
// Clear caches here | ||
|
||
for (Map.Entry<Identifier, Resource> entry : manager.findResources("planets", path -> path.getPath().endsWith(".json")).entrySet()) { | ||
Identifier id = entry.getKey(); | ||
Resource resource = entry.getValue(); | ||
try (InputStream stream = resource.getInputStream()) { | ||
|
||
} catch (Exception e) { | ||
Propulsive.LOGGER.error("Error occurred while loading planet " + id.toString(), e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.teampropulsive.types; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Rocket { | ||
double mass = 0; | ||
double drag = 1.0; | ||
int cargoSlots = 0; | ||
int playerSeats = 0; | ||
ArrayList<RocketPart> parts; | ||
|
||
public Rocket(ArrayList<RocketPart> parts) { | ||
for (RocketPart part : parts) { | ||
this.mass += part.mass; | ||
this.drag *= part.dragMultiplier; | ||
this.cargoSlots += part.extraCargoSlots; | ||
this.playerSeats += part.extraPlayerSeats; | ||
|
||
|
||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/io/github/teampropulsive/types/RocketPart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.teampropulsive.types; | ||
|
||
public class RocketPart { | ||
public double mass; | ||
public double dragMultiplier; | ||
public int extraCargoSlots; | ||
public int extraPlayerSeats; | ||
|
||
public RocketPart(double mass, double dragMultiplier, int extraCargoSlots, int extraPlayerSeats) { | ||
this.mass = mass; | ||
this.dragMultiplier = dragMultiplier; | ||
this.extraCargoSlots = extraCargoSlots; | ||
this.extraPlayerSeats = extraPlayerSeats; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.