remove a few warnings

This commit is contained in:
gnembon committed 2020-01-06 21:26:44 -04:00
1 parent 3bec43fbc8
commit 6ac249968a
41 files changed
+122 -137

No files matched your search

@@ -36,8 +36,8 @@ public class BlockValue extends Value
public static final BlockValue AIR = new BlockValue(Blocks.AIR.getDefaultState(), null, BlockPos.ORIGIN);
public static final BlockValue NULL = new BlockValue(null, null, null);
private BlockState blockState;
private BlockPos pos;
private ServerWorld world;
private final BlockPos pos;
private final ServerWorld world;
private CompoundTag data;
public static BlockValue fromCoords(CarpetContext c, int x, int y, int z)
@@ -46,7 +46,7 @@ public class BlockValue extends Value
return new BlockValue(null, c.s.getWorld(), pos);
}
private static Map<String, BlockValue> bvCache= new HashMap<>();
private static final Map<String, BlockValue> bvCache= new HashMap<>();
public static BlockValue fromString(String str)
{
try
@@ -294,8 +294,8 @@ public class BlockValue extends Value
public static class LocatorResult
{
public BlockValue block;
public int offset;
public final BlockValue block;
public final int offset;
LocatorResult(BlockValue b, int o)
{
block = b;
@@ -306,9 +306,9 @@ public class BlockValue extends Value
public static class VectorLocator
{
public Vec3d vec;
public int offset;
public double yaw;
public double pitch;
public final int offset;
public final double yaw;
public final double pitch;
public boolean fromBlock;
VectorLocator(Vec3d v, int o)
{
@@ -358,9 +358,9 @@ public class BlockValue extends Value
EASTUP("east-up", 0.0, 0.6, 0.5, Direction.EAST),
WESTUP("west-up", 1.0, 0.6, 0.5, Direction.WEST);
public String name;
public Vec3d hitOffset;
public Direction facing;
public final String name;
public final Vec3d hitOffset;
public final Direction facing;
private static final Map<String, SpecificDirection> DIRECTION_MAP = Arrays.stream(values()).collect(Collectors.toMap(SpecificDirection::getName, d -> d));
@@ -62,14 +62,14 @@ import static carpet.script.value.NBTSerializableValue.nameFromRegistryId;
// TODO: decide whether copy(entity) should duplicate entity in the world.
public class EntityValue extends Value
{
private Entity entity;
private final Entity entity;
public EntityValue(Entity e)
{
entity = e;
}
private static Map<String, EntitySelector> selectorCache = new HashMap<>();
private static final Map<String, EntitySelector> selectorCache = new HashMap<>();
public static Collection<? extends Entity > getEntitiesFromSelector(ServerCommandSource source, String selector)
{
try
@@ -177,7 +177,7 @@ public class EntityValue extends Value
return res; //TODO add more here like search by tags, or type
//if (who.startsWith('tag:'))
}
private static Map<String, Pair<EntityType<?>, Predicate<? super Entity>>> entityPredicates =
private static final Map<String, Pair<EntityType<?>, Predicate<? super Entity>>> entityPredicates =
new HashMap<String, Pair<EntityType<?>, Predicate<? super Entity>>>()
{{
put("*", Pair.of(null, EntityPredicates.VALID_ENTITY));
@@ -192,7 +192,7 @@ public class EntityValue extends Value
throw new InternalExpressionException("Unknown entity feature: "+what);
return featureAccessors.get(what).apply(entity, arg);
}
private static Map<String, EquipmentSlot> inventorySlots = new HashMap<String, EquipmentSlot>(){{
private static final Map<String, EquipmentSlot> inventorySlots = new HashMap<String, EquipmentSlot>(){{
put("mainhand", EquipmentSlot.MAINHAND);
put("offhand", EquipmentSlot.OFFHAND);
put("head", EquipmentSlot.HEAD);
@@ -200,7 +200,7 @@ public class EntityValue extends Value
put("legs", EquipmentSlot.LEGS);
put("feet", EquipmentSlot.FEET);
}};
private static Map<String, BiFunction<Entity, Value, Value>> featureAccessors = new HashMap<String, BiFunction<Entity, Value, Value>>() {{
private static final Map<String, BiFunction<Entity, Value, Value>> featureAccessors = new HashMap<String, BiFunction<Entity, Value, Value>>() {{
//put("test", (e, a) -> a == null ? Value.NULL : new StringValue(a.getString()));
put("removed", (entity, arg) -> new NumericValue(entity.removed));
put("uuid",(e, a) -> new StringValue(e.getUuidAsString()));
@@ -440,20 +440,6 @@ public class EntityValue extends Value
});
}};
private static <Req extends Entity> Req assertEntityArgType(Class<Req> klass, Value arg)
{
if (!(arg instanceof EntityValue))
{
return null;
}
Entity e = ((EntityValue) arg).getEntity();
if (!(klass.isAssignableFrom(e.getClass())))
{
return null;
}
return (Req)e;
}
public void set(String what, Value toWhat)
{
if (!(featureModifiers.containsKey(what)))
@@ -515,7 +501,7 @@ public class EntityValue extends Value
private static Map<String, BiConsumer<Entity, Value>> featureModifiers = new HashMap<String, BiConsumer<Entity, Value>>() {{
private static final Map<String, BiConsumer<Entity, Value>> featureModifiers = new HashMap<String, BiConsumer<Entity, Value>>() {{
put("remove", (entity, value) -> entity.remove());
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
put("kill", (e, v) -> e.kill());
+2 -2
View File
@@ -39,7 +39,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
}
public Value reboundedTo(String var)
{
Value copy = null;
Value copy;
try
{
copy = (Value)clone();
@@ -202,5 +202,5 @@ public abstract class Value implements Comparable<Value>, Cloneable
// should never happen
throw new InternalExpressionException("Cannot make a copy of value: "+this);
}
};
}
}