This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Crowdin-Translate, and for Colytra (see issue 45)
- Loading branch information
Showing
7 changed files
with
169 additions
and
17 deletions.
There are no files selected for viewing
Submodule Versionfiles
updated
3 files
+1 −1 | mcversion-1.16.2.properties | |
+13 −0 | mcversion-1.16.3.properties | |
+1 −1 | mcversion-1.16.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/de/guntram/mcmod/durabilityviewer/itemindicator/ColytraDamageIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package de.guntram.mcmod.durabilityviewer.itemindicator; | ||
|
||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
|
||
/** | ||
* | ||
* @author gbl | ||
*/ | ||
public class ColytraDamageIndicator extends ItemDamageIndicator { | ||
|
||
private static int elytraMaxDamage; | ||
private static ItemStack newElytra; | ||
|
||
public ColytraDamageIndicator(ItemStack chestItem) { | ||
super(chestItem); | ||
if (elytraMaxDamage == 0) { | ||
newElytra = new ItemStack(Items.ELYTRA); | ||
elytraMaxDamage = newElytra.getMaxDamage(); | ||
} | ||
} | ||
|
||
private int getDamage() { | ||
int damage; | ||
try { | ||
damage = stack.getTag().getCompound("colytra:ElytraUpgrade").getCompound("tag").getInt("Damage"); | ||
return damage; | ||
} catch (Exception ex) { | ||
return 0; | ||
} | ||
} | ||
|
||
@Override | ||
public String getDisplayValue() { | ||
return calculateDisplayValue(elytraMaxDamage, getDamage()); | ||
} | ||
|
||
@Override | ||
public int getDisplayColor() { | ||
return calculateDisplayColor(elytraMaxDamage, getDamage()); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isItemStackDamageable() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public ItemStack getItemStack() { | ||
return newElytra; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/de/guntram/mcmod/durabilityviewer/sound/ColytraBreakingWarner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package de.guntram.mcmod.durabilityviewer.sound; | ||
|
||
import de.guntram.mcmod.durabilityviewer.handler.ConfigurationHandler; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
/** | ||
* | ||
* @author gbl | ||
*/ | ||
public class ColytraBreakingWarner extends ItemBreakingWarner { | ||
|
||
private static int elytraMaxDamage; | ||
|
||
int lastDurability; | ||
|
||
@Override | ||
public boolean checkBreaks(ItemStack stack) { | ||
if (stack.getTag() == null || !stack.getTag().contains("colytra:ElytraUpgrade")) { | ||
return false; | ||
} | ||
|
||
int damage; | ||
try { | ||
damage = stack.getTag().getCompound("colytra:ElytraUpgrade").getCompound("tag").getInt("Damage"); | ||
} catch (Exception ex) { | ||
return false; | ||
} | ||
|
||
if (elytraMaxDamage == 0) { | ||
elytraMaxDamage = new ItemStack(Items.ELYTRA).getMaxDamage(); | ||
} | ||
|
||
int newDurability=elytraMaxDamage - damage; | ||
if (newDurability < lastDurability | ||
&& newDurability < ConfigurationHandler.getMinDurability() | ||
&& newDurability * 100 / ConfigurationHandler.getMinPercent() < elytraMaxDamage) { | ||
lastDurability=newDurability; | ||
return true; | ||
} | ||
lastDurability=newDurability; | ||
return false; | ||
} | ||
} |