Skip to content

Commit

Permalink
Resolving conflict with JourneyMap (fixes #202)
Browse files Browse the repository at this point in the history
  • Loading branch information
WesCook committed Feb 12, 2020
1 parent 4c9a2b1 commit cab0e06
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ca.wescook.nutrition.capabilities.SimpleImpl;
import ca.wescook.nutrition.network.Sync;
import ca.wescook.nutrition.proxy.ClientProxy;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
Expand All @@ -26,7 +27,7 @@ public void AttachCapabilitiesEvent(AttachCapabilitiesEvent<Entity> event) {
// Start tracking nutrition
if (!entity.getEntityWorld().isRemote) // Server
event.addCapability(new ResourceLocation(Nutrition.MODID, "nutrition"), new CapabilityManager.Provider()); // Attach capability to player
else // Client
else if (entity instanceof EntityPlayerSP) // Client. Extra check to ensure it's EntityPlayerSP, not EntityOtherPlayerMP
ClientProxy.localNutrition = new SimpleImpl(); // Initialize local dummy copy
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ca/wescook/nutrition/gui/NutritionGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void drawNutritionBars() {
int i = 0;
for (Nutrient nutrient : NutrientList.getVisible()) {
// Calculate percentage width for nutrition bars
float currentNutrient = (ClientProxy.localNutrition != null && ClientProxy.localNutrition.get(nutrient) != null) ? Math.round(ClientProxy.localNutrition.get(nutrient)) : 0; // If null, setPlayerNutrition to 0, else get true value
float currentNutrient = (ClientProxy.localNutrition != null && ClientProxy.localNutrition.get(nutrient) != null) ? Math.round(ClientProxy.localNutrition.get(nutrient)) : 0; // Display empty if null
int nutritionBarDisplayWidth = (int) (currentNutrient / 100 * NUTRITION_BAR_WIDTH);

// Draw icons
Expand Down

0 comments on commit cab0e06

Please sign in to comment.