Skip to content

Commit

Permalink
Update AbstractControlCar.java
Browse files Browse the repository at this point in the history
* Quick change to use enum
  • Loading branch information
RealTBEA committed Sep 15, 2024
1 parent 5b5ced0 commit a81b2b1
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main/java/train/common/api/AbstractControlCar.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ protected void readEntityFromNBT(NBTTagCompound ntc)
lightingDetailsJSONObject = lightingDetailsAsJSON();
}

isLightsEnabled = lightingDetailsJSONObject.get("isLightsEnabled").getAsBoolean();
isBeaconEnabled = lightingDetailsJSONObject.get("isBeaconEnabled").getAsBoolean();
ditchLightMode = lightingDetailsJSONObject.get("ditchLightMode").getAsByte();
beaconCycleIndex = lightingDetailsJSONObject.get("beaconCycleIndex").getAsByte();

isLightsEnabled = lightingDetailsJSONObject.get(DataMemberName.isLightsEnabled.AsString()).getAsBoolean();
isBeaconEnabled = lightingDetailsJSONObject.get(DataMemberName.isBeaconEnabled.AsString()).getAsBoolean();
ditchLightMode = lightingDetailsJSONObject.get(DataMemberName.ditchLightMode.AsString()).getAsByte();
beaconCycleIndex = lightingDetailsJSONObject.get(DataMemberName.beaconCycleIndex.AsString()).getAsByte();
dataWatcher.updateObject(28, lightingDetailsJSONString());
}

Expand Down Expand Up @@ -439,10 +438,10 @@ public String lightingDetailsJSONString()
public JsonObject lightingDetailsAsJSON()
{
JsonObject lightingDetailsJSON = new JsonObject();
lightingDetailsJSON.addProperty("isLightsEnabled", isLightsEnabled);
lightingDetailsJSON.addProperty("isBeaconEnabled", isBeaconEnabled);
lightingDetailsJSON.addProperty("beaconCycleIndex", beaconCycleIndex);
lightingDetailsJSON.addProperty("ditchLightMode", ditchLightMode);
lightingDetailsJSON.addProperty(DataMemberName.isLightsEnabled.AsString(), isLightsEnabled);
lightingDetailsJSON.addProperty(DataMemberName.isBeaconEnabled.AsString(), isBeaconEnabled);
lightingDetailsJSON.addProperty(DataMemberName.beaconCycleIndex.AsString(), beaconCycleIndex);
lightingDetailsJSON.addProperty(DataMemberName.ditchLightMode.AsString(), ditchLightMode);
return lightingDetailsJSON;
}

Expand Down Expand Up @@ -480,22 +479,22 @@ public int getLocomotiveBeingControlledEntityID()

public boolean isLightsEnabled()
{
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("isLightsEnabled").getAsBoolean();
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.isLightsEnabled.AsString()).getAsBoolean();
}

public boolean isBeaconEnabled()
{
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("isBeaconEnabled").getAsBoolean();
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.isBeaconEnabled.AsString()).getAsBoolean();
}

public byte getBeaconCycleIndex()
{
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("beaconCycleIndex").getAsByte();
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.beaconCycleIndex.AsString()).getAsByte();
}

public boolean isDitchLightsEnabled()
{
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("ditchLightMode").getAsByte() > 0;
return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.ditchLightMode.AsString()).getAsByte() > 0;
}

private JsonObject AsJsonObject(String string)
Expand Down

0 comments on commit a81b2b1

Please sign in to comment.