Skip to content

Commit

Permalink
build(build.grade): 添加數據生成
Browse files Browse the repository at this point in the history
  • Loading branch information
northgreen committed Apr 16, 2024
1 parent 692b176 commit 340e564
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ publishing {
}
}


javadoc{
options.encoding = "UTF-8"
}

sourceSets {
main{
resources {
srcDirs += [
'src/main/generated'
]
}
}
}

loom {
runs {
datagen {
server()

name "Minecraft Data"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}"

runDir "build/datagen"
}
}
}
assemble.dependsOn runDatagen
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.ictye.the_origin_of_magic.Blocks;

import com.ictye.the_origin_of_magic.GUI.MagicWorkbench.MagicWorkbenchScreenFactory;
import com.ictye.the_origin_of_magic.Items.Staff.StdStaff;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
Expand Down Expand Up @@ -53,6 +50,4 @@ public BlockRenderType getRenderType(BlockState state){
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return super.getTicker(world, state, type);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.InventoryChangedListener;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
Expand Down Expand Up @@ -178,13 +177,16 @@ public void convInventoryToSlotWithDrop(MagicInventory inventory){
}
}

/**
* 魔法格子,用於存儲魔法的喵
*/
class magicSlot extends Slot {

public magicSlot(Inventory inventory, int index, int x, int y) {
super(inventory, index, x, y);
}

public boolean canInsert(ItemStack stack) {
// 防止錯誤地放入格子裏面
if(staffInventory.getStack(0).getItem() instanceof StdStaff staff){
return this.getIndex() < staff.getSize();
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/ictye/the_origin_of_magic/ModDataGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ictye.the_origin_of_magic;

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;

public class ModDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {

}
}
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"fabricloader": ">=${loader_version}",
"fabric": "*",
"minecraft": "${minecraft_version}"
}
},
"fabric-datagen": [
"com.ictye.the_origin_of_magic.ModDataGenerator"
]
}

0 comments on commit 340e564

Please sign in to comment.