-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework tab and tier creation to be delayed
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
- Loading branch information
1 parent
443d10a
commit d62f2bd
Showing
24 changed files
with
312 additions
and
194 deletions.
There are no files selected for viewing
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
3 changes: 2 additions & 1 deletion
3
Common/src/main/java/com/blamejared/contenttweaker/core/api/object/ObjectFactory.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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package com.blamejared.contenttweaker.core.api.object; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants; | ||
import com.blamejared.contenttweaker.core.api.zen.ContentTweakerZenConstants; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
@ZenCodeType.Name(ContentTweakerZenConstants.RT_PACKAGE + ".Factory") | ||
@ZenRegister | ||
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID) | ||
public interface ObjectFactory<T> { | ||
ObjectType<T> type(); | ||
} |
28 changes: 10 additions & 18 deletions
28
...n/java/com/blamejared/contenttweaker/vanilla/api/action/tab/SetCreativeTabIconAction.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 |
---|---|---|
@@ -1,42 +1,34 @@ | ||
package com.blamejared.contenttweaker.vanilla.api.action.tab; | ||
|
||
import com.blamejared.contenttweaker.core.api.action.ContentTweakerAction; | ||
import com.blamejared.contenttweaker.vanilla.api.util.ContentTweakerCreativeTab; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.object.ItemReference; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.util.CreativeTab; | ||
import org.apache.logging.log4j.Logger; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.util.CreativeTabReference; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Consumer; | ||
|
||
public final class SetCreativeTabIconAction implements ContentTweakerAction { | ||
private final CreativeTab tab; | ||
private final CreativeTabReference tab; | ||
private final ItemReference icon; | ||
private final Consumer<ItemReference> iconSetter; | ||
|
||
private SetCreativeTabIconAction(final CreativeTab tab, final ItemReference icon) { | ||
private SetCreativeTabIconAction(final CreativeTabReference tab, final ItemReference icon, final Consumer<ItemReference> iconSetter) { | ||
this.tab = tab; | ||
this.icon = icon; | ||
this.iconSetter = iconSetter; | ||
} | ||
|
||
public static SetCreativeTabIconAction of(final CreativeTab tab, final ItemReference icon) { | ||
return new SetCreativeTabIconAction(Objects.requireNonNull(tab), Objects.requireNonNull(icon)); | ||
public static SetCreativeTabIconAction of(final CreativeTabReference tab, final ItemReference icon, final Consumer<ItemReference> iconSetter) { | ||
return new SetCreativeTabIconAction(Objects.requireNonNull(tab), Objects.requireNonNull(icon), Objects.requireNonNull(iconSetter)); | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
((ContentTweakerCreativeTab) this.tab.unwrap()).setDisplayItem(this.icon); | ||
this.iconSetter.accept(this.icon); | ||
} | ||
|
||
@Override | ||
public String describe() { | ||
return "Setting icon of tab %s to %s".formatted(this.tab, this.icon.id()); | ||
} | ||
|
||
@Override | ||
public boolean validate(final Logger logger) { | ||
if (!(this.tab.unwrap() instanceof ContentTweakerCreativeTab)) { | ||
logger.error("Creative tab " + this.tab + " is not customizable"); | ||
return false; | ||
} | ||
return true; | ||
return "Setting icon of tab %s to %s".formatted(this.tab.id(), this.icon.id()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...src/main/java/com/blamejared/contenttweaker/vanilla/api/action/tier/CreateTierAction.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,30 @@ | ||
package com.blamejared.contenttweaker.vanilla.api.action.tier; | ||
|
||
import com.blamejared.contenttweaker.core.api.action.ContentTweakerAction; | ||
import com.blamejared.contenttweaker.vanilla.api.zen.util.TierReference; | ||
|
||
import java.util.Objects; | ||
|
||
public final class CreateTierAction implements ContentTweakerAction { | ||
private final TierReference reference; | ||
private final Runnable creationAction; | ||
|
||
private CreateTierAction(final TierReference reference, final Runnable creationAction) { | ||
this.reference = reference; | ||
this.creationAction = creationAction; | ||
} | ||
|
||
public static CreateTierAction of(final TierReference reference, final Runnable creationAction) { | ||
return new CreateTierAction(Objects.requireNonNull(reference), Objects.requireNonNull(creationAction)); | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
this.creationAction.run(); | ||
} | ||
|
||
@Override | ||
public String describe() { | ||
return "Creating a new tier named %s%s".formatted(this.reference.name(), this.reference.level() < 0? "" : " with level " + this.reference.level()); | ||
} | ||
} |
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
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
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
46 changes: 0 additions & 46 deletions
46
Common/src/main/java/com/blamejared/contenttweaker/vanilla/api/zen/util/CreativeTab.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.