19w41a first pass
This commit is contained in:
1 parent
5ebfb7d1c0
commit
7b649f9ccd
28 files changed
+164
-178
No files matched your search
@@ -2,7 +2,7 @@ package carpet.script;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.fakes.MinecraftServerInterface;
|
||||
import carpet.fakes.class_4548Interface;
|
||||
import carpet.fakes.BiomeArrayInterface;
|
||||
import carpet.helpers.FeatureGenerator;
|
||||
import carpet.script.Fluff.TriFunction;
|
||||
import carpet.script.exception.CarpetExpressionException;
|
||||
@@ -676,7 +676,7 @@ public class CarpetExpression
|
||||
Entity e = ((EntityValue) arg).getEntity();
|
||||
if (e == null)
|
||||
throw new InternalExpressionException("Null entity");
|
||||
Value retval = ListValue.of(new NumericValue(e.x), new NumericValue(e.y), new NumericValue(e.z));
|
||||
Value retval = ListValue.of(new NumericValue(e.method_23317()), new NumericValue(e.method_23318()), new NumericValue(e.method_23321()));
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
else
|
||||
@@ -785,7 +785,7 @@ public class CarpetExpression
|
||||
booleanStateTest(c, "block_tick", lv, (s, p) ->
|
||||
{
|
||||
ServerWorld w = ((CarpetContext)c).s.getWorld();
|
||||
s.onRandomTick(w, p, w.random);
|
||||
s.randomTick(w, p, w.random);
|
||||
return true;
|
||||
}));
|
||||
|
||||
@@ -794,7 +794,7 @@ public class CarpetExpression
|
||||
{
|
||||
ServerWorld w = ((CarpetContext)c).s.getWorld();
|
||||
if (s.hasRandomTicks() || s.getFluidState().hasRandomTicks())
|
||||
s.onRandomTick(w, p, w.random);
|
||||
s.randomTick(w, p, w.random);
|
||||
return true;
|
||||
}));
|
||||
|
||||
@@ -1024,7 +1024,7 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Chunk chunk = world.getChunk(pos);
|
||||
((class_4548Interface)chunk.getBiomeArray()).setBiomeAtIndex(pos, world, biome);
|
||||
((BiomeArrayInterface)chunk.getBiomeArray()).setBiomeAtIndex(pos, world, biome);
|
||||
this.forceChunkUpdate(pos, world);
|
||||
return LazyValue.NULL;
|
||||
});
|
||||
@@ -1332,8 +1332,8 @@ public class CarpetExpression
|
||||
{
|
||||
LivingEntity villager = (LivingEntity)owner;
|
||||
// stolen from LookTargetUtil.give((VillagerEntity)owner, droppedStack, (LivingEntity) owner);
|
||||
double double_1 = villager.y - 0.30000001192092896D + (double)villager.getStandingEyeHeight();
|
||||
item = new ItemEntity(villager.world, villager.x, double_1, villager.z, droppedStack);
|
||||
double double_1 = villager.method_23318() - 0.30000001192092896D + (double)villager.getStandingEyeHeight();
|
||||
item = new ItemEntity(villager.world, villager.method_23317(), double_1, villager.method_23321(), droppedStack);
|
||||
Vec3d vec3d_1 = villager.getRotationVec(1.0F).normalize().multiply(0.3);// new Vec3d(0, 0.3, 0);
|
||||
item.setVelocity(vec3d_1);
|
||||
item.setToDefaultPickupDelay();
|
||||
@@ -1808,7 +1808,7 @@ public class CarpetExpression
|
||||
{
|
||||
throw new InternalExpressionException("Unknown entity selection criterion: "+who);
|
||||
}
|
||||
List<Entity> entityList = ((CarpetContext)c).s.getWorld().getEntities(pair.getKey(), area, pair.getValue());
|
||||
List<Entity> entityList = ((CarpetContext)c).s.getWorld().getEntities((EntityType<Entity>) pair.getKey(), area, pair.getValue());
|
||||
Value retval = ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList()));
|
||||
return (_c, _t ) -> retval;
|
||||
});
|
||||
@@ -2811,7 +2811,7 @@ public class CarpetExpression
|
||||
return (cc, tt) -> retval;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
||||
/*this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
if (lv.size() <= locator.offset)
|
||||
throw new InternalExpressionException("plop needs extra argument indicating what to plop");
|
||||
@@ -2822,7 +2822,7 @@ public class CarpetExpression
|
||||
if (what.equalsIgnoreCase("boulder")) // there might be more of those
|
||||
this.forceChunkUpdate(locator.block.getPos(), ((CarpetContext)c).s.getWorld());
|
||||
return (c_, t_) -> new NumericValue(res);
|
||||
});
|
||||
});*/
|
||||
|
||||
this.expr.addLazyFunction("schedule", -1, (c, t, lv) -> {
|
||||
if (lv.size()<2)
|
||||
|
||||
@@ -180,11 +180,11 @@ public class EntityValue extends Value
|
||||
put("removed", (entity, arg) -> new NumericValue(entity.removed));
|
||||
put("uuid",(e, a) -> new StringValue(e.getUuidAsString()));
|
||||
put("id",(e, a) -> new NumericValue(e.getEntityId()));
|
||||
put("pos", (e, a) -> ListValue.of(new NumericValue(e.x), new NumericValue(e.y), new NumericValue(e.z)));
|
||||
put("location", (e, a) -> ListValue.of(new NumericValue(e.x), new NumericValue(e.y), new NumericValue(e.z), new NumericValue(e.yaw), new NumericValue(e.pitch)));
|
||||
put("x", (e, a) -> new NumericValue(e.x));
|
||||
put("y", (e, a) -> new NumericValue(e.y));
|
||||
put("z", (e, a) -> new NumericValue(e.z));
|
||||
put("pos", (e, a) -> ListValue.of(new NumericValue(e.method_23317()), new NumericValue(e.method_23318()), new NumericValue(e.method_23321())));
|
||||
put("location", (e, a) -> ListValue.of(new NumericValue(e.method_23317()), new NumericValue(e.method_23318()), new NumericValue(e.method_23321()), new NumericValue(e.yaw), new NumericValue(e.pitch)));
|
||||
put("x", (e, a) -> new NumericValue(e.method_23317()));
|
||||
put("y", (e, a) -> new NumericValue(e.method_23317()));
|
||||
put("z", (e, a) -> new NumericValue(e.method_23317()));
|
||||
put("motion", (e, a) ->
|
||||
{
|
||||
Vec3d velocity = e.getVelocity();
|
||||
@@ -422,7 +422,7 @@ public class EntityValue extends Value
|
||||
private static void updatePosition(Entity e)
|
||||
{
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.method_23317(), e.method_23318(), e.method_23321(), e.yaw, e.pitch);
|
||||
else
|
||||
((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e,new EntityPositionS2CPacket(e));
|
||||
}
|
||||
@@ -446,14 +446,16 @@ public class EntityValue extends Value
|
||||
throw new InternalExpressionException("expected a list of 5 parameters as second argument");
|
||||
}
|
||||
List<Value> coords = ((ListValue) v).getItems();
|
||||
e.x = NumericValue.asNumber(coords.get(0)).getDouble();
|
||||
e.y = NumericValue.asNumber(coords.get(1)).getDouble();
|
||||
e.z = NumericValue.asNumber(coords.get(2)).getDouble();
|
||||
e.method_23327(
|
||||
NumericValue.asNumber(coords.get(0)).getDouble(),
|
||||
NumericValue.asNumber(coords.get(1)).getDouble(),
|
||||
NumericValue.asNumber(coords.get(2)).getDouble()
|
||||
);
|
||||
e.pitch = (float) NumericValue.asNumber(coords.get(4)).getDouble();
|
||||
e.prevPitch = e.pitch;
|
||||
e.yaw = (float) NumericValue.asNumber(coords.get(3)).getDouble();
|
||||
e.prevYaw = e.yaw;
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
e.setPosition(e.method_23317(), e.method_23318(), e.method_23321());
|
||||
updatePosition(e);
|
||||
});
|
||||
put("pos", (e, v) ->
|
||||
@@ -463,28 +465,30 @@ public class EntityValue extends Value
|
||||
throw new InternalExpressionException("expected a list of 3 parameters as second argument");
|
||||
}
|
||||
List<Value> coords = ((ListValue) v).getItems();
|
||||
e.x = NumericValue.asNumber(coords.get(0)).getDouble();
|
||||
e.y = NumericValue.asNumber(coords.get(1)).getDouble();
|
||||
e.z = NumericValue.asNumber(coords.get(2)).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
e.method_23327(
|
||||
NumericValue.asNumber(coords.get(0)).getDouble(),
|
||||
NumericValue.asNumber(coords.get(1)).getDouble(),
|
||||
NumericValue.asNumber(coords.get(2)).getDouble()
|
||||
);
|
||||
e.setPosition(e.method_23317(), e.method_23318(), e.method_23321());
|
||||
updatePosition(e);
|
||||
});
|
||||
put("x", (e, v) ->
|
||||
{
|
||||
e.x = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
//e.x = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(NumericValue.asNumber(v).getDouble(), e.method_23318(), e.method_23321());
|
||||
updatePosition(e);
|
||||
});
|
||||
put("y", (e, v) ->
|
||||
{
|
||||
e.y = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
//e.y = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.method_23317(), NumericValue.asNumber(v).getDouble(), e.method_23321());
|
||||
updatePosition(e);
|
||||
});
|
||||
put("z", (e, v) ->
|
||||
{
|
||||
e.z = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
//e.z = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.method_23317(), e.method_23318(), NumericValue.asNumber(v).getDouble());
|
||||
updatePosition(e);
|
||||
});
|
||||
put("pitch", (e, v) ->
|
||||
@@ -510,10 +514,7 @@ public class EntityValue extends Value
|
||||
throw new InternalExpressionException("expected a list of 3 parameters as second argument");
|
||||
}
|
||||
List<Value> coords = ((ListValue) v).getItems();
|
||||
e.x += NumericValue.asNumber(coords.get(0)).getDouble();
|
||||
e.y += NumericValue.asNumber(coords.get(1)).getDouble();
|
||||
e.z += NumericValue.asNumber(coords.get(2)).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
e.setPosition(NumericValue.asNumber(coords.get(0)).getDouble(),NumericValue.asNumber(coords.get(1)).getDouble(), NumericValue.asNumber(coords.get(2)).getDouble());
|
||||
updatePosition(e);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user