Compare commits
No commits in common. "1.18.2" and "master" have entirely different histories.
|
|
@ -1,6 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'net.minecraftforge.gradle' version '5.1.+'
|
id 'net.minecraftforge.gradle' version '5.1.+'
|
||||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,7 +26,6 @@ minecraft {
|
||||||
// Use non-default mappings at your own risk. They may not always work.
|
// Use non-default mappings at your own risk. They may not always work.
|
||||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||||
mappings channel: 'official', version: '1.18.2'
|
mappings channel: 'official', version: '1.18.2'
|
||||||
mappings channel: 'parchment', version: '2022.08.07-1.18.2'
|
|
||||||
|
|
||||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven { url = 'https://maven.minecraftforge.net/' }
|
maven { url = 'https://maven.minecraftforge.net/' }
|
||||||
maven { url = 'https://maven.parchmentmc.org' }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
52118334c4e8b293f37eefd1db8cb96477f8b059 assets/enchantmentscraping/lang/en_us.json
|
|
||||||
bed6d7371e70035c88c57e34d0c83da63dca1ea4 assets/enchantmentscraping/models/item/diamond_scraper.json
|
|
||||||
df77f6065e5d44bb1983287443715a3444eef938 assets/enchantmentscraping/models/item/iron_scraper.json
|
|
||||||
e13d487e1d4600f4beeab8e5a16e7dedf0797e92 assets/enchantmentscraping/models/item/netherite_scraper.json
|
|
||||||
97741e551a753b0c6196850f68e2f0b2d8d2685e assets/enchantmentscraping/models/item/obsidian_scraper.json
|
|
||||||
91d5f477f3fd333a5cf56d96608563c886ecb01d assets/enchantmentscraping/models/item/scraping_station.json
|
|
||||||
222b292c8cbb2d5ce53f9b965d7aed1931363e94 data/enchantmentscraping/advancements/recipes/enchantmentscraping/diamond_scraper.json
|
|
||||||
8c5262105aec27e249ddc6e136cf1822758dd66b data/enchantmentscraping/advancements/recipes/enchantmentscraping/iron_scraper.json
|
|
||||||
b8a07c07323e32ec8c57a84215750aeb3df6a00c data/enchantmentscraping/advancements/recipes/enchantmentscraping/netherite_scraper.json
|
|
||||||
9c875cb8ce853cd2e51e6d7b161d594381054cb2 data/enchantmentscraping/advancements/recipes/enchantmentscraping/obsidian_scraper.json
|
|
||||||
25e1464363af03e400dedb864b344592f42961f4 data/enchantmentscraping/advancements/recipes/enchantmentscraping/scraping_station.json
|
|
||||||
e3a378ca664c150916a966da68940aaaa617d4f8 data/enchantmentscraping/recipes/diamond_scraper.json
|
|
||||||
9d4abed333cd1243de11c618726f4c73c4e937d1 data/enchantmentscraping/recipes/iron_scraper.json
|
|
||||||
ead5c986b58c076488bfacd566ff88c385507f1e data/enchantmentscraping/recipes/netherite_scraper.json
|
|
||||||
91250cc830b70218eb3a2d104069453317b961ca data/enchantmentscraping/recipes/obsidian_scraper.json
|
|
||||||
69a2b048d043021d7c49ad0464dd8417de2a35b6 data/enchantmentscraping/recipes/scraping_station.json
|
|
||||||
3104c9f1158f3d34e27c9092fdc1cb6b9427f636 data/enchantmentscraping/tags/items/scraper_item.json
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"block.enchantmentscraping.scraping_station": "Scraping Station",
|
|
||||||
"item.enchantmentscraping.diamond_scraper": "Diamond Scraper",
|
|
||||||
"item.enchantmentscraping.iron_scraper": "Iron Scraper",
|
|
||||||
"item.enchantmentscraping.netherite_scraper": "Netherite Scraper",
|
|
||||||
"item.enchantmentscraping.obsidian_scraper": "Obsidian Scraper",
|
|
||||||
"itemGroup.enchantmentscraping": "Enchantment Scraping"
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:item/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "enchantmentscraping:item/diamond_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:item/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "enchantmentscraping:item/iron_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:item/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "enchantmentscraping:item/netherite_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:item/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "enchantmentscraping:item/obsidian_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "enchantmentscraping:block/scraping_station"
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:recipes/root",
|
|
||||||
"rewards": {
|
|
||||||
"recipes": [
|
|
||||||
"enchantmentscraping:diamond_scraper"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"criteria": {
|
|
||||||
"created_scraper": {
|
|
||||||
"trigger": "minecraft:inventory_changed",
|
|
||||||
"conditions": {
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"items": [
|
|
||||||
"enchantmentscraping:scraping_station"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has_the_recipe": {
|
|
||||||
"trigger": "minecraft:recipe_unlocked",
|
|
||||||
"conditions": {
|
|
||||||
"recipe": "enchantmentscraping:diamond_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requirements": [
|
|
||||||
[
|
|
||||||
"created_scraper",
|
|
||||||
"has_the_recipe"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:recipes/root",
|
|
||||||
"rewards": {
|
|
||||||
"recipes": [
|
|
||||||
"enchantmentscraping:iron_scraper"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"criteria": {
|
|
||||||
"created_scraper": {
|
|
||||||
"trigger": "minecraft:inventory_changed",
|
|
||||||
"conditions": {
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"items": [
|
|
||||||
"enchantmentscraping:scraping_station"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has_the_recipe": {
|
|
||||||
"trigger": "minecraft:recipe_unlocked",
|
|
||||||
"conditions": {
|
|
||||||
"recipe": "enchantmentscraping:iron_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requirements": [
|
|
||||||
[
|
|
||||||
"created_scraper",
|
|
||||||
"has_the_recipe"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:recipes/root",
|
|
||||||
"rewards": {
|
|
||||||
"recipes": [
|
|
||||||
"enchantmentscraping:netherite_scraper"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"criteria": {
|
|
||||||
"created_scraper": {
|
|
||||||
"trigger": "minecraft:inventory_changed",
|
|
||||||
"conditions": {
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"items": [
|
|
||||||
"enchantmentscraping:scraping_station"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has_the_recipe": {
|
|
||||||
"trigger": "minecraft:recipe_unlocked",
|
|
||||||
"conditions": {
|
|
||||||
"recipe": "enchantmentscraping:netherite_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requirements": [
|
|
||||||
[
|
|
||||||
"created_scraper",
|
|
||||||
"has_the_recipe"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:recipes/root",
|
|
||||||
"rewards": {
|
|
||||||
"recipes": [
|
|
||||||
"enchantmentscraping:obsidian_scraper"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"criteria": {
|
|
||||||
"created_scraper": {
|
|
||||||
"trigger": "minecraft:inventory_changed",
|
|
||||||
"conditions": {
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"items": [
|
|
||||||
"enchantmentscraping:scraping_station"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has_the_recipe": {
|
|
||||||
"trigger": "minecraft:recipe_unlocked",
|
|
||||||
"conditions": {
|
|
||||||
"recipe": "enchantmentscraping:obsidian_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requirements": [
|
|
||||||
[
|
|
||||||
"created_scraper",
|
|
||||||
"has_the_recipe"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "minecraft:recipes/root",
|
|
||||||
"rewards": {
|
|
||||||
"recipes": [
|
|
||||||
"enchantmentscraping:scraping_station"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"criteria": {
|
|
||||||
"created_enchanting_table": {
|
|
||||||
"trigger": "minecraft:inventory_changed",
|
|
||||||
"conditions": {
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"items": [
|
|
||||||
"minecraft:enchanting_table"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has_the_recipe": {
|
|
||||||
"trigger": "minecraft:recipe_unlocked",
|
|
||||||
"conditions": {
|
|
||||||
"recipe": "enchantmentscraping:scraping_station"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requirements": [
|
|
||||||
[
|
|
||||||
"created_enchanting_table",
|
|
||||||
"has_the_recipe"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:crafting_shaped",
|
|
||||||
"pattern": [
|
|
||||||
" m ",
|
|
||||||
"msm",
|
|
||||||
" m "
|
|
||||||
],
|
|
||||||
"key": {
|
|
||||||
"m": {
|
|
||||||
"item": "minecraft:diamond"
|
|
||||||
},
|
|
||||||
"s": {
|
|
||||||
"item": "minecraft:stick"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "enchantmentscraping:diamond_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:crafting_shaped",
|
|
||||||
"pattern": [
|
|
||||||
" m ",
|
|
||||||
"msm",
|
|
||||||
" m "
|
|
||||||
],
|
|
||||||
"key": {
|
|
||||||
"m": {
|
|
||||||
"item": "minecraft:iron_ingot"
|
|
||||||
},
|
|
||||||
"s": {
|
|
||||||
"item": "minecraft:stick"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "enchantmentscraping:iron_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:crafting_shaped",
|
|
||||||
"pattern": [
|
|
||||||
" m ",
|
|
||||||
"msm",
|
|
||||||
" m "
|
|
||||||
],
|
|
||||||
"key": {
|
|
||||||
"m": {
|
|
||||||
"item": "minecraft:netherite_scrap"
|
|
||||||
},
|
|
||||||
"s": {
|
|
||||||
"item": "minecraft:stick"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "enchantmentscraping:netherite_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:crafting_shaped",
|
|
||||||
"pattern": [
|
|
||||||
" m ",
|
|
||||||
"msm",
|
|
||||||
" m "
|
|
||||||
],
|
|
||||||
"key": {
|
|
||||||
"m": {
|
|
||||||
"item": "minecraft:obsidian"
|
|
||||||
},
|
|
||||||
"s": {
|
|
||||||
"item": "minecraft:stick"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "enchantmentscraping:obsidian_scraper"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:crafting_shaped",
|
|
||||||
"pattern": [
|
|
||||||
"s s",
|
|
||||||
"sos",
|
|
||||||
"lll"
|
|
||||||
],
|
|
||||||
"key": {
|
|
||||||
"s": {
|
|
||||||
"item": "minecraft:stick"
|
|
||||||
},
|
|
||||||
"o": {
|
|
||||||
"tag": "forge:obsidian"
|
|
||||||
},
|
|
||||||
"l": {
|
|
||||||
"item": "minecraft:smooth_quartz_slab"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "enchantmentscraping:scraping_station"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"replace": false,
|
|
||||||
"values": [
|
|
||||||
"enchantmentscraping:iron_scraper",
|
|
||||||
"enchantmentscraping:diamond_scraper",
|
|
||||||
"enchantmentscraping:obsidian_scraper",
|
|
||||||
"enchantmentscraping:netherite_scraper"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping;
|
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import xyz.nuark.enchantmentscraping.setup.ClientSetup;
|
|
||||||
import xyz.nuark.enchantmentscraping.setup.ModSetup;
|
|
||||||
import xyz.nuark.enchantmentscraping.setup.Registration;
|
|
||||||
|
|
||||||
@Mod(EnchantmentScraping.MOD_ID)
|
|
||||||
public class EnchantmentScraping {
|
|
||||||
public static final String MOD_ID = "enchantmentscraping";
|
|
||||||
public static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
|
|
||||||
|
|
||||||
public EnchantmentScraping() {
|
|
||||||
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
||||||
|
|
||||||
ModSetup.setup();
|
|
||||||
Registration.register(eventBus);
|
|
||||||
|
|
||||||
eventBus.addListener(ModSetup::init);
|
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> eventBus.addListener(ClientSetup::init));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package xyz.nuark.enchantmentscraping;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.InterModComms;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||||
|
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
|
@Mod("enchantmentscraping")
|
||||||
|
public class Enchantmentscraping {
|
||||||
|
|
||||||
|
// Directly reference a slf4j logger
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
public Enchantmentscraping() {
|
||||||
|
// Register the setup method for modloading
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||||
|
// Register the enqueueIMC method for modloading
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
|
||||||
|
// Register the processIMC method for modloading
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
|
||||||
|
|
||||||
|
// Register ourselves for server and other game events we are interested in
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setup(final FMLCommonSetupEvent event) {
|
||||||
|
// Some preinit code
|
||||||
|
LOGGER.info("HELLO FROM PREINIT");
|
||||||
|
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enqueueIMC(final InterModEnqueueEvent event) {
|
||||||
|
// Some example code to dispatch IMC to another mod
|
||||||
|
InterModComms.sendTo("enchantmentscraping", "helloworld", () -> {
|
||||||
|
LOGGER.info("Hello world from the MDK");
|
||||||
|
return "Hello world";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processIMC(final InterModProcessEvent event) {
|
||||||
|
// Some example code to receive and process InterModComms from other mods
|
||||||
|
LOGGER.info("Got IMC {}", event.getIMCStream().
|
||||||
|
map(m -> m.messageSupplier().get()).
|
||||||
|
collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onServerStarting(ServerStartingEvent event) {
|
||||||
|
// Do something when the server starts
|
||||||
|
LOGGER.info("HELLO from server starting");
|
||||||
|
}
|
||||||
|
|
||||||
|
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
|
||||||
|
// Event bus for receiving Registry Events)
|
||||||
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public static class RegistryEvents {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
|
||||||
|
// Register a new block here
|
||||||
|
LOGGER.info("HELLO from Register Block");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping;
|
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class ModTags {
|
|
||||||
public static class Items {
|
|
||||||
public static final TagKey<Item> SCRAPER_ITEM = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(EnchantmentScraping.MOD_ID, "scraper_item"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.block;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.custom.ScrapingStationBlock;
|
|
||||||
|
|
||||||
public class ModBlocks {
|
|
||||||
public static final DeferredRegister<Block> BLOCKS =
|
|
||||||
DeferredRegister.create(ForgeRegistries.BLOCKS, EnchantmentScraping.MOD_ID);
|
|
||||||
|
|
||||||
public static final RegistryObject<Block> SCRAPING_STATION = BLOCKS.register("scraping_station", ScrapingStationBlock::new);
|
|
||||||
// public static final RegistryObject<Block> SCRAPING_STATION = BLOCKS.register("scraping_station", ()->new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
|
||||||
|
|
||||||
public static void register(IEventBus eventBus) {
|
|
||||||
BLOCKS.register(eventBus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,125 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.block.custom;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
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.*;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
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.DirectionProperty;
|
|
||||||
import net.minecraft.world.level.material.Fluids;
|
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.entity.custom.ScrapingStationBlockEntity;
|
|
||||||
|
|
||||||
public class ScrapingStationBlock extends BaseEntityBlock {
|
|
||||||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
|
||||||
private static final VoxelShape SHAPE_BASE = Shapes.box(0.0, 0.0, 0.0, 1.0, 0.375, 1.0);
|
|
||||||
private static final VoxelShape SHAPE_RODS_V = Shapes.or(
|
|
||||||
Shapes.box(0.4375, 0.375, 0.0625, 0.5625, 0.8125, 0.1875),
|
|
||||||
Shapes.box(0.4375, 0.375, 0.8125, 0.5625, 0.8125, 0.9375),
|
|
||||||
Shapes.box(0.5, 0.5625, 0.1875, 0.5, 0.75, 0.8125)
|
|
||||||
);
|
|
||||||
private static final VoxelShape SHAPE_RODS_H = Shapes.or(
|
|
||||||
Shapes.box(0.8125, 0.375, 0.4375, 0.9375, 0.8125, 0.5625),
|
|
||||||
Shapes.box(0.0625, 0.375, 0.4375, 0.1875, 0.8125, 0.5625),
|
|
||||||
Shapes.box(0.1875, 0.5625, 0.5, 0.8125, 0.75, 0.5)
|
|
||||||
);
|
|
||||||
private static final VoxelShape SHAPE_N = Shapes.or(SHAPE_BASE, SHAPE_RODS_H);
|
|
||||||
private static final VoxelShape SHAPE_W = Shapes.or(SHAPE_BASE, SHAPE_RODS_V);
|
|
||||||
private static final VoxelShape SHAPE_S = Shapes.or(SHAPE_BASE, SHAPE_RODS_H);
|
|
||||||
private static final VoxelShape SHAPE_E = Shapes.or(SHAPE_BASE, SHAPE_RODS_V);
|
|
||||||
|
|
||||||
public ScrapingStationBlock() {
|
|
||||||
super(Properties.of(Material.HEAVY_METAL).lightLevel((p_187435_) -> 14));
|
|
||||||
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RenderShape getRenderShape(BlockState pState) {
|
|
||||||
return RenderShape.MODEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
|
|
||||||
if (pState.getBlock() != pNewState.getBlock()) {
|
|
||||||
BlockEntity blockEntity = pLevel.getBlockEntity(pPos);
|
|
||||||
if (blockEntity instanceof ScrapingStationBlockEntity) {
|
|
||||||
((ScrapingStationBlockEntity) blockEntity).drops();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos,
|
|
||||||
Player player, InteractionHand interactionHand, BlockHitResult hitResult) {
|
|
||||||
if (!level.isClientSide()) {
|
|
||||||
BlockEntity entity = level.getBlockEntity(blockPos);
|
|
||||||
if (entity instanceof ScrapingStationBlockEntity) {
|
|
||||||
NetworkHooks.openGui(((ServerPlayer) player), (ScrapingStationBlockEntity) entity, blockPos);
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Our Container provider is missing!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
|
||||||
if (!level.isClientSide()) {
|
|
||||||
return (lvl, pos, stt, te) -> {
|
|
||||||
if (te instanceof ScrapingStationBlockEntity scraper) scraper.tickServer();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) {
|
|
||||||
return switch (state.getValue(FACING)) {
|
|
||||||
default -> SHAPE_N;
|
|
||||||
case SOUTH -> SHAPE_S;
|
|
||||||
case WEST -> SHAPE_W;
|
|
||||||
case EAST -> SHAPE_E;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public BlockEntity newBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState blockState) {
|
|
||||||
return new ScrapingStationBlockEntity(blockPos, blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
||||||
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
||||||
builder.add(FACING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.block.entity;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.entity.custom.ScrapingStationBlockEntity;
|
|
||||||
|
|
||||||
public class ModBlockEntities {
|
|
||||||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
|
|
||||||
DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, EnchantmentScraping.MOD_ID);
|
|
||||||
|
|
||||||
public static final RegistryObject<BlockEntityType<ScrapingStationBlockEntity>> SCRAPING_STATION_BLOCK_ENTITY =
|
|
||||||
BLOCK_ENTITIES.register("scraping_station_block_entity", () -> BlockEntityType.Builder.of(ScrapingStationBlockEntity::new, ModBlocks.SCRAPING_STATION.get()).build(null));
|
|
||||||
|
|
||||||
public static void register(IEventBus eventBus) {
|
|
||||||
BLOCK_ENTITIES.register(eventBus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.block.entity.custom;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.world.Containers;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
|
||||||
import net.minecraft.world.SimpleContainer;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
||||||
import net.minecraft.world.inventory.ContainerData;
|
|
||||||
import net.minecraft.world.item.EnchantedBookItem;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.entity.ModBlockEntities;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.custom.ScraperItem;
|
|
||||||
import xyz.nuark.enchantmentscraping.screen.ScrapingStationMenu;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class ScrapingStationBlockEntity extends BlockEntity implements MenuProvider {
|
|
||||||
private final int CRAFTING_TIME = 200;
|
|
||||||
private int craftingTicker = 0;
|
|
||||||
private boolean isCrafting = false;
|
|
||||||
private final Random random = new Random();
|
|
||||||
|
|
||||||
protected final ContainerData dataAccess = new ContainerData() {
|
|
||||||
public int get(int idx) {
|
|
||||||
return switch (idx) {
|
|
||||||
case 0 -> ScrapingStationBlockEntity.this.craftingTicker;
|
|
||||||
default -> 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(int idx, int value) {
|
|
||||||
switch (idx) {
|
|
||||||
case 0 -> ScrapingStationBlockEntity.this.craftingTicker = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final ItemStackHandler itemHandler = new ItemStackHandler(4) {
|
|
||||||
@Override
|
|
||||||
protected void onContentsChanged(int slot) {
|
|
||||||
setChanged();
|
|
||||||
updateCraftingState();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private LazyOptional<ItemStackHandler> lazyItemHandler = LazyOptional.empty();
|
|
||||||
|
|
||||||
public ScrapingStationBlockEntity(BlockPos pos, BlockState blockState) {
|
|
||||||
super(ModBlockEntities.SCRAPING_STATION_BLOCK_ENTITY.get(), pos, blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Component getDisplayName() {
|
|
||||||
return new TranslatableComponent("block.enchantmentscraping.scraping_station");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public AbstractContainerMenu createMenu(int containerID, Inventory inventory, Player player) {
|
|
||||||
return new ScrapingStationMenu(containerID, inventory, this, dataAccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @javax.annotation.Nullable Direction side) {
|
|
||||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
|
||||||
return lazyItemHandler.cast();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getCapability(cap, side);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
super.onLoad();
|
|
||||||
lazyItemHandler = LazyOptional.of(() -> itemHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invalidateCaps() {
|
|
||||||
super.invalidateCaps();
|
|
||||||
lazyItemHandler.invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveAdditional(@NotNull CompoundTag tag) {
|
|
||||||
tag.put("inventory", itemHandler.serializeNBT());
|
|
||||||
tag.putBoolean("isCrafting", isCrafting);
|
|
||||||
tag.putInt("craftingTicker", craftingTicker);
|
|
||||||
super.saveAdditional(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(@NotNull CompoundTag nbt) {
|
|
||||||
super.load(nbt);
|
|
||||||
itemHandler.deserializeNBT(nbt.getCompound("inventory"));
|
|
||||||
isCrafting = nbt.getBoolean("isCrafting");
|
|
||||||
craftingTicker = nbt.getInt("craftingTicker");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drops() {
|
|
||||||
SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots());
|
|
||||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
|
||||||
inventory.setItem(i, itemHandler.getStackInSlot(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.level != null) {
|
|
||||||
Containers.dropContents(this.level, this.worldPosition, inventory);
|
|
||||||
} else {
|
|
||||||
EnchantmentScraping.LOGGER.error("ScrapingStationBlockEntity.drops() - level is null");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCraftingState() {
|
|
||||||
var item = itemHandler.getStackInSlot(0);
|
|
||||||
var books = itemHandler.getStackInSlot(1);
|
|
||||||
var scraper = itemHandler.getStackInSlot(2);
|
|
||||||
var result = itemHandler.getStackInSlot(3);
|
|
||||||
|
|
||||||
isCrafting = !item.isEmpty() && !books.isEmpty() && !scraper.isEmpty() && result.isEmpty();
|
|
||||||
craftingTicker = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tickServer() {
|
|
||||||
if (!isCrafting) return;
|
|
||||||
craftingTicker++;
|
|
||||||
if (craftingTicker >= CRAFTING_TIME) {
|
|
||||||
craftingTicker = 0;
|
|
||||||
|
|
||||||
var enchantments = EnchantmentHelper.getEnchantments(itemHandler.getStackInSlot(0));
|
|
||||||
if (!enchantments.isEmpty()) {
|
|
||||||
var scraperChance = ((ScraperItem) itemHandler.getStackInSlot(2).getItem()).getScrapingChance();
|
|
||||||
var applicableEnchantments = enchantments.entrySet().stream().filter(entry -> random.nextFloat(1) < scraperChance).map(e -> new EnchantmentInstance(e.getKey(), e.getValue())).toList();
|
|
||||||
if (applicableEnchantments.isEmpty()) {
|
|
||||||
itemHandler.setStackInSlot(3, new ItemStack(Items.BOOK));
|
|
||||||
} else {
|
|
||||||
var enchantedBook = new ItemStack(Items.ENCHANTED_BOOK);
|
|
||||||
applicableEnchantments.forEach(e -> EnchantedBookItem.addEnchantment(enchantedBook, e));
|
|
||||||
itemHandler.setStackInSlot(3, enchantedBook);
|
|
||||||
}
|
|
||||||
itemHandler.getStackInSlot(2).setDamageValue(itemHandler.getStackInSlot(2).getDamageValue() + 1);
|
|
||||||
itemHandler.getStackInSlot(1).setCount(itemHandler.getStackInSlot(1).getCount() - 1);
|
|
||||||
itemHandler.getStackInSlot(0).getEnchantmentTags().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.datagen;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
|
|
||||||
public class BlockStatesGenerator extends BlockStateProvider {
|
|
||||||
public BlockStatesGenerator(DataGenerator gen, ExistingFileHelper exFileHelper) {
|
|
||||||
super(gen, EnchantmentScraping.MOD_ID, exFileHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void registerStatesAndModels() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.datagen;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = EnchantmentScraping.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public class DataGenerators {
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void gatherData(GatherDataEvent event) {
|
|
||||||
DataGenerator generator = event.getGenerator();
|
|
||||||
if (event.includeServer()) {
|
|
||||||
generator.addProvider(new RecipesGenerator(generator));
|
|
||||||
var blockTags = new TagsGenerator.BlockTags(generator, event.getExistingFileHelper());
|
|
||||||
generator.addProvider(blockTags);
|
|
||||||
generator.addProvider(new TagsGenerator.ItemTags(generator, blockTags, event.getExistingFileHelper()));
|
|
||||||
}
|
|
||||||
if (event.includeClient()) {
|
|
||||||
generator.addProvider(new BlockStatesGenerator(generator, event.getExistingFileHelper()));
|
|
||||||
generator.addProvider(new ItemModelGenerator(generator, event.getExistingFileHelper()));
|
|
||||||
generator.addProvider(new LanguageGenerator(generator, "en_us"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.datagen;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.ModItems;
|
|
||||||
|
|
||||||
public class ItemModelGenerator extends ItemModelProvider {
|
|
||||||
public ItemModelGenerator(DataGenerator generator, ExistingFileHelper exFileHelper) {
|
|
||||||
super(generator, EnchantmentScraping.MOD_ID, exFileHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void registerModels() {
|
|
||||||
basicItem(ModItems.IRON_SCRAPER_ITEM.get());
|
|
||||||
basicItem(ModItems.DIAMOND_SCRAPER_ITEM.get());
|
|
||||||
basicItem(ModItems.OBSIDIAN_SCRAPER_ITEM.get());
|
|
||||||
basicItem(ModItems.NETHERITE_SCRAPER_ITEM.get());
|
|
||||||
|
|
||||||
withExistingParent(ModItems.SCRAPING_STATION_ITEM.get().getRegistryName().getPath(), modLoc("block/scraping_station"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.datagen;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraftforge.common.data.LanguageProvider;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.ModItems;
|
|
||||||
|
|
||||||
public class LanguageGenerator extends LanguageProvider {
|
|
||||||
public LanguageGenerator(DataGenerator gen, String locale) {
|
|
||||||
super(gen, EnchantmentScraping.MOD_ID, locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addTranslations() {
|
|
||||||
add("itemGroup." + EnchantmentScraping.MOD_ID, "Enchantment Scraping");
|
|
||||||
|
|
||||||
add(ModBlocks.SCRAPING_STATION.get(), "Scraping Station");
|
|
||||||
add(ModItems.IRON_SCRAPER_ITEM.get(), "Iron Scraper");
|
|
||||||
add(ModItems.DIAMOND_SCRAPER_ITEM.get(), "Diamond Scraper");
|
|
||||||
add(ModItems.OBSIDIAN_SCRAPER_ITEM.get(), "Obsidian Scraper");
|
|
||||||
add(ModItems.NETHERITE_SCRAPER_ITEM.get(), "Netherite Scraper");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.datagen;
|
|
||||||
|
|
||||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraft.data.recipes.FinishedRecipe;
|
|
||||||
import net.minecraft.data.recipes.RecipeProvider;
|
|
||||||
import net.minecraft.data.recipes.ShapedRecipeBuilder;
|
|
||||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraftforge.common.Tags;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.ModItems;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class RecipesGenerator extends RecipeProvider {
|
|
||||||
public RecipesGenerator(DataGenerator generator) {
|
|
||||||
super(generator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buildCraftingRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
|
|
||||||
ShapedRecipeBuilder.shaped(ModBlocks.SCRAPING_STATION.get())
|
|
||||||
.pattern("s s")
|
|
||||||
.pattern("sos")
|
|
||||||
.pattern("lll")
|
|
||||||
.define('s', Items.STICK)
|
|
||||||
.define('o', Tags.Items.OBSIDIAN)
|
|
||||||
.define('l', Items.SMOOTH_QUARTZ_SLAB)
|
|
||||||
.unlockedBy("created_enchanting_table", InventoryChangeTrigger.TriggerInstance.hasItems(Items.ENCHANTING_TABLE))
|
|
||||||
.save(consumer);
|
|
||||||
|
|
||||||
ShapedRecipeBuilder.shaped(ModItems.IRON_SCRAPER_ITEM.get())
|
|
||||||
.pattern(" m ")
|
|
||||||
.pattern("msm")
|
|
||||||
.pattern(" m ")
|
|
||||||
.define('m', Items.IRON_INGOT)
|
|
||||||
.define('s', Items.STICK)
|
|
||||||
.unlockedBy("created_scraper", InventoryChangeTrigger.TriggerInstance.hasItems(ModBlocks.SCRAPING_STATION.get()))
|
|
||||||
.save(consumer);
|
|
||||||
|
|
||||||
ShapedRecipeBuilder.shaped(ModItems.DIAMOND_SCRAPER_ITEM.get())
|
|
||||||
.pattern(" m ")
|
|
||||||
.pattern("msm")
|
|
||||||
.pattern(" m ")
|
|
||||||
.define('m', Items.DIAMOND)
|
|
||||||
.define('s', Items.STICK)
|
|
||||||
.unlockedBy("created_scraper", InventoryChangeTrigger.TriggerInstance.hasItems(ModBlocks.SCRAPING_STATION.get()))
|
|
||||||
.save(consumer);
|
|
||||||
|
|
||||||
ShapedRecipeBuilder.shaped(ModItems.OBSIDIAN_SCRAPER_ITEM.get())
|
|
||||||
.pattern(" m ")
|
|
||||||
.pattern("msm")
|
|
||||||
.pattern(" m ")
|
|
||||||
.define('m', Items.OBSIDIAN)
|
|
||||||
.define('s', Items.STICK)
|
|
||||||
.unlockedBy("created_scraper", InventoryChangeTrigger.TriggerInstance.hasItems(ModBlocks.SCRAPING_STATION.get()))
|
|
||||||
.save(consumer);
|
|
||||||
|
|
||||||
ShapedRecipeBuilder.shaped(ModItems.NETHERITE_SCRAPER_ITEM.get())
|
|
||||||
.pattern(" m ")
|
|
||||||
.pattern("msm")
|
|
||||||
.pattern(" m ")
|
|
||||||
.define('m', Items.NETHERITE_SCRAP)
|
|
||||||
.define('s', Items.STICK)
|
|
||||||
.unlockedBy("created_scraper", InventoryChangeTrigger.TriggerInstance.hasItems(ModBlocks.SCRAPING_STATION.get()))
|
|
||||||
.save(consumer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.datagen;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraft.data.tags.BlockTagsProvider;
|
|
||||||
import net.minecraft.data.tags.ItemTagsProvider;
|
|
||||||
import net.minecraft.data.tags.TagsProvider;
|
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.ModTags;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.ModItems;
|
|
||||||
|
|
||||||
public class TagsGenerator {
|
|
||||||
public static class ItemTags extends ItemTagsProvider {
|
|
||||||
public ItemTags(DataGenerator generator, BlockTagsProvider blockTagsProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
|
||||||
super(generator, blockTagsProvider, EnchantmentScraping.MOD_ID, existingFileHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addTags() {
|
|
||||||
tag(ModTags.Items.SCRAPER_ITEM)
|
|
||||||
.add(ModItems.IRON_SCRAPER_ITEM.get())
|
|
||||||
.add(ModItems.DIAMOND_SCRAPER_ITEM.get())
|
|
||||||
.add(ModItems.OBSIDIAN_SCRAPER_ITEM.get())
|
|
||||||
.add(ModItems.NETHERITE_SCRAPER_ITEM.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class BlockTags extends BlockTagsProvider {
|
|
||||||
public BlockTags(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
|
|
||||||
super(generator, EnchantmentScraping.MOD_ID, existingFileHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addTags() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.item;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.Rarity;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.custom.ScraperItem;
|
|
||||||
import xyz.nuark.enchantmentscraping.setup.ModSetup;
|
|
||||||
|
|
||||||
public class ModItems {
|
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, EnchantmentScraping.MOD_ID);
|
|
||||||
|
|
||||||
public static final RegistryObject<Item> SCRAPING_STATION_ITEM = fromBlock(ModBlocks.SCRAPING_STATION);
|
|
||||||
public static final RegistryObject<Item> IRON_SCRAPER_ITEM = createScraper("iron_scraper", 5, Rarity.COMMON, 0.25f);
|
|
||||||
public static final RegistryObject<Item> DIAMOND_SCRAPER_ITEM = createScraper("diamond_scraper", 40, Rarity.UNCOMMON, 0.4f);
|
|
||||||
public static final RegistryObject<Item> OBSIDIAN_SCRAPER_ITEM = createScraper("obsidian_scraper", 60, Rarity.RARE, 0.55f);
|
|
||||||
public static final RegistryObject<Item> NETHERITE_SCRAPER_ITEM = createScraper("netherite_scraper", 120, Rarity.EPIC, 0.7f);
|
|
||||||
|
|
||||||
public static void register(IEventBus eventBus) {
|
|
||||||
ITEMS.register(eventBus);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <B extends Block> RegistryObject<Item> fromBlock(RegistryObject<B> block) {
|
|
||||||
return ITEMS.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties().tab(ModSetup.ITEM_GROUP)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <I extends Item> RegistryObject<Item> createScraper(String name, int durability, Rarity rarity, float scrapingChance) {
|
|
||||||
return ITEMS.register(name, () -> new ScraperItem(durability, rarity, scrapingChance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.item.custom;
|
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.Rarity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import xyz.nuark.enchantmentscraping.setup.ModSetup;
|
|
||||||
|
|
||||||
public class ScraperItem extends Item {
|
|
||||||
private final float scrapingChance;
|
|
||||||
|
|
||||||
public ScraperItem(int durability, Rarity rarity, float scrapingChance) {
|
|
||||||
super(new Item.Properties().tab(ModSetup.ITEM_GROUP).durability(durability).rarity(rarity));
|
|
||||||
this.scrapingChance = scrapingChance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScrapingChance() {
|
|
||||||
return scrapingChance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Component getDescription() {
|
|
||||||
return new TextComponent("Scraping chance: " + (int)(scrapingChance * 100) + "%");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.screen;
|
|
||||||
|
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
||||||
import net.minecraft.world.inventory.MenuType;
|
|
||||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.network.IContainerFactory;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
|
|
||||||
public class ModMenuTypes {
|
|
||||||
public static final DeferredRegister<MenuType<?>> MENUS =
|
|
||||||
DeferredRegister.create(ForgeRegistries.CONTAINERS, EnchantmentScraping.MOD_ID);
|
|
||||||
|
|
||||||
public static final RegistryObject<MenuType<ScrapingStationMenu>> SCRAPING_STATION_MENU = registerMenuType(
|
|
||||||
ScrapingStationMenu::new, "enchanter_menu"
|
|
||||||
);
|
|
||||||
|
|
||||||
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name) {
|
|
||||||
return MENUS.register(name, () -> IForgeMenuType.create(factory));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void register(IEventBus eventBus) {
|
|
||||||
MENUS.register(eventBus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.screen;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.inventory.*;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraftforge.common.Tags;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import xyz.nuark.enchantmentscraping.ModTags;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.entity.custom.ScrapingStationBlockEntity;
|
|
||||||
import xyz.nuark.enchantmentscraping.screen.slot.FilteredSlot;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ScrapingStationMenu extends AbstractContainerMenu {
|
|
||||||
private final ScrapingStationBlockEntity blockEntity;
|
|
||||||
private final Level level;
|
|
||||||
private final ContainerData scrapingStationData;
|
|
||||||
|
|
||||||
public ScrapingStationMenu(int containerId, Inventory inv, FriendlyByteBuf extraData) {
|
|
||||||
this(containerId, inv, inv.player.level.getBlockEntity(extraData.readBlockPos()), new SimpleContainerData(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScrapingStationMenu(int containerId, Inventory inv, BlockEntity entity, ContainerData scrapingStationData) {
|
|
||||||
super(ModMenuTypes.SCRAPING_STATION_MENU.get(), containerId);
|
|
||||||
checkContainerSize(inv, 4);
|
|
||||||
blockEntity = ((ScrapingStationBlockEntity) entity);
|
|
||||||
this.level = inv.player.level;
|
|
||||||
this.scrapingStationData = scrapingStationData;
|
|
||||||
|
|
||||||
addPlayerInventory(inv);
|
|
||||||
addPlayerHotbar(inv);
|
|
||||||
|
|
||||||
this.blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(handler -> {
|
|
||||||
this.addSlot(new FilteredSlot(
|
|
||||||
handler, 0, 49, 23,
|
|
||||||
ItemStack::isEnchanted
|
|
||||||
));
|
|
||||||
this.addSlot(new FilteredSlot(
|
|
||||||
handler, 1, 49, 44,
|
|
||||||
stack -> stack.is(Items.BOOK)
|
|
||||||
));
|
|
||||||
this.addSlot(new FilteredSlot(
|
|
||||||
handler, 2, 89, 34,
|
|
||||||
stack -> stack.is(ModTags.Items.SCRAPER_ITEM)
|
|
||||||
));
|
|
||||||
this.addSlot(new FilteredSlot(
|
|
||||||
handler, 3, 129, 34,
|
|
||||||
stack -> false
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
addDataSlots(this.scrapingStationData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stillValid(@NotNull Player player) {
|
|
||||||
return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), player, ModBlocks.SCRAPING_STATION.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCraftingTicker() {
|
|
||||||
return scrapingStationData.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPlayerInventory(Inventory playerInventory) {
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
for (int j = 0; j < 9; j++) {
|
|
||||||
addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPlayerHotbar(Inventory playerInventory) {
|
|
||||||
for (int i = 0; i < 9; i++) {
|
|
||||||
addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
|
||||||
// must assign a slot number to each of the slots used by the GUI.
|
|
||||||
// For this container, we can see both the tile inventory's slots and the player inventory slots and the hotbar.
|
|
||||||
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
|
||||||
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
|
||||||
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
|
||||||
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
|
||||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
|
||||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
|
||||||
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
|
||||||
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
|
||||||
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
|
||||||
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
|
||||||
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
|
||||||
|
|
||||||
// THIS YOU HAVE TO DEFINE!
|
|
||||||
private static final int TE_INVENTORY_SLOT_COUNT = 4; // must be the number of slots you have!
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ItemStack quickMoveStack(@NotNull Player playerIn, int index) {
|
|
||||||
Slot sourceSlot = slots.get(index);
|
|
||||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
|
||||||
ItemStack sourceStack = sourceSlot.getItem();
|
|
||||||
ItemStack copyOfSourceStack = sourceStack.copy();
|
|
||||||
|
|
||||||
// Check if the slot clicked is one of the vanilla container slots
|
|
||||||
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
|
||||||
// This is a vanilla container slot so merge the stack into the tile inventory
|
|
||||||
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
|
||||||
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
|
||||||
return ItemStack.EMPTY; // EMPTY_ITEM
|
|
||||||
}
|
|
||||||
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
|
||||||
// This is a TE slot so merge the stack into the players inventory
|
|
||||||
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("Invalid slotIndex:" + index);
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
|
||||||
if (sourceStack.getCount() == 0) {
|
|
||||||
sourceSlot.set(ItemStack.EMPTY);
|
|
||||||
} else {
|
|
||||||
sourceSlot.setChanged();
|
|
||||||
}
|
|
||||||
sourceSlot.onTake(playerIn, sourceStack);
|
|
||||||
return copyOfSourceStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.screen;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import org.apache.commons.compress.utils.Lists;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.ModTags;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.custom.ScraperItem;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class ScrapingStationScreen extends AbstractContainerScreen<ScrapingStationMenu> {
|
|
||||||
private static final ResourceLocation TEXTURE =
|
|
||||||
new ResourceLocation(EnchantmentScraping.MOD_ID, "textures/gui/scraping_station_gui.png");
|
|
||||||
|
|
||||||
public ScrapingStationScreen(ScrapingStationMenu scrapingStationMenu, Inventory inventory, Component title) {
|
|
||||||
super(scrapingStationMenu, inventory, title);
|
|
||||||
|
|
||||||
imageWidth = 176;
|
|
||||||
imageHeight = 166;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderBg(@NotNull PoseStack pPoseStack, float pPartialTick, int pMouseX, int pMouseY) {
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
|
||||||
int x = (width - imageWidth) / 2;
|
|
||||||
int y = (height - imageHeight) / 2;
|
|
||||||
|
|
||||||
this.blit(pPoseStack, x, y, 0, 0, imageWidth, imageHeight);
|
|
||||||
|
|
||||||
int progress = (int) (40f * ((float) menu.getCraftingTicker() / 200f));
|
|
||||||
if (progress > 0) {
|
|
||||||
this.blit(pPoseStack, x + 77, y + 33, 176, 0, progress, 18);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderLabels(@NotNull PoseStack pPoseStack, int pMouseX, int pMouseY) {
|
|
||||||
this.font.draw(pPoseStack, this.title, (float) this.titleLabelX, (float) this.titleLabelY, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(@NotNull PoseStack pPoseStack, int mouseX, int mouseY, float delta) {
|
|
||||||
renderBackground(pPoseStack);
|
|
||||||
super.render(pPoseStack, mouseX, mouseY, delta);
|
|
||||||
if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null && hoveredSlot.hasItem() && hoveredSlot.getItem().is(ModTags.Items.SCRAPER_ITEM)) {
|
|
||||||
List<Component> componentList = getTooltipFromItem(hoveredSlot.getItem());
|
|
||||||
componentList.add(hoveredSlot.getItem().getItem().getDescription());
|
|
||||||
renderTooltip(pPoseStack, componentList, Optional.empty(), mouseX, mouseY);
|
|
||||||
} else {
|
|
||||||
renderTooltip(pPoseStack, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.screen.slot;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class FilteredSlot extends SlotItemHandler {
|
|
||||||
Predicate<ItemStack> filter;
|
|
||||||
|
|
||||||
public FilteredSlot(IItemHandler itemHandler, int index, int xPosition, int yPosition, Predicate<ItemStack> filter) {
|
|
||||||
super(itemHandler, index, xPosition, yPosition);
|
|
||||||
this.filter = filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mayPlace(@NotNull ItemStack stack) {
|
|
||||||
return filter.test(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.screen.widget;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
|
||||||
import net.minecraft.client.gui.components.Widget;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public class Label implements Widget {
|
|
||||||
private Component text;
|
|
||||||
private final int x;
|
|
||||||
private final int y;
|
|
||||||
private final int color;
|
|
||||||
private final boolean centered;
|
|
||||||
|
|
||||||
public Label(Component p_120736_, int p_120737_, int p_120738_, int p_120739_, boolean centered) {
|
|
||||||
this.text = p_120736_.copy();
|
|
||||||
this.x = p_120737_;
|
|
||||||
this.y = p_120738_;
|
|
||||||
this.color = p_120739_;
|
|
||||||
this.centered = centered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
|
|
||||||
if (centered) {
|
|
||||||
GuiComponent.drawCenteredString(poseStack, Minecraft.getInstance().font, this.text, this.x, this.y, this.color);
|
|
||||||
} else {
|
|
||||||
GuiComponent.drawString(poseStack, Minecraft.getInstance().font, this.text, this.x, this.y, this.color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(Component p_175041_) {
|
|
||||||
this.text = p_175041_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getText() {
|
|
||||||
return this.text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.setup;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.MenuScreens;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|
||||||
import xyz.nuark.enchantmentscraping.screen.ModMenuTypes;
|
|
||||||
import xyz.nuark.enchantmentscraping.screen.ScrapingStationScreen;
|
|
||||||
|
|
||||||
public class ClientSetup {
|
|
||||||
public static void init(final FMLClientSetupEvent event) {
|
|
||||||
event.enqueueWork(() -> {
|
|
||||||
MenuScreens.register(ModMenuTypes.SCRAPING_STATION_MENU.get(), ScrapingStationScreen::new);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.setup;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import xyz.nuark.enchantmentscraping.EnchantmentScraping;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.ModItems;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = EnchantmentScraping.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public class ModSetup {
|
|
||||||
public static final CreativeModeTab ITEM_GROUP = new CreativeModeTab(EnchantmentScraping.MOD_ID) {
|
|
||||||
@Override
|
|
||||||
public @NotNull ItemStack makeIcon() {
|
|
||||||
return new ItemStack(ModItems.SCRAPING_STATION_ITEM.get());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void setup() {
|
|
||||||
IEventBus bus = MinecraftForge.EVENT_BUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(FMLCommonSetupEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package xyz.nuark.enchantmentscraping.setup;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.ModBlocks;
|
|
||||||
import xyz.nuark.enchantmentscraping.block.entity.ModBlockEntities;
|
|
||||||
import xyz.nuark.enchantmentscraping.item.ModItems;
|
|
||||||
import xyz.nuark.enchantmentscraping.screen.ModMenuTypes;
|
|
||||||
|
|
||||||
public class Registration {
|
|
||||||
public static void register(IEventBus eventBus) {
|
|
||||||
ModItems.register(eventBus);
|
|
||||||
ModBlocks.register(eventBus);
|
|
||||||
ModBlockEntities.register(eventBus);
|
|
||||||
ModMenuTypes.register(eventBus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -19,7 +19,7 @@ modId = "enchantmentscraping" #mandatory
|
||||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||||
version = "1.0.0" #mandatory
|
version = "${file.jarVersion}" #mandatory
|
||||||
# A display name for the mod
|
# A display name for the mod
|
||||||
displayName = "Enchantmentscraping" #mandatory
|
displayName = "Enchantmentscraping" #mandatory
|
||||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||||
|
|
@ -34,7 +34,7 @@ displayName = "Enchantmentscraping" #mandatory
|
||||||
authors = "nuark" #optional
|
authors = "nuark" #optional
|
||||||
# The description text for the mod (multi line!) (#mandatory)
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
description = '''
|
description = '''
|
||||||
This mod allows you to scrape enchantments from items to books with help of scraping instruments
|
This mod allows you to scrape enchantments from items to books with help of instruments
|
||||||
'''
|
'''
|
||||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
[[dependencies.enchantmentscraping]] #optional
|
[[dependencies.enchantmentscraping]] #optional
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"variants": {
|
|
||||||
"facing=east": {
|
|
||||||
"model": "enchantmentscraping:block/scraping_station"
|
|
||||||
},
|
|
||||||
"facing=north": {
|
|
||||||
"model": "enchantmentscraping:block/scraping_station",
|
|
||||||
"y": 90
|
|
||||||
},
|
|
||||||
"facing=south": {
|
|
||||||
"model": "enchantmentscraping:block/scraping_station",
|
|
||||||
"y": 270
|
|
||||||
},
|
|
||||||
"facing=west": {
|
|
||||||
"model": "enchantmentscraping:block/scraping_station",
|
|
||||||
"y": 180
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
{
|
|
||||||
"credit": "Made with Blockbench",
|
|
||||||
"textures": {
|
|
||||||
"0": "enchantmentscraping:block/scraping_station",
|
|
||||||
"1": "enchantmentscraping:block/scraping_station_rod",
|
|
||||||
"2": "enchantmentscraping:block/scraping_station_blade",
|
|
||||||
"particle": "enchantmentscraping:block/scraping_station"
|
|
||||||
},
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"from": [0, 0, 0],
|
|
||||||
"to": [16, 6, 16],
|
|
||||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 3, 8]},
|
|
||||||
"faces": {
|
|
||||||
"north": {"uv": [0, 0, 16, 6], "texture": "#0"},
|
|
||||||
"east": {"uv": [1, 0, 15, 16], "texture": "#0"},
|
|
||||||
"south": {"uv": [1, 0, 15, 16], "texture": "#0"},
|
|
||||||
"west": {"uv": [1, 0, 15, 16], "texture": "#0"},
|
|
||||||
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
|
|
||||||
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"from": [7, 6, 1],
|
|
||||||
"to": [9, 13, 3],
|
|
||||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 9.5, 2]},
|
|
||||||
"faces": {
|
|
||||||
"north": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"east": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"south": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"west": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"up": {"uv": [6, 0, 12, 6], "texture": "#1"},
|
|
||||||
"down": {"uv": [6, 0, 12, 6], "texture": "#1"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"from": [7, 6, 13],
|
|
||||||
"to": [9, 13, 15],
|
|
||||||
"faces": {
|
|
||||||
"north": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"east": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"south": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"west": {"uv": [0, 0, 6, 16], "texture": "#1"},
|
|
||||||
"up": {"uv": [6, 0, 12, 6], "texture": "#1"},
|
|
||||||
"down": {"uv": [6, 0, 12, 6], "texture": "#1"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"from": [8, 9, 3],
|
|
||||||
"to": [8, 12, 13],
|
|
||||||
"faces": {
|
|
||||||
"north": {"uv": [0, 0, 0, 3], "texture": "#2"},
|
|
||||||
"east": {"uv": [0, 0, 6, 1], "texture": "#2"},
|
|
||||||
"south": {"uv": [0, 0, 0, 3], "texture": "#2"},
|
|
||||||
"west": {"uv": [0, 0, 6, 1], "texture": "#2"},
|
|
||||||
"up": {"uv": [0, 0, 0, 10], "texture": "#2"},
|
|
||||||
"down": {"uv": [0, 0, 0, 10], "texture": "#2"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"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]
|
|
||||||
},
|
|
||||||
"head": {
|
|
||||||
"rotation": [0, 180, 0],
|
|
||||||
"translation": [0, 13, 7]
|
|
||||||
},
|
|
||||||
"fixed": {
|
|
||||||
"scale": [0.5, 0.5, 0.5]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 108 B |
|
Before Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 155 B |
|
Before Width: | Height: | Size: 1,008 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 212 B |