Skip to content

Commit

Permalink
make space suit only able to store oxygen, fix space suit upgrade rec…
Browse files Browse the repository at this point in the history
…ipes
  • Loading branch information
screret committed Apr 1, 2024
1 parent 15272b9 commit 819b9ea
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 59 deletions.
6 changes: 4 additions & 2 deletions src/generated/resources/assets/gcyr/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"item.gcyr.laser_satellite": "ǝʇıןןǝʇɐS ɹǝsɐꞀ",
"item.gcyr.ore_finder_satellite": "ǝʇıןןǝʇɐS ɹǝpuıℲ ǝɹO",
"item.gcyr.photovoltaic_cell": "ןןǝƆ ɔıɐʇןoʌoʇoɥԀ",
"item.gcyr.smithing_template.space_upgrade.additions_slot_description": "ɔıɹqɐℲ ǝɔɐdS ppⱯ",
"item.gcyr.smithing_template.space_upgrade.additions_slot_description": "ʇɹɐԀ ʇınS ǝɔɐdS ppⱯ",
"item.gcyr.smithing_template.space_upgrade.ingredients": "ɔıɹqɐℲ ǝɔɐdS",
"item.gcyr.space_boots": "sʇooᗺ ǝɔɐdS",
"item.gcyr.space_chestplate": "ǝʇɐןdʇsǝɥƆ ǝɔɐdS",
Expand Down Expand Up @@ -141,5 +141,7 @@
"tagprefix.moon": "ǝɹO %s uooW",
"tagprefix.venus": "ǝɹO %s snuǝΛ",
"tooltip.gcyr.spacesuit": "˙ʇıns ǝɔɐds ɐ sɐ sʞɹoM",
"trim_material.gcyr.space": "ʇınS ǝɔɐdS"
"tooltip.gcyr.spacesuit.stored": "ᗺɯ %s / %s :uǝbʎxO pǝɹoʇS",
"trim_material.gcyr.space": "ʇınS ǝɔɐdS",
"trim_pattern.gcyr.space": "ǝpɐɹbd∩ ʇınS ǝɔɐdS"
}
6 changes: 4 additions & 2 deletions src/generated/resources/assets/gcyr/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"item.gcyr.laser_satellite": "Laser Satellite",
"item.gcyr.ore_finder_satellite": "Ore Finder Satellite",
"item.gcyr.photovoltaic_cell": "Photovoltaic Cell",
"item.gcyr.smithing_template.space_upgrade.additions_slot_description": "Add Space Fabric",
"item.gcyr.smithing_template.space_upgrade.additions_slot_description": "Add Space Suit Part",
"item.gcyr.smithing_template.space_upgrade.ingredients": "Space Fabric",
"item.gcyr.space_boots": "Space Boots",
"item.gcyr.space_chestplate": "Space Chestplate",
Expand Down Expand Up @@ -141,5 +141,7 @@
"tagprefix.moon": "Moon %s Ore",
"tagprefix.venus": "Venus %s Ore",
"tooltip.gcyr.spacesuit": "Works as a space suit.",
"trim_material.gcyr.space": "Space Suit"
"tooltip.gcyr.spacesuit.stored": "Stored Oxygen: %s / %s mB",
"trim_material.gcyr.space": "Space Suit",
"trim_pattern.gcyr.space": "Space Suit Upgrade"
}
3 changes: 1 addition & 2 deletions src/main/java/argent_matter/gcyr/common/data/GCyRItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,14 @@ public class GCyRItems {
.defaultModel()
.register();

// SmithingTemplateItem.createArmorTrimTemplate(GCyRTrimPatterns.SPACE)
public static final ItemEntry<SmithingTemplateItem> SPACE_UPGRADE_SMITHING_TEMPLATE = REGISTRATE.item("space_upgrade_smithing_template", properties ->
new SmithingTemplateItem(SmithingTemplateItem.ARMOR_TRIM_APPLIES_TO,
Component.translatable(Util.makeDescriptionId("item", GCyR.id("smithing_template.space_upgrade.ingredients"))),
Component.translatable(Util.makeDescriptionId("trim_pattern", GCyRTrimPatterns.SPACE.location())).withStyle(ChatFormatting.GRAY),
SmithingTemplateItem.ARMOR_TRIM_BASE_SLOT_DESCRIPTION,
Component.translatable(Util.makeDescriptionId("item", GCyR.id("smithing_template.space_upgrade.additions_slot_description"))),
SmithingTemplateItem.createTrimmableArmorIconList(),
List.of(GCyR.id("item/empty_slot_space_fabric"))))
SmithingTemplateItem.createTrimmableArmorIconList()))
.register();

// endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package argent_matter.gcyr.common.item.armor;

import argent_matter.gcyr.common.recipe.type.SmithingSpaceSuitRecipe;
import argent_matter.gcyr.data.recipe.GCyRTags;
import com.lowdragmc.lowdraglib.misc.ItemStackTransfer;
import com.lowdragmc.lowdraglib.side.fluid.FluidHelper;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;
Expand All @@ -9,7 +10,6 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
Expand All @@ -27,7 +27,12 @@ public SpaceSuitArmorItem(ArmorItem.Type type, Properties properties) {

public static <T> LazyOptional<T> getCapability(@Nonnull final ItemStack itemStack, @Nonnull final Capability<T> cap) {
if (cap == ForgeCapabilities.FLUID_HANDLER_ITEM) {
return ForgeCapabilities.FLUID_HANDLER_ITEM.orEmpty(cap, LazyOptional.of(() -> new FluidHandlerItemStack(itemStack, Math.toIntExact(SpaceSuitArmorItem.CAPACITY))));
return ForgeCapabilities.FLUID_HANDLER_ITEM.orEmpty(cap, LazyOptional.of(() -> new FluidHandlerItemStack(itemStack, Math.toIntExact(SpaceSuitArmorItem.CAPACITY)) {
@Override
public boolean canFillFluidType(net.minecraftforge.fluids.FluidStack fluid) {
return fluid.getFluid().defaultFluidState().is(GCyRTags.OXYGEN);
}
}));
}
return LazyOptional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package argent_matter.gcyr.common.recipe.type;

import argent_matter.gcyr.common.data.GCyRRecipeTypes;
import argent_matter.gcyr.common.data.GCyRVanillaRecipeTypes;
import argent_matter.gcyr.common.item.armor.trim.GCyRTrimMaterials;
import argent_matter.gcyr.common.item.armor.trim.GCyRTrimPatterns;
import com.google.gson.JsonObject;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.armortrim.*;
import net.minecraft.world.item.armortrim.ArmorTrim;
import net.minecraft.world.item.armortrim.TrimMaterial;
import net.minecraft.world.item.armortrim.TrimPattern;
import net.minecraft.world.item.armortrim.TrimPatterns;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SmithingRecipe;
Expand Down Expand Up @@ -77,12 +76,12 @@ public static void setTrim(RegistryAccess registryAccess, ItemStack armor, Armor
@Override
public ItemStack getResultItem(RegistryAccess registryAccess) {
ItemStack itemstack = new ItemStack(Items.DIAMOND_CHESTPLATE);
Optional<Holder.Reference<TrimPattern>> optional = registryAccess.registryOrThrow(Registries.TRIM_PATTERN).holders().findFirst();
if (optional.isPresent()) {
Optional<Holder.Reference<TrimMaterial>> optional1 = registryAccess.registryOrThrow(Registries.TRIM_MATERIAL).getHolder(TrimMaterials.REDSTONE);
if (optional1.isPresent()) {
ArmorTrim armortrim = new ArmorTrim(optional1.get(), optional.get());
ArmorTrim.setTrim(registryAccess, itemstack, armortrim);
Optional<Holder.Reference<TrimPattern>> pattern = registryAccess.registryOrThrow(Registries.TRIM_PATTERN).getHolder(GCyRTrimPatterns.SPACE);
if (pattern.isPresent()) {
Optional<Holder.Reference<TrimMaterial>> material = registryAccess.registryOrThrow(Registries.TRIM_MATERIAL).getHolder(GCyRTrimMaterials.SPACE);
if (material.isPresent()) {
ArmorTrim armortrim = new ArmorTrim(material.get(), pattern.get());
setTrim(registryAccess, itemstack, armortrim);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/argent_matter/gcyr/data/lang/LangHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public static void init(RegistrateLangProvider provider) {
provider.add("metaitem.planet_id_circuit.id", "Currently selected planet: ");
provider.add("metaitem.planet_id_circuit.station", "To in-orbit space station (ID: %s)");
provider.add("item.gcyr.smithing_template.space_upgrade.ingredients", "Space Fabric");
provider.add("item.gcyr.smithing_template.space_upgrade.additions_slot_description", "Add Space Fabric");
provider.add("item.gcyr.smithing_template.space_upgrade.additions_slot_description", "Add Space Suit Part");
provider.add("trim_material.gcyr.space", "Space Suit");
provider.add("trim_pattern.gcyr.space", "Space Suit Upgrade");
provider.add("tooltip.gcyr.spacesuit", "Works as a space suit.");
provider.add("tooltip.gcyr.spacesuit.stored", "Stored Oxygen: %s / %s mB");

// machines
provider.add("gcyr.machine.satellite_jammer.jammed", "Jammed %s");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/argent_matter/gcyr/data/recipe/GCyRTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class GCyRTags {

// Fluid
public static final TagKey<Fluid> VEHICLE_FUELS = GCyRTagUtil.createModFluidTag("vehicle_fuels");
public static final TagKey<Fluid> OXYGEN = TagUtil.createFluidTag("oxygen");

// Biome
public static final TagKey<Biome> IS_SPACE = GCyRTagUtil.createModTag(Registries.BIOME, "is_space");
Expand Down
50 changes: 26 additions & 24 deletions src/main/java/argent_matter/gcyr/data/recipe/MiscRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static void init(Consumer<FinishedRecipe> provider) {
GTRecipeTypes.ASSEMBLER_RECIPES.recipeBuilder(GCyR.id("space_fabric"))
.inputItems(foil, Polytetrafluoroethylene, 4)
.inputItems(foil, ParaAramid, 4)
.inputItems(foil, Polybenzimidazole, 4)
.inputItems(dust, FiberGlass, 4)
.outputItems(GCyRItems.SPACE_FABRIC.asStack(1))
.duration(100).EUt(VA[HV]).save(provider);
Expand All @@ -72,22 +73,44 @@ public static void init(Consumer<FinishedRecipe> provider) {
"SFS", "FFF", "SCS",
'S', GCyRItems.SPACE_FABRIC.asStack(), 'F', new UnificationEntry(foil, Gold), 'C', CustomTags.EV_CIRCUITS
);

VanillaRecipeHelper.addShapedRecipe(provider, GCyR.id("space_chest"), GCyRItems.SPACE_SUIT_CHEST.asStack(),
"STS", "SCS", "SCS",
'S', GCyRItems.SPACE_FABRIC.asStack(), 'T', GTItems.FLUID_CELL_LARGE_TUNGSTEN_STEEL.asStack(), 'C', CustomTags.EV_CIRCUITS
);

VanillaRecipeHelper.addShapedRecipe(provider, GCyR.id("space_legs"), GCyRItems.SPACE_SUIT_LEGS.asStack(),
"SCS", "S S", "S S",
'S', GCyRItems.SPACE_FABRIC.asStack(), 'C', CustomTags.EV_CIRCUITS
);

VanillaRecipeHelper.addShapedRecipe(provider, GCyR.id("space_boots"), GCyRItems.SPACE_SUIT_BOOTS.asStack(),
"S S", "S S",
'S', GCyRItems.SPACE_FABRIC.asStack()
);

GTRecipeTypes.ASSEMBLER_RECIPES.recipeBuilder(GCyR.id("space_upgrade_smithing_template"))
.inputItems(GCyRItems.SPACE_FABRIC.asStack(5))
.inputItems(plate, Titanium, 2)
.inputItems(foil, Polybenzimidazole, 4)
.outputItems(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.asStack(1))
.EUt(VA[IV]).duration(50)
.save(provider);

SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_BOOTS),
Ingredient.of(GCyRItems.SPACE_SUIT_BOOTS.get()))
.save(provider, GCyR.id("space_suit_boots_smithing_trim"));
SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_LEGGINGS),
Ingredient.of(GCyRItems.SPACE_SUIT_LEGS.get()))
.save(provider, GCyR.id("space_suit_leggings_smithing_trim"));
SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_CHESTPLATES),
Ingredient.of(GCyRItems.SPACE_SUIT_CHEST.get()))
.save(provider, GCyR.id("space_suit_chestplate_smithing_trim"));
SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_HELMETS),
Ingredient.of(GCyRItems.SPACE_SUIT_HELMET.get()))
.save(provider, GCyR.id("space_suit_helmet_smithing_trim"));

//endregion

//region machines
Expand Down Expand Up @@ -135,27 +158,6 @@ public static void init(Consumer<FinishedRecipe> provider) {
.save(provider);

//endregion

SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_BOOTS),
Ingredient.of(GCyRItems.SPACE_SUIT_BOOTS.get()),
RecipeCategory.MISC)
.save(provider, GCyR.id("space_suit_boots_smithing_trim"));
SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_LEGGINGS),
Ingredient.of(GCyRItems.SPACE_SUIT_LEGS.get()),
RecipeCategory.MISC)
.save(provider, GCyR.id("space_suit_leggings_smithing_trim"));
SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_CHESTPLATES),
Ingredient.of(GCyRItems.SPACE_SUIT_CHEST.get()),
RecipeCategory.MISC)
.save(provider, GCyR.id("space_suit_chestplate_smithing_trim"));
SmithingSpaceSuitRecipeBuilder.smithingSpacesuit(Ingredient.of(GCyRItems.SPACE_UPGRADE_SMITHING_TEMPLATE.get()),
Ingredient.of(Tags.Items.ARMORS_HELMETS),
Ingredient.of(GCyRItems.SPACE_SUIT_HELMET.get()),
RecipeCategory.MISC)
.save(provider, GCyR.id("space_suit_helmet_smithing_trim"));
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package argent_matter.gcyr.data.recipe.builder;


import argent_matter.gcyr.common.data.GCyRVanillaRecipeTypes;
import com.google.gson.JsonObject;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
Expand All @@ -12,22 +12,20 @@
import java.util.function.Consumer;

public class SmithingSpaceSuitRecipeBuilder {
private final RecipeCategory category;
private final Ingredient template;
private final Ingredient base;
private final Ingredient addition;
private final RecipeSerializer<?> type;

public SmithingSpaceSuitRecipeBuilder(RecipeSerializer<?> type, RecipeCategory category, Ingredient template, Ingredient base, Ingredient addition) {
this.category = category;
public SmithingSpaceSuitRecipeBuilder(RecipeSerializer<?> type,Ingredient template, Ingredient base, Ingredient addition) {
this.type = type;
this.template = template;
this.base = base;
this.addition = addition;
}

public static SmithingSpaceSuitRecipeBuilder smithingSpacesuit(Ingredient template, Ingredient base, Ingredient addition, RecipeCategory category) {
return new SmithingSpaceSuitRecipeBuilder(RecipeSerializer.SMITHING_TRIM, category, template, base, addition);
public static SmithingSpaceSuitRecipeBuilder smithingSpacesuit(Ingredient template, Ingredient base, Ingredient addition) {
return new SmithingSpaceSuitRecipeBuilder(GCyRVanillaRecipeTypes.SMITHING_SPACESUIT_SERIALIZER.get(), template, base, addition);
}

public void save(Consumer<FinishedRecipe> recipeConsumer, ResourceLocation location) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@
import argent_matter.gcyr.common.networking.s2c.PacketSyncDysonSphereStatus;
import argent_matter.gcyr.common.recipe.type.SmithingSpaceSuitRecipe;
import argent_matter.gcyr.data.loader.PlanetData;
import com.lowdragmc.lowdraglib.misc.ItemStackTransfer;
import com.lowdragmc.lowdraglib.side.fluid.FluidTransferHelper;
import com.lowdragmc.lowdraglib.side.fluid.IFluidTransfer;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.AttachCapabilitiesEvent;
Expand All @@ -29,8 +27,6 @@
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
import net.minecraftforge.fml.common.Mod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -107,7 +103,11 @@ public static void levelTick(TickEvent.LevelTickEvent event) {
@SubscribeEvent
public static void onAddTooltips(ItemTooltipEvent event) {
if (event.getItemStack().hasTag() && event.getItemStack().getTag().getBoolean(SmithingSpaceSuitRecipe.SPACE_SUIT_ARMOR_KEY)) {
event.getToolTip().add(Component.translatable("tooltip.gcyr.spacesuit"));
event.getToolTip().add(1, Component.translatable("tooltip.gcyr.spacesuit"));
IFluidTransfer transfer = FluidTransferHelper.getFluidTransfer(new ItemStackTransfer(event.getItemStack()), 0);
if (transfer != null) {
event.getToolTip().add(1, Component.translatable("tooltip.gcyr.spacesuit.stored", transfer.getFluidInTank(0), transfer.getTankCapacity(0)));
}
}
}
}

0 comments on commit 819b9ea

Please sign in to comment.