ZotCoreLOader
- EventHandler добавлен priority = EventPriority.LOWEST - исправлено получение BlockSource - исправлен двойной дроп блоков - обновлён Nukkit-Mot
This commit is contained in:
Binary file not shown.
@@ -5,6 +5,7 @@ import cn.nukkit.block.Block;
|
|||||||
import cn.nukkit.entity.Entity;
|
import cn.nukkit.entity.Entity;
|
||||||
import cn.nukkit.event.Event;
|
import cn.nukkit.event.Event;
|
||||||
import cn.nukkit.event.EventHandler;
|
import cn.nukkit.event.EventHandler;
|
||||||
|
import cn.nukkit.event.EventPriority;
|
||||||
import cn.nukkit.event.Listener;
|
import cn.nukkit.event.Listener;
|
||||||
import cn.nukkit.event.block.BlockBreakEvent;
|
import cn.nukkit.event.block.BlockBreakEvent;
|
||||||
import cn.nukkit.event.block.BlockPlaceEvent;
|
import cn.nukkit.event.block.BlockPlaceEvent;
|
||||||
@@ -28,7 +29,7 @@ public class EventListener implements Listener {
|
|||||||
CallbackHelper.apply(event, apply);
|
CallbackHelper.apply(event, apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void use(PlayerInteractEvent event) {
|
public void use(PlayerInteractEvent event) {
|
||||||
Vector3 pos = event.getTouchVector();
|
Vector3 pos = event.getTouchVector();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
@@ -44,19 +45,19 @@ public class EventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void breakBlock(BlockBreakEvent event){
|
public void breakBlock(BlockBreakEvent event){
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
preventedCallback(event, () -> NativeCallback.onBlockDestroyed((int) block.x, (int) block.y, (int) block.z, event.getFace().getIndex(), event.getPlayer().getId()));
|
preventedCallback(event, () -> NativeCallback.onBlockDestroyed((int) block.x, (int) block.y, (int) block.z, event.getFace().getIndex(), event.getPlayer().getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void playerEat(PlayerEatFoodEvent event){
|
public void playerEat(PlayerEatFoodEvent event){
|
||||||
Food food = event.getFood();
|
Food food = event.getFood();
|
||||||
preventedCallback(event, () -> NativeCallback.onPlayerEat(food.getRestoreFood(), food.getRestoreSaturation(), event.getPlayer().getId()));
|
preventedCallback(event, () -> NativeCallback.onPlayerEat(food.getRestoreFood(), food.getRestoreSaturation(), event.getPlayer().getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void placeBlock(BlockPlaceEvent event){
|
public void placeBlock(BlockPlaceEvent event){
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
preventedCallback(event, () -> NativeCallback.onBlockBuild((int) block.x, (int) block.y, (int) block.z, 0, event.getPlayer().getId()));
|
preventedCallback(event, () -> NativeCallback.onBlockBuild((int) block.x, (int) block.y, (int) block.z, 0, event.getPlayer().getId()));
|
||||||
|
|||||||
@@ -33,9 +33,21 @@ public class BlockSourceMethods {
|
|||||||
level.updateComparatorOutputLevel(target);
|
level.updateComparatorOutputLevel(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Level getLevelForDimension(int dimension){
|
public static Level getLevelForDimension(int dimension){
|
||||||
if(dimension >= 0 && dimension <= 2)
|
if(dimension >= 0 && dimension <= 2){
|
||||||
dimension++;
|
switch (dimension) {
|
||||||
|
case 0 -> {
|
||||||
|
return InnerCoreServer.server.getLevelByName("world");
|
||||||
|
}
|
||||||
|
case 1 -> {
|
||||||
|
return InnerCoreServer.server.getLevelByName("nether");
|
||||||
|
}
|
||||||
|
case 2 -> {
|
||||||
|
return InnerCoreServer.server.getLevelByName("the_end");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return InnerCoreServer.server.getLevel(dimension);
|
return InnerCoreServer.server.getLevel(dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -593,10 +593,9 @@ public class NativeCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if block was already destroyed, prevent default action
|
// if block was already destroyed, prevent default action
|
||||||
/*System.out.println(blockSource.getBlockId(x, y, z));
|
|
||||||
if (blockSource.getBlockId(x, y, z) == 0) {
|
if (blockSource.getBlockId(x, y, z) == 0) {
|
||||||
NativeAPI.preventDefault();
|
NativeAPI.preventDefault();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// guard end
|
// guard end
|
||||||
isDestroyBlockCallbackInProgress = false;
|
isDestroyBlockCallbackInProgress = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user