Merge branch 'master' into 1.15
# Conflicts: # src/main/java/carpet/script/CarpetExpression.java
This commit is contained in:
commit
3e6f83905c
21 files changed
+1019
-296
No files matched your search
@@ -21,6 +21,7 @@ import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -129,15 +130,24 @@ public class BlockValue extends Value
|
||||
|
||||
public static LocatorResult fromParams(CarpetContext c, List<LazyValue> params, int offset)
|
||||
{
|
||||
return fromParams(c, params,offset, false);
|
||||
return fromParams(c, params,offset, false, false);
|
||||
}
|
||||
|
||||
public static LocatorResult fromParams(CarpetContext c, List<LazyValue> params, int offset, boolean acceptString)
|
||||
{
|
||||
return fromParams(c, params,offset, acceptString, false);
|
||||
}
|
||||
|
||||
public static LocatorResult fromParams(CarpetContext c, List<LazyValue> params, int offset, boolean acceptString, boolean optional)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset).evalValue(c);
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
{
|
||||
return new LocatorResult(null, 1+offset);
|
||||
}
|
||||
if (acceptString && v1 instanceof StringValue)
|
||||
{
|
||||
return new LocatorResult(fromString(v1.getString()), 1+offset);
|
||||
@@ -192,6 +202,15 @@ public class BlockValue extends Value
|
||||
throw new InternalExpressionException("Attempted to fetch block state without world or stored block state");
|
||||
}
|
||||
|
||||
public static BlockEntity getBlockEntity(ServerWorld world, BlockPos pos)
|
||||
{
|
||||
if (world.getServer().isOnThread())
|
||||
return world.getBlockEntity(pos);
|
||||
else
|
||||
return world.getWorldChunk(pos).getBlockEntity(pos, WorldChunk.CreationType.IMMEDIATE);
|
||||
}
|
||||
|
||||
|
||||
public CompoundTag getData()
|
||||
{
|
||||
if (data != null)
|
||||
@@ -202,7 +221,7 @@ public class BlockValue extends Value
|
||||
}
|
||||
if (world != null && pos != null)
|
||||
{
|
||||
BlockEntity be = world.getBlockEntity(pos);
|
||||
BlockEntity be = getBlockEntity(world, pos);
|
||||
CompoundTag tag = new CompoundTag();
|
||||
if (be == null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user