Skip to content

Commit

Permalink
fix more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yor42 committed Nov 18, 2024
1 parent ef7efbe commit 37f14f7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 52 deletions.
12 changes: 0 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,6 @@ processResources {
)
}

inputs.property "version", project.version
inputs.property "lambdalib_ver", project.lambdalib_ver
inputs.property "mc_version", project.minecraft.version

filesMatching('**/*.java') {
filter(ReplaceTokens, tokens: [
'VERSION': project.version,
'LAMBDA_LIB_VERSION': "[${project.lambdalib_ver}]",
'MC_VERSION': project.minecraft.version
])
}

}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Collection<ImagFusorRecipes.IFRecipe> getRecipes() {

@MethodDescription(example = @Example("item('academy:crystal_normal'), item('academy:crystal_low'), 3000"), type = MethodDescription.Type.ADDITION)
public void addRecipe(ItemStack output, IIngredient input, int liquidAmount){
this.add(new ImagFusorRecipes.IFRecipe(input.toMcIngredient(), input.getAmount(), liquidAmount, output));
recipeBuilder().fluid(liquidAmount).input(input).output(output).register();
}

@MethodDescription(example = @Example("item('academy:crystal_normal')"))
Expand All @@ -43,6 +43,8 @@ public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Property(property = "input", comp = @Comp(eq=1))
@Property(property = "output", comp = @Comp(eq=1))
public static class RecipeBuilder extends AbstractRecipeBuilder<ImagFusorRecipes.IFRecipe> {

@Property(defaultValue = "1000", comp = @Comp(gt = 0))
Expand All @@ -56,7 +58,7 @@ public RecipeBuilder fluid(int fluid) {

@Override
public String getErrorMsg() {
return "Error Adding AcademyCraft Metal Former Recipe";
return "Error Adding AcademyCraft Imag Fusor Recipe";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

import cn.academy.Main;
import cn.academy.block.tileentity.TileMetalFormer;
import cn.academy.crafting.ImagFusorRecipes;
import cn.academy.crafting.MetalFormerRecipes;
import cn.academy.support.groovyscript.AcademyCraftGroovyPlugin;
import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
import com.cleanroommc.groovyscript.compat.mods.roots.Moss;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.StandardListRegistry;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

@RegistryDescription(linkGenerator = Main.MODID)
Expand Down Expand Up @@ -95,7 +88,7 @@ public void removeByMode(TileMetalFormer.Mode mode){
}

public void addRecipe(IIngredient input, ItemStack output, TileMetalFormer.Mode mode){
this.add(new MetalFormerRecipes.RecipeObject(input.toMcIngredient(), input.getAmount(), output, mode));
recipeBuilder().mode(mode).input(input).output(output).register();
}

public void removeByInputAndMode(IIngredient input, TileMetalFormer.Mode mode) {
Expand Down Expand Up @@ -124,10 +117,12 @@ public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Property(property = "input", comp = @Comp(eq=1))
@Property(property = "output", comp = @Comp(eq=1))
public static class RecipeBuilder extends AbstractRecipeBuilder<MetalFormerRecipes.RecipeObject>{

@Property(defaultValue = "ETCH", comp = @Comp(not = "null"))
private TileMetalFormer.Mode MODE = TileMetalFormer.Mode.ETCH;
private TileMetalFormer.Mode mode = TileMetalFormer.Mode.ETCH;

@Override
public String getErrorMsg() {
Expand All @@ -137,32 +132,32 @@ public String getErrorMsg() {
@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
msg.add(MODE == null, "mode must not be null!");
msg.add(mode == null, "mode must not be null!");
}

@RecipeBuilderMethodDescription
@RecipeBuilderMethodDescription(field = "mode")
public RecipeBuilder mode(TileMetalFormer.Mode mode){
this.MODE = mode;
this.mode = mode;
return this;
}
@RecipeBuilderMethodDescription
@RecipeBuilderMethodDescription(field = "mode")
public RecipeBuilder incise(){
this.MODE = TileMetalFormer.Mode.INCISE;
this.mode = TileMetalFormer.Mode.INCISE;
return this;
}
@RecipeBuilderMethodDescription
@RecipeBuilderMethodDescription(field = "mode")
public RecipeBuilder plate(){
this.MODE = TileMetalFormer.Mode.PLATE;
this.mode = TileMetalFormer.Mode.PLATE;
return this;
}
@RecipeBuilderMethodDescription
@RecipeBuilderMethodDescription(field = "mode")
public RecipeBuilder refine(){
this.MODE = TileMetalFormer.Mode.REFINE;
this.mode = TileMetalFormer.Mode.REFINE;
return this;
}
@RecipeBuilderMethodDescription
@RecipeBuilderMethodDescription(field = "mode")
public RecipeBuilder etch(){
this.MODE = TileMetalFormer.Mode.ETCH;
this.mode = TileMetalFormer.Mode.ETCH;
return this;
}

Expand All @@ -177,7 +172,7 @@ public MetalFormerRecipes.RecipeObject register() {
if(!validate()){
return null;
}
MetalFormerRecipes.RecipeObject object = new MetalFormerRecipes.RecipeObject(input.get(0).toMcIngredient(), input.get(0).getAmount(), output.get(0), this.MODE);
MetalFormerRecipes.RecipeObject object = new MetalFormerRecipes.RecipeObject(input.get(0).toMcIngredient(), input.get(0).getAmount(), output.get(0), this.mode);
AcademyCraftGroovyPlugin.FORMER.add(object);
return object;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/academy/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,6 @@ groovyscript.wiki.academy.metal_former.removeRefineByInput=Removes an entry matc
groovyscript.wiki.academy.metal_former.removeAllEtch=Removes all etching entry of metal former
groovyscript.wiki.academy.metal_former.removeAllIncise=Removes all incising entry of metal former
groovyscript.wiki.academy.metal_former.removeAllPlate=Removes all plating entry of metal former
groovyscript.wiki.academy.metal_former.removeAllRefine=Removes all refining entry of metal former
groovyscript.wiki.academy.metal_former.removeAllRefine=Removes all refining entry of metal former
groovyscript.wiki.academy.imag_fusor.fluidAmount.value=Amount of Imag Phase Liquid consumed for this recipe
groovyscript.wiki.academy.metal_former.mode.value=Working mode of Metal former required for this recipe
23 changes: 12 additions & 11 deletions src/main/scala/cn/academy/misc/media/MediaGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import cn.lambdalib2.registry.StateEventCallback
import cn.lambdalib2.util.{Colors, GameTimer}
import net.minecraftforge.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityPlayerSP
import net.minecraftforge.fml.common.event.FMLInitializationEvent

private object MediaGuiInit {
Expand All @@ -29,15 +30,15 @@ class MediaGui extends CGuiScreen {
import MediaGuiInit._
import cn.lambdalib2.cgui.ScalaCGUI._

val backend = MediaBackend(thePlayer)
private val backend = MediaBackend(thePlayer)

val T_PLAY = Resources.getTexture("guis/apps/media_player/play")
val T_PAUSE = Resources.getTexture("guis/apps/media_player/pause")
private val T_PLAY = Resources.getTexture("guis/apps/media_player/play")
private val T_PAUSE = Resources.getTexture("guis/apps/media_player/pause")

val pageMain = document.getWidget("back").copy
private val pageMain = document.getWidget("back").copy

val data = MediaAcquireData(thePlayer)
val allInstalled = MediaManager.allMedias.filter(data.isInstalled)
val data: MediaAcquireData = MediaAcquireData(thePlayer)
private val allInstalled = MediaManager.allMedias.filter(data.isInstalled)

{ // Init media elements
val area = pageMain.child("area")
Expand Down Expand Up @@ -125,7 +126,7 @@ class MediaGui extends CGuiScreen {

updatePlayDisplay()

def wrapEdit(button: Widget, box: Widget, callback: String => Any) = {
def wrapEdit(button: Widget, box: Widget, callback: String => Any): Widget = {
button.transform.doesDraw = true

val dt = new DrawTexture(null).setColor(Colors.monoBlend(.4f, 0))
Expand Down Expand Up @@ -161,7 +162,7 @@ class MediaGui extends CGuiScreen {
/**
* Fetches current playing info and updates it to all GUI elements.
*/
def updatePlayDisplay() = {
private def updatePlayDisplay() = {
val playTimeText = pageMain.child("play_time").component[TextBox]
val progress = pageMain.child("progress").component[ProgressBar]
val title = pageMain.child("title").component[TextBox]
Expand All @@ -181,9 +182,9 @@ class MediaGui extends CGuiScreen {
}
}

def currentPlaying = backend.currentPlaying
def currentPlaying: Option[PlayInfo] = backend.currentPlaying

def thePlayer = Minecraft.getMinecraft.player
def thePlayer: EntityPlayerSP = Minecraft.getMinecraft.player

override def doesGuiPauseGame(): Boolean = false
}
Expand All @@ -193,7 +194,7 @@ private object MediaAuxGui {
import cn.lambdalib2.cgui.ScalaCGUI._

@StateEventCallback
def init(ev: FMLInitializationEvent) = {
def init(ev: FMLInitializationEvent): Widget = {
val base = CGUIDocument.read(Resources.getGui("media_player_aux")).getWidget("base")

ACHud.instance.addElement(base, new Condition {
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/cn/lambdalib2/cgui/ScalaCGUI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RichWidget(val w: Widget) extends AnyVal {

def listens[T <: GuiEvent](handler: (Widget, T) => Any, priority: Int = 0)(implicit evidence: ClassTag[T]): Widget = {
w.listen[T](evidence.runtimeClass.asInstanceOf[Class[T]], priority, new IGuiEventHandler[T] {
override def handleEvent(w: Widget, event: T) = {
override def handleEvent(w: Widget, event: T): Unit = {
handler(w, event)
}
})
Expand All @@ -38,20 +38,20 @@ class RichWidget(val w: Widget) extends AnyVal {

def :+(c: Component): Unit = w.addComponent(c)

def component[T <: Component](implicit evidence: ClassTag[T]) = {
def component[T <: Component](implicit evidence: ClassTag[T]): T = {
w.getComponent(evidence.runtimeClass.asInstanceOf[Class[T]])
}

def child(name: String) = w.getWidget(name)
def child(name: String): Widget = w.getWidget(name)

def child(idx: Int) = w.getWidget(idx)
def child(idx: Int): Widget = w.getWidget(idx)

}

class RichComponent(val c: Component) extends AnyVal {
def listens[T <: GuiEvent](handler: (Widget, T) => Any)(implicit tag: ClassTag[T]): Unit = {
c.listen[T](tag.runtimeClass.asInstanceOf[Class[T]], new IGuiEventHandler[T] {
override def handleEvent(w: Widget, e: T) = handler(w, e)
override def handleEvent(w: Widget, e: T): Unit = handler(w, e)
})
}

Expand Down

0 comments on commit 37f14f7

Please sign in to comment.