Skip to content

Commit

Permalink
20231025
Browse files Browse the repository at this point in the history
  • Loading branch information
PiggyChu620 committed Oct 25, 2023
1 parent 59477c5 commit f6ba17b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 31 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mindustry Java Mod - Random Planet v0.4.4
# Mindustry Java Mod - Random Planet v0.4.5
A Java Mindustry mod.

Randomly generate a planet and its sectors, including the starting sector.
Expand Down Expand Up @@ -119,6 +119,9 @@ I combined both technologies from Serpulo and Erekir as best as I could, includi
- Increase the size of the pathways, so it doesn't look like "tunnels/canals".
- Increase the range of ore selection.

*v0.4.5*
- Rework liquid placement to sync with [Mineable Alloys](https://github.com/PiggyChu620/MindustryMineableAlloys) 1.3 update

---

**1.** [Schematic Instruction](SchematicInstruction.md)
Expand Down
4 changes: 2 additions & 2 deletions mod.hjson
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#the mod name as displayed in-game
displayName: "Random Planet v0.4.4"
displayName: "Random Planet v0.4.5"

repo: "PiggyChu620/MindustryRandomPlanet"

Expand All @@ -16,7 +16,7 @@ main: "ec620.EC620JavaMod"
description: "Randomly generate a planet and its sectors.\nIt's a mixtech mod, I myself don't like the idea of \"Oh, you can only use these things here, and you can only use those things there, bruh, bruh, bruh!\", so I make one myself, if you don't like mixtech and think it's \"unbalanced\" and \"boring\", then please go away, much appreciated!"

#the mod version
version: 0.4.4
version: 0.4.5

#the minimum game build required to run this mod
minGameVersion: 140
Expand Down
2 changes: 1 addition & 1 deletion src/ec620/EC620JavaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public EC620JavaMod()
dd.titleFont= Fonts.def;
dd.titleFontColor=new Color(1,0,0);
BaseDialog dialog = new BaseDialog("Random Planet", dd);
dialog.cont.add("Welcome to Random Planet v0.4.4",Color.green,1.2f).center().row();
dialog.cont.add("Welcome to Random Planet v0.4.5",Color.green,1.2f).center().row();
dialog.cont.add("Please see Settings for customization",Color.cyan).center().row();
//dialog.cont.add("in order to see the setting info,",Color.cyan).row();
//dialog.cont.add("I can not figure out how to make it wrap,",Color.cyan).row();
Expand Down
85 changes: 58 additions & 27 deletions src/ec620/content/EC620PlanetGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.Map;

import static ec620.EC620JavaMod.*;
import static mindustry.Vars.*;
Expand Down Expand Up @@ -386,7 +387,7 @@ else if(moss > 0.21f){
//return toShallowMoss.get(res, res);
return Blocks.moss;
}
if(!hasSand && res.itemDrop== Items.sand) hasSand=true;
if(!hasSand && res.itemDrop == Items.sand) hasSand=true;

return res;
}
Expand Down Expand Up @@ -596,7 +597,9 @@ void setOre(Block block)
for(int i=0;i<l;i++)
{
Block b=availableOres.get(i);
if(pgRand.chance(0.01d) || pgRand.nextDouble()*2>=b.itemDrop.cost) ores.add(b);
String name="ma620."+b.name;
if(Core.settings.has(name)) if(pgRand.chance(Core.settings.getFloat(name)/100f)) ores.add(b);
else if(pgRand.nextDouble()*2>=b.itemDrop.cost) ores.add(b);
// if(Simplex.noise3d(seed, 2, 0.5, scl, sector.tile.v.x+i, sector.tile.v.y, sector.tile.v.z)*nmag + poles > (i+1)*addscl/(l+1))
// {
// ores.add(availableOres.get(i));
Expand All @@ -605,8 +608,10 @@ void setOre(Block block)
while(ores.size<5)
{
Block b=availableOres.getFrac(pgRand.nextFloat());
String n="ma620."+b.name;

if(pgRand.chance(0.01d) || pgRand.nextDouble()*2>=b.itemDrop.cost) ores.add(b);
if(Core.settings.has(n)) if(pgRand.chance(Core.settings.getFloat(n)/100f)) ores.add(b);
else if(pgRand.nextDouble()*2>=b.itemDrop.cost) ores.add(b);
}

}
Expand Down Expand Up @@ -817,14 +822,14 @@ void setOre(Block block)
// r.setFloor(arkyciteFloor.asFloor());
// }

boolean isWater=pgRand.chance(.5f) || sector.id==0;
//boolean isWater=pgRand.chance(.5f) || sector.id==0;
Seq<LakeHandler> lakeSeq=new Seq<>();
Seq<Vec2> lakeVec=new Seq<>();
Seq<Room> newRooms=new Seq<>();
//rivers
pass((x, y) ->
{
//if(block.solid) return;
if(block.solid) return;

Vec3 v = sector.rect.project(x, y);

Expand All @@ -841,19 +846,19 @@ void setOre(Block block)
//do not place rivers on ice, they're frozen
//ignore pre-existing liquids

if(!(floor == Blocks.ice || floor == Blocks.iceSnow || floor == Blocks.snow || floor.asFloor().isLiquid))
if(!floor.asFloor().isLiquid)
{
if(isWater)
{
floor = spore ?
(deep ? Blocks.taintedWater : Blocks.darksandTaintedWater) :
(deep ? Blocks.water :
(floor == Blocks.sand || floor == Blocks.salt ? Blocks.sandWater : Blocks.darksandWater));
}
else
{
// if(isWater)
// {
// floor = spore ?
// (deep ? Blocks.taintedWater : Blocks.darksandTaintedWater) :
// (deep ? Blocks.water :
// (floor == Blocks.sand || floor == Blocks.salt ? Blocks.sandWater : Blocks.darksandWater));
// }
// else
// {
lakeVec.add(new Vec2(x,y));
}
//}
// {
// if(lakeSeq.size==0)
// {
Expand Down Expand Up @@ -884,9 +889,40 @@ void setOre(Block block)
}
}
});
Seq<Block> availableLiquids=Seq.with(Blocks.water, cryofluid, slag, tar, arkyciteFloor);
int n=pgRand.nextInt(5)+1;
Seq<Block> availableLiquids=content.blocks().select(x->x instanceof Floor && x.asFloor().liquidDrop!=null);
// ObjectMap<Liquid,Seq<Block>> availableLiquids=new ObjectMap<>();
// Seq<Liquid> keys=new Seq<>();
// for(Liquid li: content.liquids().select(x->!x.hidden))
// {
// Seq<Block> bs=content.blocks().select(x->x instanceof Floor && x.asFloor().liquidDrop==li);
// if(bs.size>0)
// {
// keys.add(li);
// availableLiquids.put(li, bs);
// }
// }
int n=pgRand.nextInt(availableLiquids.size)+1;

Seq<Block> liquids=new Seq<>();
while(liquids.size<n)
{
Block li = availableLiquids.getFrac(pgRand.nextFloat());
String name="ma620."+li.name;
if(Core.settings.has(name))
{
if(pgRand.chance(Core.settings.getFloat(name)/100f))
{
liquids.add(li);
availableLiquids.remove(li);
}
}
else
{
liquids.add(li);
availableLiquids.remove(li);
}
}
if(!liquids.contains(x->x.asFloor().liquidDrop==Liquids.water) && (sector.id==0 || pgRand.chance(.5f))) liquids.add(Blocks.water);
while(lakeVec.size>0)
{
Vec2 vec=lakeVec.get(0);
Expand All @@ -899,18 +935,13 @@ void setOre(Block block)
lakeVec.removeAll(s);
seq.addAll(s);
}
Block b;
if(liquids.size<n)
{
b=availableLiquids.getFrac(pgRand.nextFloat());
liquids.addUnique(b);
}
else b=liquids.getFrac(pgRand.nextFloat());
LakeHandler lh=new LakeHandler(seq,b);

//Liquid li = liquids.getFrac(pgRand.nextFloat());
//LakeHandler lh=new LakeHandler(seq,availableLiquids.get(li).getFrac(pgRand.nextFloat()));
LakeHandler lh=new LakeHandler(seq,liquids.getFrac(pgRand.nextFloat()));
lakeSeq.add(lh);
//newRooms.add(new Room((int)lh.center.x,(int)lh.center.y,(int)lh.radius));
}

for(LakeHandler lh:lakeSeq)
{
for(Vec2 v:lh.pos)
Expand Down

0 comments on commit f6ba17b

Please sign in to comment.