feat: update place func & fix: Block.isSolid
This commit is contained in:
@@ -84,6 +84,9 @@ public class BlockMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSolid(int id) {
|
public static boolean isSolid(int id) {
|
||||||
|
if(InnerCoreServer.canEndLoadMods()) {
|
||||||
|
return validateThen(id, Block::isSolid,true);
|
||||||
|
}
|
||||||
return (boolean) getOrDefault(id, SOLID, true);
|
return (boolean) getOrDefault(id, SOLID, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6517,8 +6517,7 @@ function setPlayerItem(id, count, data, extra) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Callback.addCallback("ItemUse", function(coords, item, block, isExternal, player) {
|
Callback.addCallback("ItemUse", function(coords, item, block, isExternal, player) {
|
||||||
var blockSource = BlockSource.getDefaultForActor(player);
|
let blockSource = BlockSource.getDefaultForActor(player);
|
||||||
var placeFunc = BlockRegistry.getPlaceFunc(item.id);
|
|
||||||
if (TileEntity.isTileEntityBlock(block.id)) {
|
if (TileEntity.isTileEntityBlock(block.id)) {
|
||||||
let tileEntity = TileEntity.getTileEntity(coords.x, coords.y, coords.z, blockSource);
|
let tileEntity = TileEntity.getTileEntity(coords.x, coords.y, coords.z, blockSource);
|
||||||
if (!tileEntity) {
|
if (!tileEntity) {
|
||||||
@@ -6529,46 +6528,50 @@ Callback.addCallback("ItemUse", function(coords, item, block, isExternal, player
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Entity.isSneaking(player) || !doesVanillaTileHasUI(block.id)) {
|
if (Entity.isSneaking(player) || !doesVanillaTileHasUI(block.id)) {
|
||||||
if (TileEntity.isTileEntityBlock(item.id)) {
|
let placeCoords = null;
|
||||||
var tile = blockSource.getBlockId(coords.relative.x, coords.relative.y, coords.relative.z);
|
let placeFunc = BlockRegistry.getPlaceFunc(item.id);
|
||||||
if (canTileBeReplaced(tile)) {
|
if (placeFunc) {
|
||||||
if (placeFunc) {
|
placeCoords = placeFunc(coords, item, block, player, blockSource);
|
||||||
let placeCoords = placeFunc(coords, item, block, player, blockSource) || coords.relative;
|
}
|
||||||
let tileEntity = TileEntity.addTileEntity(placeCoords.x, placeCoords.y, placeCoords.z, blockSource);
|
|
||||||
|
let isTileEntity = TileEntity.isTileEntityBlock(item.id);
|
||||||
|
if (isTileEntity) {
|
||||||
|
if (!placeFunc) {
|
||||||
|
if (canTileBeReplaced(block.id, block.data)) {
|
||||||
|
placeCoords = coords;
|
||||||
} else {
|
} else {
|
||||||
blockSource.setBlock(coords.relative.x, coords.relative.y, coords.relative.z, item.id, item.data);
|
let tile = blockSource.getBlock(coords.relative.x, coords.relative.y, coords.relative.z);
|
||||||
let tileEntity = TileEntity.addTileEntity(coords.relative.x, coords.relative.y, coords.relative.z, blockSource);
|
if (canTileBeReplaced(tile.id, tile.data)) {
|
||||||
}
|
placeCoords = coords.relative;
|
||||||
if (GameAPI.isItemSpendingAllowed(player)) {
|
|
||||||
if (item.count > 1) {
|
|
||||||
Entity.setCarriedItem(player, item.id, item.count - 1, item.data, item.extra);
|
|
||||||
} else {
|
|
||||||
Entity.setCarriedItem(player, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorldAPI.playSound(coords.x, coords.y, coords.z, "dig.stone", 1, 0.8);
|
if (placeCoords) {
|
||||||
preventDefault();
|
blockSource.setBlock(placeCoords.x, placeCoords.y, placeCoords.z, item.id, item.data);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (placeCoords) {
|
||||||
if (placeFunc) {
|
TileEntity.addTileEntity(placeCoords.x, placeCoords.y, placeCoords.z, blockSource);
|
||||||
placeFunc(coords, item, block, player, blockSource);
|
|
||||||
if (GameAPI.isItemSpendingAllowed(player)) {
|
|
||||||
if (item.count > 1) {
|
|
||||||
Entity.setCarriedItem(player, item.id, item.count - 1, item.data, item.extra);
|
|
||||||
} else {
|
|
||||||
Entity.setCarriedItem(player, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WorldAPI.playSound(coords.x, coords.y, coords.z, "dig.stone", 1, 0.8);
|
|
||||||
preventDefault();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemRegistry.onItemUsed(coords, item, block, player);
|
if (placeCoords) {
|
||||||
|
if (GameAPI.isItemSpendingAllowed(player)) {
|
||||||
|
if (item.count > 1) {
|
||||||
|
Entity.setCarriedItem(player, item.id, item.count - 1, item.data, item.extra);
|
||||||
|
} else {
|
||||||
|
Entity.setCarriedItem(player, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blockSource.playSound(placeCoords.x, placeCoords.y, placeCoords.z, "dig.stone", 1, 0.8);
|
||||||
|
preventDefault();
|
||||||
|
} else {
|
||||||
|
ItemRegistry.onItemUsed(coords, item, block, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var EntityDataRegistry = {
|
var EntityDataRegistry = {
|
||||||
isLevelLoaded: false,
|
isLevelLoaded: false,
|
||||||
entityData: {},
|
entityData: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user