Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int slot,
public static boolean checkImplosion(ItemStack item, World world) {
if (item.getItemDamage() == 0 && item.hasTagCompound()) {
NBTTagCompound tag = item.getTagCompound();
int remaining = tag.getInteger("ImplosionTimer");
if (remaining > 0) {
tag.setInteger("ImplosionTimer", remaining - 1);
} else {
if (tag.getBoolean("Crafted") && !tag.hasKey("CraftedAt")) {
tag.setLong("CraftedAt", world.getTotalWorldTime());
item.setTagCompound(tag);
}

long passed = world.getTotalWorldTime() - tag.getLong("CraftedAt");
if (passed > InversionConfig.invertedIngotImplosionTimer) {
return (world.isRemote);
}
}
Expand All @@ -76,20 +79,23 @@ public String getUnlocalizedName(ItemStack stack) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean p_77624_4_) {
if (stack.getItemDamage() == 0) {
if (InversionConfig.invertedIngotsImplode) {
NBTTagCompound tag = stack.getTagCompound();
if (tag == null) {
if (!stack.hasTagCompound()) {
tooltip.add(StatCollector.translateToLocal("item.inverted_ingot.desc.c"));
} else {
tooltip.add(StatCollector.translateToLocal("item.inverted_ingot.desc.1"));
if (stack.hasTagCompound()) {
double time = (double) stack.getTagCompound()
.getInteger("ImplosionTimer") / 20;
NBTTagCompound tag = stack.getTagCompound();
if (tag.hasKey("CraftedAt")) {
double passed = player.worldObj.getTotalWorldTime() - tag.getLong("CraftedAt");
double timeLeft = (InversionConfig.invertedIngotImplosionTimer - passed) / 20D;
tooltip.add(
StatCollector.translateToLocalFormatted(
"item.inverted_ingot.desc.2",
formatNumber(Math.max(0, time))));
formatNumber(Math.max(0, timeLeft))));
} else {
tooltip.add(StatCollector.translateToLocalFormatted("item.inverted_ingot.desc.2", 10));
tooltip.add(
StatCollector.translateToLocalFormatted(
"item.inverted_ingot.desc.2",
InversionConfig.invertedIngotImplosionTimer / 20));
}
tooltip.add(StatCollector.translateToLocal("item.inverted_ingot.desc.3"));
tooltip.add(StatCollector.translateToLocal("item.inverted_ingot.desc.4"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ItemStack getRecipeOutput() {
ItemStack output = super.getRecipeOutput().copy();
if (InversionConfig.invertedIngotsImplode) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("ImplosionTimer", InversionConfig.invertedIngotImplosionTimer);
nbt.setBoolean("Crafted", true);
output.setTagCompound(nbt);
}
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
.getIconFromDamageForRenderPass(stack.getItemDamage(), 0);

NBTTagCompound tag = stack.getTagCompound();
if (tag != null && tag.hasKey("ImplosionTimer")) {
if (tag != null && tag.hasKey("CraftedAt")) {

World world = Minecraft.getMinecraft().theWorld;
if (world == null) return;

int remaining = tag.getInteger("ImplosionTimer");
double passed = world.getTotalWorldTime() - tag.getLong("CraftedAt");
int remaining = (int) (InversionConfig.invertedIngotImplosionTimer - passed);

float progress = MathHelper
.clamp_float((float) remaining / InversionConfig.invertedIngotImplosionTimer, 0f, 1f);
Expand Down