Slightly different implementation of #6910

This commit is contained in:
Anuken 2022-06-08 08:33:01 -04:00
parent 1c0eff0871
commit e627008fbc

View File

@ -68,12 +68,14 @@ public class GlobalVars{
}
for(Block block : Vars.content.blocks()){
put("@" + block.name, block);
//only register blocks that have no item equivalent (this skips sand)
if(content.item(block.name) == null){
put("@" + block.name, block);
}
}
//used as a special value for any environmental solid block
put("@solid", Blocks.stoneWall);
put("@air", Blocks.air);
for(UnitType type : Vars.content.units()){
put("@" + type.name, type);
@ -161,6 +163,12 @@ public class GlobalVars{
/** Adds a constant value by name. */
public int put(String name, Object value){
int existingIdx = namesToIds.get(name, -1);
if(existingIdx != -1){ //don't overwrite existing vars (see #6910)
Log.debug("Failed to add global logic variable '@', as it already exists.", name);
return existingIdx;
}
Var var = new Var(name);
var.constant = true;
if(value instanceof Number num){