Skip to content

Commit 4db6f7e

Browse files
fixed engineer table
1 parent 9dbe407 commit 4db6f7e

4 files changed

Lines changed: 21 additions & 24 deletions

File tree

src/generated/resources/data/creatingspace/recipe/engine_recipe/exhaust_pack/aerospike.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
]
6464
}
6565
],
66-
"transitionalItem": {
66+
"transitional_item": {
6767
"id": "creatingspace:incomplete_exhaust_pack"
6868
}
6969
}

src/generated/resources/data/creatingspace/recipe/engine_recipe/exhaust_pack/bell_nozzle.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
]
6464
}
6565
],
66-
"transitionalItem": {
66+
"transitional_item": {
6767
"id": "creatingspace:incomplete_exhaust_pack"
6868
}
6969
}

src/main/java/com/rae/creatingspace/content/rocket/engine/table/EngineFabricationBlueprint.java

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.rae.creatingspace.content.rocket.engine.design.PropellantType;
66
import com.rae.creatingspace.init.MiscInit;
77
import com.rae.creatingspace.init.ingameobject.PropellantTypeInit;
8-
import net.minecraft.core.HolderLookup;
98
import net.minecraft.core.component.DataComponents;
109
import net.minecraft.nbt.CompoundTag;
1110
import net.minecraft.nbt.NbtOps;
@@ -15,8 +14,7 @@
1514
import net.minecraft.world.item.ItemStack;
1615
import net.minecraft.world.item.TooltipFlag;
1716
import 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

2119
import 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
}

src/main/java/com/rae/creatingspace/content/rocket/engine/table/EngineerTableScreen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ private void craftEngine(BlockPos blockEntityPos, ResourceLocation propellantTyp
309309
float efficiency = isp / Objects.requireNonNull(getSyncedPropellantRegistry().get(propellantType)).getMaxISP();
310310
ItemStack engineBlueprint = ((EngineFabricationBlueprint) ItemInit.ENGINE_BLUEPRINT.get().asItem())
311311
.getBlueprintForEngine(engineSizeInput.getState(), expansionRatioSlider.getValueInt(), materialLevel, (int) thrust, efficiency, propellantType, exhaustType, powerPackType);
312+
System.out.println(engineBlueprint.getComponents());
312313
CatnipServices.NETWORK
313314
.sendToServer(
314315
EngineerTableCraft

0 commit comments

Comments
 (0)