Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit f955cb8

Browse files
committed
feat: started working on spawn egg editor
1 parent fbef4be commit f955cb8

File tree

14 files changed

+116
-30
lines changed

14 files changed

+116
-30
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import net.darkhax.curseforgegradle.TaskPublishCurseForge
55

66
plugins {
77
id "architectury-plugin" version "3.4-SNAPSHOT"
8-
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false
9-
id 'net.darkhax.curseforgegradle' version "1.0.7"
8+
id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false
9+
id "net.darkhax.curseforgegradle" version "1.0.10"
1010
id "com.modrinth.minotaur" version "1.2.1"
1111
id "com.github.breadmoirai.github-release" version "2.2.12"
1212
}

common/src/main/java/com/github/franckyi/guapi/api/Color.java

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public static int fromRGB(int r, int g, int b) {
2929
return fromRGBA(r, g, b, 0);
3030
}
3131

32+
public static int fromRGBForRender(int r, int g, int b) {
33+
return fromRGBA(r, g, b, 255);
34+
}
35+
3236
public static int fromRGBA(int r, int g, int b, int a) {
3337
checkValues(r, g, b, a);
3438
return (a & 0xff) << 24 |
@@ -41,6 +45,10 @@ public static int fromRGB(double r, double g, double b) {
4145
return fromRGB((int) (r * 255), (int) (g * 255), (int) (b * 255));
4246
}
4347

48+
public static int fromRGBForRender(double r, double g, double b) {
49+
return fromRGBForRender((int) (r * 255), (int) (g * 255), (int) (b * 255));
50+
}
51+
4452
public static int fromRGBA(double r, double g, double b, double a) {
4553
return fromRGBA((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255));
4654
}

common/src/main/java/com/github/franckyi/guapi/base/node/AbstractTexturedToggleButton.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public abstract class AbstractTexturedToggleButton extends AbstractTexturedButton implements TexturedToggleButton {
1111
private final BooleanProperty activeProperty = BooleanProperty.create();
12-
private final IntegerProperty borderColorProperty = IntegerProperty.create(Color.fromRGB(1.0, 1.0, 1.0));
12+
private final IntegerProperty borderColorProperty = IntegerProperty.create(Color.fromRGBForRender(1.0, 1.0, 1.0));
1313

1414
protected AbstractTexturedToggleButton(ResourceLocation textureId, boolean drawButton) {
1515
super(textureId, drawButton);

common/src/main/java/com/github/franckyi/guapi/base/node/AbstractToggleButton.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public abstract class AbstractToggleButton extends AbstractButton implements ToggleButton {
1111
private final BooleanProperty activeProperty = BooleanProperty.create();
12-
private final IntegerProperty borderColorProperty = IntegerProperty.create(Color.fromRGB(1.0, 1.0, 1.0));
12+
private final IntegerProperty borderColorProperty = IntegerProperty.create(Color.fromRGBForRender(1.0, 1.0, 1.0));
1313

1414
protected AbstractToggleButton() {
1515
}

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/model/ItemEditorModel.java

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ protected void setupCategories() {
3939
if (item instanceof BlockItem) {
4040
getCategories().add(new ItemBlockListCategoryModel(ModTexts.CAN_PLACE_ON, this, "CanPlaceOn"));
4141
}
42+
/*if (item instanceof SpawnEggItem) {
43+
getCategories().add(new ItemSpawnEggCategoryModel(this, (SpawnEggItem) item));
44+
}*/
4245
}
4346

4447
@Override
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
package com.github.franckyi.ibeeditor.client.screen.model.category.item;
22

33
import com.github.franckyi.ibeeditor.client.screen.model.ItemEditorModel;
4+
import com.github.franckyi.ibeeditor.client.screen.model.entry.EntityEntryModel;
45
import com.github.franckyi.ibeeditor.common.ModTexts;
6+
import net.minecraft.nbt.CompoundTag;
7+
import net.minecraft.world.entity.EntityType;
8+
import net.minecraft.world.item.SpawnEggItem;
59

610
public class ItemSpawnEggCategoryModel extends ItemEditorCategoryModel {
7-
public ItemSpawnEggCategoryModel(ItemEditorModel editor) {
11+
private final SpawnEggItem item;
12+
private CompoundTag spawnData;
13+
14+
public ItemSpawnEggCategoryModel(ItemEditorModel editor, SpawnEggItem item) {
815
super(ModTexts.SPAWN_EGG, editor);
16+
this.item = item;
17+
spawnData = getTag().getCompound("EntityTag");
918
}
1019

1120
@Override
1221
protected void setupEntries() {
22+
getEntries().add(
23+
new EntityEntryModel(this, EntityType.by(spawnData).orElse(item.getType(getTag())), spawnData, this::setEntity)
24+
);
25+
}
1326

27+
private void setEntity(CompoundTag compoundTag) {
28+
this.spawnData = compoundTag;
1429
}
1530
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.github.franckyi.ibeeditor.client.screen.model.entry;
2+
3+
import com.github.franckyi.ibeeditor.client.screen.model.category.CategoryModel;
4+
import com.github.franckyi.ibeeditor.common.ModTexts;
5+
import net.minecraft.nbt.CompoundTag;
6+
import net.minecraft.world.entity.EntityType;
7+
8+
import java.util.function.Consumer;
9+
10+
public class EntityEntryModel extends ValueEntryModel<CompoundTag> {
11+
private EntityType<?> entityType;
12+
13+
public EntityEntryModel(CategoryModel category, EntityType<?> entityType, CompoundTag spawnData, Consumer<CompoundTag> action) {
14+
super(category, ModTexts.ENTITY, spawnData, action);
15+
this.entityType = entityType;
16+
}
17+
18+
@Override
19+
public void apply() {
20+
21+
}
22+
23+
@Override
24+
public Type getType() {
25+
return Type.ENTITY;
26+
}
27+
}

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/model/entry/EntryModel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void reset() {
6767
public abstract Type getType();
6868

6969
public enum Type {
70-
STRING, NUMBER, TEXT, ENUM, ACTION, ADD_LIST_ENTRY, BOOLEAN,
70+
STRING, NUMBER, TEXT, ENUM, ACTION, ADD_LIST_ENTRY, BOOLEAN, ITEM, ENTITY,
7171
ENCHANTMENT, HIDE_FLAG, ATTRIBUTE_MODIFIER, SELECTION, SELECTION_POTION, POTION_EFFECT, ARMOR_COLOR,
7272
VAULT_ITEM, VAULT_ENTITY
7373
}

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/mvc/EntryMVC.java

+29-14
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,37 @@ public final class EntryMVC implements MVC<EntryModel, EntryView, EntryControlle
2222
@Override
2323
public EntryView setup(EntryModel model) {
2424
return switch (model.getType()) {
25-
case STRING -> MVC.createViewAndBind((StringEntryModel) model, StringEntryView::new, StringEntryController::new);
26-
case NUMBER -> MVC.createViewAndBind((NumberEntryModel<?>) model, NumberEntryView::new, NumberEntryController::new);
25+
case STRING ->
26+
MVC.createViewAndBind((StringEntryModel) model, StringEntryView::new, StringEntryController::new);
27+
case NUMBER ->
28+
MVC.createViewAndBind((NumberEntryModel<?>) model, NumberEntryView::new, NumberEntryController::new);
2729
case TEXT -> MVC.createViewAndBind((TextEntryModel) model, TextEntryView::new, TextEntryController::new);
2830
case ENUM -> createEnumViewAndBind((EnumEntryModel<?>) model);
29-
case ACTION -> MVC.createViewAndBind((ActionEntryModel) model, ActionEntryView::new, ActionEntryController::new);
30-
case ADD_LIST_ENTRY -> MVC.createViewAndBind((AddListEntryEntryModel) model, AddListEntryEntryView::new, AddListEntryEntryController::new);
31-
case BOOLEAN -> MVC.createViewAndBind((BooleanEntryModel) model, BooleanEntryView::new, BooleanEntryController::new);
32-
case ENCHANTMENT -> MVC.createViewAndBind((EnchantmentEntryModel) model, EnchantmentEntryView::new, EnchantmentEntryController::new);
33-
case HIDE_FLAG -> MVC.createViewAndBind((HideFlagEntryModel) model, HideFlagEntryView::new, HideFlagEntryController::new);
34-
case ATTRIBUTE_MODIFIER -> MVC.createViewAndBind((AttributeModifierEntryModel) model, AttributeModifierEntryView::new, AttributeModifierEntryController::new);
35-
case SELECTION -> MVC.createViewAndBind((SelectionEntryModel) model, SelectionEntryView::new, SelectionEntryController::new);
36-
case SELECTION_POTION -> MVC.createViewAndBind(((PotionSelectionEntryModel) model), PotionSelectionEntryView::new, PotionSelectionEntryController::new);
37-
case POTION_EFFECT -> MVC.createViewAndBind(((PotionEffectEntryModel) model), PotionEffectEntryView::new, PotionEffectEntryController::new);
38-
case ARMOR_COLOR -> MVC.createViewAndBind((ArmorColorEntryModel) model, ArmorColorEntryView::new, ArmorColorEntryController::new);
39-
case VAULT_ITEM -> MVC.createViewAndBind((VaultItemEntryModel) model, VaultItemEntryView::new, VaultItemEntryController::new);
40-
case VAULT_ENTITY -> MVC.createViewAndBind((VaultEntityEntryModel) model, VaultEntityEntryView::new, VaultEntityEntryController::new);
31+
case ACTION ->
32+
MVC.createViewAndBind((ActionEntryModel) model, ActionEntryView::new, ActionEntryController::new);
33+
case ADD_LIST_ENTRY ->
34+
MVC.createViewAndBind((AddListEntryEntryModel) model, AddListEntryEntryView::new, AddListEntryEntryController::new);
35+
case BOOLEAN ->
36+
MVC.createViewAndBind((BooleanEntryModel) model, BooleanEntryView::new, BooleanEntryController::new);
37+
case ITEM, ENTITY -> throw new AssertionError("Not implemented");
38+
case ENCHANTMENT ->
39+
MVC.createViewAndBind((EnchantmentEntryModel) model, EnchantmentEntryView::new, EnchantmentEntryController::new);
40+
case HIDE_FLAG ->
41+
MVC.createViewAndBind((HideFlagEntryModel) model, HideFlagEntryView::new, HideFlagEntryController::new);
42+
case ATTRIBUTE_MODIFIER ->
43+
MVC.createViewAndBind((AttributeModifierEntryModel) model, AttributeModifierEntryView::new, AttributeModifierEntryController::new);
44+
case SELECTION ->
45+
MVC.createViewAndBind((SelectionEntryModel) model, SelectionEntryView::new, SelectionEntryController::new);
46+
case SELECTION_POTION ->
47+
MVC.createViewAndBind(((PotionSelectionEntryModel) model), PotionSelectionEntryView::new, PotionSelectionEntryController::new);
48+
case POTION_EFFECT ->
49+
MVC.createViewAndBind(((PotionEffectEntryModel) model), PotionEffectEntryView::new, PotionEffectEntryController::new);
50+
case ARMOR_COLOR ->
51+
MVC.createViewAndBind((ArmorColorEntryModel) model, ArmorColorEntryView::new, ArmorColorEntryController::new);
52+
case VAULT_ITEM ->
53+
MVC.createViewAndBind((VaultItemEntryModel) model, VaultItemEntryView::new, VaultItemEntryController::new);
54+
case VAULT_ENTITY ->
55+
MVC.createViewAndBind((VaultEntityEntryModel) model, VaultEntityEntryView::new, VaultEntityEntryController::new);
4156
};
4257
}
4358

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.github.franckyi.ibeeditor.client.screen.view.entry;
2+
3+
import com.github.franckyi.guapi.api.node.Node;
4+
5+
import static com.github.franckyi.guapi.api.GuapiHelper.*;
6+
7+
public class EntityEntryView extends LabeledEntryView {
8+
@Override
9+
protected Node createLabeledContent() {
10+
return hBox(content -> {
11+
12+
});
13+
}
14+
}
Loading

forge_update.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"homepage": "https://www.curseforge.com/minecraft/mc-mods/ibe-editor",
33
"promos": {
4-
"1.18.1-latest": "2.0.10",
5-
"1.18.1-recommended": "2.0.10",
6-
"1.18-latest": "2.0.10",
7-
"1.18-recommended": "2.0.10",
4+
"1.18.1-latest": "2.1.0",
5+
"1.18.1-recommended": "2.1.0",
6+
"1.18-latest": "2.1.0",
7+
"1.18-recommended": "2.1.0",
88
"1.17.1-latest": "2.0.10",
99
"1.17.1-recommended": "2.0.10",
1010
"1.16.5-latest": "2.0.10",

gradle.properties

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx3G
33
org.gradle.daemon=false
44
# IBE Editor
5-
minecraft_version=1.18.1
5+
minecraft_version=1.18.2
66
archives_base_name=IBEEditor
7-
mod_version=2.0.10
7+
mod_version=2.1.0
88
maven_group=com.github.franckyi.ibeeditor
99
# Fabric https://fabricmc.net/develop/
10-
fabric_loader_version=0.12.12
11-
fabric_api_version=0.46.2+1.18
10+
fabric_loader_version=0.14.7
11+
fabric_api_version=0.55.1+1.18.2
1212
# Forge https://files.minecraftforge.net/
13-
forge_version=39.0.44
13+
forge_version=40.1.51
1414
# Build and release info
1515
java_version=17
1616
major_minecraft_version=1.18
17-
compatible_minecraft_versions=["1.18", "1.18.1"]
17+
compatible_minecraft_versions=["1.18", "1.18.1", "1.18.2"]

versions.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"2.1.0": {
3+
"type": "release",
4+
"changelog": "* Added Block Editor (not finished yet)\n* Added Entity Editor (not finished yet)\n* Added Vault: allows to save items and entities and re-use them between saves or servers (not finished yet)\n* Added \"Copy command\" button\n* Added buttons to switch between editors (standard, NBT, SNBT)\n* Various fixes"
5+
},
26
"2.0.10": {
37
"type": "beta",
48
"changelog": "* Fixed an issue while editing an item from the creative survival inventory screen or from a chest\n* Added automatic file upload to Modrinth"

0 commit comments

Comments
 (0)