From 31833b974a53ff92b57c805a8b39a412970dabbc Mon Sep 17 00:00:00 2001 From: RangerMauve Date: Thu, 31 Jul 2014 20:16:48 -0400 Subject: [PATCH] Simplified randomizeFloor to be more performant --- src/ca/gibstick/discosheep/DiscoParty.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ca/gibstick/discosheep/DiscoParty.java b/src/ca/gibstick/discosheep/DiscoParty.java index f41ad54..2119c38 100644 --- a/src/ca/gibstick/discosheep/DiscoParty.java +++ b/src/ca/gibstick/discosheep/DiscoParty.java @@ -337,9 +337,10 @@ public class DiscoParty { sheep.setColor(discoColours[(r.nextInt(discoColours.length))]); } - void randomizeFloor(Block block) { + void randomizeFloor(Block block, int index) { + int to_color = (index + state) % disocColors.length; block.setType(Material.WOOL); - block.setData(discoColours[(r.nextInt(discoColours.length))].getData()); + block.setData(discoColours[to_color].getData()); } void jump(Entity entity) { @@ -433,9 +434,8 @@ public class DiscoParty { } } } - - for (Block block : this.floorBlocks) { - this.randomizeFloor(block); + for(int i = 0; i < this.floorBlocks.length;i++){ + this.randomizeFloor(block,i); } }