Skip to content

Commit

Permalink
Release 2.1.0 for Minecraft 1.20.1
Browse files Browse the repository at this point in the history
Co-Authored-By: Edrax Doodles <[email protected]>
  • Loading branch information
Jeryn99 and EdusgprNetwork committed Dec 26, 2024
1 parent ba009a1 commit 1a1dfa6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public class ManipulatorCraftingIngredient {
public static final Codec<ManipulatorCraftingIngredient> CODEC = RecordCodecBuilder.create(
builder -> builder.group(
BlockPos.CODEC.fieldOf("relative_pos").forGetter(recipe -> recipe.relativeBlockPos),
BlockState.CODEC.fieldOf("block_state").forGetter(recipe -> recipe.blockState),
TagKey.codec(Registries.BLOCK).optionalFieldOf("block_tag").forGetter(recipe -> recipe.blockTagKey)
BlockState.CODEC.fieldOf("block_state").forGetter(recipe -> recipe.blockState)
)
.apply(builder, ManipulatorCraftingIngredient::new)
);
Expand All @@ -32,17 +31,12 @@ public class ManipulatorCraftingIngredient {
private Optional<TagKey<Block>> blockTagKey;

public ManipulatorCraftingIngredient(BlockPos pos, Block block) {
this(pos, block.defaultBlockState(), Optional.empty());
this(pos, block.defaultBlockState());
}

public ManipulatorCraftingIngredient(BlockPos pos, BlockState blockState) {
this(pos, blockState, Optional.empty());
}

public ManipulatorCraftingIngredient(BlockPos pos, BlockState blockState, Optional<TagKey<Block>> blockTagKey) {
this.relativeBlockPos = pos;
this.blockState = blockState;
this.blockTagKey = blockTagKey;
}

/**
Expand All @@ -52,8 +46,7 @@ public ManipulatorCraftingIngredient(BlockPos pos, BlockState blockState, Option
* @return If the items are equivalent.
**/
public boolean IsSameAs(ManipulatorCraftingIngredient compared) {
if (!compared.blockState.is(this.blockState.getBlock()) ||
blockTagKey.isPresent() && compared.blockState.is(blockTagKey.get())) {
if (!compared.blockState.is(this.blockState.getBlock())) {
return false;
}
return this.relativeBlockPos.getX() == compared.relativeBlockPos.getX() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.piston.PistonBaseBlock;
import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DirectionalBlock;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.registry.TRBlockRegistry;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
* Default recipes added by Tardis Refined. Used for data generators
Expand All @@ -42,13 +37,13 @@ public static void registerRecipes() {
new ManipulatorCraftingIngredient(new BlockPos(2, 0, 1), TRBlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()),
new ManipulatorCraftingIngredient(new BlockPos(2, 0, 2), Blocks.SMOOTH_STONE_SLAB.defaultBlockState().setValue(SlabBlock.TYPE, SlabType.TOP)),
new ManipulatorCraftingIngredient(new BlockPos(0, 1, 0), Blocks.IRON_TRAPDOOR),
new ManipulatorCraftingIngredient(new BlockPos(0, 1, 1), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR), Optional.of(BlockTags.BUTTONS)),
new ManipulatorCraftingIngredient(new BlockPos(0, 1, 1), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR)),
new ManipulatorCraftingIngredient(new BlockPos(0, 1, 2), Blocks.IRON_TRAPDOOR),
new ManipulatorCraftingIngredient(new BlockPos(1, 1, 0), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR), Optional.of(BlockTags.BUTTONS)),
new ManipulatorCraftingIngredient(new BlockPos(1, 1, 0), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR)),
new ManipulatorCraftingIngredient(new BlockPos(1, 1, 1), Blocks.GLASS),
new ManipulatorCraftingIngredient(new BlockPos(1, 1, 2), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR), Optional.of(BlockTags.BUTTONS)),
new ManipulatorCraftingIngredient(new BlockPos(1, 1, 2), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR)),
new ManipulatorCraftingIngredient(new BlockPos(2, 1, 0), Blocks.IRON_TRAPDOOR),
new ManipulatorCraftingIngredient(new BlockPos(2, 1, 1), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR), Optional.of(BlockTags.BUTTONS)),
new ManipulatorCraftingIngredient(new BlockPos(2, 1, 1), Blocks.STONE_BUTTON.defaultBlockState().setValue(ButtonBlock.FACE, AttachFace.FLOOR)),
new ManipulatorCraftingIngredient(new BlockPos(2, 1, 2), Blocks.IRON_TRAPDOOR)

), TRBlockRegistry.GLOBAL_CONSOLE_BLOCK.get().defaultBlockState()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package whocraft.tardis_refined.common.items;

import com.google.gson.JsonObject;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
Expand All @@ -16,19 +14,12 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.client.model.pallidium.BedrockModelUtil;
import whocraft.tardis_refined.common.blockentity.device.AstralManipulatorBlockEntity;
import whocraft.tardis_refined.common.util.PlayerUtil;
import whocraft.tardis_refined.constants.ModMessages;
import whocraft.tardis_refined.registry.TRBlockRegistry;
import whocraft.tardis_refined.registry.TRSoundRegistry;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -59,48 +50,10 @@ public int getColor(ItemStack itemStack) {
@Override
public InteractionResult useOn(UseOnContext context) {

Minecraft.getInstance().getEntityModels().roots.forEach((location, definition) -> {
TardisRefined.LOGGER.info("EXPORT: " + location);
JsonObject model = BedrockModelUtil.toJsonModel(definition, location.getModel().getPath());

// Define the absolute export folder path
Path exportFolder = Paths.get("export_models", location.getLayer());

// Ensure the parent folder exists, including any missing directories
try {
Files.createDirectories(exportFolder.getParent()); // Create parent directories if they don't exist
} catch (IOException e) {
TardisRefined.LOGGER.error("Failed to create directories for: " + exportFolder.getParent(), e);
return; // Return early if we can't create the directory
}

// Define the file path for the model
Path modelFile = exportFolder.resolve(location.getModel().getPath().replaceAll("_ext", "").replaceAll("int", "door") + ".json");

// Ensure the model file's parent directory exists
try {
Files.createDirectories(modelFile.getParent()); // Create parent directories for model file
} catch (IOException e) {
TardisRefined.LOGGER.error("Failed to create parent directories for file: " + modelFile, e);
return; // Return early if we can't create the parent directories
}

// Write the model to the file
try (BufferedWriter writer = Files.newBufferedWriter(modelFile)) {
writer.write(model.toString());
} catch (IOException e) {
TardisRefined.LOGGER.error("Failed to write model to file: " + modelFile, e);
throw new RuntimeException("Failed to write model to file", e);
}
});

if (!(context.getLevel() instanceof ServerLevel serverLevel)) {
return super.useOn(context);
}




var player = context.getPlayer();
var itemInHand = context.getItemInHand();
var clickedPos = context.getClickedPos();
Expand Down

0 comments on commit 1a1dfa6

Please sign in to comment.