This commit is contained in:
Eoghanmc22 2020-08-13 14:51:40 -04:00
commit 94279e2dbf
5 changed files with 32 additions and 23 deletions

View File

@ -112,7 +112,7 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.12'
// Path finding
api 'com.github.MadMartian:hydrazine-path-finding:1.3.0'
api 'com.github.MadMartian:hydrazine-path-finding:1.3.1'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
api 'com.github.jglrxavpok:Hephaistos:v1.0.5'

View File

@ -339,8 +339,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
return;
}
boolean chunkUnloaded = !ChunkUtils.isLoaded(instance, position.getX(), position.getZ());
if (chunkUnloaded) {
if (!ChunkUtils.isLoaded(instance, position.getX(), position.getZ())) {
// No update for entities in unloaded chunk
return;
}
@ -392,6 +391,11 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
);
onGround = CollisionUtils.handlePhysics(this, deltaPos, newPosition, newVelocityOut);
// Check chunk
if (!ChunkUtils.isLoaded(instance, newPosition.getX(), newPosition.getZ())) {
return;
}
// World border collision
{
final WorldBorder worldBorder = instance.getWorldBorder();
@ -461,10 +465,11 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
chunkUnloaded = !ChunkUtils.isLoaded(instance, x, z);
if (chunkUnloaded)
final Chunk chunk = instance.getChunkAt(x, z);
if (!ChunkUtils.isLoaded(chunk))
continue;
final CustomBlock customBlock = instance.getCustomBlock(x, y, z);
final CustomBlock customBlock = chunk.getCustomBlock(x, y, z);
if (customBlock != null) {
tmpPosition.setX(x);
tmpPosition.setY(y);

View File

@ -650,7 +650,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
* @param z the Z position
* @return the chunk at the given position, null if not loaded
*/
public Chunk getChunkAt(double x, double z) {
public Chunk getChunkAt(float x, float z) {
final int chunkX = ChunkUtils.getChunkCoordinate((int) x);
final int chunkZ = ChunkUtils.getChunkCoordinate((int) z);
return getChunk(chunkX, chunkZ);

View File

@ -518,10 +518,8 @@ public class InventoryClickProcessor {
// Wait for inventory conditions + events to possibly close the inventory
player.UNSAFE_changeDidCloseInventory(false);
final List<InventoryCondition> inventoryConditions = isPlayerInventory ?
player.getInventory().getInventoryConditions() : inventory.getInventoryConditions();
if (!inventoryConditions.isEmpty()) {
// PreClickEvent
{
InventoryPreClickEvent inventoryPreClickEvent = new InventoryPreClickEvent(player, inventory, slot, clickType, clicked, cursor);
player.callEvent(InventoryPreClickEvent.class, inventoryPreClickEvent);
cursor = inventoryPreClickEvent.getCursorItem();
@ -531,6 +529,12 @@ public class InventoryClickProcessor {
if (inventoryPreClickEvent.isCancelled()) {
clickResult.setRefresh(true);
}
}
// Inventory conditions
final List<InventoryCondition> inventoryConditions = isPlayerInventory ?
player.getInventory().getInventoryConditions() : inventory.getInventoryConditions();
if (!inventoryConditions.isEmpty()) {
for (InventoryCondition inventoryCondition : inventoryConditions) {
InventoryConditionResult result = new InventoryConditionResult(clicked, cursor);

View File

@ -623,8 +623,8 @@ public class ItemStack implements DataContainer {
/**
* Called when the player right clicks with this item
*
* @param player
* @param hand
* @param player the player who used the item
* @param hand the hand used
*/
public void onRightClick(Player player, Player.Hand hand) {
}
@ -632,8 +632,8 @@ public class ItemStack implements DataContainer {
/**
* Called when the player left clicks with this item
*
* @param player
* @param hand
* @param player the player who used the item
* @param hand the hand used
*/
public void onLeftClick(Player player, Player.Hand hand) {
}
@ -641,10 +641,10 @@ public class ItemStack implements DataContainer {
/**
* Called when the player right clicks with this item on a block
*
* @param player
* @param hand
* @param position
* @param blockFace
* @param player the player who used the item
* @param hand the hand used
* @param position the position of the interacted block
* @param blockFace the block face
* @return true if it prevents normal item use (placing blocks for instance)
*/
public boolean onUseOnBlock(Player player, Player.Hand hand, BlockPosition position, Direction blockFace) {
@ -656,10 +656,10 @@ public class ItemStack implements DataContainer {
* <p>
* Executed before any events
*
* @param player
* @param clickType
* @param slot
* @param playerInventory
* @param player the player who clicked on the item
* @param clickType the click type
* @param slot the slot clicked
* @param playerInventory true if the click is in the player inventory
*/
public void onInventoryClick(Player player, ClickType clickType, int slot, boolean playerInventory) {