Skip to content

Commit

Permalink
Merge pull request #872 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NextdoorPsycho authored Aug 23, 2022
2 parents eae7fc0 + 0b403cf commit 1d3681b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 56 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/volmit/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ public static void reportError(Throwable e) {
}

private void enable() {
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
instance = this;
services = new KMap<>();
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
Expand Down Expand Up @@ -414,8 +416,6 @@ private void enable() {
splash();
autoStartStudio();
checkForBukkitWorlds();
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void hand() {
@Decree(description = "What biome am i in?", origin = DecreeOrigin.PLAYER)
public void biome() {
try {
IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ());
IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY() - player().getWorld().getMinHeight(), player().getLocation().getBlockZ());
sender().sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");

} catch(Throwable e) {
Expand Down
65 changes: 16 additions & 49 deletions src/main/java/com/volmit/iris/engine/IrisWorldManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@

import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
import com.volmit.iris.engine.object.IRare;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBlockDrops;
import com.volmit.iris.engine.object.IrisEngineChunkData;
import com.volmit.iris.engine.object.IrisEngineData;
import com.volmit.iris.engine.object.IrisEngineSpawnerCooldown;
import com.volmit.iris.engine.object.IrisEntitySpawn;
import com.volmit.iris.engine.object.IrisMarker;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.IrisSpawner;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
Expand All @@ -55,6 +45,7 @@
import lombok.EqualsAndHashCode;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
Expand All @@ -69,7 +60,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -617,7 +607,6 @@ public Map<IrisPosition, KSet<IrisSpawner>> getSpawnersFromMarkers(Chunk c) {
@Override
public void onBlockBreak(BlockBreakEvent e) {
if(e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) {

J.a(() -> {
MatterMarker marker = getMantle().get(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class);

Expand All @@ -635,52 +624,30 @@ public void onBlockBreak(BlockBreakEvent e) {
});

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());
List<IrisBlockDrops> dropProviders = filterDrops(b.getBlockDrops(), e, getData());

if(dropItems(e, d, drop, b.getBlockDrops(), b)) {
return;
if(dropProviders.stream().noneMatch(IrisBlockDrops::isSkipParents)) {
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
dropProviders.addAll(filterDrops(r.getBlockDrops(), e, getData()));
dropProviders.addAll(filterDrops(getEngine().getDimension().getBlockDrops(), e, getData()));
}

IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
dropProviders.forEach(provider -> provider.fillDrops(false, d));

if(dropItems(e, d, drop, r.getBlockDrops(), b)) {
return;
if(dropProviders.stream().anyMatch(IrisBlockDrops::isReplaceVanillaDrops)) {
e.setDropItems(false);
}

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;
}
}
if(d.isNotEmpty()) {
World w = e.getBlock().getWorld();
J.s(() -> d.forEach(item -> w.dropItemNaturally(e.getBlock().getLocation().clone().add(.5, .5, .5), item)));
}
}
}

private boolean dropItems(BlockBreakEvent e, KList<ItemStack> d, Runnable drop, KList<IrisBlockDrops> blockDrops, IrisBiome b) {
for(IrisBlockDrops i : blockDrops) {
if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
if(i.isReplaceVanillaDrops()) {
e.setDropItems(false);
}

i.fillDrops(false, d);

if(i.isSkipParents()) {
drop.run();
return true;
}
}
}
return false;
private List<IrisBlockDrops> filterDrops(KList<IrisBlockDrops> drops, BlockBreakEvent e, IrisData data) {
return new KList<>(drops.stream().filter(d -> d.shouldDropFor(e.getBlock().getBlockData(), data)).toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public class IrisBlockDrops {
private boolean replaceVanillaDrops = false;

public boolean shouldDropFor(BlockData data, IrisData rdata) {
KList<BlockData> list = this.data.aquire(() ->
{
KList<BlockData> list = this.data.aquire(() -> {
KList<BlockData> b = new KList<>();

for(IrisBlockData i : getBlocks()) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/volmit/iris/util/mantle/Mantle.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ public MantleChunk getChunk(Chunk e) {
}

public void deleteChunkSlice(int x, int z, Class<?> c) {
if(!IrisToolbelt.toolbeltConfiguration.isEmpty() && IrisToolbelt.toolbeltConfiguration.getOrDefault("retain.mantle." + c.getCanonicalName(), false))
{
if(!IrisToolbelt.toolbeltConfiguration.isEmpty() && IrisToolbelt.toolbeltConfiguration.getOrDefault("retain.mantle." + c.getCanonicalName(), false)) {
return;
}

Expand Down

0 comments on commit 1d3681b

Please sign in to comment.