hey i would like to change the cycle speed of day and light, who is normally to 10min day and 10min night, i want to change it to 5min day and 5min night, but there is no .setTimeSpeed, only .setTime or setTimeFull.. So what i'm trying to do is: Code: private void dayChanger() { Bukkit.getScheduler().runTaskTimer(this, new BukkitRunnable() { @Override public void run() { Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime() + LONG VALUE); } }, 0, 1); } but is the long value in ticks? help me please
@Xhork The long value is in Minecraft ticks. 20 ticks to a second in real life. You could proportionally increase it every 10 ticks to half the time.
thank's for reply but i don't understand the "to half the time", setTime(getTime *2 ) ? cause this will not work
It's 6000 at midday and 18000 at midnight but i can't find the right long tick value to put to have a day of 5min but i'll find it (i hope)
So, when i add 1 tick to the time (gettime +1) every tick, the sun sets at 5:21, and when i add 2 ticks the sun si too fast ! I can't find how to do this, cause we can't add 1.5 ticks
@Xhork What currently happens is that it increments once every tick right? So you just increment it twice every tick instead?
When I increment it once every tick the sun sets à 5:21, and when I increment it twice every tick the sun sets too fast
@Xhork Incrementing by two is double the speed which halves the time taken. Could you time how long it takes to complete 1 day with the increment of 2?
Hi, so i tested something, Code: double d = 1.8; Bukkit.getWorld("world").setTime((long) (Bukkit.getWorld("world").getTime() + d)); but i can't set the day duration to 5min
@Xhork I don't think you'll be able to get it to exactly 5 minutes but you can definitely get somewhere close.
@CraftCreeper6 I play on a UHC server, and the day is exacly 5min so it's possible but i can't understand how
Make sure you set the day cycle gamerule to false when you are doing this. Otherwise you won't be factoring the natural progression of time.
Heya @Xhork I found this issue quite interesting and I think I came up with a compromising solution. Calculate <ticks per cycle you want> / 24000 Ticks. Now don't save it as double, instead save it as numerator and denominator. Let's make an example with 12.000 Ticks per cycle. 12000 / 24000 = 0.5 (1/2) -> But we cant call a runnable every 0.5 ticks to increment the time by one, so instead we run it every whole tick and increment int by two. 14000 / 24000 = 0.58333 (7/12) -> Run every 7 ticks and increment the time by 12 ticks. As far as I can think this works. Code:java private void setDayNightSpeed(long ticks) { if(ticks != 0 && ticks <= 24000) { for(World world : Bukkit.getWorlds()) { final long finalTime; final long runnableTicks; Bruch bruch = new Bruch(ticks, 24000).kuerzen(); runnableTicks = bruch.getNum(); finalTime = bruch.getDenom(); new BukkitRunnable() { @Override public void run() { world.setTime(world.getTime() + finalTime); } }.runTaskTimer(this, 0L, runnableTicks); } } } Code:java public class Bruch { private long num; private long denom; public Bruch(long num, long denom) { this.num = num; this.denom = denom; } public long getNum() { return this.num; } public long getDenom() { return this.denom; } public Bruch kuerzen() { long numResult = this.num / ggT(); long denumResult = this.denom / ggT(); return new Bruch(numResult, denumResult); } public long ggT() { ArrayList<Long> longListNum = new ArrayList<Long>(); for(long i=1; i<=this.num; i++) { if(this.num % i == 0) { longListNum.add(i); } } ArrayList<Long> longListdenum = new ArrayList<Long>(); for(long i=1; i<=this.denom; i++) { if(this.denom % i == 0) { longListdenum.add(i); } } ArrayList<Long> complete = new ArrayList<Long>(); for(long l1 : longListNum) { for(long l2 : longListdenum) { if(l1 == l2) { complete.add(l1); } } } long max = 0; for(int i=0; i<complete.size(); i++) { max = Long.MIN_VALUE; if(complete.get(i) > max) { max = complete.get(i); } } return max; } public Bruch addBruch(Bruch other) { long numResult = this.num * other.denom + this.denom * other.num; long denumResult = this.num * other.denom; Bruch ausgabe = new Bruch(numResult, denumResult); return ausgabe; } public Bruch subBruch(Bruch other) { long numResult = this.num * other.denom - this.denom * other.num; long denumResult = this.num * other.denom; Bruch ausgabe = new Bruch(numResult, denumResult); return ausgabe; } public Bruch multBruch(Bruch other) { long numResult = this.num * other.denom; long denumResult = this.denom * other.num; return new Bruch(numResult, denumResult); }}