Merge branch 'master' into 1.15

This commit is contained in:
gnembon committed 2019-10-28 21:55:49 -03:00
commit b1e2b4367d
5 files changed
+75 -29

No files matched your search

@@ -36,11 +36,15 @@ public class InventoryHelper
}
if (bet.isEmpty())
{
tag.remove("BlockEntityTag");
changed = true;
}
if (tag.isEmpty())
{
stack.setTag(null);
changed = true;
}
return changed;
}
+3 -2
View File
@@ -24,6 +24,7 @@ import carpet.script.value.MapValue;
import carpet.script.value.NumericValue;
import carpet.script.value.StringValue;
import carpet.script.value.Value;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.apache.commons.lang3.text.WordUtils;
import java.math.BigInteger;
@@ -388,10 +389,10 @@ public class Expression implements Cloneable
private LazyValue ast = null;
/** script specific operatos and built-in functions */
private Map<String, ILazyOperator> operators = new HashMap<>();
private Map<String, ILazyOperator> operators = new Object2ObjectOpenHashMap<>();
boolean isAnOperator(String opname) { return operators.containsKey(opname) || operators.containsKey(opname+"u");}
private Map<String, ILazyFunction> functions = new HashMap<>();
private Map<String, ILazyFunction> functions = new Object2ObjectOpenHashMap<>();
Set<String> getFunctionNames() {return functions.keySet();}
@Override
+4 -3
View File
@@ -9,6 +9,7 @@ import carpet.script.value.NumericValue;
import carpet.script.value.StringValue;
import carpet.script.value.Value;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.Tag;
@@ -29,9 +30,9 @@ import static java.lang.Math.max;
public class ScriptHost
{
private final Map<String, ScriptHost> userHosts = new HashMap<>();
public Map<String, UserDefinedFunction> globalFunctions = new HashMap<>();
public Map<String, LazyValue> globalVariables = new HashMap<>();
private final Map<String, ScriptHost> userHosts = new Object2ObjectOpenHashMap<>();
public Map<String, UserDefinedFunction> globalFunctions = new Object2ObjectOpenHashMap<>();
public Map<String, LazyValue> globalVariables = new Object2ObjectOpenHashMap<>();
private Tag globalState;
private int saveTimeout;
+9 -14
View File
@@ -121,12 +121,9 @@ public class Tokenizer implements Iterator<Tokenizer.Token>
{
pos++;
linepos++;
if (pos == input.length())
{
token.type = Token.TokenType.STRINGPARAM;
if (expression != null)
throw new ExpressionException(this.expression, token, "Program truncated");
}
token.type = Token.TokenType.STRINGPARAM;
if (pos == input.length() && expression != null)
throw new ExpressionException(this.expression, token, "Program truncated");
ch = input.charAt(pos);
while (ch != '\'')
{
@@ -134,20 +131,18 @@ public class Tokenizer implements Iterator<Tokenizer.Token>
{
pos++;
linepos++;
if (pos == input.length())
{
token.type = Token.TokenType.STRINGPARAM;
if (expression != null)
throw new ExpressionException(this.expression, token, "Program truncated");
}
if (pos == input.length() && expression != null)
throw new ExpressionException(this.expression, token, "Program truncated");
}
token.append(input.charAt(pos++));
linepos++;
ch = pos == input.length() ? 0 : input.charAt(pos);
if (pos == input.length() && expression != null)
throw new ExpressionException(this.expression, token, "Program truncated");
ch = input.charAt(pos);
}
pos++;
linepos++;
token.type = Token.TokenType.STRINGPARAM;
}
else if (Character.isLetter(ch) || "_".indexOf(ch) >= 0)
{
@@ -1,13 +1,26 @@
__on_player_jumps(player) -> print('Player '+player+' jumps.');
__on_player_jumps(player) -> (
print('');
print('__on_player_jumps(player)');
print('Player '+player+' jumps.')
);
__on_player_deploys_elytra(player) -> print('Player '+player+' deploys elytra.');
__on_player_deploys_elytra(player) -> (
print('');
print('__on_player_deploys_elytra(player)');
print('Player '+player+' deploys elytra.')
);
__on_player_wakes_up(player) -> print('Player '+player+' wakes up. Lemme know when this starts working');
__on_player_wakes_up(player) -> (
print('');
print('__on_player_wakes_up(player)');
print('Player '+player+' wakes up. Lemme know when this starts working')
);
__on_player_rides(player, forward, strafe, jumping, sneaking) ->
(
print('');
print('__on_player_rides(player, forward, strafe, jumping, sneaking)');
print('player rides a vehicle:');
print(' - player: '+player);
print(' - forward/backward: '+forward);
@@ -20,6 +33,7 @@ __on_player_uses_item(player, item_tuple, hand) ->
(
l(item, count, nbt) = item_tuple || l('None', 0, null);
print('');
print('__on_player_uses_item(player, item_tuple, hand)');
print('player uses an item:');
print(' - player: '+player);
print(' - item:');
@@ -32,6 +46,7 @@ __on_player_uses_item(player, item_tuple, hand) ->
__on_player_clicks_block(player, block, face) ->
(
print('');
print('__on_player_clicks_block(player, block, face)');
print('player clicks a block:');
print(' - player: '+player);
print(' - block: '+block+' at '+map(pos(block), str('%.2f',_)));
@@ -43,6 +58,7 @@ __on_player_right_clicks_block(player, item_tuple, hand, block, face, hitvec) ->
(
l(item, count, nbt) = item_tuple || l('None', 0, null);
print('');
print('__on_player_right_clicks_block(player, item_tuple, hand, block, face, hitvec) ');
print('block right clicked by player:');
print(' - player: '+player);
print(' - item: '+item);
@@ -55,6 +71,7 @@ __on_player_right_clicks_block(player, item_tuple, hand, block, face, hitvec) ->
__on_player_breaks_block(player, block) ->
(
print('');
print('__on_player_breaks_block(player, block)');
print('player breaks block:');
print(' - player: '+player);
print(' - block: '+block+' at '+map(pos(block), str('%.2f',_)))
@@ -63,6 +80,7 @@ __on_player_breaks_block(player, block) ->
__on_player_interacts_with_entity(player, entity, hand) ->
(
print('');
print('__on_player_interacts_with_entity(player, entity, hand)');
print('player interacts with entity:');
print(' - player: '+player);
print(' - entity: '+entity+' at '+map(pos(entity), str('%.2f',_)));
@@ -72,23 +90,41 @@ __on_player_interacts_with_entity(player, entity, hand) ->
__on_player_attacks_entity(player, entity) ->
(
print('');
print('__on_player_attacks_entity(player, entity)');
print('player attacks entity:');
print(' - player: '+player);
print(' - entity: '+entity+' at '+map(pos(entity), str('%.2f',_)))
);
__on_player_starts_sneaking(player) -> print('Player '+player+' starts sneaking.');
__on_player_starts_sneaking(player) -> (
print('');
print('__on_player_starts_sneaking(player)');
print('Player '+player+' starts sneaking.')
);
__on_player_stops_sneaking(player) -> print('Player '+player+' stops sneaking.');
__on_player_stops_sneaking(player) -> (
print('');
print('__on_player_stops_sneaking(player)');
print(' Player '+player+' stops sneaking.')
);
__on_player_starts_sprinting(player) -> print('Player '+player+' starts sprinting.');
__on_player_starts_sprinting(player) -> (
print('');
print('__on_player_starts_sprinting(player)');
print(' Player '+player+' starts sprinting.')
);
__on_player_stops_sprinting(player) -> print('Player '+player+' stops sprinting.');
__on_player_stops_sprinting(player) -> (
print('');
print('__on_player_stops_sprinting(player)');
print('Player '+player+' stops sprinting.')
);
__on_player_releases_item(player, item_tuple, hand) ->
(
l(item, count, nbt) = item_tuple || l('None', 0, null);
print('');
print('__on_player_releases_item(player, item_tuple, hand)');
print('player releases an item:');
print(' - player: '+player);
print(' - item:');
@@ -102,6 +138,7 @@ __on_player_finishes_using_item(player, item_tuple, hand) ->
(
l(item, count, nbt) = item_tuple || l('None', 0, null);
print('');
print('__on_player_finishes_using_item(player, item_tuple, hand)');
print('player finishes using an item:');
print(' - player: '+player);
print(' - item:');
@@ -111,6 +148,14 @@ __on_player_finishes_using_item(player, item_tuple, hand) ->
print(' - hand: '+hand)
);
__on_player_drops_item(player) -> print('Player '+player+' drops current item.');
__on_player_drops_item(player) -> (
print('');
print('__on_player_drops_item(player)');
print('Player '+player+' drops current item.')
);
__on_player_drops_stack(player) -> print('Player '+player+' drops current stack.');
__on_player_drops_stack(player) -> (
print('');
print('__on_player_drops_stack(player)');
print('Player '+player+' drops current stack.')
);