Skip to content

Commit

Permalink
Added Error Flag to Hellfire Forge
Browse files Browse the repository at this point in the history
Added an error flag to the Hellfire Forge that tells players when the recipe isn't working due to not having enough Demon Will on hand.

* Added flag texture to the Hellfire Forge's GUI.  Also saved the texture more efficiently, decreasing file size.
* Added translation keys for tooltip text.
* added a boolean variable to the Tile, and a method to read it.
* added the flag and tooltip to the Screen.

I also tweaked the TileSoulForge's operation.  The `|| burnTime > 0` check caused a minor bug where a player could start the recipe going, then swap to a gem without enough will and it would look like it would keep going.  It seems to work fine without it.

I also then could remove two if statements checking for the level being not client side, and having enough Will.  the client side check was done earlier so was always true, and by removing the `burnTime > 0` alternative the minimum souls check is also already done and always true.
  • Loading branch information
VT-14 committed Oct 11, 2023
1 parent e573e39 commit cff3a34
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/generated/resources/assets/bloodmagic/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@
"tooltip.bloodmagic.soulGem.lesser": "A gem used to contain some will.",
"tooltip.bloodmagic.soulGem.petty": "A gem used to contain a little will.",
"tooltip.bloodmagic.soulSnare.desc": "Throw at a monster and then kill them to obtain their demonic will.",
"tooltip.bloodmagic.soulforge.willerror.text": "Not enough Demon Will for this recipe.",
"tooltip.bloodmagic.soulforge.willerror.title": "Demon Will Error",
"tooltip.bloodmagic.specialspawn": "You feel a spatial distortion in this room...",
"tooltip.bloodmagic.syntheticpoint.desc": "A synthetic living armour point. It's... wriggling.",
"tooltip.bloodmagic.tagfilter.desc": "Filters based off of an item's ItemTags.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package wayoftime.bloodmagic.client.screens;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -11,17 +10,27 @@
import wayoftime.bloodmagic.common.container.tile.ContainerSoulForge;
import wayoftime.bloodmagic.common.tile.TileSoulForge;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class ScreenSoulForge extends ScreenBase<ContainerSoulForge>
{
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/soulforge.png");
public Container tileSoulForge;
private static final List<Component> willError = new ArrayList<Component>();

public ScreenSoulForge(ContainerSoulForge container, Inventory playerInventory, Component title)
{
super(container, playerInventory, title);
tileSoulForge = container.tileForge;
this.imageWidth = 176;
this.imageHeight = 205;


willError.clear();
willError.add(Component.translatable("tooltip.bloodmagic.soulforge.willerror.title").withStyle(ChatFormatting.RED));
willError.add(Component.translatable("tooltip.bloodmagic.soulforge.willerror.text").withStyle(ChatFormatting.GRAY));
}

@Override
Expand Down Expand Up @@ -65,6 +74,13 @@ protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX,

int l = this.getCookProgressScaled(90);
guiGraphics.blit(background, i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);

if (getWillFlag())
{
guiGraphics.blit(background, i + 116, j + 51, 194, 0, 16, 16);
if (mouseX >= i + 116 && mouseX < i + 116 + 16 && mouseY >= j + 51 && mouseY < j + 51 + 16)
guiGraphics.renderTooltip(this.font, willError, Optional.empty(), mouseX, mouseY);
}
}

//
Expand All @@ -79,4 +95,6 @@ public int getCookProgressScaled(int scale)
// System.out.println(this.container.data.get(0));
return (int) (progress * scale);
}

public boolean getWillFlag() { return ((TileSoulForge) tileSoulForge).getWillFlagForGUI(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ protected void addTranslations()
add("tooltip.bloodmagic.alchemytable.lperror.title", "Soul Network Error");
add("tooltip.bloodmagic.alchemytable.lperror.text", "Insufficient LP in Soul Network, or Blood Orb is not Bound.");

add("tooltip.bloodmagic.soulforge.willerror.title", "Demon Will Error");
add("tooltip.bloodmagic.soulforge.willerror.text", "Not enough Demon Will for this recipe.");

add("tooltip.bloodmagic.incorrectKey", "The key does not fit in this lock...");
add("tooltip.bloodmagic.specialspawn", "You feel a spatial distortion in this room...");
add("tooltip.bloodmagic.blockeddoor", "The lock breaks and fizzles out of existence!");
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/wayoftime/bloodmagic/common/tile/TileSoulForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class TileSoulForge extends TileInventory implements MenuProvider, IDemon

public int burnTime = 0;

public boolean showWillFlag = false; // show an insufficient will flag in the GUI.

public TileSoulForge(BlockEntityType<?> type, BlockPos pos, BlockState state)
{
super(type, 6, "soulforge", pos, state);
Expand Down Expand Up @@ -104,6 +106,7 @@ public void tick()
{
if (!hasSoulGemOrSoul())
{
showWillFlag = false; // clear flag if there is no Will Holder.
burnTime = 0;
return;
}
Expand Down Expand Up @@ -148,10 +151,11 @@ public void tick()
typeInGem = type;
}
}
if (soulsInGem >= recipe.getMinimumSouls() || burnTime > 0)
if (soulsInGem >= recipe.getMinimumSouls())
{
if (canCraft(recipe))
{
showWillFlag = false; // clear flag if crafting is in progress.
burnTime++;

if (burnTime == ticksRequired)
Expand All @@ -161,31 +165,28 @@ public void tick()
double requiredSouls = recipe.getSoulDrain();
if (requiredSouls > 0)
{
if (!getLevel().isClientSide && soulsInGem >= recipe.getMinimumSouls())
{
consumeSouls(typeInGem, requiredSouls);
}
consumeSouls(typeInGem, requiredSouls);
}

if (!getLevel().isClientSide && soulsInGem >= recipe.getMinimumSouls())
craftItem(recipe);
craftItem(recipe);
}

burnTime = 0;
} else if (burnTime > ticksRequired + 10)
{
burnTime = 0;
}
} else
{
showWillFlag = false; // clear flag if something else is blocking the crafting process.
burnTime = 0;
}
} else
{
showWillFlag = true; // show flag if not enough souls.
burnTime = 0;
}
} else
{
showWillFlag = false; // clear flag if no recipe.
burnTime = 0;
}
}
Expand Down Expand Up @@ -458,4 +459,6 @@ public double getCurrentWill(EnumDemonWillType type)
{
return 0;
}

public boolean getWillFlagForGUI() { return this.showWillFlag; }
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cff3a34

Please sign in to comment.