|
@@ -144,10 +144,6 @@ function player.safeGiveItem(player, item) {
|
|
|
item.drop(entity.getLocation(player), rest_item);
|
|
|
}
|
|
|
|
|
|
-function safeGiveItemPlayer(player, item) { //Deprecated
|
|
|
- player.safeGiveItem(player, item);
|
|
|
-}
|
|
|
-
|
|
|
function setBlockIfNotAir(location, block) {
|
|
|
if(block.getType(location) == "minecraft:air") {
|
|
|
block.set(location, block, true);
|
|
@@ -363,15 +359,7 @@ function world.isStoryName(world_name) {
|
|
|
return world_name == "story";
|
|
|
}
|
|
|
|
|
|
-function isStoryWorldName(world_name) { //Deprecated
|
|
|
- return world_name == "story";
|
|
|
-}
|
|
|
-
|
|
|
-function isGamesWorldName(world_name) { //Deprecated
|
|
|
- return world_name == "games";
|
|
|
-}
|
|
|
-
|
|
|
-function isSurvWorldName(world_name) {
|
|
|
+function word.isSurvName(world_name) {
|
|
|
if(world_name == "overworld") {
|
|
|
return true;
|
|
|
} elseif(world_name == "the_end") {
|
|
@@ -384,7 +372,7 @@ function isSurvWorldName(world_name) {
|
|
|
|
|
|
function world.canUsePlots(world) {
|
|
|
world_name = world.getName(world);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
return true;
|
|
|
}
|
|
|
if(world.isCreativeName(world_name)) {
|
|
@@ -395,7 +383,7 @@ function world.canUsePlots(world) {
|
|
|
|
|
|
function world.addTimedStatus(world, index, time, message) {
|
|
|
world_name = world.getName(world);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
worldlist = players.toWorldList(world.getOverWorld());
|
|
|
for(i = 0; i < list.getSize(worldlist); i++) {
|
|
|
status.addTimed(list.getIndex(worldlist, i), index, time, message);
|
|
@@ -434,7 +422,7 @@ function player.checkForWorldChange(player, location) {
|
|
|
return false;
|
|
|
}
|
|
|
//Wenn beide Welten in derselben Liste sind --> kein Wechsel
|
|
|
- if(isSurvWorldName(from_world_name) && isSurvWorldName(to_world_name)) {
|
|
|
+ if(word.isSurvName(from_world_name) && word.isSurvName(to_world_name)) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
@@ -461,7 +449,7 @@ function player.changeInv(player, from_world, to_world) {
|
|
|
player.setGamemode(player, gm);
|
|
|
}
|
|
|
}
|
|
|
- if(isSurvWorldName(to_world_name)) {
|
|
|
+ if(word.isSurvName(to_world_name)) {
|
|
|
if(player.hasFly(player)) {
|
|
|
scheduler.addFly(1, player, true);
|
|
|
}
|
|
@@ -473,7 +461,7 @@ function inv.saveForPlayer(sec_player, for_player_or_id, world) {
|
|
|
for_player_or_id = player.getId(for_player_or_id);
|
|
|
}
|
|
|
world_name = world.getName(world);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
pfad = "scripts/configs/inv_data/survival";
|
|
|
} else {
|
|
|
pfad = concat("scripts/configs/inv_data/", world_name);
|
|
@@ -482,7 +470,7 @@ function inv.saveForPlayer(sec_player, for_player_or_id, world) {
|
|
|
|
|
|
//Allgemeine Daten
|
|
|
if(for_player_or_id == player.getId(sec_player)) {
|
|
|
- config.set(config, "health", entity.getHealth(sec_player));
|
|
|
+ config.set(config, "health", living.getHealth(sec_player));
|
|
|
config.set(config, "hunger", player.getHunger(sec_player));
|
|
|
config.set(config, "saturation", player.getSaturation(sec_player));
|
|
|
config.set(config, "xp", player.getExp(sec_player));
|
|
@@ -490,19 +478,21 @@ function inv.saveForPlayer(sec_player, for_player_or_id, world) {
|
|
|
}
|
|
|
|
|
|
//Inventare
|
|
|
- for(i = 0; i <= 35; i++) {
|
|
|
- item_string = text.item(player.getInvSlot(sec_player, i));
|
|
|
+ inv = player.getInv(sec_player);
|
|
|
+ for(i = 0; i < 36; i++) {
|
|
|
+ item_string = text.item(inv.getItem(inv, i));
|
|
|
config.set(config, concat("slot-", i), item_string);
|
|
|
}
|
|
|
- for(i = 0; i <= 26; i++) {
|
|
|
- item_string = text.item(player.getEnderSlot(sec_player, i));
|
|
|
+ ender_inv = player.getInv(sec_player);
|
|
|
+ for(i = 0; i < 27; i++) {
|
|
|
+ item_string = text.item(inv.getItem(ender_inv, i));
|
|
|
config.set(config, concat("eslot-", i), item_string);
|
|
|
}
|
|
|
- config.set(config, "offhand", text.item(entity.getEquip(sec_player, "offhand")));
|
|
|
- config.set(config, "head", text.item(entity.getEquip(sec_player, "head")));
|
|
|
- config.set(config, "chest", text.item(entity.getEquip(sec_player, "chest")));
|
|
|
- config.set(config, "legs", text.item(entity.getEquip(sec_player, "legs")));
|
|
|
- config.set(config, "feet", text.item(entity.getEquip(sec_player, "feet")));
|
|
|
+ config.set(config, "offhand", text.item(living.getEquip(sec_player, "offhand")));
|
|
|
+ config.set(config, "head", text.item(living.getEquip(sec_player, "head")));
|
|
|
+ config.set(config, "chest", text.item(living.getEquip(sec_player, "chest")));
|
|
|
+ config.set(config, "legs", text.item(living.getEquip(sec_player, "legs")));
|
|
|
+ config.set(config, "feet", text.item(living.getEquip(sec_player, "feet")));
|
|
|
config.saveAsync(config);
|
|
|
}
|
|
|
|
|
@@ -511,7 +501,7 @@ function inv.loadFromPlayer(sec_player, from_player_or_id, world) {
|
|
|
from_player_or_id = player.getId(from_player_or_id);
|
|
|
}
|
|
|
world_name = world.getName(world);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
pfad = "scripts/configs/inv_data/survival";
|
|
|
} else {
|
|
|
pfad = concat("scripts/configs/inv_data/", world_name);
|
|
@@ -523,7 +513,7 @@ function inv.loadFromPlayer(sec_player, from_player_or_id, world) {
|
|
|
|
|
|
//Allgemeine Daten
|
|
|
if(from_player_or_id == player.getId(sec_player)) {
|
|
|
- entity.setHealth(sec_player, config.getDouble(config, "health", 20));
|
|
|
+ living.setHealth(sec_player, config.getDouble(config, "health", 20));
|
|
|
player.setHunger(sec_player, config.getDouble(config, "hunger", 20));
|
|
|
player.setSaturation(sec_player, config.getDouble(config, "saturation", 5));
|
|
|
player.setExp(sec_player, config.getDouble(config, "xp", 0));
|
|
@@ -535,21 +525,23 @@ function inv.loadFromPlayer(sec_player, from_player_or_id, world) {
|
|
|
item_string = config.getString(config, concat("slot-", i), "minecraft:air");
|
|
|
item = read.item(item_string);
|
|
|
if(item != null) {
|
|
|
- player.setInvSlot(sec_player, i, item);
|
|
|
+ inv = player.getInv(sec_player);
|
|
|
+ inv.setItem(inv, i, item);
|
|
|
}
|
|
|
}
|
|
|
for(i = 0; i <= 26; i++) {
|
|
|
item_string = config.getString(config, concat("eslot-", i), "minecraft:air");
|
|
|
item = read.item(item_string);
|
|
|
if(item != null) {
|
|
|
- player.setEnderSlot(sec_player, i, item);
|
|
|
+ ender_inv = player.getInv(sec_player);
|
|
|
+ inv.setItem(ender_inv, i, item);
|
|
|
}
|
|
|
}
|
|
|
- entity.setEquip(sec_player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
|
|
|
- entity.setEquip(sec_player, "head", read.item(config.getString(config, "head", "minecraft:air")));
|
|
|
- entity.setEquip(sec_player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
|
|
|
- entity.setEquip(sec_player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
|
|
|
- entity.setEquip(sec_player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
|
|
|
+ living.setEquip(sec_player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
|
|
|
+ living.setEquip(sec_player, "head", read.item(config.getString(config, "head", "minecraft:air")));
|
|
|
+ living.setEquip(sec_player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
|
|
|
+ living.setEquip(sec_player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
|
|
|
+ living.setEquip(sec_player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
|
|
|
}
|
|
|
|
|
|
//--------------------------------------------------
|
|
@@ -1496,7 +1488,7 @@ function msg.quest(player, speaker, line_now, line_max, message) {
|
|
|
|
|
|
function sendMessageToWorld(world, message) {
|
|
|
world_name = world.getName(world);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
worldlist = players.toWorldList(world.getOverWorld());
|
|
|
for(i = 0; i < list.getSize(worldlist); i++) {
|
|
|
msg(list.getIndex(worldlist, i), message);
|
|
@@ -1519,7 +1511,7 @@ function sendMessageToWorld(world, message) {
|
|
|
|
|
|
function sendMessageToWorld2(world, message1, message2) {
|
|
|
world_name = world.getName(world);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
worldlist = players.toWorldList(world.getOverWorld());
|
|
|
for(i = 0; i < list.getSize(worldlist); i++) {
|
|
|
msg(list.getIndex(worldlist, i), message1, message2);
|
|
@@ -1607,19 +1599,19 @@ function player.hasClearInventory(player) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
- if(item.getType(entity.getEquip(player, "head")) != "minecraft:air") {
|
|
|
+ if(item.getType(living.getEquip(player, "head")) != "minecraft:air") {
|
|
|
return false;
|
|
|
}
|
|
|
- if(item.getType(entity.getEquip(player, "chest")) != "minecraft:air") {
|
|
|
+ if(item.getType(living.getEquip(player, "chest")) != "minecraft:air") {
|
|
|
return false;
|
|
|
}
|
|
|
- if(item.getType(entity.getEquip(player, "legs")) != "minecraft:air") {
|
|
|
+ if(item.getType(living.getEquip(player, "legs")) != "minecraft:air") {
|
|
|
return false;
|
|
|
}
|
|
|
- if(item.getType(entity.getEquip(player, "feet")) != "minecraft:air") {
|
|
|
+ if(item.getType(living.getEquip(player, "feet")) != "minecraft:air") {
|
|
|
return false;
|
|
|
}
|
|
|
- if(item.getType(entity.getEquip(player, "offhand")) != "minecraft:air") {
|
|
|
+ if(item.getType(living.getEquip(player, "offhand")) != "minecraft:air") {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
@@ -1766,7 +1758,7 @@ function player.showDefaultStacks(player) {
|
|
|
player_loc = entity.getLocation(player);
|
|
|
world_name = world.getName(loc.getWorld(player_loc));
|
|
|
stacks.clear(player);
|
|
|
- if(isSurvWorldName(world_name)) {
|
|
|
+ if(word.isSurvName(world_name)) {
|
|
|
stacks.set(player, 0, "km:gear");
|
|
|
stacks.set(player, 1, "km:golden_scepter");
|
|
|
stacks.set(player, 2, "minecraft:red_bed");
|
|
@@ -1868,6 +1860,14 @@ function player.clearBackPos(player) {
|
|
|
config.saveAsync(config);
|
|
|
}
|
|
|
|
|
|
+function entity.getFromDamageSource(damage_source) {
|
|
|
+ entity = damage.getImmediateSource(damage_source);
|
|
|
+ if(entity == null) {
|
|
|
+ return damage.getTrueSource(damage_source);
|
|
|
+ }
|
|
|
+ return entity;
|
|
|
+}
|
|
|
+
|
|
|
function player.getFromDamageSource(damage_source) {
|
|
|
entity = damage.getImmediateSource(damage_source);
|
|
|
if(isPlayer(entity)) {
|
|
@@ -2159,20 +2159,20 @@ function player.isCommandBlocked(player) {
|
|
|
}
|
|
|
|
|
|
function player.checkHandsForItem(player, item) {
|
|
|
- hand = entity.getEquip(player, "hand");
|
|
|
+ hand = living.getEquip(player, "hand");
|
|
|
if(item.getType(hand) == item.getType(item)) {
|
|
|
return true;
|
|
|
}
|
|
|
- offhand = entity.getEquip(player, "offhand");
|
|
|
+ offhand = living.getEquip(player, "offhand");
|
|
|
return item.getType(offhand) == item.getType(item);
|
|
|
}
|
|
|
|
|
|
function player.checkHandsForTag(player, tag) {
|
|
|
- hand = entity.getEquip(player, "hand");
|
|
|
+ hand = living.getEquip(player, "hand");
|
|
|
if(item.hasTag(tag, hand)) {
|
|
|
return true;
|
|
|
}
|
|
|
- offhand = entity.getEquip(player, "offhand");
|
|
|
+ offhand = living.getEquip(player, "offhand");
|
|
|
return item.hasTag(tag, offhand);
|
|
|
}
|
|
|
|
|
@@ -2184,14 +2184,14 @@ function block.gotWater(block, block_type, block_loc) {
|
|
|
if(block_type == "minecraft:water") {
|
|
|
return true;
|
|
|
}
|
|
|
- return block.getState(block_loc, block.getProperty("waterlogged"));
|
|
|
+ return block.property.getValue(block_loc, block.getProperty("waterlogged"));
|
|
|
}
|
|
|
|
|
|
function block.getSecondDoor(door_loc_1) {
|
|
|
prop_h_facing = block.getProperty("horizontal_facing");
|
|
|
- state_facing = block.getState(door_loc_1, prop_h_facing);
|
|
|
+ state_facing = block.property.getValue(door_loc_1, prop_h_facing);
|
|
|
prop_hinge = block.getProperty("hinge");
|
|
|
- state_hinge = block.getState(door_loc_1, prop_hinge);
|
|
|
+ state_hinge = block.property.getValue(door_loc_1, prop_hinge);
|
|
|
if(state_facing == "north") {
|
|
|
if(state_hinge == "right") {
|
|
|
door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
|
|
@@ -2217,9 +2217,9 @@ function block.getSecondDoor(door_loc_1) {
|
|
|
door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
|
|
|
}
|
|
|
}
|
|
|
- if(block.isDoor(door_loc_2)) {
|
|
|
+ if(block.hasTag(block.getTag("minecraft:wooden_doors"), block.get(door_loc_2))) {
|
|
|
if(block.isSameDoorHalf(door_loc_1, door_loc_2)) {
|
|
|
- state_hinge_2 = block.getState(door_loc_2, prop_hinge);
|
|
|
+ state_hinge_2 = block.property.getValue(door_loc_2, prop_hinge);
|
|
|
if(state_hinge == "left" && state_hinge_2 == "right" || state_hinge == "right" && state_hinge_2 == "left") {
|
|
|
return door_loc_2;
|
|
|
}
|
|
@@ -2230,8 +2230,8 @@ function block.getSecondDoor(door_loc_1) {
|
|
|
|
|
|
function block.isSameDoorHalf(door_loc_1, door_loc_2) {
|
|
|
prop_d_half = block.getProperty("double_block_half");
|
|
|
- state_half = block.getState(door_loc_1, prop_d_half);
|
|
|
- state_half_2 = block.getState(door_loc_2, prop_d_half);
|
|
|
+ state_half = block.property.getValue(door_loc_1, prop_d_half);
|
|
|
+ state_half_2 = block.property.getValue(door_loc_2, prop_d_half);
|
|
|
return state_half == state_half_2;
|
|
|
}
|
|
|
|