55import com .rae .creatingspace .content .rocket .engine .design .PropellantType ;
66import com .rae .creatingspace .init .MiscInit ;
77import com .rae .creatingspace .init .ingameobject .PropellantTypeInit ;
8- import net .minecraft .core .HolderLookup ;
98import net .minecraft .core .component .DataComponents ;
109import net .minecraft .nbt .CompoundTag ;
1110import net .minecraft .nbt .NbtOps ;
1514import net .minecraft .world .item .ItemStack ;
1615import net .minecraft .world .item .TooltipFlag ;
1716import net .minecraft .world .item .component .CustomData ;
18- import net .minecraft .world .level .Level ;
19- import org .jetbrains .annotations .Nullable ;
17+ import org .jetbrains .annotations .NotNull ;
2018
2119import java .util .List ;
2220
@@ -28,7 +26,7 @@ public EngineFabricationBlueprint(Properties properties) {
2826 }
2927
3028 @ Override
31- public void appendHoverText (ItemStack itemStack , @ Nullable TooltipContext context , List <Component > components , TooltipFlag tooltipFlag ) {
29+ public void appendHoverText (ItemStack itemStack , @ NotNull TooltipContext context , @ NotNull List <Component > components , @ NotNull TooltipFlag tooltipFlag ) {
3230 //TODO make this method static somewhere (repetition for the engine, for the engine blueprint then for every item)
3331 CustomData data = itemStack .get (DataComponents .CUSTOM_DATA );
3432 if (data !=null ) {
@@ -69,25 +67,23 @@ public ItemStack getBlueprintForEngine(int throatArea, int expansionRatio, int m
6967 PowerPackType powerPackType = MiscInit .getSyncedPowerPackRegistry ().get (powerPackTypeLocation );
7068 ItemStack defaultInstance = super .getDefaultInstance ();
7169 CustomData data = defaultInstance .get (DataComponents .CUSTOM_DATA );
72- CompoundTag nbt = new CompoundTag ();
73- if (data !=null ) {
74- nbt = data .copyTag ();
75- CompoundTag engineInfo = new CompoundTag ();
76- engineInfo .putInt ("thrust" , thrust );
77- assert exhaustPackType != null ;
78- engineInfo .putInt ("mass" , exhaustPackType .getMass ((float ) throatArea / 1000 , expansionRatio ));//size will be defined in the exhaust and powerPack as a coef (0.5 fo reach right now)
79- engineInfo .putFloat ("efficiency" , efficiency );
80- engineInfo .put ("propellantType" , ResourceLocation .CODEC .encodeStart (NbtOps .INSTANCE , propellantTypeLocation ).getOrThrow ());
70+ CompoundTag nbt = data ==null ?new CompoundTag ():data .copyTag ();
71+ CompoundTag engineInfo = new CompoundTag ();
72+ engineInfo .putInt ("thrust" , thrust );
73+ assert exhaustPackType != null ;
74+ engineInfo .putInt ("mass" , exhaustPackType .getMass ((float ) throatArea / 1000 , expansionRatio ));//size will be defined in the exhaust and powerPack as a coef (0.5 fo reach right now)
75+ engineInfo .putFloat ("efficiency" , efficiency );
76+ engineInfo .put ("propellantType" , ResourceLocation .CODEC .encodeStart (NbtOps .INSTANCE , propellantTypeLocation ).getOrThrow ());
77+
78+ CompoundTag recipeData = new CompoundTag ();
79+ recipeData .put ("exhaustPackType" , ResourceLocation .CODEC .encodeStart (NbtOps .INSTANCE , exhaustPackTypeLocation ).getOrThrow ());
80+ recipeData .put ("powerPackType" , ResourceLocation .CODEC .encodeStart (NbtOps .INSTANCE , powerPackTypeLocation ).getOrThrow ());
81+ recipeData .putInt ("size" , throatArea );
82+ recipeData .putInt ("expansionRatio" , expansionRatio );
83+ recipeData .putInt ("materialLevel" , materialLevel );
84+ nbt .put ("blockEntity" , engineInfo );
85+ nbt .put ("engineRecipeData" , recipeData );
8186
82- CompoundTag recipeData = new CompoundTag ();
83- recipeData .put ("exhaustPackType" , ResourceLocation .CODEC .encodeStart (NbtOps .INSTANCE , exhaustPackTypeLocation ).getOrThrow ());
84- recipeData .put ("powerPackType" , ResourceLocation .CODEC .encodeStart (NbtOps .INSTANCE , powerPackTypeLocation ).getOrThrow ());
85- recipeData .putInt ("size" , throatArea );
86- recipeData .putInt ("expansionRatio" , expansionRatio );
87- recipeData .putInt ("materialLevel" , materialLevel );
88- nbt .put ("blockEntity" , engineInfo );
89- nbt .put ("engineRecipeData" , recipeData );
90- }
9187 defaultInstance .set (DataComponents .CUSTOM_DATA ,CustomData .of (nbt ));
9288 return defaultInstance ;
9389 }
0 commit comments