mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-10 17:27:37 +01:00
3.0.0-SNAPSHOT-U36
+ Finished up the spray system on the droptables, therefore completing but not tested DropTables
This commit is contained in:
parent
6039cf58c4
commit
65d8827dc5
@ -13,10 +13,13 @@ import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.managers.files.DropTableFileManager;
|
||||
import com.songoda.epicbosses.managers.files.ItemsFileManager;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.RandomUtils;
|
||||
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -244,7 +247,7 @@ public class BossEntityManager {
|
||||
SprayTableElement sprayTableElement = (SprayTableElement) dropTable.getRewards();
|
||||
List<ItemStack> itemStacks = this.bossDropTableManager.getSprayItems(sprayTableElement);
|
||||
|
||||
//TODO: Spray itemstacks
|
||||
sprayDrops(sprayTableElement, itemStacks, deadBossHolder);
|
||||
} else if(dropType.equalsIgnoreCase("GIVE")) {
|
||||
GiveTableElement giveTableElement = (GiveTableElement) dropTable.getRewards();
|
||||
|
||||
@ -259,4 +262,33 @@ public class BossEntityManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void sprayDrops(SprayTableElement sprayTableElement, List<ItemStack> rewards, DeadBossHolder deadBossHolder) {
|
||||
Integer maximumDistance = sprayTableElement.getSprayMaxDistance();
|
||||
|
||||
if(maximumDistance == null) maximumDistance = 10;
|
||||
|
||||
Location deathLocation = deadBossHolder.getLocation();
|
||||
Integer finalMaximumDistance = maximumDistance;
|
||||
|
||||
rewards.forEach(itemStack -> {
|
||||
Location destinationLocation = deathLocation.clone();
|
||||
int x = RandomUtils.get().getRandomNumber(finalMaximumDistance + 1);
|
||||
int currentX = destinationLocation.getBlockX();
|
||||
int z = RandomUtils.get().getRandomNumber(finalMaximumDistance + 1);
|
||||
int currentZ = destinationLocation.getBlockZ();
|
||||
|
||||
if(RandomUtils.get().preformRandomAction()) x = -x;
|
||||
if(RandomUtils.get().preformRandomAction()) z = -z;
|
||||
|
||||
destinationLocation.setX(currentX + x);
|
||||
destinationLocation.setZ(currentZ + z);
|
||||
|
||||
Item item = deathLocation.getWorld().dropItemNaturally(deathLocation, itemStack);
|
||||
Vector vector = deathLocation.toVector().subtract(destinationLocation.toVector()).normalize();
|
||||
|
||||
item.setPickupDelay(20);
|
||||
item.setVelocity(vector);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,10 +13,20 @@ public class RandomUtils {
|
||||
|
||||
private Random random = new Random();
|
||||
|
||||
public boolean preformRandomAction() {
|
||||
int rand = getRandomNumber(2);
|
||||
|
||||
return rand <= 0;
|
||||
}
|
||||
|
||||
public int getRandomNumber() {
|
||||
return this.random.nextInt(100);
|
||||
}
|
||||
|
||||
public int getRandomNumber(int maximum) {
|
||||
return this.random.nextInt(maximum);
|
||||
}
|
||||
|
||||
public double getRandomDecimalNumber() {
|
||||
double amount = getRandomNumber();
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<plugin.version>1.0.0-SNAPSHOT-U35</plugin.version>
|
||||
<plugin.version>1.0.0-SNAPSHOT-U36</plugin.version>
|
||||
<plugin.name>EpicBosses</plugin.name>
|
||||
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
|
||||
<plugin.author>AMinecraftDev</plugin.author>
|
||||
|
Loading…
Reference in New Issue
Block a user