diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..be43be0 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,29 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} + +loom { + accessWidenerPath = file("src/main/resources/arctech.accesswidener") +} + +dependencies { + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury:${rootProject.architectury_version}" +} + +publishing { + publications { + mavenCommon(MavenPublication) { + artifactId = rootProject.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/ArcTech.java b/common/src/main/java/com/mrmelon54/ArcTech/ArcTech.java new file mode 100644 index 0000000..49bb5a6 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/ArcTech.java @@ -0,0 +1,16 @@ +package com.mrmelon54.ArcTech; + +import com.google.common.base.Suppliers; +import dev.architectury.registry.registries.RegistrarManager; + +import java.util.function.Supplier; + +public class ArcTech { + public static final String MOD_ID = "arctech"; + public static final Supplier MANAGER = Suppliers.memoize(() -> RegistrarManager.get(ArcTech.MOD_ID)); + + public static void init() { + CreativeTab.init(); + BlocksAndItems.init(); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/Blocks.java b/common/src/main/java/com/mrmelon54/ArcTech/Blocks.java new file mode 100644 index 0000000..581dae8 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/Blocks.java @@ -0,0 +1,18 @@ +package com.mrmelon54.ArcTech; + +import com.mrmelon54.ArcTech.block.CraftingStationBlock; +import com.mrmelon54.ArcTech.block.WireCopperBlock; +import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.DropExperienceBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.MapColor; + +public class Blocks { + public static final Block CRAFTING_STATION = new CraftingStationBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).strength(2.5f).ignitedByLava()); + public static final Block WIRE_COPPER = new WireCopperBlock(BlockBehaviour.Properties.of().sound(SoundType.COPPER).strength(0.5f).dynamicShape()); + public static final Block LITHIUM_ORE = new DropExperienceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.0F, 3.0F), UniformInt.of(3, 7)); + public static final Block DEEPSLATE_LITHIUM_ORE = new DropExperienceBlock(BlockBehaviour.Properties.copy(LITHIUM_ORE).mapColor(MapColor.DEEPSLATE).strength(4.5F, 3.0F).sound(SoundType.DEEPSLATE), UniformInt.of(3, 7)); +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/BlocksAndItems.java b/common/src/main/java/com/mrmelon54/ArcTech/BlocksAndItems.java new file mode 100644 index 0000000..ef02c1e --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/BlocksAndItems.java @@ -0,0 +1,29 @@ +package com.mrmelon54.ArcTech; + +import dev.architectury.registry.registries.Registrar; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +public class BlocksAndItems { + private static final Registrar blockReg = ArcTech.MANAGER.get().get(Registries.BLOCK); + private static final Registrar itemReg = ArcTech.MANAGER.get().get(Registries.ITEM); + + public static void init() { + initBlockItem("arctech:crafting_station", Blocks.CRAFTING_STATION, new Item.Properties().stacksTo(61).arch$tab(CreativeTab.ARCTECH_CREATIVE_TAB)); + initBlockItem("arctech:wire_copper", Blocks.WIRE_COPPER, new Item.Properties().arch$tab(CreativeTab.ARCTECH_CREATIVE_TAB)); + initBlockItem("arctech:lithium_ore", Blocks.LITHIUM_ORE, new Item.Properties().arch$tab(CreativeTab.ARCTECH_CREATIVE_TAB)); + initBlockItem("arctech:deepslate_lithium_ore", Blocks.DEEPSLATE_LITHIUM_ORE, new Item.Properties().arch$tab(CreativeTab.ARCTECH_CREATIVE_TAB)); + } + + private static ResourceLocation id(String a) { + return new ResourceLocation(a); + } + + private static void initBlockItem(String loc, Block block, Item.Properties properties) { + blockReg.register(id(loc), () -> block); + itemReg.register(id(loc), () -> new BlockItem(block, properties)); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/CreativeTab.java b/common/src/main/java/com/mrmelon54/ArcTech/CreativeTab.java new file mode 100644 index 0000000..6b93316 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/CreativeTab.java @@ -0,0 +1,16 @@ +package com.mrmelon54.ArcTech; + +import dev.architectury.registry.CreativeTabRegistry; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; + +public class CreativeTab { + public static final CreativeModeTab ARCTECH_CREATIVE_TAB = CreativeTabRegistry.create(Component.translatable("creative-tab.arctech.title"), () -> new ItemStack(Blocks.CRAFTING_STATION)); + + public static void init() { + ArcTech.MANAGER.get().get(Registries.CREATIVE_MODE_TAB).register(new ResourceLocation("creative-tab.arctech"), () -> CreativeTab.ARCTECH_CREATIVE_TAB); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/block/CraftingStationBlock.java b/common/src/main/java/com/mrmelon54/ArcTech/block/CraftingStationBlock.java new file mode 100644 index 0000000..370d3f6 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/block/CraftingStationBlock.java @@ -0,0 +1,79 @@ +package com.mrmelon54.ArcTech.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class CraftingStationBlock extends Block implements SimpleWaterloggedBlock { + public static VoxelShape SHAPE = Shapes.or( + Block.box(0, 13, 0, 16, 15, 16), + Block.box(0, 13, 0, 16, 16, 2), + Block.box(0, 13, 0, 2, 16, 16), + Block.box(14, 13, 0, 16, 16, 16), + Block.box(0, 13, 14, 16, 16, 16), + Block.box(0, 0, 0, 3, 15, 3), + Block.box(13, 0, 13, 16, 15, 16), + Block.box(0, 0, 13, 3, 15, 16), + Block.box(13, 0, 0, 16, 15, 3) + ); + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public CraftingStationBlock(Properties properties) { + super(properties); + registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false)); + } + + public BlockState updateShape(BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2) { + if (blockState.getValue(WATERLOGGED)) { + levelAccessor.scheduleTick(blockPos, Fluids.WATER, Fluids.WATER.getTickDelay(levelAccessor)); + } + + return super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2); + } + + @Override + public RenderShape getRenderShape(BlockState blockState) { + return RenderShape.MODEL; + } + + @Override + public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { + return SHAPE; + } + + @Override + public boolean canPlaceLiquid(BlockGetter blockGetter, BlockPos blockPos, BlockState blockState, Fluid fluid) { + return fluid == Fluids.WATER; + } + + public BlockState getStateForPlacement(BlockPlaceContext blockPlaceContext) { + FluidState fluidState = blockPlaceContext.getLevel().getFluidState(blockPlaceContext.getClickedPos()); + boolean bl = fluidState.getType() == Fluids.WATER; + return defaultBlockState().setValue(WATERLOGGED, bl); + } + + @Override + public FluidState getFluidState(BlockState blockState) { + return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(WATERLOGGED); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/block/WireBlock.java b/common/src/main/java/com/mrmelon54/ArcTech/block/WireBlock.java new file mode 100644 index 0000000..0866c1a --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/block/WireBlock.java @@ -0,0 +1,9 @@ +package com.mrmelon54.ArcTech.block; + +import net.minecraft.world.level.block.Block; + +public class WireBlock extends Block { + public WireBlock(Properties properties) { + super(properties); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/block/WireCopperBlock.java b/common/src/main/java/com/mrmelon54/ArcTech/block/WireCopperBlock.java new file mode 100644 index 0000000..780045a --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/block/WireCopperBlock.java @@ -0,0 +1,7 @@ +package com.mrmelon54.ArcTech.block; + +public class WireCopperBlock extends WireBlock { + public WireCopperBlock(Properties properties) { + super(properties); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/expect/LoadModelExpectPlatform.java b/common/src/main/java/com/mrmelon54/ArcTech/expect/LoadModelExpectPlatform.java new file mode 100644 index 0000000..70c2d65 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/expect/LoadModelExpectPlatform.java @@ -0,0 +1,14 @@ +package com.mrmelon54.ArcTech.expect; + +import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; + +import java.util.function.Supplier; + +public class LoadModelExpectPlatform { + @ExpectPlatform + public static void loadModel(ResourceLocation id, Supplier supplier) { + throw new AssertionError(); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/mixin/MixinTitleScreen.java b/common/src/main/java/com/mrmelon54/ArcTech/mixin/MixinTitleScreen.java new file mode 100644 index 0000000..2d242e2 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/mixin/MixinTitleScreen.java @@ -0,0 +1,15 @@ +package com.mrmelon54.ArcTech.mixin; + +import net.minecraft.client.gui.screens.TitleScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public class MixinTitleScreen { + @Inject(at = @At("HEAD"), method = "init()V") + private void init(CallbackInfo info) { + System.out.println("Hello from example architectury common mixin!"); + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/wire/WireBakedModel.java b/common/src/main/java/com/mrmelon54/ArcTech/wire/WireBakedModel.java new file mode 100644 index 0000000..2a1f860 --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/wire/WireBakedModel.java @@ -0,0 +1,109 @@ +package com.mrmelon54.ArcTech.wire; + +import com.mrmelon54.ArcTech.ArcTech; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.function.Function; + +@Environment(EnvType.CLIENT) +public class WireBakedModel implements BakedModel { + private final Map partModels; + private final TextureAtlasSprite particleTexture; + private static final Material TEXTURE_WIRE_COPPER = new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(ArcTech.MOD_ID, "part/wire_copper/")); + + private static final ResourceLocation PART_CENTRAL = new ResourceLocation("arctech:part/wire_copper/central"); + private static final ResourceLocation[] PART_SIDE = new ResourceLocation[]{ + new ResourceLocation("arctech:part/wire_copper/up"), + new ResourceLocation("arctech:part/wire_copper/down"), + new ResourceLocation("arctech:part/wire_copper/north"), + new ResourceLocation("arctech:part/wire_copper/south"), + new ResourceLocation("arctech:part/wire_copper/east"), + new ResourceLocation("arctech:part/wire_copper/west"), + }; + private static final BooleanProperty[] PART_PROPERTY = new BooleanProperty[]{ + BlockStateProperties.UP, + BlockStateProperties.DOWN, + BlockStateProperties.NORTH, + BlockStateProperties.SOUTH, + BlockStateProperties.EAST, + BlockStateProperties.WEST, + }; + + WireBakedModel(Map partModels, TextureAtlasSprite particleTexture) { + this.partModels = partModels; + this.particleTexture = particleTexture; + } + + + @Override + public List getQuads(@Nullable BlockState blockState, @Nullable Direction direction, RandomSource randomSource) { + if (blockState == null) return List.of(); + List sides = Arrays.stream(PART_PROPERTY).map(new Function() { + @Override + public Boolean apply(BooleanProperty booleanProperty) { + return blockState.getValue(booleanProperty); + } + }).toList(); + + // start with central quad + List bakedQuads = new ArrayList<>(partModels.get(PART_CENTRAL).getQuads(blockState, direction, randomSource)); + + // add side quads + for (int i = 0; i < sides.size(); i++) { + if (sides.get(i)) + bakedQuads.addAll(partModels.get(PART_SIDE[i]).getQuads(blockState, direction, randomSource)); + } + return bakedQuads; + } + + @Override + public boolean useAmbientOcclusion() { + return false; + } + + @Override + public boolean isGui3d() { + return false; + } + + @Override + public boolean usesBlockLight() { + return false; + } + + @Override + public boolean isCustomRenderer() { + return true; + } + + @Override + public TextureAtlasSprite getParticleIcon() { + return particleTexture; + } + + @Override + public ItemTransforms getTransforms() { + return null; + } + + @Override + public ItemOverrides getOverrides() { + return null; + } +} diff --git a/common/src/main/java/com/mrmelon54/ArcTech/wire/WireType.java b/common/src/main/java/com/mrmelon54/ArcTech/wire/WireType.java new file mode 100644 index 0000000..1bdcc6f --- /dev/null +++ b/common/src/main/java/com/mrmelon54/ArcTech/wire/WireType.java @@ -0,0 +1,5 @@ +package com.mrmelon54.ArcTech.wire; + +public enum WireType { + COPPER +} diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json new file mode 100644 index 0000000..2d41cf6 --- /dev/null +++ b/common/src/main/resources/architectury.common.json @@ -0,0 +1,3 @@ +{ + "accessWidener": "arctech.accesswidener" +} diff --git a/common/src/main/resources/arctech-common.mixins.json b/common/src/main/resources/arctech-common.mixins.json new file mode 100644 index 0000000..28bebd1 --- /dev/null +++ b/common/src/main/resources/arctech-common.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.mrmelon54.ArcTech.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + "MixinTitleScreen" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/common/src/main/resources/arctech.accesswidener b/common/src/main/resources/arctech.accesswidener new file mode 100644 index 0000000..13268c3 --- /dev/null +++ b/common/src/main/resources/arctech.accesswidener @@ -0,0 +1 @@ +accessWidener v2 named \ No newline at end of file diff --git a/common/src/main/resources/assets/arctech/blockstates/crafting_station.json b/common/src/main/resources/assets/arctech/blockstates/crafting_station.json new file mode 100644 index 0000000..1295b1a --- /dev/null +++ b/common/src/main/resources/assets/arctech/blockstates/crafting_station.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "arctech:block/crafting_station" + } + } +} diff --git a/common/src/main/resources/assets/arctech/blockstates/deepslate_lithium_ore.json b/common/src/main/resources/assets/arctech/blockstates/deepslate_lithium_ore.json new file mode 100644 index 0000000..244c1ba --- /dev/null +++ b/common/src/main/resources/assets/arctech/blockstates/deepslate_lithium_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "arctech:block/deepslate_lithium_ore" + } + } +} diff --git a/common/src/main/resources/assets/arctech/blockstates/lithium_ore.json b/common/src/main/resources/assets/arctech/blockstates/lithium_ore.json new file mode 100644 index 0000000..e5ca60c --- /dev/null +++ b/common/src/main/resources/assets/arctech/blockstates/lithium_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "arctech:block/lithium_ore" + } + } +} diff --git a/common/src/main/resources/assets/arctech/lang/en_us.json b/common/src/main/resources/assets/arctech/lang/en_us.json new file mode 100644 index 0000000..0d35e66 --- /dev/null +++ b/common/src/main/resources/assets/arctech/lang/en_us.json @@ -0,0 +1,5 @@ +{ + "creative-tab.arctech.title": "ArcTech", + "block.arctech.lithium_ore": "Lithium Ore", + "block.arctech.deepslate_lithium_ore": "Deepslate Lithium Ore" +} diff --git a/common/src/main/resources/assets/arctech/models/block/crafting_station.json b/common/src/main/resources/assets/arctech/models/block/crafting_station.json new file mode 100644 index 0000000..da6c568 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/block/crafting_station.json @@ -0,0 +1,659 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [ + 64, + 64 + ], + "textures": { + "0": "arctech:block/crafting_station", + "particle": "arctech:block/crafting_station" + }, + "elements": [ + { + "from": [ + 0, + 0, + 0 + ], + "to": [ + 3, + 13, + 3 + ], + "faces": { + "north": { + "uv": [ + 4, + 0, + 4.75, + 3.25 + ], + "texture": "#0", + "cullface": "north" + }, + "east": { + "uv": [ + 4, + 3.25, + 4.75, + 6.5 + ], + "texture": "#0" + }, + "south": { + "uv": [ + 4.75, + 0, + 5.5, + 3.25 + ], + "texture": "#0" + }, + "west": { + "uv": [ + 4.75, + 3.25, + 5.5, + 6.5 + ], + "texture": "#0", + "cullface": "west" + }, + "down": { + "uv": [ + 3.5, + 8, + 2.75, + 8.75 + ], + "texture": "#0", + "cullface": "down" + } + } + }, + { + "from": [ + 0, + 0, + 13 + ], + "to": [ + 3, + 13, + 16 + ], + "faces": { + "north": { + "uv": [ + 5.5, + 0, + 6.25, + 3.25 + ], + "texture": "#0" + }, + "east": { + "uv": [ + 5.5, + 3.25, + 6.25, + 6.5 + ], + "texture": "#0" + }, + "south": { + "uv": [ + 6.25, + 0, + 7, + 3.25 + ], + "texture": "#0", + "cullface": "south" + }, + "west": { + "uv": [ + 6.25, + 3.25, + 7, + 6.5 + ], + "texture": "#0", + "cullface": "west" + }, + "down": { + "uv": [ + 8.5, + 8.5, + 7.75, + 9.25 + ], + "texture": "#0", + "cullface": "down" + } + } + }, + { + "from": [ + 13, + 0, + 13 + ], + "to": [ + 16, + 13, + 16 + ], + "faces": { + "north": { + "uv": [ + 4, + 6.5, + 4.75, + 9.75 + ], + "texture": "#0" + }, + "east": { + "uv": [ + 4.75, + 6.5, + 5.5, + 9.75 + ], + "texture": "#0", + "cullface": "east" + }, + "south": { + "uv": [ + 5.5, + 6.5, + 6.25, + 9.75 + ], + "texture": "#0", + "cullface": "south" + }, + "west": { + "uv": [ + 6.25, + 6.5, + 7, + 9.75 + ], + "texture": "#0" + }, + "down": { + "uv": [ + 2.75, + 8.75, + 2, + 9.5 + ], + "texture": "#0", + "cullface": "down" + } + } + }, + { + "from": [ + 13, + 0, + 0 + ], + "to": [ + 16, + 13, + 3 + ], + "faces": { + "north": { + "uv": [ + 7, + 0, + 7.75, + 3.25 + ], + "texture": "#0", + "cullface": "north" + }, + "east": { + "uv": [ + 7, + 3.25, + 7.75, + 6.5 + ], + "texture": "#0", + "cullface": "east" + }, + "south": { + "uv": [ + 7, + 6.5, + 7.75, + 9.75 + ], + "texture": "#0" + }, + "west": { + "uv": [ + 7.75, + 0, + 8.5, + 3.25 + ], + "texture": "#0" + }, + "down": { + "uv": [ + 10, + 2.25, + 9.25, + 3 + ], + "texture": "#0", + "cullface": "down" + } + } + }, + { + "from": [ + 0, + 13, + 0 + ], + "to": [ + 16, + 15, + 16 + ], + "faces": { + "north": { + "uv": [ + 7.75, + 4.25, + 11.75, + 4.75 + ], + "texture": "#0", + "cullface": "north" + }, + "east": { + "uv": [ + 7.75, + 4.75, + 11.75, + 5.25 + ], + "texture": "#0", + "cullface": "east" + }, + "south": { + "uv": [ + 7.75, + 5.25, + 11.75, + 5.75 + ], + "texture": "#0", + "cullface": "south" + }, + "west": { + "uv": [ + 7.75, + 5.75, + 11.75, + 6.25 + ], + "texture": "#0", + "cullface": "west" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#0", + "cullface": "up" + }, + "down": { + "uv": [ + 4, + 4, + 0, + 8 + ], + "texture": "#0" + } + } + }, + { + "from": [ + 0, + 15, + 0 + ], + "to": [ + 16, + 16, + 2 + ], + "faces": { + "north": { + "uv": [ + 8.5, + 0.25, + 12.5, + 0.5 + ], + "texture": "#0", + "cullface": "north" + }, + "east": { + "uv": [ + 8.5, + 3, + 9, + 3.25 + ], + "texture": "#0", + "cullface": "east" + }, + "south": { + "uv": [ + 8.5, + 0.5, + 12.5, + 0.75 + ], + "texture": "#0", + "cullface": "up" + }, + "west": { + "uv": [ + 3.5, + 8.5, + 4, + 8.75 + ], + "texture": "#0", + "cullface": "west" + }, + "up": { + "uv": [ + 11.75, + 6.75, + 7.75, + 6.25 + ], + "texture": "#0", + "cullface": "up" + } + } + }, + { + "from": [ + 0, + 15, + 14 + ], + "to": [ + 16, + 16, + 16 + ], + "faces": { + "north": { + "uv": [ + 8.5, + 0.75, + 12.5, + 1 + ], + "texture": "#0", + "cullface": "up" + }, + "east": { + "uv": [ + 3.5, + 8.75, + 4, + 9 + ], + "texture": "#0", + "cullface": "east" + }, + "south": { + "uv": [ + 8.5, + 1, + 12.5, + 1.25 + ], + "texture": "#0", + "cullface": "south" + }, + "west": { + "uv": [ + 9, + 3, + 9.5, + 3.25 + ], + "texture": "#0", + "cullface": "west" + }, + "up": { + "uv": [ + 11.75, + 7.75, + 7.75, + 7.25 + ], + "texture": "#0", + "cullface": "up" + } + } + }, + { + "from": [ + 0, + 15, + 2 + ], + "to": [ + 2, + 16, + 14 + ], + "rotation": { + "angle": 0, + "axis": "y", + "origin": [ + 0, + 15, + 14 + ] + }, + "faces": { + "east": { + "uv": [ + 8.5, + 1.25, + 11.5, + 1.5 + ], + "texture": "#0", + "cullface": "up" + }, + "west": { + "uv": [ + 8.5, + 1.5, + 11.5, + 1.75 + ], + "texture": "#0", + "cullface": "west" + }, + "up": { + "uv": [ + 0.5, + 11, + 0, + 8 + ], + "texture": "#0", + "cullface": "up" + } + } + }, + { + "from": [ + 14, + 15, + 2 + ], + "to": [ + 16, + 16, + 14 + ], + "rotation": { + "angle": 0, + "axis": "y", + "origin": [ + 0, + 15, + 14 + ] + }, + "faces": { + "east": { + "uv": [ + 8.5, + 1.75, + 11.5, + 2 + ], + "texture": "#0", + "cullface": "east" + }, + "west": { + "uv": [ + 8.5, + 2, + 11.5, + 2.25 + ], + "texture": "#0", + "cullface": "up" + }, + "up": { + "uv": [ + 1.5, + 11, + 1, + 8 + ], + "texture": "#0", + "cullface": "up" + } + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [ + 75, + 45, + 0 + ], + "translation": [ + 0, + 2.5, + 0 + ], + "scale": [ + 0.375, + 0.375, + 0.375 + ] + }, + "thirdperson_lefthand": { + "rotation": [ + 75, + 45, + 0 + ], + "translation": [ + 0, + 2.5, + 0 + ], + "scale": [ + 0.375, + 0.375, + 0.375 + ] + }, + "firstperson_righthand": { + "rotation": [ + 0, + 45, + 0 + ], + "scale": [ + 0.4, + 0.4, + 0.4 + ] + }, + "firstperson_lefthand": { + "rotation": [ + 0, + 225, + 0 + ], + "scale": [ + 0.4, + 0.4, + 0.4 + ] + }, + "ground": { + "translation": [ + 0, + 3, + 0 + ], + "scale": [ + 0.25, + 0.25, + 0.25 + ] + }, + "gui": { + "rotation": [ + 30, + 225, + 0 + ], + "scale": [ + 0.625, + 0.625, + 0.625 + ] + }, + "fixed": { + "scale": [ + 0.5, + 0.5, + 0.5 + ] + } + } +} diff --git a/common/src/main/resources/assets/arctech/models/block/deepslate_lithium_ore.json b/common/src/main/resources/assets/arctech/models/block/deepslate_lithium_ore.json new file mode 100644 index 0000000..e017563 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/block/deepslate_lithium_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "arctech:block/deepslate_lithium_ore" + } +} diff --git a/common/src/main/resources/assets/arctech/models/block/lithium_ore.json b/common/src/main/resources/assets/arctech/models/block/lithium_ore.json new file mode 100644 index 0000000..a71fd25 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/block/lithium_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "arctech:block/lithium_ore" + } +} diff --git a/common/src/main/resources/assets/arctech/models/item/crafting_station.json b/common/src/main/resources/assets/arctech/models/item/crafting_station.json new file mode 100644 index 0000000..c7c1b90 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/item/crafting_station.json @@ -0,0 +1,3 @@ +{ + "parent": "arctech:block/crafting_station" +} diff --git a/common/src/main/resources/assets/arctech/models/item/deepslate_lithium_ore.json b/common/src/main/resources/assets/arctech/models/item/deepslate_lithium_ore.json new file mode 100644 index 0000000..8e86559 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/item/deepslate_lithium_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "arctech:block/deepslate_lithium_ore" +} diff --git a/common/src/main/resources/assets/arctech/models/item/lithium_ore.json b/common/src/main/resources/assets/arctech/models/item/lithium_ore.json new file mode 100644 index 0000000..931115e --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/item/lithium_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "arctech:block/lithium_ore" +} diff --git a/common/src/main/resources/assets/arctech/models/item/wire_copper.json b/common/src/main/resources/assets/arctech/models/item/wire_copper.json new file mode 100644 index 0000000..a9277b2 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/item/wire_copper.json @@ -0,0 +1,3 @@ +{ + "parent": "arctech:block/wire_copper" +} diff --git a/common/src/main/resources/assets/arctech/models/part/wire_copper/central.json b/common/src/main/resources/assets/arctech/models/part/wire_copper/central.json new file mode 100644 index 0000000..73333db --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/part/wire_copper/central.json @@ -0,0 +1,22 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "0": "arctech:block/wire_copper", + "particle": "arctech:block/wire_copper" + }, + "elements": [ + { + "name": "center", + "from": [7, 7, 7], + "to": [9, 9, 9], + "faces": { + "north": {"uv": [12, 0, 8, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [8, 4, 12, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8, 4, 12, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [8, 4, 12, 0], "rotation": 90, "texture": "#0"}, + "up": {"uv": [12, 0, 8, 4], "rotation": 90, "texture": "#0"}, + "down": {"uv": [8, 0, 12, 4], "rotation": 180, "texture": "#0"} + } + } + ] +} diff --git a/common/src/main/resources/assets/arctech/models/part/wire_copper/north.json b/common/src/main/resources/assets/arctech/models/part/wire_copper/north.json new file mode 100644 index 0000000..bce9293 --- /dev/null +++ b/common/src/main/resources/assets/arctech/models/part/wire_copper/north.json @@ -0,0 +1,22 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "0": "arctech:block/wire_copper", + "particle": "arctech:block/wire_copper" + }, + "elements": [ + { + "name": "north", + "from": [7, 7, 0], + "to": [9, 9, 7], + "faces": { + "north": {"uv": [0, 0, 4, 4], "texture": "#0", "cullface": "north"}, + "east": {"uv": [4, 4, 6, 11], "rotation": 90, "texture": "#0"}, + "south": {"uv": [4, 0, 8, 4], "texture": "#0", "cullface": "south"}, + "west": {"uv": [0, 4, 2, 11], "rotation": 90, "texture": "#0"}, + "up": {"uv": [4, 11, 2, 4], "texture": "#0"}, + "down": {"uv": [8, 4, 6, 11], "texture": "#0"} + } + } + ] +} diff --git a/common/src/main/resources/assets/arctech/textures/block/crafting_station.png b/common/src/main/resources/assets/arctech/textures/block/crafting_station.png new file mode 100644 index 0000000..da3fb56 Binary files /dev/null and b/common/src/main/resources/assets/arctech/textures/block/crafting_station.png differ diff --git a/common/src/main/resources/assets/arctech/textures/block/deepslate_lithium_ore.png b/common/src/main/resources/assets/arctech/textures/block/deepslate_lithium_ore.png new file mode 100644 index 0000000..d520ac7 Binary files /dev/null and b/common/src/main/resources/assets/arctech/textures/block/deepslate_lithium_ore.png differ diff --git a/common/src/main/resources/assets/arctech/textures/block/lithium_ore.png b/common/src/main/resources/assets/arctech/textures/block/lithium_ore.png new file mode 100644 index 0000000..1b2cc32 Binary files /dev/null and b/common/src/main/resources/assets/arctech/textures/block/lithium_ore.png differ diff --git a/common/src/main/resources/assets/arctech/textures/part/wire_copper.png b/common/src/main/resources/assets/arctech/textures/part/wire_copper.png new file mode 100644 index 0000000..f3d68c3 Binary files /dev/null and b/common/src/main/resources/assets/arctech/textures/part/wire_copper.png differ diff --git a/common/src/main/resources/data/arctech/loot_tables/blocks/deepslate_lithium_ore.json b/common/src/main/resources/data/arctech/loot_tables/blocks/deepslate_lithium_ore.json new file mode 100644 index 0000000..360055e --- /dev/null +++ b/common/src/main/resources/data/arctech/loot_tables/blocks/deepslate_lithium_ore.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "arctech:deepslate_lithium_ore" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} diff --git a/common/src/main/resources/data/arctech/loot_tables/blocks/lithium_ore.json b/common/src/main/resources/data/arctech/loot_tables/blocks/lithium_ore.json new file mode 100644 index 0000000..0222b86 --- /dev/null +++ b/common/src/main/resources/data/arctech/loot_tables/blocks/lithium_ore.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "arctech:lithium_ore" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} diff --git a/common/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/common/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json new file mode 100644 index 0000000..6c17b78 --- /dev/null +++ b/common/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "arctech:lithium_ore", + "arctech:deepslate_lithium_ore" + ] +} diff --git a/common/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json b/common/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json new file mode 100644 index 0000000..6c17b78 --- /dev/null +++ b/common/src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "arctech:lithium_ore", + "arctech:deepslate_lithium_ore" + ] +} diff --git a/fabric-like/build.gradle b/fabric-like/build.gradle new file mode 100644 index 0000000..f67d67a --- /dev/null +++ b/fabric-like/build.gradle @@ -0,0 +1,16 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" + + compileClasspath(project(path: ":common", configuration: "namedElements")) { transitive false } +} diff --git a/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/ArcTechFabricLike.java b/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/ArcTechFabricLike.java new file mode 100644 index 0000000..bc964f6 --- /dev/null +++ b/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/ArcTechFabricLike.java @@ -0,0 +1,9 @@ +package com.mrmelon54.ArcTech.fabriclike; + +import com.mrmelon54.ArcTech.ArcTech; + +public class ArcTechFabricLike { + public static void init() { + ArcTech.init(); + } +} diff --git a/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/LoadModelExpectPlatformImpl.java b/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/LoadModelExpectPlatformImpl.java new file mode 100644 index 0000000..6054d1b --- /dev/null +++ b/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/LoadModelExpectPlatformImpl.java @@ -0,0 +1,13 @@ +package com.mrmelon54.ArcTech.fabriclike; + +import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; + +import java.util.function.Supplier; + +public class LoadModelExpectPlatformImpl { + public static void loadModel(ResourceLocation id, Supplier supplier) { + ModelLoadingRegistry.INSTANCE.registerResourceProvider(resourceManager -> new SimpleModelLoader<>(id, supplier)); + } +} diff --git a/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/SimpleModelLoader.java b/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/SimpleModelLoader.java new file mode 100644 index 0000000..5710784 --- /dev/null +++ b/fabric-like/src/main/java/com/mrmelon54/ArcTech/fabriclike/SimpleModelLoader.java @@ -0,0 +1,25 @@ +package com.mrmelon54.ArcTech.fabriclike; + +import net.fabricmc.fabric.api.client.model.ModelProviderContext; +import net.fabricmc.fabric.api.client.model.ModelProviderException; +import net.fabricmc.fabric.api.client.model.ModelResourceProvider; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Supplier; + +public class SimpleModelLoader implements ModelResourceProvider { + private final ResourceLocation id; + private final Supplier supplier; + + public SimpleModelLoader(ResourceLocation id, Supplier supplier) { + this.id = id; + this.supplier = supplier; + } + + @Override + public @Nullable UnbakedModel loadModelResource(ResourceLocation resourceId, ModelProviderContext context) throws ModelProviderException { + return resourceId.equals(id) ? supplier.get() : null; + } +} diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..74f9e4e --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,84 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +architectury { + platformSetupLoomIde() + fabric() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } + common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false } +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +shadowJar { + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + injectAccessWidener = true + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenFabric(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/fabric/src/main/java/com/mrmelon54/ArcTech/fabric/ArcTechFabric.java b/fabric/src/main/java/com/mrmelon54/ArcTech/fabric/ArcTechFabric.java new file mode 100644 index 0000000..65479bb --- /dev/null +++ b/fabric/src/main/java/com/mrmelon54/ArcTech/fabric/ArcTechFabric.java @@ -0,0 +1,11 @@ +package com.mrmelon54.ArcTech.fabric; + +import com.mrmelon54.ArcTech.fabriclike.ArcTechFabricLike; +import net.fabricmc.api.ModInitializer; + +public class ArcTechFabric implements ModInitializer { + @Override + public void onInitialize() { + ArcTechFabricLike.init(); + } +} diff --git a/fabric/src/main/resources/arctech.mixins.json b/fabric/src/main/resources/arctech.mixins.json new file mode 100644 index 0000000..73497c4 --- /dev/null +++ b/fabric/src/main/resources/arctech.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "com.mrmelon54.ArcTech.mixin.fabric", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..8d88f9c --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,32 @@ +{ + "schemaVersion": 1, + "id": "arctech", + "version": "${version}", + "name": "ArcTech", + "description": "An Architectury Tech Mod", + "authors": [ + "MrMelon54" + ], + "contact": { + "homepage": "https://mrmelon54.com/minecraft/arctech", + "sources": "https://github.com/MCArcTech/ArcTech", + "issues": "https://github.com/MCArcTech/ArcTech/issues" + }, + "license": "GPL-3.0-only", + "icon": "icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "com.mrmelon54.ArcTech.fabric.ArcTechFabric" + ] + }, + "mixins": [ + "arctech.mixins.json", + "arctech-common.mixins.json" + ], + "depends": { + "fabric": "*", + "minecraft": ">=1.20", + "architectury": ">=9.0.0" + } +} diff --git a/forge/build.gradle b/forge/build.gradle new file mode 100644 index 0000000..54eb6d5 --- /dev/null +++ b/forge/build.gradle @@ -0,0 +1,89 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +architectury { + platformSetupLoomIde() + forge() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath + + forge { + convertAccessWideners = true + extraAccessWideners.add loom.accessWidenerPath.get().asFile.name + + mixinConfig "arctech-common.mixins.json" + mixinConfig "arctech.mixins.json" + } +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common +} + +dependencies { + forge "net.minecraftforge:forge:${rootProject.forge_version}" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } +} + +processResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } +} + +shadowJar { + exclude "fabric.mod.json" + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenForge(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/forge/gradle.properties b/forge/gradle.properties new file mode 100644 index 0000000..32f842a --- /dev/null +++ b/forge/gradle.properties @@ -0,0 +1 @@ +loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/com/mrmelon54/ArcTech/forge/ArcTechForge.java b/forge/src/main/java/com/mrmelon54/ArcTech/forge/ArcTechForge.java new file mode 100644 index 0000000..014b1b7 --- /dev/null +++ b/forge/src/main/java/com/mrmelon54/ArcTech/forge/ArcTechForge.java @@ -0,0 +1,15 @@ +package com.mrmelon54.ArcTech.forge; + +import com.mrmelon54.ArcTech.ArcTech; +import dev.architectury.platform.forge.EventBuses; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(ArcTech.MOD_ID) +public class ArcTechForge { + public ArcTechForge() { + // Submit our event bus to let architectury register our content on the right time + EventBuses.registerModEventBus(ArcTech.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus()); + ArcTech.init(); + } +} diff --git a/forge/src/main/java/com/mrmelon54/ArcTech/forge/LoadModelExpectPlatformImpl.java b/forge/src/main/java/com/mrmelon54/ArcTech/forge/LoadModelExpectPlatformImpl.java new file mode 100644 index 0000000..3048f78 --- /dev/null +++ b/forge/src/main/java/com/mrmelon54/ArcTech/forge/LoadModelExpectPlatformImpl.java @@ -0,0 +1,33 @@ +package com.mrmelon54.ArcTech.forge; + +import com.mrmelon54.ArcTech.ArcTech; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; + +public class LoadModelExpectPlatformImpl { + private static final Map builtInModels = new HashMap<>(); + + public static void loadModel(ResourceLocation id, Supplier supplier) { + builtInModels.put(id, supplier.get()); + } + + public static UnbakedModel getBuildInModel(ResourceLocation variantId) { + if (!ArcTech.MOD_ID.equals(variantId.getNamespace())) return null; + + // Vanilla loads item models as #inventory, which we replicate here + if (variantId instanceof ModelResourceLocation modelId) { + if ("inventory".equals(modelId.getVariant())) { + var itemModelId = new ResourceLocation(modelId.getNamespace(), "item/" + modelId.getPath()); + return builtInModels.get(itemModelId); + } + + return null; + } + return builtInModels.get(variantId); + } +} diff --git a/forge/src/main/java/com/mrmelon54/ArcTech/forge/mixin/MixinModelBakery.java b/forge/src/main/java/com/mrmelon54/ArcTech/forge/mixin/MixinModelBakery.java new file mode 100644 index 0000000..bc3393a --- /dev/null +++ b/forge/src/main/java/com/mrmelon54/ArcTech/forge/mixin/MixinModelBakery.java @@ -0,0 +1,26 @@ +package com.mrmelon54.ArcTech.forge.mixin; + +import com.mrmelon54.ArcTech.forge.LoadModelExpectPlatformImpl; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ModelBakery.class) +public abstract class MixinModelBakery { + @Shadow + protected abstract void cacheAndQueueDependencies(ResourceLocation resourceLocation, UnbakedModel unbakedModel); + + @Inject(method = "loadModel", at = @At("HEAD"), cancellable = true) + private void loadModelHook(ResourceLocation id, CallbackInfo ci) { + var model = LoadModelExpectPlatformImpl.getBuildInModel(id); + if (model != null) { + cacheAndQueueDependencies(id, model); + ci.cancel(); + } + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..8ff60dc --- /dev/null +++ b/forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,33 @@ +modLoader = "javafml" +loaderVersion = "[46,)" +issueTrackerURL = "https://github.com/MCArcTech/ArcTech/issues" +license = "GPL-3.0-only" + +[[mods]] +modId = "arctech" +version = "${version}" +displayName = "ArcTech" +authors = "MrMelon54" +description = "An Architectury Tech Mod" +logoFile = "/icon.png" + +[[dependencies.arctech]] +modId = "forge" +mandatory = true +versionRange = "[46,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.arctech]] +modId = "minecraft" +mandatory = true +versionRange = "[1.20,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.arctech]] +modId = "architectury" +mandatory = true +versionRange = "[9.0.0,)" +ordering = "AFTER" +side = "BOTH" diff --git a/forge/src/main/resources/arctech.mixins.json b/forge/src/main/resources/arctech.mixins.json new file mode 100644 index 0000000..1bae557 --- /dev/null +++ b/forge/src/main/resources/arctech.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.mrmelon54.ArcTech.forge.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + "MixinModelBakery" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..00a0dd5 --- /dev/null +++ b/forge/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "ArcTech", + "pack_format": 15 + } +} diff --git a/quilt/build.gradle b/quilt/build.gradle new file mode 100644 index 0000000..cd3a2ce --- /dev/null +++ b/quilt/build.gradle @@ -0,0 +1,94 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +repositories { + maven { url "https://maven.quiltmc.org/repository/release/" } +} + +architectury { + platformSetupLoomIde() + loader("quilt") +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentQuilt.extendsFrom common +} + +dependencies { + modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" + modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" + // Remove the next few lines if you don't want to depend on the API + modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { + // We must not pull Fabric Loader from Architectury Fabric + exclude group: "net.fabricmc" + exclude group: "net.fabricmc.fabric-api" + } + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } + common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false } +} + +processResources { + inputs.property "group", rootProject.maven_group + inputs.property "version", project.version + + filesMatching("quilt.mod.json") { + expand "group": rootProject.maven_group, + "version": project.version + } +} + +shadowJar { + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + injectAccessWidener = true + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenQuilt(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/quilt/gradle.properties b/quilt/gradle.properties new file mode 100644 index 0000000..96758ce --- /dev/null +++ b/quilt/gradle.properties @@ -0,0 +1 @@ +loom.platform=quilt \ No newline at end of file diff --git a/quilt/src/main/java/com/mrmelon54/ArcTech/quilt/ArcTechQuilt.java b/quilt/src/main/java/com/mrmelon54/ArcTech/quilt/ArcTechQuilt.java new file mode 100644 index 0000000..b6672bc --- /dev/null +++ b/quilt/src/main/java/com/mrmelon54/ArcTech/quilt/ArcTechQuilt.java @@ -0,0 +1,12 @@ +package com.mrmelon54.ArcTech.quilt; + +import com.mrmelon54.ArcTech.fabriclike.ArcTechFabricLike; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; + +public class ArcTechQuilt implements ModInitializer { + @Override + public void onInitialize(ModContainer mod) { + ArcTechFabricLike.init(); + } +} diff --git a/quilt/src/main/resources/arctech.mixins.json b/quilt/src/main/resources/arctech.mixins.json new file mode 100644 index 0000000..73497c4 --- /dev/null +++ b/quilt/src/main/resources/arctech.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "com.mrmelon54.ArcTech.mixin.fabric", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json new file mode 100644 index 0000000..6e4418d --- /dev/null +++ b/quilt/src/main/resources/quilt.mod.json @@ -0,0 +1,53 @@ +{ + "schema_version": 1, + "mixin": [ + "arctech.mixins.json", + "arctech-common.mixins.json" + ], + "quilt_loader": { + "group": "${group}", + "id": "arctech", + "version": "${version}", + "metadata": { + "name": "ArcTech", + "description": "An Architectury Tech Mod", + "contributors": { + "MrMelon54": "Owner" + }, + "contact": { + "homepage": "https://mrmelon54.com/minecraft/arctech", + "sources": "https://github.com/MCArcTech/ArcTech", + "issues": "https://github.com/MCArcTech/ArcTech/issues" + }, + "license": "GPL-3.0-only", + "icon": "icon.png" + }, + "intermediate_mappings": "net.fabricmc:intermediary", + "entrypoints": { + "init": [ + "com.mrmelon54.ArcTech.quilt.ArcTechQuilt" + ] + }, + "depends": [ + { + "id": "quilt_loader", + "version": "*" + }, + { + "id": "quilt_base", + "version": "*" + }, + { + "id": "minecraft", + "version": ">=1.20" + }, + { + "id": "architectury", + "version": ">=9.0.0" + } + ] + }, + "minecraft": { + "environment": "*" + } +}