mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-26 14:33:46 +00:00
Fix consuming primordial pearls in recipes (#117)
This commit is contained in:
1 parent
3584c8f0a1
commit
20ce1926fd
2 files changed
+26
-30
No files matched your search
@@ -118,7 +118,7 @@ public class GuiArcaneCraftingTerminal extends GuiMEMonitorable {
|
||||
private static final float ASPECT_COST_MAX_ALPHA = 0.75F;
|
||||
|
||||
private void drawAspects(int offsetX, int offsetY) {
|
||||
List<ContainerPartArcaneCraftingTerminal.ArcaneCrafingCost> aspectCosts = ((ContainerPartArcaneCraftingTerminal) this.inventorySlots)
|
||||
List<ContainerPartArcaneCraftingTerminal.ArcaneCraftingCost> aspectCosts = ((ContainerPartArcaneCraftingTerminal) this.inventorySlots)
|
||||
.getAspectCosts();
|
||||
if (aspectCosts.isEmpty()) return;
|
||||
|
||||
@@ -126,12 +126,12 @@ public class GuiArcaneCraftingTerminal extends GuiMEMonitorable {
|
||||
int column = 0;
|
||||
|
||||
// Draw each primal
|
||||
for (ContainerPartArcaneCraftingTerminal.ArcaneCrafingCost cost : aspectCosts) {
|
||||
for (ContainerPartArcaneCraftingTerminal.ArcaneCraftingCost cost : aspectCosts) {
|
||||
// Set the alpha to full
|
||||
float alpha = 1.0F;
|
||||
|
||||
// Do we have enough vis for this aspect?
|
||||
if (!cost.hasEnoughVis) {
|
||||
if (!cost.hasEnoughVis()) {
|
||||
// Ping-pong the alpha
|
||||
alpha = ThEUtils
|
||||
.pingPongFromTime(ASPECT_COST_BLINK_SPEED, ASPECT_COST_MIN_ALPHA, ASPECT_COST_MAX_ALPHA);
|
||||
@@ -144,8 +144,8 @@ public class GuiArcaneCraftingTerminal extends GuiMEMonitorable {
|
||||
UtilsFX.drawTag(
|
||||
posX,
|
||||
posY,
|
||||
cost.primal,
|
||||
cost.visCost,
|
||||
cost.primal(),
|
||||
cost.visCost(),
|
||||
0,
|
||||
this.zLevel,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA,
|
||||
|
||||
+21
-25
@@ -14,6 +14,8 @@ import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
@@ -32,6 +34,7 @@ import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.crafting.IArcaneRecipe;
|
||||
@@ -47,30 +50,18 @@ import thaumicenergistics.common.parts.PartArcaneCraftingTerminal;
|
||||
|
||||
public class ContainerPartArcaneCraftingTerminal extends ContainerMEMonitorable {
|
||||
|
||||
public static class ArcaneCrafingCost {
|
||||
|
||||
/**
|
||||
* How much vis does the recipe require?
|
||||
*/
|
||||
public final float visCost;
|
||||
|
||||
/**
|
||||
* Which aspect?
|
||||
*/
|
||||
public final Aspect primal;
|
||||
|
||||
/**
|
||||
* Do we have enough of this aspect in the wand to perform the craft?
|
||||
*/
|
||||
public final boolean hasEnoughVis;
|
||||
|
||||
public ArcaneCrafingCost(final float visCost, final Aspect primal, final boolean hasEnough) {
|
||||
// Round to 1 decimal place
|
||||
this.visCost = Math.round(visCost * 10.0F) / 10.0F;
|
||||
/**
|
||||
* @param visCost How much vis does the recipe require?
|
||||
* @param primal Which aspect?
|
||||
* @param hasEnoughVis Do we have enough of this aspect in the wand to perform the craft?
|
||||
*/
|
||||
@Desugar
|
||||
public record ArcaneCraftingCost(float visCost, Aspect primal, boolean hasEnoughVis) {
|
||||
|
||||
public ArcaneCraftingCost(final float visCost, final Aspect primal, final boolean hasEnoughVis) {
|
||||
this.visCost = Math.round(visCost * 10.0F) / 10.0F; // Round to 1 decimal place
|
||||
this.primal = primal;
|
||||
|
||||
this.hasEnoughVis = hasEnough;
|
||||
this.hasEnoughVis = hasEnoughVis;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +75,7 @@ public class ContainerPartArcaneCraftingTerminal extends ContainerMEMonitorable
|
||||
|
||||
private final IInventory resultInventory;
|
||||
private AspectList requiredAspects;
|
||||
private final List<ArcaneCrafingCost> craftingCost = new ArrayList<ArcaneCrafingCost>();
|
||||
private final List<ArcaneCraftingCost> craftingCost = new ArrayList<>();
|
||||
|
||||
private final SlotWand wandSlot;
|
||||
private final SlotArcaneCraftingResult resultSlot;
|
||||
@@ -219,7 +210,7 @@ public class ContainerPartArcaneCraftingTerminal extends ContainerMEMonitorable
|
||||
}
|
||||
|
||||
// Add to the cost list
|
||||
this.craftingCost.add(new ArcaneCrafingCost(requiredVis / 100.0F, currentAspect, hasEnough));
|
||||
this.craftingCost.add(new ArcaneCraftingCost(requiredVis / 100.0F, currentAspect, hasEnough));
|
||||
}
|
||||
|
||||
// Did we have all the vis required?
|
||||
@@ -392,6 +383,11 @@ public class ContainerPartArcaneCraftingTerminal extends ContainerMEMonitorable
|
||||
}
|
||||
|
||||
public void consumeIngredients(final EntityPlayer player) {
|
||||
MinecraftForge.EVENT_BUS.post(
|
||||
new PlayerEvent.ItemCraftedEvent(
|
||||
player,
|
||||
this.resultSlot.getStack(),
|
||||
this.terminal.craftingGridInventory));
|
||||
if (player.worldObj.isRemote) return;
|
||||
|
||||
if ((this.requiredAspects != null)) {
|
||||
@@ -498,7 +494,7 @@ public class ContainerPartArcaneCraftingTerminal extends ContainerMEMonitorable
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
public List<ArcaneCrafingCost> getAspectCosts() {
|
||||
public List<ArcaneCraftingCost> getAspectCosts() {
|
||||
return this.craftingCost;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user