Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ run-data

repo
/src/generated/resources/.cache/
/CS_1.21.1_src.zip
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
"entries": [
{
"type": "minecraft:item",
"name": "creatingspace:copper_oxygen_backtank_placeable"
"functions": [
{
"function": "minecraft:copy_components",
"include": [
"minecraft:enchantments",
"minecraft:custom_name",
"creatingspace:oxygen"
],
"source": "block_entity"
}
],
"name": "creatingspace:copper_oxygen_backtank"
}
],
"rolls": 1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"type": "minecraft:block",
"functions": [
{
"function": "minecraft:copy_components",
"include": [
"minecraft:custom_name",
"creatingspace:simple_fluid_content"
],
"source": "block_entity"
}
],
"pools": [
{
"bonus_rolls": 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
"entries": [
{
"type": "minecraft:item",
"name": "creatingspace:netherite_oxygen_backtank_placeable"
"functions": [
{
"function": "minecraft:copy_components",
"include": [
"minecraft:enchantments",
"minecraft:custom_name",
"creatingspace:oxygen"
],
"source": "block_entity"
}
],
"name": "creatingspace:netherite_oxygen_backtank"
}
],
"rolls": 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
],
"result": {
"count": 1,
"id": "creatingspace:copper_oxygen_backtank_placeable"
"id": "creatingspace:copper_oxygen_backtank"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
],
"result": {
"count": 1,
"id": "creatingspace:netherite_oxygen_backtank_placeable"
"id": "creatingspace:netherite_oxygen_backtank"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rae.creatingspace.content.fluids.storage;

import com.rae.creatingspace.init.DataComponentsInit;
import com.rae.creatingspace.init.ingameobject.BlockEntityInit;
import com.rae.creatingspace.init.ingameobject.BlockInit;

Expand All @@ -12,15 +13,19 @@
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Nameable;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.SimpleFluidContent;
import net.neoforged.neoforge.fluids.capability.templates.FluidTank;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -56,6 +61,7 @@ public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
@Override
protected void onContentsChanged() {
super.onContentsChanged();
setChanged();
notifyUpdate();
}

Expand Down Expand Up @@ -155,4 +161,31 @@ public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneak
.forGoggles(tooltip, 1);
return IHaveGoggleInformation.super.addToGoggleTooltip(tooltip, isPlayerSneaking);
}
@Override
protected void collectImplicitComponents(DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);

// Convert the FluidTank's current stack into the Component format
FluidStack currentFluid = TANK.getFluid();
if (!currentFluid.isEmpty()) {
builder.set(DataComponentsInit.SIMPLE_FLUID_CONTENT, SimpleFluidContent.copyOf(currentFluid));
}

if (this.getCustomName() != null) {
builder.set(DataComponents.CUSTOM_NAME, this.getCustomName());
}
}

@Override
protected void applyImplicitComponents(BlockEntity.DataComponentInput input) {
super.applyImplicitComponents(input);

// Retrieve the fluid from the item component and put it back into the tank
SimpleFluidContent content = input.get(DataComponentsInit.SIMPLE_FLUID_CONTENT);
if (content != null) {
TANK.setFluid(content.copy()); // .copy() returns a FluidStack
}

this.setCustomName(input.get(DataComponents.CUSTOM_NAME));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rae.creatingspace.content.life_support.spacesuit;

import com.rae.creatingspace.init.DataComponentsInit;
import com.rae.creatingspace.init.TagsInit;
import com.rae.creatingspace.init.ingameobject.BlockEntityInit;
import com.rae.creatingspace.init.ingameobject.FluidInit;
Expand All @@ -13,13 +14,16 @@
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Nameable;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -191,4 +195,33 @@ public void setCapacityEnchantLevel(int capacityEnchantLevel) {
this.OXYGEN_TANK.setCapacity(OxygenBacktankUtil.maxOxygen(capacityEnchantLevel));
}

@Override
protected void collectImplicitComponents(DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);

// This pushes your current values into the Component system
// so the loot table can "see" and copy them.
builder.set(DataComponentsInit.OXYGEN_LEVEL, this.oxygenLevel);

// If you have a custom component for capacity, add it here too
// builder.set(DataComponentsInit.CAPACITY_LEVEL.get(), this.capacityEnchantLevel);

if (this.customName != null) {
builder.set(DataComponents.CUSTOM_NAME, this.customName);
}
}

@Override
protected void applyImplicitComponents(BlockEntity.DataComponentInput input) {
super.applyImplicitComponents(input);

// This pulls data from the item stack when you PLACE the block
this.oxygenLevel = input.getOrDefault(DataComponentsInit.OXYGEN_LEVEL, 0);

// Sync the internal FluidTank to match the component data
this.OXYGEN_TANK.setFluid(new FluidStack(FluidInit.LIQUID_OXYGEN.get(), this.oxygenLevel));

this.customName = input.get(DataComponents.CUSTOM_NAME);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.rae.creatingspace.content.rocket.engine.table.RocketEngineerTableBlock;
import com.rae.creatingspace.content.rocket.flight_recorder.FlightRecorderBlock;
import com.rae.creatingspace.init.CreativeModeTabsInit;
import com.rae.creatingspace.init.DataComponentsInit;
import com.rae.creatingspace.init.graphics.SpriteShiftInit;
import com.rae.creatingspace.content.life_support.spacesuit.OxygenBacktankBlock;
import com.rae.creatingspace.legacy.server.blocks.multiblock.BigRocketStructuralBlock;
Expand Down Expand Up @@ -45,6 +46,7 @@
import com.tterrag.registrate.util.entry.BlockEntry;
import com.tterrag.registrate.util.nullness.NonNullFunction;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
Expand All @@ -60,8 +62,13 @@
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount;
import net.minecraft.world.level.storage.loot.functions.CopyComponentsFunction;
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.neoforged.neoforge.common.Tags;

import java.util.Map;
Expand Down Expand Up @@ -366,17 +373,20 @@ public class BlockInit {
.initialProperties(SharedProperties::copperMetal)
.blockstate((c,p)-> p.horizontalBlock(c.getEntry(),p.models().getExistingFile(resource("block/oxygen_backtank/copper"))))
.properties(BlockBehaviour.Properties::dynamicShape)
.loot((lt, block) -> lt.add(block, LootTable.lootTable() // Use a fresh loot table builder
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(ItemInit.COPPER_OXYGEN_BACKTANK.get()) // Explicitly drop the wearable item
.apply(CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY)
.include(DataComponents.ENCHANTMENTS)
.include(DataComponents.CUSTOM_NAME)
.include(DataComponentsInit.OXYGEN_LEVEL)
)
)
.when(ExplosionCondition.survivesExplosion())
)
))
.tag(AllTags.AllBlockTags.WRENCH_PICKUP.tag)
.recipe((c,p) ->
MechanicalCraftingRecipeBuilder.shapedRecipe(c.get(), 1)
.key('F', ItemInit.BASIC_SPACESUIT_FABRIC.get())
.key('N', commonItemTag("plates/nickel"))
.key('W', Items.RED_WOOL)
.key('T', AllBlocks.FLUID_TANK.get())
.patternLine(" F F ")
.patternLine("WTNTW")
.patternLine(" FWF ")
.build(p, resource("mechanical_crafting/armor/" + c.getName())))
.transform(pickaxeOnly())
.register();

Expand All @@ -385,17 +395,20 @@ public class BlockInit {
.initialProperties(SharedProperties::netheriteMetal)
.blockstate((c,p)-> p.horizontalBlock(c.getEntry(),p.models().getExistingFile(resource("block/oxygen_backtank/netherite"))))
.properties(BlockBehaviour.Properties::dynamicShape)
.loot((lt, block) -> lt.add(block, LootTable.lootTable() // Use a fresh loot table builder
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(ItemInit.NETHERITE_OXYGEN_BACKTANK.get()) // Explicitly drop the wearable item
.apply(CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY)
.include(DataComponents.ENCHANTMENTS)
.include(DataComponents.CUSTOM_NAME)
.include(DataComponentsInit.OXYGEN_LEVEL)
)
)
.when(ExplosionCondition.survivesExplosion())
)
))
.tag(AllTags.AllBlockTags.WRENCH_PICKUP.tag)
.recipe((c,p) ->
MechanicalCraftingRecipeBuilder.shapedRecipe(c.get(), 1)
.key('F', ItemInit.ADVANCED_SPACESUIT_FABRIC.get())
.key('N', commonItemTag("plates/aluminum"))
.key('W', Items.WHITE_WOOL)
.key('T', AllBlocks.FLUID_TANK.get())
.patternLine(" F F ")
.patternLine("WTNTW")
.patternLine(" FWF ")
.build(p, resource("mechanical_crafting/armor/" + c.getName())))
.transform(pickaxeOnly())
.register();

Expand All @@ -404,6 +417,10 @@ public class BlockInit {
.initialProperties(SharedProperties::copperMetal)
.blockstate((c,p)-> p.simpleBlock(c.getEntry(), p.models().getExistingFile(resource("block/cryogenic_tank"))))
.transform(pickaxeOnly())
.loot((lt, block) -> lt.add(block, lt.createSingleItemTable(block)
.apply(CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY)
.include(DataComponents.CUSTOM_NAME)
.include(DataComponentsInit.SIMPLE_FLUID_CONTENT))))
.tag(AllTags.AllBlockTags.WRENCH_PICKUP.tag)
.recipe((c,p) ->
ShapedRecipeBuilder.shaped(RecipeCategory.MISC, c.get(), 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllTags;
import com.simibubi.create.api.data.recipe.MechanicalCraftingRecipeBuilder;
import com.simibubi.create.content.equipment.armor.AllArmorMaterials;
import com.simibubi.create.content.equipment.armor.BaseArmorItem;
import com.simibubi.create.content.processing.sequenced.SequencedAssemblyItem;
Expand Down Expand Up @@ -505,6 +506,16 @@ private static ItemEntry<SequencedAssemblyItem> registerSequencedEngineItem(Stri
COPPER_BACKTANK_PLACEABLE))
.model((c,p) -> p.withExistingParent("copper_oxygen_backtank",
MODID + ":block/oxygen_backtank/copper"))
.recipe((c,p) ->
MechanicalCraftingRecipeBuilder.shapedRecipe(c.get(), 1)
.key('F', ItemInit.BASIC_SPACESUIT_FABRIC.get())
.key('N', commonItemTag("plates/nickel"))
.key('W', Items.RED_WOOL)
.key('T', AllBlocks.FLUID_TANK.get())
.patternLine(" F F ")
.patternLine("WTNTW")
.patternLine(" FWF ")
.build(p, resource("mechanical_crafting/armor/" + c.getName())))
.tag(TagsInit.CustomItemTags.OXYGEN_SOURCES.tag)
.tag(ItemTags.CHEST_ARMOR)
.tag(ItemTags.TRIMMABLE_ARMOR)
Expand Down Expand Up @@ -532,6 +543,16 @@ private static ItemEntry<SequencedAssemblyItem> registerSequencedEngineItem(Stri
.tag(ItemTags.CHEST_ARMOR)
.tag(ItemTags.TRIMMABLE_ARMOR)
.tag(TagsInit.CustomItemTags.SPACESUIT.tag)
.recipe((c,p) ->
MechanicalCraftingRecipeBuilder.shapedRecipe(c.get(), 1)
.key('F', ItemInit.ADVANCED_SPACESUIT_FABRIC.get())
.key('N', commonItemTag("plates/aluminum"))
.key('W', Items.WHITE_WOOL)
.key('T', AllBlocks.FLUID_TANK.get())
.patternLine(" F F ")
.patternLine("WTNTW")
.patternLine(" FWF ")
.build(p, resource("mechanical_crafting/armor/" + c.getName())))
.register();

public static final ItemEntry<BaseArmorItem> BASIC_SPACESUIT_LEGGINGS =
Expand Down
Loading