Kotlinify!
This commit is contained in:
parent
19f2ee2aab
commit
2421099131
26 changed files with 445 additions and 400 deletions
|
@ -3,6 +3,6 @@ org.gradle.parallel=true
|
|||
kotlin.incremental=true
|
||||
kotlin.code.style=official
|
||||
|
||||
group=com.example
|
||||
version=1.0.0
|
||||
archives_base_name=quilt-kotlin-template-mod
|
||||
group=xyz.limepot
|
||||
version=0.1.0
|
||||
archives_base_name=stellarworks
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package xyz.limepot.stellarworks;
|
||||
|
||||
|
||||
import org.quiltmc.qsl.lifecycle.api.client.event.ClientTickEvents ;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.option.KeyBind;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
|
||||
import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap;
|
||||
import xyz.limepot.stellarworks.block.ModBlocks;
|
||||
|
||||
public abstract class StellarworksClient implements ClientModInitializer {
|
||||
|
||||
//private static final KeyBind ARCTEST = new KeyBind("key.stellarworks.arctest", GLFW.GLFW_KEY_H, "key.categories.misc");
|
||||
public void onInitializeClient() {
|
||||
|
||||
BlockRenderLayerMap.put(RenderLayer.getCutout(), ModBlocks.ARC_FURNACE);
|
||||
|
||||
//ModModelPredicateProvider.registerModModels();
|
||||
|
||||
|
||||
//keybinds
|
||||
/*
|
||||
KeyBindingHelper.registerKeyBinding(ARCTEST);
|
||||
ClientTickEvents.END.register(client -> {
|
||||
while (ARCTEST.wasPressed()) {
|
||||
|
||||
}
|
||||
});*/
|
||||
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package xyz.limepot.stellarworks.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder;
|
||||
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;
|
||||
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
|
||||
import xyz.limepot.stellarworks.Stellarworks;
|
||||
import xyz.limepot.stellarworks.block.custom.ArcFurnaceBlock;
|
||||
import xyz.limepot.stellarworks.block.entity.ArcFurnaceBlockEntity;
|
||||
|
||||
//NOTE: this file only registers the blocks, for more indepth block coding, make a new java file in "BlockName.java" Format
|
||||
//and make extra code there.
|
||||
|
||||
public class ModBlocks {
|
||||
|
||||
//ores
|
||||
public static final Block TIN_ORE = registerBlock("tin_ore", new ExperienceDroppingBlock(QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()));
|
||||
public static final Block ALUMINIUM_ORE = registerBlock("aluminium_ore", new ExperienceDroppingBlock(QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()));
|
||||
//Deepslate Variety
|
||||
public static final Block DEEPSLATE_ALUMINIUM_ORE = registerBlock("deepslate_aluminium_ore", new ExperienceDroppingBlock(QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()));
|
||||
public static final Block DEEPSLATE_TIN_ORE = registerBlock("deepslate_tin_ore", new ExperienceDroppingBlock(QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()));
|
||||
|
||||
//special blocks
|
||||
public static final Block ARC_FURNACE = registerBlock("arc_furnace", new ArcFurnaceBlock(QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(2f)));
|
||||
public static final Block ENGINEERING_TABLE = registerBlock("engineering_table", new Block(QuiltBlockSettings.copyOf(Blocks.CRAFTING_TABLE)
|
||||
.strength(2f)));
|
||||
//don't forget to add these to the tools shit thingy in the resources.
|
||||
public static final Block MOON_DUST = registerBlock("moon_dust", new Block(QuiltBlockSettings.copyOf(Blocks.SNOW_BLOCK)
|
||||
.strength(2f)));
|
||||
public static final Block MOON_ROCK = registerBlock("moon_rock", new Block(QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(2f)));
|
||||
|
||||
//BLOCK ENTITIES
|
||||
public static final BlockEntityType<ArcFurnaceBlockEntity> ARC_FURNACE_ENTITY = Registry.register(
|
||||
Registries.BLOCK_ENTITY_TYPE,
|
||||
new Identifier("stellarworks", "arc_furnace_entity"),
|
||||
QuiltBlockEntityTypeBuilder.create(ArcFurnaceBlockEntity::new, ARC_FURNACE).build()
|
||||
);
|
||||
|
||||
private static Block registerBlock(String name, Block block) {
|
||||
registerBlockItem(name, block);
|
||||
return Registry.register(Registries.BLOCK, new Identifier(Stellarworks.MOD_ID, name), block);
|
||||
}
|
||||
|
||||
private static void registerBlockItem(String name, Block block) {
|
||||
Registry.register(Registries.ITEM, new Identifier(Stellarworks.MOD_ID, name), new BlockItem(block, new QuiltItemSettings()));
|
||||
}
|
||||
|
||||
public static void registerModBlocks() {
|
||||
Stellarworks.INSTANCE.getLOGGER().debug("Registering Blocks...");
|
||||
}
|
||||
|
||||
}
|
|
@ -141,7 +141,7 @@ public class ArcFurnaceBlockEntity extends BlockEntity implements NamedScreenHan
|
|||
if(hasRecipe(entity)) {
|
||||
entity.removeStack(1, 1);
|
||||
|
||||
entity.setStack(2, new ItemStack(ModItems.PIG_IRON_INGOT, entity.getStack(2).getCount() + 1));
|
||||
entity.setStack(2, new ItemStack(ModItems.INSTANCE.getPIG_IRON_INGOT(), entity.getStack(2).getCount() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class ArcFurnaceBlockEntity extends BlockEntity implements NamedScreenHan
|
|||
boolean hasArcSmeltableInFirstSlot = entity.getStack(1).getItem() == Items.IRON_INGOT;
|
||||
|
||||
return hasArcSmeltableInFirstSlot && canInsertAmountIntoOutputSlot(inventory, 1)
|
||||
&& canInsertItemIntoOutputSlot(inventory, ModItems.PIG_IRON_INGOT);
|
||||
&& canInsertItemIntoOutputSlot(inventory, ModItems.INSTANCE.getPIG_IRON_INGOT());
|
||||
}
|
||||
|
||||
private static boolean canInsertItemIntoOutputSlot(SimpleInventory inventory, Item output) {
|
||||
|
|
|
@ -15,6 +15,6 @@ public class ModBlockEntities {
|
|||
ARC_FURNACE_ENTITY = Registry.register(Registries.BLOCK_ENTITY_TYPE,
|
||||
new Identifier(Stellarworks.MOD_ID, "arc_furnace"),
|
||||
QuiltBlockEntityTypeBuilder.create(ArcFurnaceBlockEntity::new,
|
||||
ModBlocks.ARC_FURNACE).build(null));
|
||||
ModBlocks.INSTANCE.getARC_FURNACE()).build(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
package xyz.limepot.stellarworks.item;
|
||||
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import xyz.limepot.stellarworks.Stellarworks;
|
||||
import xyz.limepot.stellarworks.block.ModBlocks;
|
||||
|
||||
public class ModItemGroup {
|
||||
public static ItemGroup STELLAR = Registry.register(Registries.ITEM_GROUP, new Identifier(Stellarworks.MOD_ID, "stellar"),
|
||||
FabricItemGroup.builder()
|
||||
.name(Text.translatable("itemgroup.stellar"))
|
||||
.icon(() -> new ItemStack(ModBlocks.ENGINEERING_TABLE)).entries((displayContext, entries) -> {
|
||||
//blocks
|
||||
entries.addItem(ModBlocks.ENGINEERING_TABLE);
|
||||
entries.addItem(ModBlocks.ARC_FURNACE);
|
||||
entries.addItem(ModBlocks.MOON_DUST);
|
||||
entries.addItem(ModBlocks.MOON_ROCK);
|
||||
entries.addItem(ModBlocks.ALUMINIUM_ORE);
|
||||
entries.addItem(ModBlocks.DEEPSLATE_ALUMINIUM_ORE);
|
||||
entries.addItem(ModBlocks.TIN_ORE);
|
||||
entries.addItem(ModBlocks.DEEPSLATE_TIN_ORE);
|
||||
|
||||
|
||||
//metals
|
||||
entries.addItem(ModItems.ALUMINIUM_INGOT);
|
||||
entries.addItem(ModItems.BRONZE_INGOT);
|
||||
entries.addItem(ModItems.PIG_IRON_INGOT);
|
||||
entries.addItem(ModItems.RAW_ALUMINIUM);
|
||||
entries.addItem(ModItems.RAW_BRONZE);
|
||||
entries.addItem(ModItems.RAW_TIN);
|
||||
entries.addItem(ModItems.TIN_INGOT);
|
||||
|
||||
//tools
|
||||
//pig iron
|
||||
entries.addItem(ModItems.PIG_IRON_SWORD);
|
||||
entries.addItem(ModItems.PIG_IRON_AXE);
|
||||
entries.addItem(ModItems.PIG_IRON_PICKAXE);
|
||||
entries.addItem(ModItems.PIG_IRON_SHOVEL);
|
||||
entries.addItem(ModItems.PIG_IRON_HOE);
|
||||
|
||||
}).build());
|
||||
|
||||
public static void registerItemGroups() {
|
||||
Stellarworks.INSTANCE.getLOGGER().debug("Registering Creative Tab Entries...");
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package xyz.limepot.stellarworks.item;
|
||||
|
||||
import net.minecraft.item.ShovelItem;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
|
||||
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
import xyz.limepot.stellarworks.Stellarworks;
|
||||
import xyz.limepot.stellarworks.item.custom.ModAxeItem;
|
||||
import xyz.limepot.stellarworks.item.custom.ModHoeItem;
|
||||
import xyz.limepot.stellarworks.item.custom.ModPickaxe;
|
||||
import xyz.limepot.stellarworks.item.custom.ModToolMaterials;
|
||||
|
||||
import static xyz.limepot.stellarworks.Stellarworks.MOD_ID;
|
||||
|
||||
public class ModItems {
|
||||
|
||||
|
||||
|
||||
//ingots
|
||||
public static final Item TIN_INGOT = registerItem("tin_ingot",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
public static final Item BRONZE_INGOT = registerItem("bronze_ingot",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
public static final Item ALUMINIUM_INGOT = registerItem("aluminium_ingot",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
public static final Item PIG_IRON_INGOT = registerItem("pig_iron_ingot",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
|
||||
//raw metal materials
|
||||
public static final Item RAW_ALUMINIUM = registerItem("raw_aluminium",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
public static final Item RAW_TIN = registerItem("raw_tin",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
public static final Item RAW_BRONZE = registerItem("raw_bronze",
|
||||
new Item(new QuiltItemSettings()));
|
||||
|
||||
|
||||
//tools
|
||||
//pig iron tools
|
||||
public static final Item PIG_IRON_SWORD = registerItem("pig_iron_sword",
|
||||
new SwordItem(ModToolMaterials.PIG_IRON, 3, -2.8F, new QuiltItemSettings()));
|
||||
public static final Item PIG_IRON_SHOVEL = registerItem("pig_iron_shovel",
|
||||
new ShovelItem(ModToolMaterials.PIG_IRON, 1.5F, -3.1F, new QuiltItemSettings()));
|
||||
public static final Item PIG_IRON_AXE = registerItem("pig_iron_axe",
|
||||
new ModAxeItem(ModToolMaterials.PIG_IRON, 7.0F, -3.2F, new QuiltItemSettings()));
|
||||
public static final Item PIG_IRON_PICKAXE = registerItem("pig_iron_pickaxe",
|
||||
new ModPickaxe(ModToolMaterials.PIG_IRON, 1, -2.8F, new QuiltItemSettings()));
|
||||
public static final Item PIG_IRON_HOE = registerItem("pig_iron_hoe",
|
||||
new ModHoeItem(ModToolMaterials.PIG_IRON, 1, -3.2F, new QuiltItemSettings()));
|
||||
|
||||
|
||||
//registry template
|
||||
private static Item registerItem(String name, Item item){
|
||||
return Registry.register(Registries.ITEM, new Identifier(MOD_ID, name), item);
|
||||
}
|
||||
|
||||
public static void registerModItems() {
|
||||
Stellarworks.INSTANCE.getLOGGER().debug("Registering Items....");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package xyz.limepot.stellarworks.item.custom;
|
||||
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
|
||||
public class ModAxeItem extends AxeItem {
|
||||
public ModAxeItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package xyz.limepot.stellarworks.item.custom;
|
||||
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
|
||||
public class ModHoeItem extends PickaxeItem {
|
||||
public ModHoeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package xyz.limepot.stellarworks.item.custom;
|
||||
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
|
||||
public class ModPickaxe extends PickaxeItem {
|
||||
public ModPickaxe(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public enum ModToolMaterials implements ToolMaterial {
|
|||
});
|
||||
*/
|
||||
PIG_IRON(2, 560, 7.0F, 2.6F, 12, () -> {
|
||||
return Ingredient.ofItems(ModItems.PIG_IRON_INGOT);
|
||||
return Ingredient.ofItems(ModItems.INSTANCE.getPIG_IRON_INGOT());
|
||||
});
|
||||
|
||||
private final int miningLevel;
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
package xyz.limepot.stellarworks.screen;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.screen.ArrayPropertyDelegate;
|
||||
import net.minecraft.screen.PropertyDelegate;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
|
||||
public class ArcFurnaceScreenHandler extends ScreenHandler {
|
||||
private final Inventory inventory;
|
||||
private final PropertyDelegate propertyDelegate;
|
||||
public ArcFurnaceScreenHandler(int syncId, PlayerInventory inventory, PacketByteBuf buf) {
|
||||
this(syncId, inventory, (Inventory) inventory.player.getWorld().getBlockEntity(buf.readBlockPos()),
|
||||
new ArrayPropertyDelegate(2));
|
||||
}
|
||||
|
||||
public ArcFurnaceScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate delegate) {
|
||||
super(ModScreenHandlers.ARC_FURNACE_SCREEN_HANDLER, syncId);
|
||||
checkSize(inventory, 3);
|
||||
this.inventory = inventory;
|
||||
inventory.onOpen(playerInventory.player);
|
||||
this.propertyDelegate = delegate;
|
||||
|
||||
this.addSlot(new Slot(inventory, 0, 12, 15));
|
||||
this.addSlot(new Slot(inventory, 1, 86, 15));
|
||||
this.addSlot(new Slot(inventory, 2, 86, 60));
|
||||
|
||||
addPlayerInventory(playerInventory);
|
||||
addPlayerHotbar(playerInventory);
|
||||
|
||||
addProperties(delegate);
|
||||
}
|
||||
|
||||
public boolean isCrafting() {
|
||||
return propertyDelegate.get(0) > 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress() {
|
||||
int progress = this.propertyDelegate.get(0);
|
||||
int maxProgress = this.propertyDelegate.get(1); // Max Progress
|
||||
int progressArrowSize = 26; // This is the width in pixels of your arrow
|
||||
|
||||
return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickTransfer(PlayerEntity player, int invSlot) {
|
||||
ItemStack newStack = ItemStack.EMPTY;
|
||||
Slot slot = this.slots.get(invSlot);
|
||||
if (slot != null && slot.hasStack()) {
|
||||
ItemStack originalStack = slot.getStack();
|
||||
newStack = originalStack.copy();
|
||||
if (invSlot < this.inventory.size()) {
|
||||
if (!this.insertItem(originalStack, this.inventory.size(), this.slots.size(), true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.insertItem(originalStack, 0, this.inventory.size(), false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (originalStack.isEmpty()) {
|
||||
slot.setStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
return newStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(PlayerEntity player) {
|
||||
return this.inventory.canPlayerUse(player);
|
||||
}
|
||||
|
||||
private void addPlayerInventory(PlayerInventory playerInventory) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int l = 0; l < 9; ++l) {
|
||||
this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 86 + i * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayerHotbar(PlayerInventory playerInventory) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 144));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package xyz.limepot.stellarworks.screen;
|
||||
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import xyz.limepot.stellarworks.Stellarworks;
|
||||
|
||||
public class ModScreenHandlers {
|
||||
public static ScreenHandlerType<ArcFurnaceScreenHandler> ARC_FURNACE_SCREEN_HANDLER =
|
||||
new ExtendedScreenHandlerType<>(ArcFurnaceScreenHandler::new);
|
||||
|
||||
public static void registerAllScreenHandlers() {
|
||||
Registry.register(Registries.SCREEN_HANDLER_TYPE, new Identifier(Stellarworks.MOD_ID, "arc_furnace"),
|
||||
ARC_FURNACE_SCREEN_HANDLER);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package xyz.limepot.stellarworks.util;
|
||||
|
||||
public class ModModelPredicateProvider {
|
||||
//public static void registerModModels() {
|
||||
// FabricModelPredicateProviderRegistry.register(ModBlocks.CERAMIC_FURNACE, new Identifier("facing"), (itemStack, clientWorld, livingEntity) -> {
|
||||
// return 0;
|
||||
// });
|
||||
//}
|
||||
|
||||
public static void registerModModels() {
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package xyz.limepot.stellarworks.world;
|
||||
|
||||
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.gen.feature.PlacedFeature;
|
||||
import xyz.limepot.stellarworks.Stellarworks;
|
||||
|
||||
public class ModFeatures {
|
||||
|
||||
public static final RegistryKey<PlacedFeature> ALUMINIUM_ORE_PLACED_KEY = RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier("stellarworks","aluminium_ore"));
|
||||
public static final RegistryKey<PlacedFeature> TIN_ORE_PLACED_KEY = RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier("stellarworks","tin_ore"));
|
||||
|
||||
public static void registerFeatures() {
|
||||
Stellarworks.INSTANCE.getLOGGER().debug("Registering Features...");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package xyz.limepot.stellarworks
|
||||
|
||||
import net.minecraft.client.render.RenderLayer
|
||||
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer
|
||||
import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap
|
||||
import xyz.limepot.stellarworks.block.ModBlocks.ARC_FURNACE
|
||||
|
||||
|
||||
abstract class StellarworksClient : ClientModInitializer {
|
||||
//private static final KeyBind ARCTEST = new KeyBind("key.stellarworks.arctest", GLFW.GLFW_KEY_H, "key.categories.misc");
|
||||
fun onInitializeClient() {
|
||||
BlockRenderLayerMap.put(RenderLayer.getCutout(), ARC_FURNACE)
|
||||
|
||||
|
||||
//ModModelPredicateProvider.registerModModels();
|
||||
|
||||
|
||||
//keybinds
|
||||
/*
|
||||
KeyBindingHelper.registerKeyBinding(ARCTEST);
|
||||
ClientTickEvents.END.register(client -> {
|
||||
while (ARCTEST.wasPressed()) {
|
||||
|
||||
}
|
||||
});*/
|
||||
}
|
||||
}
|
88
src/main/kotlin/xyz/limepot/stellarworks/block/ModBlocks.kt
Normal file
88
src/main/kotlin/xyz/limepot/stellarworks/block/ModBlocks.kt
Normal file
|
@ -0,0 +1,88 @@
|
|||
package xyz.limepot.stellarworks.block
|
||||
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.Blocks
|
||||
import net.minecraft.block.ExperienceDroppingBlock
|
||||
import net.minecraft.item.BlockItem
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.util.Identifier
|
||||
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings
|
||||
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings
|
||||
import xyz.limepot.stellarworks.Stellarworks
|
||||
import xyz.limepot.stellarworks.Stellarworks.LOGGER
|
||||
import xyz.limepot.stellarworks.block.custom.ArcFurnaceBlock
|
||||
|
||||
//NOTE: this file only registers the blocks, for more indepth block coding, make a new java file in "BlockName.java" Format
|
||||
//and make extra code there.
|
||||
object ModBlocks {
|
||||
//ores
|
||||
val TIN_ORE: Block = registerBlock(
|
||||
"tin_ore", ExperienceDroppingBlock(
|
||||
QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()
|
||||
)
|
||||
)
|
||||
val ALUMINIUM_ORE: Block = registerBlock(
|
||||
"aluminium_ore", ExperienceDroppingBlock(
|
||||
QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()
|
||||
)
|
||||
)
|
||||
|
||||
//Deepslate Variety
|
||||
val DEEPSLATE_ALUMINIUM_ORE: Block = registerBlock(
|
||||
"deepslate_aluminium_ore", ExperienceDroppingBlock(
|
||||
QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()
|
||||
)
|
||||
)
|
||||
val DEEPSLATE_TIN_ORE: Block = registerBlock(
|
||||
"deepslate_tin_ore", ExperienceDroppingBlock(
|
||||
QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(4f).requiresTool()
|
||||
)
|
||||
)
|
||||
|
||||
//special blocks
|
||||
val ARC_FURNACE: Block = registerBlock(
|
||||
"arc_furnace", ArcFurnaceBlock(
|
||||
QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(2f)
|
||||
)
|
||||
)
|
||||
val ENGINEERING_TABLE: Block = registerBlock(
|
||||
"engineering_table", Block(
|
||||
QuiltBlockSettings.copyOf(Blocks.CRAFTING_TABLE)
|
||||
.strength(2f)
|
||||
)
|
||||
)
|
||||
|
||||
//don't forget to add these to the tools shit thingy in the resources.
|
||||
val MOON_DUST: Block = registerBlock(
|
||||
"moon_dust", Block(
|
||||
QuiltBlockSettings.copyOf(Blocks.SNOW_BLOCK)
|
||||
.strength(2f)
|
||||
)
|
||||
)
|
||||
val MOON_ROCK: Block = registerBlock(
|
||||
"moon_rock", Block(
|
||||
QuiltBlockSettings.copyOf(Blocks.STONE)
|
||||
.strength(2f)
|
||||
)
|
||||
)
|
||||
|
||||
//BLOCK ENTITIES
|
||||
private fun registerBlock(name: String, block: Block): Block {
|
||||
registerBlockItem(name, block)
|
||||
return Registry.register(Registries.BLOCK, Identifier(Stellarworks.MOD_ID, name), block)
|
||||
}
|
||||
|
||||
private fun registerBlockItem(name: String, block: Block) {
|
||||
Registry.register(Registries.ITEM, Identifier(Stellarworks.MOD_ID, name), BlockItem(block, QuiltItemSettings()))
|
||||
}
|
||||
|
||||
fun registerModBlocks() {
|
||||
LOGGER.debug("Registering Blocks...")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package xyz.limepot.stellarworks.item
|
||||
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup
|
||||
import net.minecraft.item.ItemGroup
|
||||
import net.minecraft.item.ItemGroup.DisplayParameters
|
||||
import net.minecraft.item.ItemGroup.ItemStackCollector
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
import xyz.limepot.stellarworks.Stellarworks
|
||||
import xyz.limepot.stellarworks.Stellarworks.LOGGER
|
||||
import xyz.limepot.stellarworks.block.ModBlocks
|
||||
|
||||
object ModItemGroup {
|
||||
var STELLAR: ItemGroup = Registry.register(
|
||||
Registries.ITEM_GROUP, Identifier(Stellarworks.MOD_ID, "stellar"),
|
||||
FabricItemGroup.builder()
|
||||
.name(Text.translatable("itemgroup.stellar"))
|
||||
.icon { ItemStack(ModBlocks.ENGINEERING_TABLE) }
|
||||
.entries { displayContext: DisplayParameters?, entries: ItemStackCollector ->
|
||||
//blocks
|
||||
entries.addItem(ModBlocks.ENGINEERING_TABLE)
|
||||
entries.addItem(ModBlocks.ARC_FURNACE)
|
||||
entries.addItem(ModBlocks.MOON_DUST)
|
||||
entries.addItem(ModBlocks.MOON_ROCK)
|
||||
entries.addItem(ModBlocks.ALUMINIUM_ORE)
|
||||
entries.addItem(ModBlocks.DEEPSLATE_ALUMINIUM_ORE)
|
||||
entries.addItem(ModBlocks.TIN_ORE)
|
||||
entries.addItem(ModBlocks.DEEPSLATE_TIN_ORE)
|
||||
|
||||
|
||||
//metals
|
||||
entries.addItem(ModItems.ALUMINIUM_INGOT)
|
||||
entries.addItem(ModItems.BRONZE_INGOT)
|
||||
entries.addItem(ModItems.PIG_IRON_INGOT)
|
||||
entries.addItem(ModItems.RAW_ALUMINIUM)
|
||||
entries.addItem(ModItems.RAW_BRONZE)
|
||||
entries.addItem(ModItems.RAW_TIN)
|
||||
entries.addItem(ModItems.TIN_INGOT)
|
||||
|
||||
//tools
|
||||
//pig iron
|
||||
entries.addItem(ModItems.PIG_IRON_SWORD)
|
||||
entries.addItem(ModItems.PIG_IRON_AXE)
|
||||
entries.addItem(ModItems.PIG_IRON_PICKAXE)
|
||||
entries.addItem(ModItems.PIG_IRON_SHOVEL)
|
||||
entries.addItem(ModItems.PIG_IRON_HOE)
|
||||
}.build()
|
||||
)
|
||||
|
||||
fun registerItemGroups() {
|
||||
LOGGER.debug("Registering Creative Tab Entries...")
|
||||
}
|
||||
}
|
87
src/main/kotlin/xyz/limepot/stellarworks/item/ModItems.kt
Normal file
87
src/main/kotlin/xyz/limepot/stellarworks/item/ModItems.kt
Normal file
|
@ -0,0 +1,87 @@
|
|||
package xyz.limepot.stellarworks.item
|
||||
|
||||
import net.minecraft.item.*
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.util.*
|
||||
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings
|
||||
import xyz.limepot.stellarworks.Stellarworks.LOGGER
|
||||
import xyz.limepot.stellarworks.Stellarworks.MOD_ID
|
||||
import xyz.limepot.stellarworks.item.custom.ModAxeItem
|
||||
import xyz.limepot.stellarworks.item.custom.ModHoeItem
|
||||
import xyz.limepot.stellarworks.item.custom.ModPickaxe
|
||||
import xyz.limepot.stellarworks.item.custom.ModToolMaterials
|
||||
|
||||
object ModItems {
|
||||
//ingots
|
||||
val TIN_INGOT: Item = registerItem(
|
||||
"tin_ingot",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
val BRONZE_INGOT: Item = registerItem(
|
||||
"bronze_ingot",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
val ALUMINIUM_INGOT: Item = registerItem(
|
||||
"aluminium_ingot",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
val PIG_IRON_INGOT: Item = registerItem(
|
||||
"pig_iron_ingot",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
|
||||
//raw metal materials
|
||||
val RAW_ALUMINIUM: Item = registerItem(
|
||||
"raw_aluminium",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
val RAW_TIN: Item = registerItem(
|
||||
"raw_tin",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
val RAW_BRONZE: Item = registerItem(
|
||||
"raw_bronze",
|
||||
Item(QuiltItemSettings())
|
||||
)
|
||||
|
||||
|
||||
//tools
|
||||
//pig iron tools
|
||||
val PIG_IRON_SWORD: Item = registerItem(
|
||||
"pig_iron_sword",
|
||||
SwordItem(ModToolMaterials.PIG_IRON, 3, -2.8f, QuiltItemSettings())
|
||||
)
|
||||
val PIG_IRON_SHOVEL: Item = registerItem(
|
||||
"pig_iron_shovel",
|
||||
ShovelItem(ModToolMaterials.PIG_IRON, 1.5f, -3.1f, QuiltItemSettings())
|
||||
)
|
||||
val PIG_IRON_AXE: Item = registerItem(
|
||||
"pig_iron_axe",
|
||||
ModAxeItem(ModToolMaterials.PIG_IRON, 7.0f, -3.2f, QuiltItemSettings())
|
||||
)
|
||||
val PIG_IRON_PICKAXE: Item = registerItem(
|
||||
"pig_iron_pickaxe",
|
||||
ModPickaxe(ModToolMaterials.PIG_IRON, 1, -2.8f, QuiltItemSettings())
|
||||
)
|
||||
val PIG_IRON_HOE: Item = registerItem(
|
||||
"pig_iron_hoe",
|
||||
ModHoeItem(ModToolMaterials.PIG_IRON, 1, -3.2f, QuiltItemSettings())
|
||||
)
|
||||
|
||||
|
||||
//registry template
|
||||
private fun registerItem(name: String, item: Item): Item {
|
||||
return Registry.register<Item, Item>(Registries.ITEM, Identifier(MOD_ID, name), item)
|
||||
}
|
||||
|
||||
fun registerModItems() {
|
||||
LOGGER.debug("Registering Items....")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package xyz.limepot.stellarworks.item.custom
|
||||
|
||||
import net.minecraft.item.AxeItem
|
||||
import net.minecraft.item.ToolMaterial
|
||||
|
||||
class ModAxeItem(material: ToolMaterial?, attackDamage: Float, attackSpeed: Float, settings: Settings?) :
|
||||
AxeItem(material, attackDamage, attackSpeed, settings)
|
|
@ -0,0 +1,7 @@
|
|||
package xyz.limepot.stellarworks.item.custom
|
||||
|
||||
import net.minecraft.item.PickaxeItem
|
||||
import net.minecraft.item.ToolMaterial
|
||||
|
||||
class ModHoeItem(material: ToolMaterial?, attackDamage: Int, attackSpeed: Float, settings: Settings?) :
|
||||
PickaxeItem(material, attackDamage, attackSpeed, settings)
|
|
@ -0,0 +1,7 @@
|
|||
package xyz.limepot.stellarworks.item.custom
|
||||
|
||||
import net.minecraft.item.PickaxeItem
|
||||
import net.minecraft.item.ToolMaterial
|
||||
|
||||
class ModPickaxe(material: ToolMaterial?, attackDamage: Int, attackSpeed: Float, settings: Settings?) :
|
||||
PickaxeItem(material, attackDamage, attackSpeed, settings)
|
|
@ -0,0 +1,100 @@
|
|||
package xyz.limepot.stellarworks.screen
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity
|
||||
import net.minecraft.entity.player.PlayerInventory
|
||||
import net.minecraft.inventory.Inventory
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.network.PacketByteBuf
|
||||
import net.minecraft.screen.ArrayPropertyDelegate
|
||||
import net.minecraft.screen.PropertyDelegate
|
||||
import net.minecraft.screen.ScreenHandler
|
||||
import net.minecraft.screen.slot.Slot
|
||||
|
||||
class ArcFurnaceScreenHandler(
|
||||
syncId: Int,
|
||||
playerInventory: PlayerInventory,
|
||||
inventory: Inventory?,
|
||||
delegate: PropertyDelegate
|
||||
) : ScreenHandler(ModScreenHandlers.ARC_FURNACE_SCREEN_HANDLER, syncId) {
|
||||
private val inventory: Inventory?
|
||||
private val propertyDelegate: PropertyDelegate
|
||||
|
||||
constructor(syncId: Int, inventory: PlayerInventory, buf: PacketByteBuf) : this(
|
||||
syncId, inventory, inventory.player.world.getBlockEntity(buf.readBlockPos()) as Inventory?,
|
||||
ArrayPropertyDelegate(2)
|
||||
)
|
||||
|
||||
init {
|
||||
checkSize(inventory, 3)
|
||||
this.inventory = inventory
|
||||
inventory!!.onOpen(playerInventory.player)
|
||||
this.propertyDelegate = delegate
|
||||
|
||||
this.addSlot(Slot(inventory, 0, 12, 15))
|
||||
this.addSlot(Slot(inventory, 1, 86, 15))
|
||||
this.addSlot(Slot(inventory, 2, 86, 60))
|
||||
|
||||
addPlayerInventory(playerInventory)
|
||||
addPlayerHotbar(playerInventory)
|
||||
|
||||
addProperties(delegate)
|
||||
}
|
||||
|
||||
val isCrafting: Boolean
|
||||
get() = propertyDelegate[0] > 0
|
||||
|
||||
val scaledProgress: Int
|
||||
get() {
|
||||
val progress = propertyDelegate[0]
|
||||
val maxProgress = propertyDelegate[1] // Max Progress
|
||||
val progressArrowSize = 26 // This is the width in pixels of your arrow
|
||||
|
||||
return if (maxProgress != 0 && progress != 0) progress * progressArrowSize / maxProgress else 0
|
||||
}
|
||||
|
||||
override fun quickTransfer(player: PlayerEntity, invSlot: Int): ItemStack {
|
||||
var newStack = ItemStack.EMPTY
|
||||
val slot = slots[invSlot]
|
||||
if (slot != null && slot.hasStack()) {
|
||||
val originalStack = slot.stack
|
||||
newStack = originalStack.copy()
|
||||
if (invSlot < inventory!!.size()) {
|
||||
if (!this.insertItem(
|
||||
originalStack,
|
||||
inventory.size(), slots.size, true
|
||||
)
|
||||
) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
} else if (!this.insertItem(originalStack, 0, inventory.size(), false)) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
if (originalStack.isEmpty) {
|
||||
slot.stack = ItemStack.EMPTY
|
||||
} else {
|
||||
slot.markDirty()
|
||||
}
|
||||
}
|
||||
|
||||
return newStack
|
||||
}
|
||||
|
||||
override fun canUse(player: PlayerEntity): Boolean {
|
||||
return inventory!!.canPlayerUse(player)
|
||||
}
|
||||
|
||||
private fun addPlayerInventory(playerInventory: PlayerInventory) {
|
||||
for (i in 0..2) {
|
||||
for (l in 0..8) {
|
||||
this.addSlot(Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 86 + i * 18))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addPlayerHotbar(playerInventory: PlayerInventory) {
|
||||
for (i in 0..8) {
|
||||
this.addSlot(Slot(playerInventory, i, 8 + i * 18, 144))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package xyz.limepot.stellarworks.screen
|
||||
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType
|
||||
import net.minecraft.entity.player.PlayerInventory
|
||||
import net.minecraft.network.PacketByteBuf
|
||||
import net.minecraft.registry.Registries
|
||||
import net.minecraft.registry.Registry
|
||||
import net.minecraft.screen.ScreenHandlerType
|
||||
import net.minecraft.util.Identifier
|
||||
import xyz.limepot.stellarworks.Stellarworks
|
||||
|
||||
object ModScreenHandlers {
|
||||
var ARC_FURNACE_SCREEN_HANDLER: ScreenHandlerType<ArcFurnaceScreenHandler> =
|
||||
ExtendedScreenHandlerType { syncId: Int, inventory: PlayerInventory, buf: PacketByteBuf ->
|
||||
ArcFurnaceScreenHandler(
|
||||
syncId,
|
||||
inventory,
|
||||
buf
|
||||
)
|
||||
}
|
||||
|
||||
fun registerAllScreenHandlers() {
|
||||
Registry.register(
|
||||
Registries.SCREEN_HANDLER_TYPE, Identifier(Stellarworks.MOD_ID, "arc_furnace"),
|
||||
ARC_FURNACE_SCREEN_HANDLER
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package xyz.limepot.stellarworks.util
|
||||
|
||||
object ModModelPredicateProvider {
|
||||
//public static void registerModModels() {
|
||||
// FabricModelPredicateProviderRegistry.register(ModBlocks.CERAMIC_FURNACE, new Identifier("facing"), (itemStack, clientWorld, livingEntity) -> {
|
||||
// return 0;
|
||||
// });
|
||||
//}
|
||||
fun registerModModels() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package xyz.limepot.stellarworks.world
|
||||
|
||||
import net.minecraft.registry.RegistryKey
|
||||
import net.minecraft.registry.RegistryKeys
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.world.gen.feature.PlacedFeature
|
||||
import xyz.limepot.stellarworks.Stellarworks.LOGGER
|
||||
|
||||
|
||||
object ModFeatures {
|
||||
val ALUMINIUM_ORE_PLACED_KEY: RegistryKey<PlacedFeature> =
|
||||
RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier("stellarworks", "aluminium_ore"))
|
||||
val TIN_ORE_PLACED_KEY: RegistryKey<PlacedFeature> =
|
||||
RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier("stellarworks", "tin_ore"))
|
||||
|
||||
fun registerFeatures() {
|
||||
LOGGER.debug("Registering Features...")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue