Skip to content

Commit

Permalink
Merge pull request #920 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NextdoorPsycho authored Oct 28, 2022
2 parents 7b93542 + ef9966d commit a642726
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 56 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}

version '2.3.6-1.19.2' // Needs to be version specific
version '2.3.7-1.19.2' // Needs to be version specific
def nmsVersion = "1.19.2" //[NMS]
def apiVersion = '1.19'
def specialSourceVersion = '1.11.0' //[NMS]
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/volmit/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {

public static final String OVERWORLD_TAG = "2090";
public static final String OVERWORLD_TAG = "2091";

private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.entity.EnderSignal;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.inventory.EquipmentSlot;

import java.util.concurrent.atomic.AtomicBoolean;

Expand Down Expand Up @@ -100,35 +99,40 @@ public void on(WorldSaveEvent e) {
}

@EventHandler
public void on(EntitySpawnEvent e) {
if(e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) {
if(e.getEntityType().equals(EntityType.ENDER_SIGNAL)) {
KList<Position2> p = getEngine().getDimension().getStrongholds(getEngine().getSeedManager().getSpawn());
Position2 px = new Position2(e.getEntity().getLocation().getBlockX(), e.getEntity().getLocation().getBlockZ());
Position2 pr = null;
double d = Double.MAX_VALUE;

Iris.debug("Ps: " + p.size());

for(Position2 i : p) {
Iris.debug("- " + i.getX() + " " + i.getZ());
}

for(Position2 i : p) {
double dx = i.distance(px);
if(dx < d) {
d = dx;
pr = i;
}
public void onItemUse(PlayerInteractEvent e) {
if(e.getItem() == null || e.getHand() != EquipmentSlot.HAND)
return;
if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR)
return;
if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld()) && e.getItem().getType() == Material.ENDER_EYE) {
KList<Position2> positions = getEngine().getDimension().getStrongholds(getEngine().getSeedManager().getSpawn());
if(positions.isEmpty())
return;

Position2 playerPos = new Position2(e.getPlayer().getLocation().getBlockX(), e.getPlayer().getLocation().getBlockZ());
Position2 pr = positions.get(0);
double d = pr.distance(playerPos);

for(Position2 pos : positions) {
double distance = pos.distance(playerPos);
if(distance < d) {
d = distance;
pr = pos;
}
}

if(pr != null) {
e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.ITEM_TRIDENT_THROW, 1f, 1.6f);
Location ll = new Location(e.getEntity().getWorld(), pr.getX(), 40, pr.getZ());
Iris.debug("ESignal: " + ll.getBlockX() + " " + ll.getBlockZ());
((EnderSignal) e.getEntity()).setTargetLocation(ll);
if(e.getPlayer().getGameMode() != GameMode.CREATIVE) {
if(e.getItem().getAmount() > 1) {
e.getPlayer().getInventory().getItemInMainHand().setAmount(e.getItem().getAmount() - 1);
} else {
e.getPlayer().getInventory().setItemInMainHand(null);
}
}

EnderSignal eye = e.getPlayer().getWorld().spawn(e.getPlayer().getLocation().clone().add(0, 0.5F, 0), EnderSignal.class);
eye.setTargetLocation(new Location(e.getPlayer().getWorld(), pr.getX(), 40, pr.getZ()));
eye.getWorld().playSound(eye, Sound.ENTITY_ENDER_EYE_LAUNCH, 1, 1);
Iris.debug("ESignal: " + eye.getTargetLocation().getBlockX() + " " + eye.getTargetLocation().getBlockX());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjec
int zz = i.getPosition().getZ() + sz;
RNG rngf = new RNG(Cache.key(xx, zz));
int offset = i.getPosition().getY() - startHeight;
int height = 0;
int height;

if(i.getStructure().getStructure().getLockY() == -1) {
if(i.getStructure().getStructure().getOverrideYRange() != null) {
Expand Down
44 changes: 23 additions & 21 deletions src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,31 +190,33 @@ default int getRealRadius() {

@ChunkCoordinates
default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
if(!getEngine().getDimension().isUseMantle()) {
return;
}
synchronized(this) {
if(!getEngine().getDimension().isUseMantle()) {
return;
}

int s = getRealRadius();
BurstExecutor burst = burst().burst(multicore);
MantleWriter writer = getMantle().write(this, x, z, s * 2);
for(int i = -s; i <= s; i++) {
for(int j = -s; j <= s; j++) {
int xx = i + x;
int zz = j + z;
burst.queue(() -> {
IrisContext.touch(getEngine().getContext());
getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> {
MantleChunk mc = getMantle().getChunk(xx, zz);

for(MantleComponent k : getComponents()) {
generateMantleComponent(writer, xx, zz, k, mc, context);
}
int s = getRealRadius();
BurstExecutor burst = burst().burst(multicore);
MantleWriter writer = getMantle().write(this, x, z, s * 2);
for(int i = -s; i <= s; i++) {
for(int j = -s; j <= s; j++) {
int xx = i + x;
int zz = j + z;
burst.queue(() -> {
IrisContext.touch(getEngine().getContext());
getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> {
MantleChunk mc = getMantle().getChunk(xx, zz);

for(MantleComponent k : getComponents()) {
generateMantleComponent(writer, xx, zz, k, mc, context);
}
});
});
});
}
}
}

burst.complete();
burst.complete();
}
}

default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc, ChunkContext context) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/volmit/iris/util/mantle/Mantle.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ public boolean hasTectonicPlate(int x, int z) {
*/
@ChunkCoordinates
public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator) {
if(!hasTectonicPlate(x >> 5, z >> 5)) {
/*if(!hasTectonicPlate(x >> 5, z >> 5)) {
return;
}
}*/

get(x >> 5, z >> 5).getOrCreate(x & 31, z & 31).iterate(type, iterator);
}
Expand Down

0 comments on commit a642726

Please sign in to comment.