mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Attempt block drops
This commit is contained in:
parent
e1e0368f8c
commit
cff402affb
@ -32,6 +32,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class IrisWorldManager extends EngineAssignedWorldManager {
|
public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||||
private boolean spawnable;
|
private boolean spawnable;
|
||||||
@ -155,7 +156,71 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent e) {
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
|
if(e.getBlock().getWorld().equals(getTarget().getWorld().realWorld()) && getEngine().contains(e.getBlock().getLocation()))
|
||||||
|
{
|
||||||
|
KList<ItemStack> d = new KList<>();
|
||||||
|
Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i)));
|
||||||
|
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation());
|
||||||
|
|
||||||
|
for(IrisBlockDrops i : b.getBlockDrops())
|
||||||
|
{
|
||||||
|
if(i.shouldDropFor(e.getBlock().getBlockData(), getData()))
|
||||||
|
{
|
||||||
|
if(i.isReplaceVanillaDrops())
|
||||||
|
{
|
||||||
|
e.setDropItems(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
i.fillDrops(false, d);
|
||||||
|
|
||||||
|
if(i.isSkipParents())
|
||||||
|
{
|
||||||
|
drop.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
|
||||||
|
|
||||||
|
for(IrisBlockDrops i : r.getBlockDrops())
|
||||||
|
{
|
||||||
|
if(i.shouldDropFor(e.getBlock().getBlockData(), getData()))
|
||||||
|
{
|
||||||
|
if(i.isReplaceVanillaDrops())
|
||||||
|
{
|
||||||
|
e.setDropItems(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
i.fillDrops(false, d);
|
||||||
|
|
||||||
|
if(i.isSkipParents())
|
||||||
|
{
|
||||||
|
drop.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(IrisBlockDrops i : getEngine().getDimension().getBlockDrops())
|
||||||
|
{
|
||||||
|
if(i.shouldDropFor(e.getBlock().getBlockData(), getData()))
|
||||||
|
{
|
||||||
|
if(i.isReplaceVanillaDrops())
|
||||||
|
{
|
||||||
|
e.setDropItems(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
i.fillDrops(false, d);
|
||||||
|
|
||||||
|
if(i.isSkipParents())
|
||||||
|
{
|
||||||
|
drop.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,8 +83,6 @@ public class IrisBlockDrops {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: WARNING USES RNG.R
|
|
||||||
@Deprecated
|
|
||||||
public void fillDrops(boolean debug, KList<ItemStack> d) {
|
public void fillDrops(boolean debug, KList<ItemStack> d) {
|
||||||
for (IrisLoot i : getDrops()) {
|
for (IrisLoot i : getDrops()) {
|
||||||
if (RNG.r.i(1, i.getRarity()) == i.getRarity()) {
|
if (RNG.r.i(1, i.getRarity()) == i.getRarity()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user