Merge branch 'master' into 1.17
This commit is contained in:
commit
c2436f1f09
8 files changed
+88
-24
No files matched your search
+15
-10
@@ -2072,18 +2072,19 @@ print(b); // 'stone', block was evaluated 'eagerly' but call to `block`
|
||||
All the functions below can be used with block value, queried with coord triple, or 3-long list. All `pos` in the
|
||||
functions referenced below refer to either method of passing block position.
|
||||
|
||||
### `set(pos, block, property?, value?, ..., block_data?)`, `set(pos, block, l(property?, value?, ...), block_data?)`
|
||||
### `set(pos, block, property?, value?, ..., block_data?)`, `set(pos, block, [property?, value?, ...], block_data?)`, `set(pos, block, {property? -> value?, ...}, block_data?)`
|
||||
|
||||
First part of the `set` function is either a coord triple, list of three numbers, or other block with coordinates.
|
||||
Second part, `block` is either block value as a result of `block()` function string value indicating the block name,
|
||||
and optional `property - value` pairs for extra block properties. Optional `block_data` include the block data to
|
||||
First argument for the `set` function is either a coord triple, list of three numbers, or a world localized block value.
|
||||
Second argument, `block`, is either an existing block value, a result of `block()` function, or a string value indicating the block name
|
||||
with optional state and block data. It is then followed by an optional
|
||||
`property - value` pairs for extra block state (which can also be provided in a list or a map). Optional `block_data` include the block data to
|
||||
be set for the target block.
|
||||
|
||||
If `block` is specified only by name, then if a
|
||||
destination block is the same the `set` operation is skipped, otherwise is executed, for other potential extra
|
||||
properties.
|
||||
properties that the original source block may have contained.
|
||||
|
||||
The returned value is either the block state that has been set, or `false` if block setting was skipped
|
||||
The returned value is either the block state that has been set, or `false` if block setting was skipped, or failed
|
||||
|
||||
<pre>
|
||||
set(0,5,0,'bedrock') => bedrock
|
||||
@@ -2099,11 +2100,15 @@ scan(0,100,0,20,20,20,set(_,block('glass')))
|
||||
b = block('glass'); scan(0,100,0,20,20,20,set(_,b))
|
||||
// yet another option, skips all parsing
|
||||
set(x,y,z,'iron_trapdoor') // sets bottom iron trapdoor
|
||||
set(x,y,z,'iron_trapdoor[half=top]') // Incorrect. sets bottom iron trapdoor - no parsing of properties
|
||||
set(x,y,z,'iron_trapdoor','half','top') // correct - top trapdoor
|
||||
set(x,y,z, block('iron_trapdoor[half=top]')) // also correct, block() provides extra parsing
|
||||
|
||||
set(x,y,z,'iron_trapdoor[half=top]') // sets the top trapdoor
|
||||
set(x,y,z,'iron_trapdoor','half','top') // also correct - top trapdoor
|
||||
set(x,y,z,'iron_trapdoor', ['half','top']) // same
|
||||
set(x,y,z,'iron_trapdoor', {'half' -> 'top'}) // same
|
||||
set(x,y,z, block('iron_trapdoor[half=top]')) // also correct, block() provides extra parsing of block state
|
||||
|
||||
set(x,y,z,'hopper[facing=north]{Items:[{Slot:1b,id:"minecraft:slime_ball",Count:16b}]}') // extra block data
|
||||
set(x,y,z,'hopper', l('facing', 'north'), nbt('{Items:[{Slot:1b,id:"minecraft:slime_ball",Count:16b}]}') ) // same
|
||||
set(x,y,z,'hopper', {'facing' -> 'north'}, nbt('{Items:[{Slot:1b,id:"minecraft:slime_ball",Count:16b}]}') ) // same
|
||||
</pre>
|
||||
|
||||
### `without_updates(expr)`
|
||||
|
||||
@@ -36,18 +36,19 @@ print(b); // 'stone', block was evaluated 'eagerly' but call to `block`
|
||||
All the functions below can be used with block value, queried with coord triple, or 3-long list. All `pos` in the
|
||||
functions referenced below refer to either method of passing block position.
|
||||
|
||||
### `set(pos, block, property?, value?, ..., block_data?)`, `set(pos, block, l(property?, value?, ...), block_data?)`
|
||||
### `set(pos, block, property?, value?, ..., block_data?)`, `set(pos, block, [property?, value?, ...], block_data?)`, `set(pos, block, {property? -> value?, ...}, block_data?)`
|
||||
|
||||
First part of the `set` function is either a coord triple, list of three numbers, or other block with coordinates.
|
||||
Second part, `block` is either block value as a result of `block()` function string value indicating the block name,
|
||||
and optional `property - value` pairs for extra block properties. Optional `block_data` include the block data to
|
||||
First argument for the `set` function is either a coord triple, list of three numbers, or a world localized block value.
|
||||
Second argument, `block`, is either an existing block value, a result of `block()` function, or a string value indicating the block name
|
||||
with optional state and block data. It is then followed by an optional
|
||||
`property - value` pairs for extra block state (which can also be provided in a list or a map). Optional `block_data` include the block data to
|
||||
be set for the target block.
|
||||
|
||||
If `block` is specified only by name, then if a
|
||||
destination block is the same the `set` operation is skipped, otherwise is executed, for other potential extra
|
||||
properties.
|
||||
properties that the original source block may have contained.
|
||||
|
||||
The returned value is either the block state that has been set, or `false` if block setting was skipped
|
||||
The returned value is either the block state that has been set, or `false` if block setting was skipped, or failed
|
||||
|
||||
<pre>
|
||||
set(0,5,0,'bedrock') => bedrock
|
||||
@@ -63,11 +64,15 @@ scan(0,100,0,20,20,20,set(_,block('glass')))
|
||||
b = block('glass'); scan(0,100,0,20,20,20,set(_,b))
|
||||
// yet another option, skips all parsing
|
||||
set(x,y,z,'iron_trapdoor') // sets bottom iron trapdoor
|
||||
set(x,y,z,'iron_trapdoor[half=top]') // Incorrect. sets bottom iron trapdoor - no parsing of properties
|
||||
set(x,y,z,'iron_trapdoor','half','top') // correct - top trapdoor
|
||||
set(x,y,z, block('iron_trapdoor[half=top]')) // also correct, block() provides extra parsing
|
||||
|
||||
set(x,y,z,'iron_trapdoor[half=top]') // sets the top trapdoor
|
||||
set(x,y,z,'iron_trapdoor','half','top') // also correct - top trapdoor
|
||||
set(x,y,z,'iron_trapdoor', ['half','top']) // same
|
||||
set(x,y,z,'iron_trapdoor', {'half' -> 'top'}) // same
|
||||
set(x,y,z, block('iron_trapdoor[half=top]')) // also correct, block() provides extra parsing of block state
|
||||
|
||||
set(x,y,z,'hopper[facing=north]{Items:[{Slot:1b,id:"minecraft:slime_ball",Count:16b}]}') // extra block data
|
||||
set(x,y,z,'hopper', l('facing', 'north'), nbt('{Items:[{Slot:1b,id:"minecraft:slime_ball",Count:16b}]}') ) // same
|
||||
set(x,y,z,'hopper', {'facing' -> 'north'}, nbt('{Items:[{Slot:1b,id:"minecraft:slime_ball",Count:16b}]}') ) // same
|
||||
</pre>
|
||||
|
||||
### `without_updates(expr)`
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
loader_version=0.10.8
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.4.20+v201202
|
||||
mod_version = 1.4.21+v201216
|
||||
maven_group = carpet
|
||||
archives_base_name = fabric-carpet
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import static carpet.settings.RuleCategory.CLIENT;
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
public class CarpetSettings
|
||||
{
|
||||
public static final String carpetVersion = "1.4.20+v201202";
|
||||
public static final String carpetVersion = "1.4.21+v201216";
|
||||
public static final Logger LOG = LogManager.getLogger("carpet");
|
||||
public static boolean skipGenerationChecks = false;
|
||||
public static boolean impendingFillSkipUpdates = false;
|
||||
|
||||
@@ -777,6 +777,21 @@ public class WorldAccess {
|
||||
}
|
||||
args = ((ListValue) args.get(0)).getItems();
|
||||
}
|
||||
else if (args.get(0) instanceof MapValue)
|
||||
{
|
||||
if (args.size() == 2)
|
||||
{
|
||||
Value dataValue = NBTSerializableValue.fromValue( args.get(1));
|
||||
if (dataValue instanceof NBTSerializableValue)
|
||||
{
|
||||
data = ((NBTSerializableValue) dataValue).getCompoundTag();
|
||||
}
|
||||
}
|
||||
Map<Value, Value> state = ((MapValue) args.get(0)).getMap();
|
||||
List<Value> mapargs = new ArrayList<>();
|
||||
state.forEach( (k, v) -> {mapargs.add(k); mapargs.add(v);});
|
||||
args = mapargs;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((args.size() & 1) == 1)
|
||||
@@ -812,7 +827,7 @@ public class WorldAccess {
|
||||
{
|
||||
Clearable.clear(world.getBlockEntity(targetPos));
|
||||
boolean success = world.setBlockState(targetPos, finalSourceBlockState, 2);
|
||||
if (success && finalData != null)
|
||||
if (finalData != null)
|
||||
{
|
||||
BlockEntity be = world.getBlockEntity(targetPos);
|
||||
if (be != null)
|
||||
@@ -823,6 +838,7 @@ public class WorldAccess {
|
||||
destTag.putInt("z", targetPos.getZ());
|
||||
be.fromTag(destTag);
|
||||
be.markDirty();
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
result[0] = success;
|
||||
|
||||
@@ -3,6 +3,7 @@ package carpet.script.value;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class FormattedTextValue extends StringValue
|
||||
@@ -14,6 +15,33 @@ public class FormattedTextValue extends StringValue
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public static Value combine(Value left, Value right) {
|
||||
BaseText text;
|
||||
if (left instanceof FormattedTextValue)
|
||||
{
|
||||
text = (BaseText) ((FormattedTextValue) left).getText().shallowCopy();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left instanceof NullValue)
|
||||
return right;
|
||||
text = new LiteralText(left.getString());
|
||||
}
|
||||
|
||||
if (right instanceof FormattedTextValue)
|
||||
{
|
||||
text.append(((FormattedTextValue) right).getText().shallowCopy());
|
||||
return new FormattedTextValue(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (right instanceof NullValue)
|
||||
return left;
|
||||
text.append(right.getString());
|
||||
return new FormattedTextValue(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return text.getString();
|
||||
@@ -48,10 +76,16 @@ public class FormattedTextValue extends StringValue
|
||||
return StringTag.of(Text.Serializer.toJson(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value add(Value o) {
|
||||
return combine(this, o);
|
||||
}
|
||||
|
||||
public String serialize()
|
||||
{
|
||||
return Text.Serializer.toJson(text);
|
||||
}
|
||||
|
||||
public static FormattedTextValue deserialize(String serialized)
|
||||
{
|
||||
return new FormattedTextValue(Text.Serializer.fromJson(serialized));
|
||||
|
||||
@@ -79,6 +79,10 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
||||
|
||||
public Value add(Value o) {
|
||||
String lstr = this.getString();
|
||||
if (o instanceof FormattedTextValue)
|
||||
{
|
||||
return FormattedTextValue.combine(this, o);
|
||||
}
|
||||
if (lstr == null) // null
|
||||
return new StringValue(o.getString());
|
||||
String rstr = o.getString();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "carpet",
|
||||
"version": "1.4.20",
|
||||
"version": "1.4.21",
|
||||
|
||||
"name": "Carpet Mod in Fabric",
|
||||
"description": "Carpet made out of fabric",
|
||||
|
||||
Reference in new issue
Block a user