mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Fixes
This commit is contained in:
parent
ee18217520
commit
9a11021560
@ -402,4 +402,9 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
IrisBiome getFocus();
|
||||
|
||||
void hotloading();
|
||||
|
||||
default void saveProperties()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Data
|
||||
@Desc("Represents a combined duration. Fill each property to add time into a single duration")
|
||||
public class IrisDuration {
|
||||
@Desc("Milliseconds (1000ms = 1 second)")
|
||||
private int milliseconds = 0;
|
||||
|
||||
@Desc("Minecraft Ticks (20 minecraft ticks = 1 second")
|
||||
private int minecraftTicks = 0;
|
||||
|
||||
@Desc("Seconds (60 seconds = 1 minute)")
|
||||
private int seconds = 0;
|
||||
|
||||
@Desc("Minutes (60 minutes = 1 hour)")
|
||||
private int minutes = 0;
|
||||
|
||||
@Desc("Minecraft Hours (about 50 real seconds)")
|
||||
private int minecraftHours = 0;
|
||||
|
||||
@Desc("Hours (24 hours = 1 day)")
|
||||
private int hours = 0;
|
||||
|
||||
@Desc("Minecraft Days (1 minecraft day = 20 real minutes)")
|
||||
private int minecraftDays = 0;
|
||||
|
||||
@Desc("Minecraft Weeks (1 minecraft week = 2 real hours and 18 real minutes)")
|
||||
private int minecraftWeeks = 0;
|
||||
|
||||
@Desc("Minecraft Lunar Cycles (1 minecraft lunar cycle = 2 real hours and 36 real minutes)")
|
||||
private int minecraftLunarCycles = 0;
|
||||
|
||||
@Desc("REAL (not minecraft) Days")
|
||||
private int days = 0;
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return Form.duration((double) toMilliseconds(), 2);
|
||||
}
|
||||
|
||||
public long toMilliseconds()
|
||||
{
|
||||
return getMilliseconds()
|
||||
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
||||
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
||||
+ TimeUnit.HOURS.toMillis(getHours())
|
||||
+ TimeUnit.DAYS.toMillis(getDays())
|
||||
+ (getMinecraftTicks() * 50L)
|
||||
+ (getMinecraftHours() * 50000L)
|
||||
+ (getMinecraftWeeks() * 50000L)
|
||||
+ (getMinecraftDays() * 24000L)
|
||||
+ (getMinecraftWeeks() * 168000L)
|
||||
+ (getMinecraftLunarCycles() * 192000L);
|
||||
}
|
||||
}
|
54
src/main/java/com/volmit/iris/engine/object/IrisRate.java
Normal file
54
src/main/java/com/volmit/iris/engine/object/IrisRate.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Desc("Represents a count of something per time duration")
|
||||
public class IrisRate {
|
||||
@Desc("The amount of things. Leave 0 for infinite (meaning always spawn whenever)")
|
||||
private int amount = 0;
|
||||
|
||||
@Desc("The time interval. Leave blank for infinite 0 (meaning always spawn all the time)")
|
||||
private IrisDuration per = new IrisDuration();
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return Form.f(amount) + "/" + per;
|
||||
}
|
||||
|
||||
public long getInterval()
|
||||
{
|
||||
long t = per.getMilliseconds() / amount;
|
||||
return Math.abs(t <= 0 ? 1 : t);
|
||||
}
|
||||
|
||||
public ChronoLatch toChronoLatch()
|
||||
{
|
||||
return new ChronoLatch(getInterval());
|
||||
}
|
||||
}
|
@ -34,6 +34,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ -46,23 +47,17 @@ public class IrisSpawner extends IrisRegistrant {
|
||||
@Desc("The entity spawns to add")
|
||||
private KList<IrisEntitySpawn> spawns = new KList<>();
|
||||
|
||||
private AtomicCache<KList<IrisEntitySpawn>> selection = new AtomicCache<>();
|
||||
@Desc("The block of 24 hour time to contain this spawn in.")
|
||||
private IrisTimeBlock timeBlock = new IrisTimeBlock();
|
||||
|
||||
public boolean spawnInChunk(Engine engine, Chunk c) {
|
||||
if(spawns.isEmpty())
|
||||
{
|
||||
Iris.warn(" Spawner " + getLoadKey() + " has an empty spawn list! (" + getLoadFile().getPath() + ")");
|
||||
return false;
|
||||
}
|
||||
@Desc("The block of 24 hour time to contain this spawn in.")
|
||||
private IrisWeather weather = IrisWeather.ANY;
|
||||
|
||||
return selection.aquire(() -> {
|
||||
KList<IrisEntitySpawn> rarityTypes = new KList<>();
|
||||
@Desc("The maximum rate this spawner can fire")
|
||||
private IrisRate maximumRate = new IrisRate();
|
||||
|
||||
for (IrisEntitySpawn i : spawns) {
|
||||
rarityTypes.addMultiple(i, IRare.get(i));
|
||||
}
|
||||
|
||||
return rarityTypes;
|
||||
}).getRandom(RNG.r).spawn(engine, c, RNG.r);
|
||||
public boolean isValid(World world)
|
||||
{
|
||||
return timeBlock.isWithin(world) && weather.is(world);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
@Data
|
||||
@Desc("Represents a time of day (24h time, not 12h am/pm). Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
public class IrisTimeBlock {
|
||||
@Desc("The beginning hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double startHour = 0;
|
||||
|
||||
@Desc("The ending hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double endHour = 0;
|
||||
|
||||
public boolean isWithin(World world)
|
||||
{
|
||||
return isWithin(world.getTime() / 1000D);
|
||||
}
|
||||
|
||||
public boolean isWithin(double hour)
|
||||
{
|
||||
if(startHour == endHour)
|
||||
{
|
||||
if(endHour == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(startHour > endHour)
|
||||
{
|
||||
return !(hour >= startHour && hour <= endHour);
|
||||
}
|
||||
|
||||
return hour >= startHour && hour <= endHour;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
@Desc("Represents a weather type")
|
||||
public enum IrisWeather {
|
||||
@ -27,5 +28,22 @@ public enum IrisWeather {
|
||||
NONE,
|
||||
|
||||
@Desc("Represents rain or snow")
|
||||
DOWNFALL
|
||||
DOWNFALL,
|
||||
|
||||
@Desc("Represents rain or snow with thunder")
|
||||
DOWNFALL_WITH_THUNDER,
|
||||
|
||||
@Desc("Any weather")
|
||||
ANY;
|
||||
|
||||
public boolean is(World world)
|
||||
{
|
||||
return switch(this)
|
||||
{
|
||||
case NONE -> world.isClearWeather();
|
||||
case DOWNFALL -> world.hasStorm() && world.isThundering();
|
||||
case DOWNFALL_WITH_THUNDER -> world.hasStorm();
|
||||
case ANY -> true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -16,22 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
package com.volmit.iris.engine.object.engine;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Desc("Represents a time of day (24h time, not 12h am/pm)")
|
||||
public class IrisTime {
|
||||
@Desc("The beginning hour")
|
||||
private double startHour = 0;
|
||||
public class IrisEngineData
|
||||
{
|
||||
|
||||
@Desc("The ending hour")
|
||||
private double endHour = 24;
|
||||
|
||||
public boolean isWithin(double hour)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object.engine;
|
||||
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.IrisRate;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IrisEngineSpawnerCooldown
|
||||
{
|
||||
private long lastSpawn;
|
||||
private String spawner;
|
||||
|
||||
public void spawn(Engine engine)
|
||||
{
|
||||
lastSpawn = M.ms();
|
||||
engine.saveProperties();
|
||||
}
|
||||
|
||||
public boolean canSpawn(IrisRate s)
|
||||
{
|
||||
return M.ms() - lastSpawn > s.getInterval();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user