diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..9590f0c --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,199 @@ + plugins { + alias(libs.plugins.loom) + java +} + +val lwjglNatives = resolveLwjglNatives() + +val modVersion = "${providers.gradleProperty("mod_version").get()}+${libs.versions.bta.get()}" +val modGroup: Provider = providers.gradleProperty("mod_group") +val modName: Provider = providers.gradleProperty("mod_name") + +val javaVersion: Provider = libs.versions.java.map { it.toInt() } + +base.archivesName = modName +group = modGroup.get() +version = modVersion +loom { + val btaChannel = libs.versions.btaChannel.get() + val btaVersion = (if (btaChannel == "nightly") "" else "v") + libs.versions.bta.get() + customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${btaChannel}/$btaVersion/manifest.json") +} +repositories { + mavenCentral() + ivy("https://piston-data.mojang.com") { + patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") } + metadataSources { artifact() } + } + maven("https://maven.fabricmc.net/") { name = "Fabric" } + maven("https://maven.danygames2014.net/signalum") { name = "SignalumMavenMirror1" } + maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" } + maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" } + maven("https://maven.thesignalumproject.net/nightly") { name = "SignalumMavenNightly" } + maven("https://api.modrinth.com/maven") { name = "Modrinth" + content { + includeGroup("maven.modrinth") + } + } +} +dependencies { + minecraft("::${libs.versions.bta.get()}") + + // Required at compilation & runtime + // included in builds as a runtime dependency + implementation(libs.loader) + implementation(libs.halplibe) // If you do not need halplibe you can delete this line + + //-Dmixin.debug.export=true mixin flag + + compileOnly(libs.btabackpacks) + compileOnly(libs.paxels) + compileOnly(libs.commandly) + + // for later +// compileOnly(libs.aether) + + + // Only required at compilation + // provides documentation, can be removed if that isn't needed + compileOnly(libs.bundles.btaLwjgl) + compileOnly(libs.joml) + compileOnly(libs.joml.primitives) + compileOnly(libs.slf4jApi) + + // Only required for development/launch at runtime, won't be part of any builds + localRuntime(libs.modMenu) // Optional, can be removed + runtimeClasspath(libs.clientJar) + val lwjglVer = libs.versions.lwjgl.get() + localRuntime(platform("org.lwjgl:lwjgl-bom:${lwjglVer}")) + localRuntime("org.lwjgl:lwjgl::$lwjglNatives") + localRuntime("org.lwjgl:lwjgl-glfw::$lwjglNatives") + localRuntime("org.lwjgl:lwjgl-openal::$lwjglNatives") + localRuntime("org.lwjgl:lwjgl-opengl::$lwjglNatives") + localRuntime("org.lwjgl:lwjgl-stb::$lwjglNatives") +} +java { + toolchain { + languageVersion = javaVersion.map { JavaLanguageVersion.of(it) } + vendor = JvmVendorSpec.ADOPTIUM + } + sourceCompatibility = JavaVersion.toVersion(javaVersion.get()) + targetCompatibility = JavaVersion.toVersion(javaVersion.get()) + withSourcesJar() +} +val licenseFile = run { + val rootLicense = layout.projectDirectory.file("LICENSE") + val parentLicense = layout.projectDirectory.file("../LICENSE") + when { + rootLicense.asFile.exists() -> { + logger.lifecycle("Using LICENSE from project root: {}", rootLicense.asFile) + rootLicense + } + parentLicense.asFile.exists() -> { + logger.lifecycle("Using LICENSE from parent directory: {}", parentLicense.asFile) + parentLicense + } + else -> { + logger.warn("No LICENSE file found in project or parent directory.") + null + } + } +} +tasks { + withType().configureEach { + options.encoding = "UTF-8" + sourceCompatibility = javaVersion.get().toString() + targetCompatibility = javaVersion.get().toString() + if (javaVersion.get() > 8) options.release = javaVersion + } + named("updateDaemonJvm") { + languageVersion = libs.versions.gradleJava.map { JavaLanguageVersion.of(it.toInt()) } + vendor = JvmVendorSpec.ADOPTIUM + } + withType().configureEach { defaultCharacterEncoding = "UTF-8" } + withType().configureEach { options.encoding = "UTF-8" } + withType().configureEach { defaultCharacterEncoding = "UTF-8" } + withType().configureEach { + licenseFile?.let { + from(it) { + rename { original -> "${original}_${archiveBaseName.get()}" } + } + } + } + processResources { + val resourceMap = mapOf( + "version" to modVersion, + "fabricloader" to libs.versions.loader.get(), + "halplibe" to libs.versions.halplibe.get(), + "java" to libs.versions.java.get(), + "modmenu" to libs.versions.modMenu.get() + ) + // This is needed for gradle to recognize changes + // made to expanded files + inputs.properties(resourceMap) + + duplicatesStrategy = DuplicatesStrategy.INCLUDE + with(copySpec { + from("src/main/resources/") { + include("fabric.mod.json") + include("*.mixins.json") + expand(resourceMap) + } + }) + } +} +// Removes all outdated manifest.json dependencies +configurations.configureEach { + exclude(group = "org.lwjgl.lwjgl") + exclude(group = "net.java.jutils") + exclude(group = "net.java.jinput") + exclude(group = "net.sf.jopt-simple") + exclude(group = "net.minecraft", module = "launchwrapper") +} + +// not sure about this, so this is useless exclusive +//publishing { +// repositories { +// maven { +// name = "signalumMaven" +// url = "https://maven.thesignalumproject.net/releases" +// credentials(PasswordCredentials) +// authentication { +// basic(BasicAuthentication) +// } +// } +// } +// +// publications { +// maven(MavenPublication) { +// groupId = project.mod_group +// artifactId = project.mod_name +// version = project.mod_version +// from components.java +// } +// } +//} + +fun resolveLwjglNatives(): String { // Sourced from https://www.lwjgl.org/ + return Pair( + System.getProperty("os.name")!!, + System.getProperty("os.arch")!! + ).let { (name, arch) -> + when { + arrayOf("Linux", "SunOS", "Unit").any { name.startsWith(it) } -> + if (arrayOf("arm", "aarch64").any { arch.startsWith(it) }) + "natives-linux${if (arch.contains("64") || arch.startsWith("armv8")) "-arm64" else "-arm32"}" + else + "natives-linux" + arrayOf("Mac OS X", "Darwin").any { name.startsWith(it) } -> + "natives-macos${if (arch.startsWith("aarch64")) "-arm64" else ""}" + arrayOf("Windows").any { name.startsWith(it) } -> + if (arch.contains("64")) + "natives-windows${if (arch.startsWith("aarch64")) "-arm64" else ""}" + else + "natives-windows-x86" + else -> + throw Error("Unrecognized or unsupported platform. Please set \"lwjglNatives\" manually") + } + } +} diff --git a/gradle.properties b/gradle.properties index 94b9234..09abd50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,18 @@ -org.gradle.jvmargs=-Xmx2G -org.gradle.parallel = true -org.gradle.daemon = true -fabric.loom.multiProjectOptimisation=true - -# BTA -bta_version=7.3_03 -bta_channel=release - -# Loader -loader_version=0.15.6-bta.7 - -# Other Mods -mod_menu_version=3.0.0 -halplibe_version=5.2.4 - -# Mod -mod_version=1.1.0-7.3_03 +########################################################################## +# Standard Properties +org.gradle.jvmargs = -Xmx2G +org.gradle.warning.mode = all +# This currently has to be set to false because the "Minecraft Client" and "Minecraft Server" configurations generated +# by IntelliJ aren't currently compatible with the configuration cache. If you use the runClient and runServer Gradle +# tasks instead, then this can (and should) be set to true. +org.gradle.configuration-cache = false +########################################################################## +# Mod Properties +mod_version=1.1.2 mod_group=useless mod_name=moonsteel +########################################################################## +# Plugin Dependency +# Check this on https://plugins.gradle.org/plugin/org.gradle.toolchains.foojay-resolver-convention/ +foojay_resolver_version = 1.0.0 +########################################################################## diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties new file mode 100644 index 0000000..e409a46 --- /dev/null +++ b/gradle/gradle-daemon-jvm.properties @@ -0,0 +1,13 @@ +#This file is generated by updateDaemonJvm +toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect +toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect +toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect +toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect +toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect +toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect +toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect +toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect +toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect +toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect +toolchainVendor=ADOPTIUM +toolchainVersion=21 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..5c71e94 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,62 @@ +[versions] +########################################################################## +# Plugins +# Check this on https://github.com/FabricMC/fabric-loom/releases/latest/ +loom = "1.15-SNAPSHOT" +########################################################################## +# Java Configuration +# The Java version the JDK will be for compiling and running code. +java = "17" +# The Java version the JDK will be for running Gradle. +gradleJava = "21" +##########################################################################EEE +# Mod Dependencies +# Check this on https://downloads.betterthanadventure.net/bta-client/ +bta = "8.0.1" +# Options are release, prerelease, nightly, and misc. +btaChannel = "release" +# Check this on https://maven.thesignalumproject.net/#/infrastructure/net/fabricmc/fabric-loader/ +loader = "0.18.4-bta.11" +# Check this on https://github.com/Turnip-Labs/ModMenu/releases/latest/ +modMenu = "5.0.2" +# Check this on https://github.com/Turnip-Labs/bta-halplibe/releases/latest/ +halplibe = "6.2.0+8.0.1" +# Check this on https://github.com/Better-than-Adventure/legacy-lwjgl3/releases/latest/ +legacyLwjgl = "1.0.6" +########################################################################## +# Dependencies +# Check this on https://central.sonatype.com/artifact/org.slf4j/slf4j-api/ +slf4jApi = "2.0.17" +# This should match the version used by the current BTA release. +lwjgl = "3.3.3" +joml = "1.10.8" # Note: BTA uses 1.10.7, patch 8 removes the kotlin stdlib dependency +jomlPrimitivess = "1.10.0" +commandly = "1.1.6+8.0.1" +paxels = "1.5.0+8.0.1" +btabackpacks = "1.2.0-8.0" +########################################################################## + +[libraries] +btabackpacks = { group = "maven.modrinth", name = "better-with-backpacks", version.ref = "btabackpacks" } +loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "loader" } +halplibe = { group = "turniplabs", name = "halplibe", version.ref = "halplibe" } +modMenu = { group = "turniplabs", name = "modmenu-bta", version.ref = "modMenu" } +legacyLwjgl = { group = "com.github.Better-than-Adventure", name = "legacy-lwjgl3", version.ref = "legacyLwjgl" } +slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4jApi" } +commandly = { group = "maven.modrinth", name = "commandly", version.ref = "commandly" } +paxels = { group = "maven.modrinth", name = "paxels-bta", version.ref = "paxels" } +# https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar +clientJar = { group = "objects", name = "client", version = "43db9b498cb67058d2e12d394e6507722e71bb45" } +joml = { group = "org.joml", name = "joml", version.ref = "joml" } +joml-primitives = { group = "org.joml", name = "joml-primitives", version.ref = "jomlPrimitivess" } +lwjgl = { group = "org.lwjgl", name = "lwjgl", version.ref = "lwjgl"} +lwjgl-glfw = { group = "org.lwjgl", name = "lwjgl-glfw", version.ref = "lwjgl"} +lwjgl-openal = { group = "org.lwjgl", name = "lwjgl-openal", version.ref = "lwjgl"} +lwjgl-opengl = { group = "org.lwjgl", name = "lwjgl-opengl", version.ref = "lwjgl"} +lwjgl-stb = { group = "org.lwjgl", name = "lwjgl-stb", version.ref = "lwjgl"} + +[bundles] +btaLwjgl = [ "lwjgl", "lwjgl-glfw", "lwjgl-openal", "lwjgl-opengl", "lwjgl-stb", "legacyLwjgl" ] + +[plugins] +loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..8bdaf60 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d6e308a..56fd94f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,8 @@ +# Check this on https://gradle.org/releases/ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/useless/moonsteel/MoonSteel.java b/src/main/java/useless/moonsteel/MoonSteel.java index dda0a95..fc06e85 100644 --- a/src/main/java/useless/moonsteel/MoonSteel.java +++ b/src/main/java/useless/moonsteel/MoonSteel.java @@ -1,33 +1,50 @@ package useless.moonsteel; import net.fabricmc.api.ModInitializer; -import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.core.block.Blocks; +import net.minecraft.core.block.entity.TileEntityDispatcher; +import net.minecraft.core.item.IItemConvertible; import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.Items; import net.minecraft.core.sound.SoundTypes; import net.minecraft.core.util.collection.NamespaceID; import net.minecraft.core.world.World; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import tosutosu.betterwithbackpacks.ModItems; -import turniplabs.halplibe.helper.CreativeHelper; -import turniplabs.halplibe.helper.EntityHelper; +import org.jetbrains.annotations.NotNull; +import turniplabs.halplibe.HalpLibe; +import turniplabs.halplibe.event.defs.CommonEvents; +import turniplabs.halplibe.helper.creativeInventory.CreativeInventoryCategory; +import turniplabs.halplibe.helper.creativeInventory.CreativeInventoryPlacement; +import turniplabs.halplibe.helper.creativeInventory.CreativeInventoryRegistry; import turniplabs.halplibe.util.ConfigHandler; -import turniplabs.halplibe.util.GameStartEntrypoint; -import useless.moonsteel.block.TileEntityStellarRewinder; +import turniplabs.halplibe.util.dependency.Key; +import useless.moonsteel.api.MoonSteelCompat; +import useless.moonsteel.block.MoonSteelBlocks; +import useless.moonsteel.block.rewinder.TileEntityStellarRewinder; +import useless.moonsteel.item.MoonSteelItems; +import useless.moonsteel.recipe.MoonSteelRecipes; import java.util.Properties; +import java.util.function.Supplier; +import static useless.moonsteel.block.MoonSteelBlocks.*; +import static useless.moonsteel.item.MoonSteelItems.*; -public class MoonSteel implements ModInitializer, GameStartEntrypoint { - public static final String MOD_ID = "moonsteel"; - public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - public static boolean backpackPresent = FabricLoader.getInstance().isModLoaded("betterwithbackpacks"); + +public class MoonSteel implements ModInitializer { + public static final String MOD_ID = HalpLibe.registerMod(MoonSteelConstants.MOD_ID); + public static final Key KEY = Key.of(MOD_ID); + public static final String STAR = "moonsteel$star"; + public static final String SMOKE = "moonsteel$magic_smoke"; + // Settings public static int blockId; public static int itemId; public static int GUI_ID; public static int FORTUNE_AMOUNT; public static int LOOTING_AMOUNT; public static int STAR_SPAWN_RATE; + public static ItemStack starZombieSword; + public static boolean forceChunkLoads = false; + static { final Properties prop = new Properties(); prop.setProperty("starting_block_id","6700"); @@ -48,31 +65,63 @@ public class MoonSteel implements ModInitializer, GameStartEntrypoint { config.updateConfig(); } - public static ItemStack starZombieSword; - public static boolean forceChunkLoads = false; @Override public void onInitialize() { - LOGGER.info("MoonSteel initialized."); + MoonSteelConstants.LOGGER.info("MoonSteel initialized."); + CommonEvents.BEFORE_GAME_START.listen(KEY, this::beforeGameStart); + CommonEvents.RECIPES_READY.listen(KEY, MoonSteelRecipes::onRecipesReady); + CommonEvents.RECIPES_NAMESPACE_INIT.listen(KEY, MoonSteelRecipes::initNamespaces); + MoonSteelCompat.init(); } - @Override public void beforeGameStart() { SoundTypes.loadSoundsJson(MOD_ID); - EntityHelper.createTileEntity(TileEntityStellarRewinder.class, NamespaceID.getPermanent(MOD_ID, "moonsteel$stellar_rewinder"), "moonsteel$stellar_rewinder"); + TileEntityDispatcher.addMapping( + TileEntityStellarRewinder.class, + NamespaceID.fromPool(MOD_ID, "moonsteel$stellar_rewinder") + ); MoonSteelBlocks.init(); MoonSteelItems.init(); - if (backpackPresent){ - CreativeHelper.setParent(MoonSteelItems.BACKPACK_COSMIC.getDefaultStack(), ModItems.diamondBackpack.getDefaultStack()); + // blocks + CreativeInventoryRegistry.INSTANCE.register(BLOCK_MOONSTEEL, place(() -> Blocks.BLOCK_OLIVINE)); + CreativeInventoryRegistry.INSTANCE.register(TORCH_STAR, place(() -> Blocks.TORCH_COAL)); + CreativeInventoryRegistry.INSTANCE.register(STELLAR_REWINDER, place()); + CreativeInventoryRegistry.INSTANCE.register(STAR_LAMP, place(() -> Blocks.TORCH_COAL)); + CreativeInventoryRegistry.INSTANCE.register(STAR_JAR, place(() -> Items.LANTERN_FIREFLY_RED)); + CreativeInventoryRegistry.INSTANCE.register(MOONSTEEL_BRICKS, place(() -> Blocks.SLAB_BRICK_RUBYGLASS)); + CreativeInventoryRegistry.INSTANCE.register(SLAB_MOONSTEEL_BRICK, place(() -> Blocks.SLAB_BRICK_RUBYGLASS)); + CreativeInventoryRegistry.INSTANCE.register(STAIR_MOONSTEEL_BRICKS, place(() -> Blocks.SLAB_BRICK_RUBYGLASS)); + // items + CreativeInventoryRegistry.INSTANCE.register(INGOT_MOONSTEEL_CRUDE, place(() -> Items.INGOT_STEEL_CRUDE)); + CreativeInventoryRegistry.INSTANCE.register(INGOT_MOONSTEEL, place(() -> Items.INGOT_STEEL_CRUDE)); + CreativeInventoryRegistry.INSTANCE.register(STAR_FALLEN, place(() -> Items.INGOT_STEEL_CRUDE)); + CreativeInventoryRegistry.INSTANCE.register(STAR_CONNECTED, place(() -> Items.INGOT_STEEL_CRUDE)); + CreativeInventoryRegistry.INSTANCE.register(TOOL_SHOVEL_MOONSTEEL, place(() -> Items.TOOL_SWORD_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(TOOL_PICKAXE_MOONSTEEL, place(() -> Items.TOOL_SWORD_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(TOOL_AXE_MOONSTEEL, place(() -> Items.TOOL_SWORD_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(TOOL_HOE_MOONSTEEL, place(() -> Items.TOOL_SWORD_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(TOOL_SWORD_MOONSTEEL, place(() -> Items.TOOL_SWORD_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(ARMOR_HELMET_MOONSTEEL, place(() -> Items.ARMOR_WOLF_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(ARMOR_CHESTPLATE_MOONSTEEL, place(() -> Items.ARMOR_WOLF_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(ARMOR_LEGGINGS_MOONSTEEL, place(() -> Items.ARMOR_WOLF_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(ARMOR_BOOTS_MOONSTEEL, place(() -> Items.ARMOR_WOLF_STEEL)); + CreativeInventoryRegistry.INSTANCE.register(ARMOR_WOLF_MOONSTEEL, place(() -> Items.ARMOR_WOLF_STEEL)); + + if (MoonSteelConstants.BACKPACKS.getAsBoolean()){ + CreativeInventoryRegistry.INSTANCE.register(BACKPACK_COSMIC, place(() -> Items.ARMOR_WOLF_STEEL)); } } - @Override - public void afterGameStart() { + private static CreativeInventoryPlacement.@NotNull After place(Supplier iItemConvertibleSupplier) { + return new CreativeInventoryPlacement.After(iItemConvertibleSupplier); + } + private static CreativeInventoryPlacement.@NotNull Category place() { + return new CreativeInventoryPlacement.Category(CreativeInventoryCategory.WORKBENCHES); } public static boolean isStarTime(final World world){ - if (world.worldType.hasCeiling()) return false; + if (world.getWorldType().hasCeiling()) return false; if (world.isDaytime()) return false; return world.getWorldTime() % 2000 <= 200; } diff --git a/src/main/java/useless/moonsteel/MoonSteelBlocks.java b/src/main/java/useless/moonsteel/MoonSteelBlocks.java deleted file mode 100644 index e5715d2..0000000 --- a/src/main/java/useless/moonsteel/MoonSteelBlocks.java +++ /dev/null @@ -1,60 +0,0 @@ -package useless.moonsteel; - -import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockLogic; -import net.minecraft.core.block.BlockLogicLeavesBase; -import net.minecraft.core.block.BlockLogicOreCoal; -import net.minecraft.core.block.BlockLogicOreDiamond; -import net.minecraft.core.block.BlockLogicOreGold; -import net.minecraft.core.block.BlockLogicOreIron; -import net.minecraft.core.block.BlockLogicOreLapis; -import net.minecraft.core.block.BlockLogicOreNetherCoal; -import net.minecraft.core.block.BlockLogicOreRedstone; -import net.minecraft.core.block.BlockLogicTallGrass; -import net.minecraft.core.block.material.Material; -import net.minecraft.core.block.tag.BlockTags; -import net.minecraft.core.data.tag.Tag; -import turniplabs.halplibe.helper.BlockBuilder; -import useless.moonsteel.block.BlockStellarRewinder; -import useless.moonsteel.block.BlockTorchStar; - -import static useless.moonsteel.MoonSteel.MOD_ID; - -public class MoonSteelBlocks { - public static Block BLOCK_MOONSTEEL = new BlockBuilder(MOD_ID) - .setHardness(5f) - .setResistance(2000f) - .addTags(BlockTags.MINEABLE_BY_PICKAXE) - .build("block", "block_moonsteel", MoonSteel.blockId++, b -> new BlockLogic(b, Material.metal)); - public static Block TORCH_STAR = new BlockBuilder(MOD_ID) - .setLuminance(15) - .build("torch.star", "torch_star", MoonSteel.blockId++,BlockTorchStar::new) - .withDisabledNeighborNotifyOnMetadataChange(); - public static Block STELLAR_REWINDER = new BlockBuilder(MOD_ID) - .setHardness(3.5f) - .addTags(BlockTags.MINEABLE_BY_PICKAXE) - .build("stellar.rewinder", "stellar_rewinder", MoonSteel.blockId++, b -> new BlockStellarRewinder(b, Material.metal)) - .withImmovableFlagSet(); - - - public static Tag> FORCE_FORTUNE = Tag.of("moonsteel$force_enable_fortune"); - public static Tag> FORCE_NO_FORTUNE = Tag.of("moonsteel$force_disable_fortune"); - public static boolean canBeFortuned(Block block){ - if (block.hasTag(FORCE_FORTUNE)) return true; - if (block.hasTag(FORCE_NO_FORTUNE)) return false; - if (Block.hasLogicClass(block, BlockLogicLeavesBase.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreCoal.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreDiamond.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreGold.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreIron.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreLapis.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreNetherCoal.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreRedstone.class)) return true; - if (Block.hasLogicClass(block, BlockLogicTallGrass.class)) return true; - return false; - } - - public static void init() { - - } -} diff --git a/src/main/java/useless/moonsteel/MoonSteelClient.java b/src/main/java/useless/moonsteel/MoonSteelClient.java index 77a747f..027ab02 100644 --- a/src/main/java/useless/moonsteel/MoonSteelClient.java +++ b/src/main/java/useless/moonsteel/MoonSteelClient.java @@ -1,34 +1,54 @@ package useless.moonsteel; -import net.minecraft.client.entity.particle.ParticleDispatcher; +import net.fabricmc.api.ClientModInitializer; +import net.minecraft.client.render.particle.ParticleDispatcher; import net.minecraft.client.render.texture.stitcher.AtlasStitcher; import net.minecraft.client.render.texture.stitcher.TextureRegistry; import net.minecraft.client.sound.SoundRepository; -import turniplabs.halplibe.util.ClientStartEntrypoint; +import net.minecraft.core.entity.EntityPainting; +import net.minecraft.core.net.command.CommandManager; +import net.minecraft.core.util.collection.NamespaceID; +import turniplabs.halplibe.event.defs.ClientEvents; +import useless.moonsteel.api.MoonSteelCompatClient; +import useless.moonsteel.command.CommandScore; import useless.moonsteel.fx.ParticleMagicSmoke; import useless.moonsteel.fx.ParticleStar; +import useless.moonsteel.item.MoonSteelItems; import java.io.IOException; import java.net.URISyntaxException; -import static useless.moonsteel.MoonSteel.MOD_ID; +import static useless.moonsteel.MoonSteel.*; + +public class MoonSteelClient implements ClientModInitializer { -public class MoonSteelClient implements ClientStartEntrypoint { @Override + public void onInitializeClient() { + ClientEvents.BEFORE_CLIENT_START.listen(KEY, this::beforeClientStart); + ClientEvents.AFTER_CLIENT_START.listen(KEY, this::afterClientStart); + ClientEvents.ITEM_MODEL_RELOAD.listen(KEY, MoonSteelModels::initItemModels); + ClientEvents.BLOCK_MODEL_RELOAD.listen(KEY, MoonSteelModels::initBlockModels); + CommandManager.registerCommand(new CommandScore()); + MoonSteelCompatClient.init(); + } + + public void beforeClientStart() { for (final AtlasStitcher stitcher : TextureRegistry.stitcherMap.values()) { try { TextureRegistry.initializeAllFiles(MOD_ID, stitcher, true); } catch (URISyntaxException | IOException e) { - MoonSteel.LOGGER.error("Failed to initialize texture files!", e); + MoonSteelConstants.LOGGER.error("Failed to initialize texture files!", e); } } - SoundRepository.registerNamespace(MOD_ID); + SoundRepository.namespaceAdded(MOD_ID); } - @Override + public void afterClientStart() { - ParticleDispatcher.getInstance().addDispatch("moonsteel$star", (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleStar(world, x, y, z, motionX, motionY, motionX)); - ParticleDispatcher.getInstance().addDispatch("moonsteel$magic_smoke", (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleMagicSmoke(world, x, y, z, motionX, motionY, motionX)); + ParticleDispatcher.getInstance().addDispatch(STAR, (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleStar(world, x, y, z, motionX, motionY, motionX)); + ParticleDispatcher.getInstance().addDispatch(SMOKE, (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleMagicSmoke(world, x, y, z, motionX, motionY, motionX)); + EntityPainting.addBorder(MoonSteelItems.INGOT_MOONSTEEL.getDefaultStack(), NamespaceID.fromPool(MOD_ID, "border_moonsteel")); + } } diff --git a/src/main/java/useless/moonsteel/MoonSteelConstants.java b/src/main/java/useless/moonsteel/MoonSteelConstants.java new file mode 100644 index 0000000..7cce5d4 --- /dev/null +++ b/src/main/java/useless/moonsteel/MoonSteelConstants.java @@ -0,0 +1,17 @@ +package useless.moonsteel; + +import net.fabricmc.loader.api.FabricLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.function.BooleanSupplier; + +public class MoonSteelConstants { + private MoonSteelConstants(){} + // called to be seperate from game classes to allow use in configs as well as mixin configurations + public static final String MOD_ID = "moonsteel"; + public static final BooleanSupplier BACKPACKS = () -> FabricLoader.getInstance().isModLoaded("betterwithbackpacks"); + public static final BooleanSupplier PAXEL = () -> FabricLoader.getInstance().isModLoaded("paxels"); + public static final BooleanSupplier COMMANDLY = () -> FabricLoader.getInstance().isModLoaded("commandly"); + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); +} diff --git a/src/main/java/useless/moonsteel/MoonSteelItems.java b/src/main/java/useless/moonsteel/MoonSteelItems.java deleted file mode 100644 index 88b975e..0000000 --- a/src/main/java/useless/moonsteel/MoonSteelItems.java +++ /dev/null @@ -1,66 +0,0 @@ -package useless.moonsteel; - -import net.minecraft.core.item.IArmorItem; -import net.minecraft.core.item.Item; -import net.minecraft.core.item.ItemArmor; -import net.minecraft.core.item.material.ArmorMaterial; -import net.minecraft.core.item.material.ToolMaterial; -import net.minecraft.core.item.tag.ItemTags; -import net.minecraft.core.item.tool.ItemToolAxe; -import net.minecraft.core.item.tool.ItemToolHoe; -import net.minecraft.core.item.tool.ItemToolPickaxe; -import net.minecraft.core.item.tool.ItemToolShovel; -import net.minecraft.core.item.tool.ItemToolSword; -import turniplabs.halplibe.helper.ArmorHelper; -import turniplabs.halplibe.helper.ItemBuilder; -import useless.moonsteel.item.ItemConnectedStar; - -import static useless.moonsteel.MoonSteel.MOD_ID; - -public class MoonSteelItems { - public static ToolMaterial moonSteelTool = new ToolMaterial().setDurability(1536).setEfficiency(7.0f, 14.0f).setMiningLevel(3).setDamage(2); - public static Item INGOT_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new Item("ingot.moonsteel", MOD_ID + ":item/ingot_moonsteel", MoonSteel.itemId++)); - public static Item INGOT_MOONSTEEL_CRUDE = new ItemBuilder(MOD_ID) - .build(new Item("crude.moonsteel", MOD_ID + ":item/ingot_moonsteel_crude", MoonSteel.itemId++)); - public static Item TOOL_PICKAXE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolPickaxe("tool.pickaxe.moonsteel", MOD_ID + ":item/tool_pickaxe_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_AXE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolAxe("tool.axe.moonsteel", MOD_ID + ":item/tool_axe_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_SHOVEL_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolShovel("tool.shovel.moonsteel", MOD_ID + ":item/tool_shovel_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_HOE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolHoe("tool.hoe.moonsteel", MOD_ID + ":item/tool_hoe_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_SWORD_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolSword("tool.sword.moonsteel", MOD_ID + ":item/tool_sword_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static ArmorMaterial moonSteelArmor = ArmorHelper.createArmorMaterial(MOD_ID, "moonsteel", 800, 51f, 45f, 45f, 100f); - public static Item ARMOR_HELMET_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("helmet.moonsteel", MOD_ID + ":item/armor_helmet_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_HEAD)); - public static Item ARMOR_CHESTPLATE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("chestplate.moonsteel", MOD_ID + ":item/armor_chestplate_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_CHEST)); - public static Item ARMOR_LEGGINGS_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("leggings.moonsteel", MOD_ID + ":item/armor_leggings_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_LEGS)); - public static Item ARMOR_BOOTS_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("boots.moonsteel", MOD_ID + ":item/armor_boots_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_BOOTS)); - public static Item STAR_FALLEN = new ItemBuilder(MOD_ID) - .build(new Item("star.fallen", MOD_ID + ":item/star_fallen", MoonSteel.itemId++)); - public static Item STAR_CONNECTED = new ItemBuilder(MOD_ID) - .setStackSize(1) - .build(new ItemConnectedStar("star.connected", MOD_ID + ":item/star_connected", MoonSteel.itemId++)); - public static Item BACKPACK_COSMIC; - - public static void init() { - MoonSteel.LOGGER.info("Backpacks present: {}", MoonSteel.backpackPresent); - if (MoonSteel.backpackPresent){ - BACKPACK_COSMIC = new ItemBuilder(MOD_ID) - .setStackSize(1) - .build( BackpackProxy.proxyBackpack("backpack.cosmic", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); - } else { - BACKPACK_COSMIC = new ItemBuilder(MOD_ID) - .setStackSize(1) - .setTags(ItemTags.NOT_IN_CREATIVE_MENU) - .build(new Item("backpack.cosmic.missing", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); - } - MoonSteel.starZombieSword = MoonSteelItems.TOOL_SWORD_MOONSTEEL.getDefaultStack(); - } -} diff --git a/src/main/java/useless/moonsteel/MoonSteelModels.java b/src/main/java/useless/moonsteel/MoonSteelModels.java index fb446aa..bcaba27 100644 --- a/src/main/java/useless/moonsteel/MoonSteelModels.java +++ b/src/main/java/useless/moonsteel/MoonSteelModels.java @@ -1,64 +1,70 @@ package useless.moonsteel; -import net.minecraft.client.render.EntityRenderDispatcher; -import net.minecraft.client.render.TileEntityRenderDispatcher; -import net.minecraft.client.render.block.color.BlockColorDispatcher; import net.minecraft.client.render.block.model.BlockModelDispatcher; -import net.minecraft.client.render.block.model.BlockModelStandard; -import net.minecraft.client.render.block.model.BlockModelTorch; +import net.minecraft.client.render.block.model.generic.*; import net.minecraft.client.render.item.model.ItemModelDispatcher; import net.minecraft.client.render.item.model.ItemModelStandard; import net.minecraft.client.render.texture.stitcher.TextureRegistry; import net.minecraft.core.item.Item; import net.minecraft.core.util.collection.NamespaceID; -import net.minecraft.core.util.helper.Side; import org.jetbrains.annotations.NotNull; -import turniplabs.halplibe.util.ModelEntrypoint; -import useless.moonsteel.block.BlockModelStellarRewinder; -import useless.moonsteel.item.ItemModelConnectStar; - +import useless.moonsteel.block.lamp.BlockModelStarLamp; +import useless.moonsteel.block.rewinder.BlockModelStellarRewinder; +import useless.moonsteel.block.MoonSteelBlocks; +import useless.moonsteel.item.connectstar.ItemModelConnectStar; +import useless.moonsteel.item.MoonSteelItems; + +import static net.minecraft.client.render.block.model.BlockModelDispatcher.loadDataModel; +import static net.minecraft.client.render.item.model.ItemModelDispatcher.*; import static useless.moonsteel.MoonSteel.MOD_ID; -public class MoonSteelModels implements ModelEntrypoint { - @Override - public void initBlockModels(final BlockModelDispatcher dispatcher) { - final Side[] S_TB = {Side.TOP, Side.BOTTOM}; - final Side[] S_SIDES = {Side.NORTH, Side.EAST, Side.SOUTH, Side.WEST}; +public class MoonSteelModels { - dispatcher.addDispatch(new BlockModelStandard<>(MoonSteelBlocks.BLOCK_MOONSTEEL) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_side", S_SIDES) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_top", Side.TOP) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_bottom", Side.BOTTOM)); + private MoonSteelModels(){} - dispatcher.addDispatch(new BlockModelTorch<>(MoonSteelBlocks.TORCH_STAR) - .setAllTextures(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/startorch")); + public static void initBlockModels(final BlockModelDispatcher dispatcher) { + dispatcher.addDispatch(new BlockModelGeneric<>(MoonSteelBlocks.BLOCK_MOONSTEEL, loadDataModel(MOD_ID + ":block/moonsteel"))); + dispatcher.addDispatch(new BlockModelGenericTorch<>(MoonSteelBlocks.TORCH_STAR, MOD_ID + ":block/star_torch").render3D(false)); + dispatcher.addDispatch(new BlockModelStellarRewinder<>(MoonSteelBlocks.STELLAR_REWINDER, MOD_ID + ":block/stellarrewinder")); + dispatcher.addDispatch(new BlockModelStarLamp<>(MoonSteelBlocks.STAR_LAMP, loadDataModel(MOD_ID + ":block/starlamp"))); + dispatcher.addDispatch(new BlockModelGenericLantern<>(MoonSteelBlocks.JAR_STAR, loadDataModel(MOD_ID + ":block/jar_star"), loadDataModel(MOD_ID + ":block/jar_star_hanging"))); - dispatcher.addDispatch(new BlockModelStellarRewinder<>(MoonSteelBlocks.STELLAR_REWINDER) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_side", Side.SOUTH, Side.WEST, Side.EAST) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_front", Side.NORTH) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_top", S_TB)); + dispatcher.addDispatch(new BlockModelGeneric<>(MoonSteelBlocks.MOONSTEEL_BRICKS, loadDataModel(MOD_ID + ":block/moonsteel_brick"))); + dispatcher.addDispatch(new BlockModelGenericSlab<>(MoonSteelBlocks.SLAB_MOONSTEEL_BRICK, loadDataModel(MOD_ID + ":block/slab/lower"), loadDataModel(MOD_ID + ":block/slab/upper"), loadDataModel(MOD_ID + ":block/slab/full"))); + dispatcher.addDispatch(new BlockModelGenericStairs<>(MoonSteelBlocks.STAIR_MOONSTEEL_BRICKS, loadDataModel(MOD_ID + ":block/moonsteel_stair"))); } - @Override - public void initItemModels(final ItemModelDispatcher dispatcher) { + + public static void initItemModels(final ItemModelDispatcher dispatcher) { dispatcher.addDispatch(makeModel(MoonSteelItems.INGOT_MOONSTEEL, "moonsteel_ingot")); dispatcher.addDispatch(makeModel(MoonSteelItems.INGOT_MOONSTEEL_CRUDE, "moonsteel_crude")); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_PICKAXE_MOONSTEEL, "moonsteel_pickaxe").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_AXE_MOONSTEEL, "moonsteel_axe").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_SHOVEL_MOONSTEEL, "moonsteel_shovel").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_HOE_MOONSTEEL, "moonsteel_hoe").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_SWORD_MOONSTEEL, "moonsteel_sword").setFull3D()); + dispatcher.addDispatch(makeHoldModel(MoonSteelItems.TOOL_PICKAXE_MOONSTEEL, "moonsteel_pickaxe")); + dispatcher.addDispatch(makeHoldModel(MoonSteelItems.TOOL_AXE_MOONSTEEL, "moonsteel_axe")); + dispatcher.addDispatch(makeHoldModel(MoonSteelItems.TOOL_SHOVEL_MOONSTEEL, "moonsteel_shovel")); + dispatcher.addDispatch(makeHoldModel(MoonSteelItems.TOOL_HOE_MOONSTEEL, "moonsteel_hoe")); + dispatcher.addDispatch(makeHoldModel(MoonSteelItems.TOOL_SWORD_MOONSTEEL, "moonsteel_sword")); dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_HELMET_MOONSTEEL, "moonsteel_helmet")); dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL, "moonsteel_chestplate")); dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL, "moonsteel_leggings")); dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_BOOTS_MOONSTEEL, "moonsteel_boots")); dispatcher.addDispatch(makeModel(MoonSteelItems.STAR_FALLEN, "fallen_star").setFullBright()); - dispatcher.addDispatch(setIcon(new ItemModelConnectStar(MoonSteelItems.STAR_CONNECTED, null), MOD_ID + ":item/connected_star_off").setFullBright()); + dispatcher.addDispatch(setIcon(new ItemModelConnectStar(MoonSteelItems.STAR_CONNECTED), MOD_ID + ":item/connected_star_off").setFullBright()); dispatcher.addDispatch(makeModel(MoonSteelItems.BACKPACK_COSMIC, "starpack")); + dispatcher.addDispatch(makeModel(MoonSteelItems.STAR_JAR, "jar_star")); + dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_WOLF_MOONSTEEL, "moonsteel_wolf_armor")); } + public static @NotNull ItemModelStandard makeModel(@NotNull final Item item, @NotNull final String textureValue) { - return setIcon(new ItemModelStandard(item, null), NamespaceID.getTemp(MOD_ID, "item/" + textureValue)); + return setIcon(new ItemModelStandard(item, true), NamespaceID.fromPool(MOD_ID, "item/" + textureValue)); + } + + public static @NotNull ItemModelStandard makeHoldModel(@NotNull final Item item, @NotNull final String textureValue) { + return setIcon(new ItemModelStandard(item, true), NamespaceID.fromPool(MOD_ID, "item/" + textureValue)) + .setDisplayPos("firstperson_righthand", HANDHELD_FIRST_PERSON_RIGHT_HAND) + .setDisplayPos("firstperson_lefthand", HANDHELD_FIRST_PERSON_LEFT_HAND) + .setDisplayPos("thirdperson_righthand", HANDHELD_THIRD_PERSON_RIGHT_HAND) + .setDisplayPos("thirdperson_lefthand", HANDHELD_THIRD_PERSON_LEFT_HAND); } public static @NotNull T setIcon(@NotNull final T model, @NotNull final String texture) { @@ -70,19 +76,4 @@ public void initItemModels(final ItemModelDispatcher dispatcher) { model.icon = TextureRegistry.getTexture(texture); return model; } - - @Override - public void initEntityModels(final EntityRenderDispatcher dispatcher) { - - } - - @Override - public void initTileEntityModels(final TileEntityRenderDispatcher dispatcher) { - - } - - @Override - public void initBlockColors(final BlockColorDispatcher dispatcher) { - - } } diff --git a/src/main/java/useless/moonsteel/MoonSteelServer.java b/src/main/java/useless/moonsteel/MoonSteelServer.java new file mode 100644 index 0000000..fde0dfb --- /dev/null +++ b/src/main/java/useless/moonsteel/MoonSteelServer.java @@ -0,0 +1,13 @@ +package useless.moonsteel; + +import net.fabricmc.api.DedicatedServerModInitializer; +import net.minecraft.core.net.command.CommandManager; +import useless.moonsteel.command.CommandScore; + +public class MoonSteelServer implements DedicatedServerModInitializer { + + @Override + public void onInitializeServer() { + CommandManager.registerCommand(new CommandScore()); + } +} diff --git a/src/main/java/useless/moonsteel/api/MoonSteelCompat.java b/src/main/java/useless/moonsteel/api/MoonSteelCompat.java new file mode 100644 index 0000000..9d41bdc --- /dev/null +++ b/src/main/java/useless/moonsteel/api/MoonSteelCompat.java @@ -0,0 +1,23 @@ +package useless.moonsteel.api; + +import net.fabricmc.loader.api.FabricLoader; +import turniplabs.halplibe.event.defs.CommonEvents; +import turniplabs.halplibe.util.dependency.Key; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.api.paxel.MoonSteelPaxel; +import useless.moonsteel.MoonSteelConstants; + +public class MoonSteelCompat { + private MoonSteelCompat() { + } + + public static void init() { + if(FabricLoader.getInstance().isModLoaded("aether")){ + /* gona work on it later */ + } + if(MoonSteelConstants.PAXEL.getAsBoolean()){ + CommonEvents.AFTER_ITEM_INIT.listen(Key.of(MoonSteel.MOD_ID ,"paxels"), MoonSteelPaxel::initItem); + CommonEvents.RECIPES_READY.listen(Key.of(MoonSteel.MOD_ID ,"paxels"), MoonSteelPaxel::recipeReady); + } + } +} diff --git a/src/main/java/useless/moonsteel/api/MoonSteelCompatClient.java b/src/main/java/useless/moonsteel/api/MoonSteelCompatClient.java new file mode 100644 index 0000000..bed1ca8 --- /dev/null +++ b/src/main/java/useless/moonsteel/api/MoonSteelCompatClient.java @@ -0,0 +1,21 @@ +package useless.moonsteel.api; + +import net.fabricmc.loader.api.FabricLoader; +import turniplabs.halplibe.event.defs.ClientEvents; +import useless.moonsteel.MoonSteelConstants; +import useless.moonsteel.api.paxel.MoonSteelPaxel; + +import static useless.moonsteel.MoonSteel.KEY; + +public class MoonSteelCompatClient { + + private MoonSteelCompatClient(){ + + } + + public static void init(){ + if(MoonSteelConstants.PAXEL.getAsBoolean()){ + ClientEvents.ITEM_MODEL_RELOAD.listen(KEY, MoonSteelPaxel::initItemModels); + } + } +} diff --git a/src/main/java/useless/moonsteel/MoonSteelMixinPlugin.java b/src/main/java/useless/moonsteel/api/MoonSteelMixinPlugin.java similarity index 71% rename from src/main/java/useless/moonsteel/MoonSteelMixinPlugin.java rename to src/main/java/useless/moonsteel/api/MoonSteelMixinPlugin.java index e4a6e68..350b1e5 100644 --- a/src/main/java/useless/moonsteel/MoonSteelMixinPlugin.java +++ b/src/main/java/useless/moonsteel/api/MoonSteelMixinPlugin.java @@ -1,19 +1,19 @@ -package useless.moonsteel; +package useless.moonsteel.api; -import net.fabricmc.loader.api.FabricLoader; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import useless.moonsteel.MoonSteelConstants; +import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.function.Supplier; public class MoonSteelMixinPlugin implements IMixinConfigPlugin { - private static final Supplier BACKPACKS = () -> FabricLoader.getInstance().isModLoaded("betterwithbackpacks"); + @Override public void onLoad(String mixinPackage) { - + /* not need */ } @Override @@ -23,27 +23,32 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if (mixinClassName.startsWith("useless.moonsteel.mixin.backpack")) return BACKPACKS.get(); + if (mixinClassName.startsWith("useless.moonsteel.mixin.backpack")) { + return MoonSteelConstants.BACKPACKS.getAsBoolean(); + } + if (mixinClassName.startsWith("useless.moonsteel.mixin.commandly")) { + return MoonSteelConstants.COMMANDLY.getAsBoolean(); + } return true; } @Override public void acceptTargets(Set myTargets, Set otherTargets) { - + /* not need */ } @Override public List getMixins() { - return null; + return Collections.emptyList(); } @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - + /* not need */ } @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - + /* not need */ } } diff --git a/src/main/java/useless/moonsteel/BackpackProxy.java b/src/main/java/useless/moonsteel/api/backpack/BackpackProxy.java similarity index 74% rename from src/main/java/useless/moonsteel/BackpackProxy.java rename to src/main/java/useless/moonsteel/api/backpack/BackpackProxy.java index 7d052a2..a07e54c 100644 --- a/src/main/java/useless/moonsteel/BackpackProxy.java +++ b/src/main/java/useless/moonsteel/api/backpack/BackpackProxy.java @@ -1,7 +1,6 @@ -package useless.moonsteel; +package useless.moonsteel.api.backpack; import net.minecraft.core.item.Item; -import useless.moonsteel.item.ItemStarBackpack; public class BackpackProxy { public static Item proxyBackpack(final String name, final String namespaceId, final int id) { diff --git a/src/main/java/useless/moonsteel/ContainerStarBackpack.java b/src/main/java/useless/moonsteel/api/backpack/ContainerStarBackpack.java similarity index 68% rename from src/main/java/useless/moonsteel/ContainerStarBackpack.java rename to src/main/java/useless/moonsteel/api/backpack/ContainerStarBackpack.java index 47a7d42..fa16306 100644 --- a/src/main/java/useless/moonsteel/ContainerStarBackpack.java +++ b/src/main/java/useless/moonsteel/api/backpack/ContainerStarBackpack.java @@ -1,44 +1,44 @@ -package useless.moonsteel; +package useless.moonsteel.api.backpack; +import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.core.InventoryAction; import net.minecraft.core.entity.player.Player; import net.minecraft.core.player.inventory.menu.MenuAbstract; import net.minecraft.core.player.inventory.slot.Slot; -import useless.moonsteel.interfaces.IStarBackpack; - -import java.util.List; +import org.jetbrains.annotations.NotNull; public class ContainerStarBackpack extends MenuAbstract { public StarBackpackInventory backpackInventory; + public ContainerStarBackpack(final Player player) { - this.backpackInventory = ((IStarBackpack)player).moonsteel$getStarBackpackInventory(); + this.backpackInventory = ((IStarBackpack) player).moonsteel$getStarBackpackInventory(); final int slotsNum = this.backpackInventory.getContainerSize(); - final int rows = (int)Math.ceil((double)slotsNum / 9.0); + final int rows = (int) Math.ceil(slotsNum / 9.0); - for(int i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { int width = 9; if (i == rows - 1) { width = slotsNum - 9 * i; } - for(int k = 0; k < width; ++k) { + for (int k = 0; k < width; ++k) { this.addSlot(new SlotStarBackpack(this.backpackInventory, k + i * 9, 8 + k * 18, 18 + 18 * i)); } } - for(int i = 0; i < 3; ++i) { - for(int k = 0; k < 9; ++k) { + for (int i = 0; i < 3; ++i) { + for (int k = 0; k < 9; ++k) { this.addSlot(new Slot(player.inventory, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); } } - for(int j = 0; j < 9; ++j) { + for (int j = 0; j < 9; ++j) { this.addSlot(new Slot(player.inventory, j, 8 + j * 18, 142)); } } @Override - public List getMoveSlots(final InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { + public IntList getMoveSlots(final @NotNull InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { final int chestSize = this.backpackInventory.getContainerSize(); if (slot.index >= 0 && slot.index < chestSize) { return this.getSlots(0, chestSize, false); @@ -60,13 +60,13 @@ public List getMoveSlots(final InventoryAction inventoryAction, final S } @Override - public List getTargetSlots(final InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { + public IntList getTargetSlots(final @NotNull InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { final int chestSize = this.backpackInventory.getContainerSize(); return slot.index < chestSize ? this.getSlots(chestSize, 36, true) : this.getSlots(0, chestSize, false); } @Override - public boolean stillValid(final Player entityPlayer) { + public boolean stillValid(final @NotNull Player entityPlayer) { return this.backpackInventory.stillValid(entityPlayer); } diff --git a/src/main/java/useless/moonsteel/GuiStarBackpack.java b/src/main/java/useless/moonsteel/api/backpack/GuiStarBackpack.java similarity index 58% rename from src/main/java/useless/moonsteel/GuiStarBackpack.java rename to src/main/java/useless/moonsteel/api/backpack/GuiStarBackpack.java index 5f91553..7531819 100644 --- a/src/main/java/useless/moonsteel/GuiStarBackpack.java +++ b/src/main/java/useless/moonsteel/api/backpack/GuiStarBackpack.java @@ -1,4 +1,4 @@ -package useless.moonsteel; +package useless.moonsteel.api.backpack; import net.minecraft.client.gui.container.ScreenContainerAbstract; import net.minecraft.core.entity.player.Player; @@ -7,8 +7,8 @@ import tosutosu.betterwithbackpacks.BetterWithBackpacks; public class GuiStarBackpack extends ScreenContainerAbstract { - private int GUIx; - private int GUIy; + private int guiX; + private int guiY; private int rows; private int slotsNum; private final ContainerStarBackpack backpack; @@ -17,29 +17,32 @@ public GuiStarBackpack(Player player) { backpack = (ContainerStarBackpack) inventorySlots; } + @Override public void init() { - this.GUIx = (this.width - this.xSize) / 2; - this.GUIy = (this.height - this.ySize) / 2; + this.guiX = (this.width - this.xSize) / 2; + this.guiY = (this.height - this.ySize) / 2; this.slotsNum = this.backpack.backpackInventory.getContainerSize(); - this.rows = (int)Math.ceil((double)this.slotsNum / 9.0); + this.rows = (int)Math.ceil(this.slotsNum / 9.0); super.init(); } + @Override protected void drawGuiContainerForegroundLayer() { - this.font.drawString(I18n.getInstance().translateKey(this.backpack.backpackInventory.getNameTranslationKey()), 8, 6, BetterWithBackpacks.GUI_LABEL_COLOR); - this.font.drawString("Inventory", 8, this.ySize - 96 + 2, BetterWithBackpacks.GUI_LABEL_COLOR); + String name = I18n.getInstance().translateKey(this.backpack.backpackInventory.getNameTranslationKey()); + this.drawStringNoShadow(this.fontRenderer, name, 8, 6, BetterWithBackpacks.GUI_LABEL_COLOR); + this.drawStringNoShadow(this.fontRenderer, "Inventory", 8, this.ySize - 96 + 2, BetterWithBackpacks.GUI_LABEL_COLOR); } protected void drawGuiContainerBackgroundLayer(float f) { GL11.glColor3d(1.0, 1.0, 1.0); this.mc.textureManager.loadTexture("/assets/betterwithbackpacks/gui/backpack.png").bind(); - this.drawTexturedModalRect(this.GUIx, this.GUIy, 0, 0, this.xSize, this.ySize); + this.drawTexturedModalRect(this.guiX, this.guiY, 0, 0, this.xSize, this.ySize); for(int i = 0; i < this.rows; ++i) { if (i == this.rows - 1) { - this.drawTexturedModalRect(this.GUIx + 7, this.GUIy + 17 + 18 * i, 0, 166, 18 * (this.slotsNum - 9 * i), 18); + this.drawTexturedModalRect(this.guiX + 7, this.guiY + 17 + 18 * i, 0, 166, 18 * (this.slotsNum - 9 * i), 18); } else { - this.drawTexturedModalRect(this.GUIx + 7, this.GUIy + 17 + 18 * i, 0, 166, 162, 18); + this.drawTexturedModalRect(this.guiX + 7, this.guiY + 17 + 18 * i, 0, 166, 162, 18); } } } diff --git a/src/main/java/useless/moonsteel/interfaces/IStarBackpack.java b/src/main/java/useless/moonsteel/api/backpack/IStarBackpack.java similarity index 71% rename from src/main/java/useless/moonsteel/interfaces/IStarBackpack.java rename to src/main/java/useless/moonsteel/api/backpack/IStarBackpack.java index ff1f551..1a25843 100644 --- a/src/main/java/useless/moonsteel/interfaces/IStarBackpack.java +++ b/src/main/java/useless/moonsteel/api/backpack/IStarBackpack.java @@ -1,6 +1,4 @@ -package useless.moonsteel.interfaces; - -import useless.moonsteel.StarBackpackInventory; +package useless.moonsteel.api.backpack; public interface IStarBackpack { StarBackpackInventory moonsteel$getStarBackpackInventory(); diff --git a/src/main/java/useless/moonsteel/item/ItemStarBackpack.java b/src/main/java/useless/moonsteel/api/backpack/ItemStarBackpack.java similarity index 65% rename from src/main/java/useless/moonsteel/item/ItemStarBackpack.java rename to src/main/java/useless/moonsteel/api/backpack/ItemStarBackpack.java index 566f1ea..499dd23 100644 --- a/src/main/java/useless/moonsteel/item/ItemStarBackpack.java +++ b/src/main/java/useless/moonsteel/api/backpack/ItemStarBackpack.java @@ -1,23 +1,22 @@ -package useless.moonsteel.item; +package useless.moonsteel.api.backpack; import net.minecraft.core.entity.player.Player; import net.minecraft.core.item.ItemStack; import net.minecraft.core.world.World; import tosutosu.betterwithbackpacks.BetterWithBackpacks; import tosutosu.betterwithbackpacks.item.ItemBackpack; -import useless.moonsteel.StarBackpackInventory; -import useless.moonsteel.interfaces.IStarBackpack; public class ItemStarBackpack extends ItemBackpack { public ItemStarBackpack(String name, String namespaceId, int id) { - super(name, namespaceId, id, StarBackpackInventory.starBackpackSize); + super(name, namespaceId, id, StarBackpackInventory.STAR_BACKPACK_SIZE); } + + @Override - public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { + public ItemStack onUse(ItemStack itemstack, World world, Player entityplayer) { if (!world.isClientSide && BetterWithBackpacks.ENABLE_BACKPACKS) { ((IStarBackpack)entityplayer).moonsteel$displayGuiStarBackpack(); } - return itemstack; } } diff --git a/src/main/java/useless/moonsteel/SlotStarBackpack.java b/src/main/java/useless/moonsteel/api/backpack/SlotStarBackpack.java similarity index 90% rename from src/main/java/useless/moonsteel/SlotStarBackpack.java rename to src/main/java/useless/moonsteel/api/backpack/SlotStarBackpack.java index 37ff236..ea23bf8 100644 --- a/src/main/java/useless/moonsteel/SlotStarBackpack.java +++ b/src/main/java/useless/moonsteel/api/backpack/SlotStarBackpack.java @@ -1,4 +1,4 @@ -package useless.moonsteel; +package useless.moonsteel.api.backpack; import net.minecraft.core.item.ItemStack; import net.minecraft.core.player.inventory.container.Container; @@ -9,6 +9,8 @@ public class SlotStarBackpack extends Slot { public SlotStarBackpack(Container inventory, int id, int x, int y) { super(inventory, id, x, y); } + + @Override public boolean mayPlace(ItemStack itemstack) { return itemstack != null && !(itemstack.getItem() instanceof ItemBackpack) && !this.isLocked(); } diff --git a/src/main/java/useless/moonsteel/StarBackpackInventory.java b/src/main/java/useless/moonsteel/api/backpack/StarBackpackInventory.java similarity index 82% rename from src/main/java/useless/moonsteel/StarBackpackInventory.java rename to src/main/java/useless/moonsteel/api/backpack/StarBackpackInventory.java index 0a2f95f..b469aeb 100644 --- a/src/main/java/useless/moonsteel/StarBackpackInventory.java +++ b/src/main/java/useless/moonsteel/api/backpack/StarBackpackInventory.java @@ -1,4 +1,4 @@ -package useless.moonsteel; +package useless.moonsteel.api.backpack; import com.mojang.nbt.tags.CompoundTag; import com.mojang.nbt.tags.ListTag; @@ -6,21 +6,23 @@ import net.minecraft.core.item.ItemStack; import net.minecraft.core.player.inventory.InventorySorter; import net.minecraft.core.player.inventory.container.Container; +import org.jetbrains.annotations.NotNull; import tosutosu.betterwithbackpacks.BetterWithBackpacks; +import useless.moonsteel.item.MoonSteelItems; public class StarBackpackInventory implements Container { - public static int starBackpackSize = 18; - protected ItemStack[] backpackItemStacks; - public Player player; + public static final int STAR_BACKPACK_SIZE = 18; + private ItemStack[] backpackItemStacks; + private Player player; public StarBackpackInventory(Player player) { this.player = player; - this.backpackItemStacks = new ItemStack[starBackpackSize]; + this.backpackItemStacks = new ItemStack[STAR_BACKPACK_SIZE]; } @Override public int getContainerSize() { - return starBackpackSize; + return STAR_BACKPACK_SIZE; } @Override @@ -57,7 +59,7 @@ public void setItem(int i, ItemStack itemStack) { } @Override - public String getNameTranslationKey() { + public @NotNull String getNameTranslationKey() { return "moonsteel.container.backpack.star.name"; } @@ -68,7 +70,7 @@ public int getMaxStackSize() { @Override public void setChanged() { - + /* no need */ } public void readFromNBT(ListTag tagList) { @@ -97,7 +99,7 @@ public ListTag writeToNBT(ListTag tagList) { } @Override - public boolean stillValid(Player entityPlayer) { + public boolean stillValid(@NotNull Player entityPlayer) { if (!BetterWithBackpacks.ENABLE_BACKPACKS) { return false; } else if (entityPlayer.getHeldItem() == null) { @@ -109,7 +111,13 @@ public boolean stillValid(Player entityPlayer) { } @Override - public void sortContainer() { + public void sort() { InventorySorter.sortInventory(this.backpackItemStacks); } + + @Override + public boolean locked(int slot) { + return Container.super.locked(slot); + } + } diff --git a/src/main/java/useless/moonsteel/api/paxel/MoonSteelPaxel.java b/src/main/java/useless/moonsteel/api/paxel/MoonSteelPaxel.java new file mode 100644 index 0000000..160f206 --- /dev/null +++ b/src/main/java/useless/moonsteel/api/paxel/MoonSteelPaxel.java @@ -0,0 +1,54 @@ +package useless.moonsteel.api.paxel; + +import luke.paxels.ItemToolPaxel; +import luke.paxels.PaxelItems; +import luke.paxels.PaxelMod; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.render.item.model.ItemModelDispatcher; +import net.minecraft.client.render.item.model.ItemModelStandard; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.Items; +import turniplabs.halplibe.helper.ItemBuilder; +import turniplabs.halplibe.helper.creativeInventory.CreativeInventoryPlacement; +import turniplabs.halplibe.helper.recipeBuilders.RecipeBuilderShaped; +import useless.moonsteel.item.MoonSteelItems; + +import static net.minecraft.client.render.item.model.ItemModelDispatcher.*; +import static net.minecraft.client.render.item.model.ItemModelDispatcher.HANDHELD_THIRD_PERSON_LEFT_HAND; +import static useless.moonsteel.MoonSteel.MOD_ID; +import static useless.moonsteel.item.MoonSteelItems.MOON_STEEL_TOOL; + +public class MoonSteelPaxel { + + private MoonSteelPaxel(){} + + public static final int ID = 21000; + public static Item TOOL_PAXEL_MOONSTEEL; + + public static void initItem(){ + TOOL_PAXEL_MOONSTEEL = new ItemBuilder(MOD_ID) + .setCreativeInventoryPlacement(new CreativeInventoryPlacement.After(() -> Items.TOOL_SWORD_STEEL)) + .build(new ItemToolPaxel("tool.paxel.moonsteel", MOD_ID + ":item/tool_paxel_moonsteel", ID, MOON_STEEL_TOOL)); + } + + public static void recipeReady(){ + new RecipeBuilderShaped(PaxelMod.MOD_ID, "A5P", " S ", " S ") + .addInput('A', MoonSteelItems.TOOL_AXE_MOONSTEEL) + .addInput('5', MoonSteelItems.TOOL_SHOVEL_MOONSTEEL) + .addInput('P', MoonSteelItems.TOOL_PICKAXE_MOONSTEEL) + .addInput('S', Items.STICK) + .create("moonsteel_paxel", new ItemStack(TOOL_PAXEL_MOONSTEEL)); + } + + @Environment(EnvType.CLIENT) + public static void initItemModels(ItemModelDispatcher dispatcher) { + dispatcher.addDispatch(new ItemModelStandard(TOOL_PAXEL_MOONSTEEL).setIcon("moonsteel:item/moonsteel_paxel") + .setDisplayPos("firstperson_righthand", HANDHELD_FIRST_PERSON_RIGHT_HAND) + .setDisplayPos("firstperson_lefthand", HANDHELD_FIRST_PERSON_LEFT_HAND) + .setDisplayPos("thirdperson_righthand", HANDHELD_THIRD_PERSON_RIGHT_HAND) + .setDisplayPos("thirdperson_lefthand", HANDHELD_THIRD_PERSON_LEFT_HAND) + ); + } +} diff --git a/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java b/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java deleted file mode 100644 index 6447bad..0000000 --- a/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java +++ /dev/null @@ -1,27 +0,0 @@ -package useless.moonsteel.block; - -import net.minecraft.client.render.block.model.BlockModelHorizontalRotation; -import net.minecraft.client.render.texture.stitcher.IconCoordinate; -import net.minecraft.client.render.texture.stitcher.TextureRegistry; -import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockLogic; -import net.minecraft.core.util.helper.Side; -import net.minecraft.core.world.WorldSource; -import useless.moonsteel.MoonSteel; - -public class BlockModelStellarRewinder extends BlockModelHorizontalRotation { - private static IconCoordinate icon_front = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":block/stellarrewinder_front"); - private static IconCoordinate icon_front_active = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":block/stellarrewinder_front_active"); - public BlockModelStellarRewinder(Block block) { - super(block); - } - @Override - public IconCoordinate getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) { - IconCoordinate iconCoordinate = super.getBlockTexture(blockAccess, x, y, z, side); - TileEntityStellarRewinder rewinder = (TileEntityStellarRewinder) blockAccess.getTileEntity(x,y,z); - if (rewinder.inUse && iconCoordinate == icon_front){ - iconCoordinate = icon_front_active; - } - return iconCoordinate; - } -} diff --git a/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java b/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java deleted file mode 100644 index 2e5305a..0000000 --- a/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java +++ /dev/null @@ -1,29 +0,0 @@ -package useless.moonsteel.block; - -import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockLogicRotatable; -import net.minecraft.core.block.material.Material; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.util.helper.Side; -import net.minecraft.core.world.World; -import useless.moonsteel.MoonSteelItems; - -public class BlockStellarRewinder extends BlockLogicRotatable { - //Uses BlockTileEntityRotatable for its rotation properties not because its a tileEntity - public BlockStellarRewinder(Block block, Material material) { - super(block, material); - block.withEntity(TileEntityStellarRewinder::new); - } - - @Override - public boolean onBlockRightClicked(World world, int x, int y, int z, Player player, Side side, double xHit, double yHit) { - ItemStack heldItem = player.getHeldItem(); - TileEntityStellarRewinder rewinder = (TileEntityStellarRewinder) world.getTileEntity(x,y,z); - if (heldItem != null && heldItem.getItem() == MoonSteelItems.STAR_CONNECTED){ - rewinder.linkStar(heldItem); - return true; - } - return false; - } -} diff --git a/src/main/java/useless/moonsteel/block/BlockTorchStar.java b/src/main/java/useless/moonsteel/block/BlockTorchStar.java index 2875086..797de3b 100644 --- a/src/main/java/useless/moonsteel/block/BlockTorchStar.java +++ b/src/main/java/useless/moonsteel/block/BlockTorchStar.java @@ -3,41 +3,51 @@ import net.minecraft.core.block.Block; import net.minecraft.core.block.BlockLogicTorch; import net.minecraft.core.world.World; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import useless.moonsteel.MoonSteel; import java.util.Random; public class BlockTorchStar extends BlockLogicTorch { + public BlockTorchStar(final Block block) { super(block); } @Override - public void animationTick(final World world, final int x, final int y, final int z, final Random rand) { - final double xPos = x + 0.5; - final double yPos = y + 0.575; - final double zPos = z + 0.5; + public void animationTick(final World world, final @NotNull TilePosc tilePos, final @NotNull Random rand) { + final double xPos = tilePos.x() + 0.5; + final double yPos = tilePos.y() + 0.6F; + final double zPos = tilePos.z() + 0.5; final double d3 = 0.22; final double d4 = 0.27; - final int side = world.getBlockMetadata(x, y, z) & MASK_DIRECTION; + double py = yPos + d3; + final int side = world.getBlockData(tilePos) & MASK_DIRECTION; switch (side) { - case SIDE_WEST: - world.spawnParticle("moonsteel$magic_smoke", xPos - d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos - d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_EAST: - world.spawnParticle("moonsteel$magic_smoke", xPos + d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos + d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_NORTH: - world.spawnParticle("moonsteel$magic_smoke", xPos, yPos + d3, zPos - d4, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos, yPos + d3, zPos - d4, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_SOUTH: - world.spawnParticle("moonsteel$magic_smoke", xPos, yPos + d3, zPos + d4, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos, yPos + d3, zPos + d4, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_BOTTOM: - world.spawnParticle("moonsteel$magic_smoke", xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0); + case SIDE_WEST -> { + double px = xPos - d4; + world.spawnParticle(MoonSteel.SMOKE, px, py, zPos, 0.0F, 0.0F, 0.0F, 0, false); + world.spawnParticle(MoonSteel.STAR, px, py, zPos, 0.0F, 0.0F, 0.0F, 0, false); + } + case SIDE_EAST -> { + double px = xPos + d4; + world.spawnParticle(MoonSteel.SMOKE, px, py, zPos, 0.0F, 0.0F, 0.0F, 0, false); + world.spawnParticle(MoonSteel.STAR, px, py, zPos, 0.0F, 0.0F, 0.0F, 0, false); + } + case SIDE_SOUTH -> { + double pz = zPos + d4; + world.spawnParticle(MoonSteel.SMOKE, xPos, py, pz, 0.0F, 0.0F, 0.0F, 0, false); + world.spawnParticle(MoonSteel.STAR, xPos, py, pz, 0.0F, 0.0F, 0.0F, 0, false); + } + case SIDE_BOTTOM -> { + world.spawnParticle(MoonSteel.SMOKE, xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0, false); + world.spawnParticle(MoonSteel.STAR, xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0, false); + } + default -> { // north side is default + double pz = zPos - d4; + world.spawnParticle(MoonSteel.SMOKE, xPos, py, pz, 0.0F, 0.0F, 0.0F, 0, false); + world.spawnParticle(MoonSteel.STAR, xPos, py, pz, 0.0F, 0.0F, 0.0F, 0, false); + } } } } diff --git a/src/main/java/useless/moonsteel/block/MoonSteelBlocks.java b/src/main/java/useless/moonsteel/block/MoonSteelBlocks.java new file mode 100644 index 0000000..4bae69e --- /dev/null +++ b/src/main/java/useless/moonsteel/block/MoonSteelBlocks.java @@ -0,0 +1,148 @@ +package useless.moonsteel.block; + +import net.minecraft.core.block.*; +import net.minecraft.core.block.material.MaterialColor; +import net.minecraft.core.block.material.Materials; +import net.minecraft.core.block.tag.BlockTags; +import net.minecraft.core.data.tag.Tag; +import net.minecraft.core.sound.BlockSounds; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.block.jar.BlockLogicLantern; +import useless.moonsteel.block.lamp.BlockLogicStarLamp; +import useless.moonsteel.block.rewinder.BlockStellarRewinder; +import useless.moonsteel.item.MoonSteelItems; + +import static useless.moonsteel.MoonSteel.MOD_ID; + +public class MoonSteelBlocks { + + private MoonSteelBlocks() { + } + + private static String formatTranslationKey(String key) { + return String.format("%s.%s", MOD_ID, key); + } + + private static String formatName(String name) { + return String.format("%s:block/%s", MOD_ID, name); + } + + public static final Block BLOCK_MOONSTEEL = + Blocks.register( + formatTranslationKey("block"), + formatName("block_moonsteel"), + MoonSteel.blockId++, + b -> new BlockLogic(b, Materials.METAL) + ) + .withHardness(5f) + .withBlastResistance(2000f) + .withTags(BlockTags.MINEABLE_BY_PICKAXE); + + public static final Block TORCH_STAR = + Blocks.register( + formatTranslationKey("torch.star"), + formatName("torch_star"), + MoonSteel.blockId++, + BlockTorchStar::new + ) + .withLightEmission(15); + + public static final Block STELLAR_REWINDER = + Blocks.register( + formatTranslationKey("stellar.rewinder"), + formatName("stellar_rewinder"), + MoonSteel.blockId++, + b -> new BlockStellarRewinder(b, Materials.METAL) + ) + .withHardness(3.5f) + .withTags(BlockTags.MINEABLE_BY_PICKAXE); + + public static final Block STAR_LAMP = + Blocks.register( + formatTranslationKey("star.lamp"), + formatName("star_lamp"), + MoonSteel.blockId++, + b -> new BlockLogicStarLamp(b, Materials.METAL) + ) + .withSound(BlockSounds.GLASS) + .withHardness(0.5F) + .withLightEmission(15) + .withTags(BlockTags.NOT_IN_CREATIVE_MENU, BlockTags.MINEABLE_BY_PICKAXE); + + public static final Block JAR_STAR = + Blocks.register( + formatTranslationKey("jar.star"), + formatName("jar_star"), + MoonSteel.blockId++, + b -> new BlockLogicLantern(b, () -> MoonSteelItems.STAR_JAR ) + ) + .withSound(BlockSounds.GLASS) + .withHardness(0.1F) + .setStatParent(() -> MoonSteelItems.STAR_JAR) + .withLightEmission(15) + .withTags(BlockTags.BROKEN_BY_FLUIDS, BlockTags.MINEABLE_BY_PICKAXE, BlockTags.NOT_IN_CREATIVE_MENU); + + + public static final Block MOONSTEEL_BRICKS = + Blocks.register( + formatTranslationKey("brick.moonsteel"), + formatName("brick_moonsteel"), + MoonSteel.blockId++, + b -> new BlockLogic(b, Materials.STONE) + ) + .withSound(BlockSounds.STONE) + .withHardness(5f) + .withBlastResistance(2000f) + .withTags(BlockTags.MINEABLE_BY_PICKAXE, BlockTags.CHAINLINK_FENCES_CONNECT); + ; + + + public static final Block SLAB_MOONSTEEL_BRICK = + Blocks.register( + formatTranslationKey("slab.brick.moonsteel"), + formatName("slab_brick_moonsteel"), + MoonSteel.blockId++, + b -> new BlockLogicSlab(b, MOONSTEEL_BRICKS) + ) + .withSound(BlockSounds.METAL) + .withHardness(5f) + .withBlastResistance(2000f) + .withLitInteriorSurface(true). + withTags(BlockTags.MINEABLE_BY_PICKAXE); + + + public static final Block STAIR_MOONSTEEL_BRICKS = + Blocks.register( + formatTranslationKey("stair.brick.moonsteel"), + formatName("stair"), + MoonSteel.blockId++, + b -> new BlockLogicStairs(b, MOONSTEEL_BRICKS) + ) + .withSound(BlockSounds.METAL) + .withBlastResistance(2000f) + .withHardness(5f) + .withLitInteriorSurface(true) + .withTags(BlockTags.MINEABLE_BY_PICKAXE); + + + public static final Tag> FORCE_FORTUNE = Tag.of("moonsteel$force_enable_fortune"); + public static final Tag> FORCE_NO_FORTUNE = Tag.of("moonsteel$force_disable_fortune"); + + public static boolean canBeFortuned(Block block) { + if (block.hasTag(FORCE_FORTUNE)) return true; + if (block.hasTag(FORCE_NO_FORTUNE)) return false; + if (Block.hasLogicClass(block, BlockLogicLeavesBase.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreCoal.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreDiamond.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreGold.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreIron.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreLapis.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreNetherCoal.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreRedstone.class)) return true; + return Block.hasLogicClass(block, BlockLogicTallGrass.class); + } + + public static void init() { + /* no need */ + } +} diff --git a/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java b/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java deleted file mode 100644 index 3b0cfb4..0000000 --- a/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java +++ /dev/null @@ -1,67 +0,0 @@ -package useless.moonsteel.block; - -import com.mojang.nbt.tags.CompoundTag; -import net.minecraft.core.block.entity.TileEntity; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.util.helper.Side; -import net.minecraft.core.world.chunk.Chunk; -import useless.moonsteel.MoonSteel; - -public class TileEntityStellarRewinder extends TileEntity { - public boolean inUse = false; - public long checkCode = 0; - public Side side = Side.NORTH; - - public ItemStack linkStar(ItemStack stack){ - checkCode = worldObj.rand.nextLong(); - side = Side.getSideById(worldObj.getBlockMetadata(x, y, z)); - if (stack.getData().getBoolean("moonsteel$has_location")){ - int destX = stack.getData().getInteger("moonsteel$x"); - int destY = stack.getData().getInteger("moonsteel$y"); - int destZ = stack.getData().getInteger("moonsteel$z"); - MoonSteel.forceChunkLoads = true; - Chunk chunk = worldObj.getChunkProvider().provideChunk(destX >> 4, destZ >> 4); - MoonSteel.forceChunkLoads = false; - TileEntity te = chunk.getTileEntity(destX &0xF, destY, destZ &0xF); - if (te instanceof TileEntityStellarRewinder && ((TileEntityStellarRewinder) te).canTeleport(stack)){ - ((TileEntityStellarRewinder) te).setInUse(false); - } - } - stack.getData().putBoolean("moonsteel$has_location", true); - stack.getData().putInt("moonsteel$x", x ); - stack.getData().putInt("moonsteel$y", y ); - stack.getData().putInt("moonsteel$z", z ); - stack.getData().putInt("moonsteel$dimension", worldObj.dimension.id); - stack.getData().putLong("moonsteel$checkcode", checkCode); - setInUse(true); - return stack; - } - public boolean canTeleport(ItemStack stack){ - boolean can = true; - can &= stack.getData().getInteger("moonsteel$x") == x; - can &= stack.getData().getInteger("moonsteel$y") == y; - can &= stack.getData().getInteger("moonsteel$z") == z; - can &= stack.getData().getLong("moonsteel$checkcode") == checkCode; - return can; - } - public void setInUse(boolean flag){ - inUse = flag; - worldObj.notifyBlockChange(x, y, z, worldObj.getBlockId(x, y, z)); - } - - @Override - public void readFromNBT(CompoundTag tag) { - super.readFromNBT(tag); - this.inUse = tag.getBoolean("inuse"); - this.checkCode = tag.getLong("checkcode"); - this.side = Side.getSideById(tag.getInteger("side")); - } - - @Override - public void writeToNBT(CompoundTag tag) { - super.writeToNBT(tag); - tag.putBoolean("inuse", inUse); - tag.putLong("checkcode", checkCode); - tag.putInt("side", side.getId()); - } -} diff --git a/src/main/java/useless/moonsteel/block/jar/BlockLogicLantern.java b/src/main/java/useless/moonsteel/block/jar/BlockLogicLantern.java new file mode 100644 index 0000000..98e3923 --- /dev/null +++ b/src/main/java/useless/moonsteel/block/jar/BlockLogicLantern.java @@ -0,0 +1,136 @@ +package useless.moonsteel.block.jar; + +import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockLogic; +import net.minecraft.core.block.Blocks; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.block.material.Materials; +import net.minecraft.core.block.support.ISupport; +import net.minecraft.core.block.support.ISupportable; +import net.minecraft.core.block.support.PartialSupport; +import net.minecraft.core.block.tag.BlockTags; +import net.minecraft.core.entity.animal.MobFireflyCluster; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.enums.EnumDropCause; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.world.World; +import net.minecraft.core.world.WorldSource; +import net.minecraft.core.world.pos.TilePos; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.joml.primitives.AABBd; +import org.joml.primitives.AABBdc; + +import java.util.function.Supplier; + +public class BlockLogicLantern extends BlockLogic implements ISupportable { + public static final int MASK_HANGING = 1; + public static final int MASK_ANGLED = 2; + private final Supplier itemSupplier; + + public BlockLogicLantern(@NotNull Block block, @NotNull Supplier itemSupplier) { + super(block, Materials.GLASS); + this.itemSupplier = itemSupplier; + this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.5F, 0.6875F); + } + + @Override + public @NotNull AABBdc getBoundsFromState(@NotNull WorldSource source, @NotNull TilePosc tilePos) { + int metadata = source.getBlockData(tilePos); + float offset = 0.0F; + if ((metadata & 1) != 0) { + offset = 0.3875F; + } + + return new AABBd(0.3125F, offset, 0.3125F, 0.6875F, 0.5F + offset, 0.6875F); + } + + @Override + public boolean isSolidRender() { + return false; + } + + @Override + public boolean isCubeShaped() { + return false; + } + + @Override + public @NotNull ISupport getSupport(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side) { + return PartialSupport.INSTANCE; + } + + + @Override + public boolean onInteracted(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Player player, @Nullable Side side, double xHit, double yHit) { + world.setBlockTypeRaw(tilePos, Blocks.AIR); + world.playSoundAtEntity(player, player, "item.pickup", 1.0F, 1.0F); + if (!world.isClientSide) { + world.dropItem(tilePos, new ItemStack(this.itemSupplier.get(), 1, 0)); + } + + world.markBlockDirty(tilePos); + return true; + } + + @Override + public void onPlacedOnSide(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side, double xHit, double yHit) { + if (side != Side.BOTTOM && (side == Side.TOP || yHit < 0.5F) || !this.isSupported(world, tilePos, Side.TOP) && !world.getBlockType(tilePos.up(new TilePos())).hasTag(BlockTags.CAN_HANG_OFF)) { + if ((side == Side.TOP || side != Side.BOTTOM && yHit < 0.5F) && this.isSupported(world, tilePos, Side.BOTTOM)) { + world.setBlockDataNotify(tilePos, 0); + } else { + if (!this.isSupported(world, tilePos, Side.TOP) && !world.getBlockType(tilePos.up(new TilePos())).hasTag(BlockTags.CAN_HANG_OFF)) { + world.setBlockDataNotify(tilePos, 0); + } else { + world.setBlockDataNotify(tilePos, MASK_HANGING); + } + + } + } else { + world.setBlockDataNotify(tilePos, MASK_HANGING); + } + } + + @Override + public boolean canPlaceAt(@NotNull World world, @NotNull TilePosc tilePos) { + return this.isSupported(world, tilePos, Side.TOP) || world.getBlockType(tilePos.up(new TilePos())).hasTag(BlockTags.CAN_HANG_OFF) || this.isSupported(world, tilePos, Side.BOTTOM); + } + + @Override + public void onNeighborChanged(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Block block) { + if (!this.canStay(world, tilePos)) { + this.dropWithCause(world, EnumDropCause.WORLD, tilePos, world.getBlockData(tilePos), null, null); + world.setBlockTypeNotify(tilePos, Blocks.AIR); + } + + } + + @Override + public ItemStack[] getBreakResult(@NotNull World world, @NotNull EnumDropCause dropCause, int data, @Nullable TileEntity tileEntity) { + return switch (dropCause) { + case PICK_BLOCK, SILK_TOUCH, WORLD -> new ItemStack[]{new ItemStack(this.itemSupplier.get())}; + default -> null; + }; + } + + @Override + public boolean canStay(@NotNull World world, @NotNull TilePosc tilePos) { + int meta = world.getBlockData(tilePos); + if ((meta & 1) == 0) { + return this.isSupported(world, tilePos, Side.BOTTOM); + } else { + return this.isSupported(world, tilePos, Side.TOP) || world.getBlockType(tilePos.up(new TilePos())).hasTag(BlockTags.CAN_HANG_OFF); + } + } + + public int getPistonPushReaction(@NotNull World world, @NotNull TilePosc tilePos) { + return 1; + } + + public @NotNull ISupport getSupportConstraint(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side) { + return side.isVertical() ? PartialSupport.INSTANCE.center() : PartialSupport.INSTANCE; + } +} diff --git a/src/main/java/useless/moonsteel/block/lamp/BlockLogicStarLamp.java b/src/main/java/useless/moonsteel/block/lamp/BlockLogicStarLamp.java new file mode 100644 index 0000000..0b08864 --- /dev/null +++ b/src/main/java/useless/moonsteel/block/lamp/BlockLogicStarLamp.java @@ -0,0 +1,127 @@ +package useless.moonsteel.block.lamp; + +import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockLogic; +import net.minecraft.core.block.Blocks; +import net.minecraft.core.block.material.Material; +import net.minecraft.core.block.support.ISupport; +import net.minecraft.core.block.support.ISupportable; +import net.minecraft.core.block.support.PartialSupport; +import net.minecraft.core.enums.EnumDropCause; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.world.World; +import net.minecraft.core.world.WorldSource; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.joml.primitives.AABBd; +import org.joml.primitives.AABBdc; + +public class BlockLogicStarLamp extends BlockLogic implements ISupportable { + + public static final float MIN_LENGTH = 0.0F; + public static final float MAX_LENGTH = 1.0F; + public static final float THINNESS = 2.0f / 16.0f; + public static final float HEIGHT = 5.0f /16.0F; + public static final float START = 5.5F / 16.0F; + + public BlockLogicStarLamp(@NotNull Block block, @NotNull Material material) { + super(block, material); + this.setBlockBounds(MAX_LENGTH - THINNESS, START, MIN_LENGTH, MAX_LENGTH, START + HEIGHT, MAX_LENGTH); + } + + @Override + public void onPlacedOnSide(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side, double xHit, double yHit) { + int meta = world.getBlockData(tilePos); + side = side.opposite(); + if (!this.isSupported(world, tilePos, side)) { + side = this.getDefaultSide(world, tilePos); + } + + if (side != Side.NONE) { + world.setBlockData(tilePos, setSide(meta, side)); + } else { + this.dropWithCause(world, EnumDropCause.WORLD, tilePos, meta, null, null); + world.setBlockTypeNotify(tilePos, Blocks.AIR); + } + } + + @Override + public @NotNull AABBdc getBoundsFromState(@NotNull WorldSource source, @NotNull TilePosc tilePos) { + int meta = source.getBlockData(tilePos); + AABBd aabbd; + switch (sideFromMeta(meta)) { + case BOTTOM -> aabbd = new AABBd(MIN_LENGTH, MIN_LENGTH, START, MAX_LENGTH, THINNESS, START + HEIGHT); + case TOP -> aabbd = new AABBd(MIN_LENGTH, MAX_LENGTH - THINNESS, START, MAX_LENGTH, MAX_LENGTH, START + HEIGHT); + case NORTH -> aabbd = new AABBd(MIN_LENGTH, START, MIN_LENGTH, MAX_LENGTH, START + HEIGHT, THINNESS); + case SOUTH -> aabbd = new AABBd(MIN_LENGTH, START, MAX_LENGTH - THINNESS, MAX_LENGTH, START + HEIGHT, MAX_LENGTH); + case WEST -> aabbd = new AABBd(MIN_LENGTH, START, MIN_LENGTH, THINNESS, START + HEIGHT, MAX_LENGTH); + default -> aabbd = new AABBd(MAX_LENGTH - THINNESS, START, MIN_LENGTH, MAX_LENGTH, START + HEIGHT, MAX_LENGTH); + } + return aabbd; + } + + @Override + public void onNeighborChanged(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Block block) { + if (!this.isSupported(world, tilePos, sideFromMeta(world.getBlockData(tilePos)))) { + this.dropWithCause(world, EnumDropCause.WORLD, tilePos, world.getBlockData(tilePos), null, null); + world.setBlockTypeNotify(tilePos, Blocks.AIR); + } + + } + + public static int setSide(int meta, @NotNull Side side) { + return meta & -15 | side.id << 1; + } + + public static @NotNull Side sideFromMeta(int meta) { + return Side.fromId((meta & 14) >> 1); + } + + private @NotNull Side getDefaultSide(@NotNull World world, @NotNull TilePosc tilePos) { + for (int i = 0; i < Side.sides.length; ++i) { + Side side = Side.sides[i]; + if (this.isSupported(world, tilePos, side)) { + return side; + } + } + + return Side.NONE; + } + + @Override + public int getPistonPushReaction(@NotNull World world, @NotNull TilePosc tilePos) { + return 1; + } + + @Override + public boolean canPlaceAt(@NotNull World world, @NotNull TilePosc tilePos) { + return this.isSupported(world, tilePos, Side.BOTTOM) + || this.isSupported(world, tilePos, Side.TOP) + || this.isSupported(world, tilePos, Side.NORTH) + || this.isSupported(world, tilePos, Side.SOUTH) + || this.isSupported(world, tilePos, Side.WEST) + || this.isSupported(world, tilePos, Side.EAST); + } + + @Override + public boolean isSolidRender() { + return false; + } + + @Override + public boolean isCubeShaped() { + return false; + } + + + @Override + public @NotNull ISupport getSupport(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side) { + return PartialSupport.INSTANCE; + } + + @Override + public @NotNull ISupport getSupportConstraint(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side) { + return PartialSupport.INSTANCE.center(); + } + +} diff --git a/src/main/java/useless/moonsteel/block/lamp/BlockModelStarLamp.java b/src/main/java/useless/moonsteel/block/lamp/BlockModelStarLamp.java new file mode 100644 index 0000000..eff7bf3 --- /dev/null +++ b/src/main/java/useless/moonsteel/block/lamp/BlockModelStarLamp.java @@ -0,0 +1,45 @@ +package useless.moonsteel.block.lamp; + +import net.minecraft.client.render.block.model.generic.BlockModelGeneric; +import net.minecraft.client.render.tessellator.TessellatorGeneral; +import net.minecraft.client.render.texture.stitcher.IconCoordinate; +import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockLogic; +import net.minecraft.core.block.BlockLogicPressurePlate; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.world.WorldSource; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.useless.dragonfly.data.block.BlockModelData; + +public class BlockModelStarLamp extends BlockModelGeneric { + + public BlockModelStarLamp(@NotNull Block block, @NotNull BlockModelData staticModel) { + super(block, staticModel); + } + + @Override + public boolean renderAttached(@NotNull TessellatorGeneral tessellator, @NotNull WorldSource worldSource, @NotNull TilePosc tilePos, boolean cullFaces, @Nullable IconCoordinate overrideTexture) { + Side direction = BlockLogicPressurePlate.sideFromMeta(worldSource.getBlockData(tilePos)); + boolean var10000; + switch (direction) { + // int rotX, int rotY, int rotZ, double xOff, double yOff, double zOff, + case BOTTOM -> var10000 = this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 1, 0, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + case TOP -> var10000 = this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 3, 0, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + case NORTH -> var10000 = this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 2, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + case SOUTH -> var10000 = this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 0, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + case WEST -> var10000 = this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 3, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + default -> var10000 = this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 1, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + + return var10000; + } + +} diff --git a/src/main/java/useless/moonsteel/block/rewinder/BlockModelStellarRewinder.java b/src/main/java/useless/moonsteel/block/rewinder/BlockModelStellarRewinder.java new file mode 100644 index 0000000..edcb3a6 --- /dev/null +++ b/src/main/java/useless/moonsteel/block/rewinder/BlockModelStellarRewinder.java @@ -0,0 +1,67 @@ +package useless.moonsteel.block.rewinder; + +import net.minecraft.client.render.block.model.BlockModelDispatcher; +import net.minecraft.client.render.block.model.generic.BlockModelGeneric; +import net.minecraft.client.render.tessellator.TessellatorGeneral; +import net.minecraft.client.render.texture.stitcher.IconCoordinate; +import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockLogic; +import net.minecraft.core.block.BlockLogicRotatable; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.util.helper.Direction; +import net.minecraft.core.world.WorldSource; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.useless.dragonfly.models.block.StaticBlockModel; + +public class BlockModelStellarRewinder extends BlockModelGeneric { + public final StaticBlockModel active; + + + public BlockModelStellarRewinder(Block block, String baseKey) { + super(block, BlockModelDispatcher.loadDataModel(baseKey)); + this.active = BlockModelDispatcher.loadDataModel(baseKey + "_active").asModel(); + } + + @Override + public @NotNull StaticBlockModel getModel(@NotNull WorldSource source, @NotNull TilePosc tilePosc) { + TileEntity tileEntity = source.getTileEntity(tilePosc); + if (tileEntity instanceof TileEntityStellarRewinder rewinder && rewinder.inUse()) { + return this.active; + } + return super.getModel(source, tilePosc); + } + + + @Override + public boolean renderAttached(@NotNull TessellatorGeneral tessellator, @NotNull WorldSource worldSource, @NotNull TilePosc tilePos, boolean cullFaces, @Nullable IconCoordinate overrideTexture) { + Direction direction = BlockLogicRotatable.getDirectionFromMeta(worldSource.getBlockData(tilePos)); + switch (direction) { + case UP -> { + return this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 1, 2, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + case DOWN -> { + return this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, -1, 2, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + case NORTH -> { + return this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 0, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + case WEST -> { + return this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 1, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + case EAST -> { + return this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 3, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + default -> { + return this.getModel(worldSource, tilePos) + .renderAttached(this, tessellator, worldSource, tilePos, 0, 2, 0, 0.0F, 0.0F, 0.0F, false, cullFaces, overrideTexture); + } + } + } +} diff --git a/src/main/java/useless/moonsteel/block/rewinder/BlockStellarRewinder.java b/src/main/java/useless/moonsteel/block/rewinder/BlockStellarRewinder.java new file mode 100644 index 0000000..db29cf9 --- /dev/null +++ b/src/main/java/useless/moonsteel/block/rewinder/BlockStellarRewinder.java @@ -0,0 +1,46 @@ +package useless.moonsteel.block.rewinder; + +import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockLogicRotatable; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.block.material.Material; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.world.World; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import useless.moonsteel.item.MoonSteelItems; + +import java.util.Random; + +public class BlockStellarRewinder extends BlockLogicRotatable { + private static final Random random = new Random(); + + //Uses BlockTileEntityRotatable for its rotation properties not because its a tileEntity + public BlockStellarRewinder(Block block, Material material) { + super(block, material); + block.withEntity(TileEntityStellarRewinder::new); + } + + @Override + public boolean onInteracted(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Player player, @Nullable Side side, double xHit, double yHit) { + ItemStack heldItem = player.getHeldItem(); + TileEntity tileEntity = world.getTileEntity(tilePos); + if(tileEntity instanceof TileEntityStellarRewinder rewinder + && heldItem != null + && heldItem.getItem() == MoonSteelItems.STAR_CONNECTED + ){ + rewinder.linkStar(heldItem); + world.playSoundAtEntity(null, player, "ui.ui_click", 5, 1f + random.nextFloat() * 0.1f); + return true; + } + return false; + } + + @Override + public int getPistonPushReaction(@NotNull World world, @NotNull TilePosc tilePos) { + return 2; + } +} diff --git a/src/main/java/useless/moonsteel/block/rewinder/TileEntityStellarRewinder.java b/src/main/java/useless/moonsteel/block/rewinder/TileEntityStellarRewinder.java new file mode 100644 index 0000000..72ce9fc --- /dev/null +++ b/src/main/java/useless/moonsteel/block/rewinder/TileEntityStellarRewinder.java @@ -0,0 +1,83 @@ +package useless.moonsteel.block.rewinder; + +import com.mojang.nbt.tags.CompoundTag; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.pos.ChunkPos; +import net.minecraft.core.world.pos.ChunkTilePos; +import org.jetbrains.annotations.NotNull; +import useless.moonsteel.MoonSteel; + +public class TileEntityStellarRewinder extends TileEntity { + private boolean inUse = false; + private long checkCode = 0; + private Side side = Side.NORTH; + + public Side side(){ + return this.side; + } + + public boolean inUse(){ + return this.inUse; + } + + public ItemStack linkStar(ItemStack stack){ + if(this.worldObj == null){ + return stack; + } + this.checkCode = this.worldObj.rand.nextLong(); + int data = this.worldObj.getBlockData(this.tilePos); + this.side = Side.fromId(data); + if (stack.getData().getBoolean("moonsteel$has_location")){ + int destX = stack.getData().getInteger("moonsteel$x"); + int destY = stack.getData().getInteger("moonsteel$y"); + int destZ = stack.getData().getInteger("moonsteel$z"); + MoonSteel.forceChunkLoads = true; + Chunk chunk = worldObj.getChunkProvider().provideChunk(new ChunkPos(destX >> 4, destZ >> 4), true); + MoonSteel.forceChunkLoads = false; + TileEntity te = chunk.getTileEntity(new ChunkTilePos(destX & 0xF, destY, destZ & 0xF)); + if (te instanceof TileEntityStellarRewinder tileEntityStellarRewinder && tileEntityStellarRewinder.canTeleport(stack)){ + tileEntityStellarRewinder.setInUse(false); + } + } + stack.getData().putBoolean("moonsteel$has_location", true); + stack.getData().putInt("moonsteel$x", this.tilePos.x() ); + stack.getData().putInt("moonsteel$y", this.tilePos.y() ); + stack.getData().putInt("moonsteel$z", this.tilePos.z() ); + stack.getData().putInt("moonsteel$dimension", this.worldObj.dimension.id); + stack.getData().putLong("moonsteel$checkcode", this.checkCode); + setInUse(true); + return stack; + } + public boolean canTeleport(ItemStack stack){ + boolean can = true; + can &= stack.getData().getInteger("moonsteel$x") == this.tilePos.x(); + can &= stack.getData().getInteger("moonsteel$y") == this.tilePos.y(); + can &= stack.getData().getInteger("moonsteel$z") == this.tilePos.z(); + can &= stack.getData().getLong("moonsteel$checkcode") == this.checkCode; + return can; + } + public void setInUse(boolean flag){ + inUse = flag; + if (this.worldObj != null) { + this.worldObj.notifyBlockChange(this.tilePos, this.worldObj.getBlockType(tilePos)); + } + } + + @Override + public void readAdditionalData(@NotNull CompoundTag tag) { + this.inUse = tag.getBoolean("inuse"); + this.checkCode = tag.getLong("checkcode"); + this.side = Side.fromId(tag.getInteger("side")); + } + + @Override + public void writeAdditionalData(@NotNull CompoundTag tag) { + tag.putBoolean("inuse", inUse); + tag.putLong("checkcode", checkCode); + tag.putInt("side", side.id); + + } +} diff --git a/src/main/java/useless/moonsteel/command/CommandScore.java b/src/main/java/useless/moonsteel/command/CommandScore.java new file mode 100644 index 0000000..663005b --- /dev/null +++ b/src/main/java/useless/moonsteel/command/CommandScore.java @@ -0,0 +1,157 @@ +package useless.moonsteel.command; + +import com.mojang.brigadier.Command; +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.LiteralMessage; +import com.mojang.brigadier.arguments.ArgumentTypeInteger; +import com.mojang.brigadier.builder.ArgumentBuilderLiteral; +import com.mojang.brigadier.builder.ArgumentBuilderRequired; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.lang.I18n; +import net.minecraft.core.net.command.CommandManager; +import net.minecraft.core.net.command.CommandSource; +import net.minecraft.core.net.command.arguments.ArgumentTypeEntity; +import net.minecraft.core.net.command.helpers.EntitySelector; + +import static useless.moonsteel.command.CommandScore.ReturnValues.*; + +public class CommandScore implements CommandManager.CommandRegistry { + + public static SimpleCommandExceptionType INVALID_ENTITY; + + @Override + public void register(CommandDispatcher commandDispatcher) { + INVALID_ENTITY = new SimpleCommandExceptionType(new LiteralMessage(I18n.getInstance().translateKey("score.command.not.applicable"))); + commandDispatcher.register(ArgumentBuilderLiteral.literal("moonsteel:score") + .then(ArgumentBuilderLiteral.literal("add") + .requires(src -> src.hasAdmin() && src.getSender() != null) + .then(ArgumentBuilderRequired.argument("player", ArgumentTypeEntity.username()) + .then(ArgumentBuilderRequired.argument("value", ArgumentTypeInteger.integer()) + .executes(ctx -> addScore(ctx, 0)) + ) + ) + ) + .then(ArgumentBuilderLiteral.literal("set") + .requires(src -> src.hasAdmin() && src.getSender() != null) + .then(ArgumentBuilderRequired.argument("player", ArgumentTypeEntity.username()) + .then(ArgumentBuilderRequired.argument("value", ArgumentTypeInteger.integer()) + .executes(CommandScore::setScore) + ) + ) + ) + .then(ArgumentBuilderLiteral.literal("remove") + .requires(src -> src.hasAdmin() && src.getSender() != null) + .then(ArgumentBuilderRequired.argument("player", ArgumentTypeEntity.username()) + .then(ArgumentBuilderRequired.argument("value", ArgumentTypeInteger.integer()) + .executes(ctx -> removeScore(ctx, 0)) + ) + ) + ) + .then(ArgumentBuilderLiteral.literal("list") + .then(ArgumentBuilderRequired.argument("player", ArgumentTypeEntity.username()) + .executes(CommandScore::infoScore) + ) + ) + ); + } + + private static Player getPlayer(CommandContext ctx) throws CommandSyntaxException { + Player player = null; + try { + player = ctx.getArgument("player", Player.class); + } catch (IllegalArgumentException e) { + player = ctx.getSource().getSender(); + } + if (player == null) { + throw INVALID_ENTITY.create(); + } + return player; + } + + private static int addScore(CommandContext ctx, int counter) throws CommandSyntaxException { + if (counter > 2) { + ctx.getSource().sendTranslatableMessage("score.command.cannot"); + return code(FAIL); + } + final Player player = getPlayer(ctx); + int value = ctx.getArgument("value", Integer.class); + if (value < 0) { + return removeScore(ctx, counter + 1); + } + value = CommandScore.addScore(player, value); + ctx.getSource().sendTranslatableMessage("score.command.add", player.getDisplayName(), value); + return Command.SINGLE_SUCCESS; + } + + private static int setScore(CommandContext ctx) throws CommandSyntaxException { + final Player player = getPlayer(ctx); + final int value = ctx.getArgument("value", Integer.class); + CommandScore.setScore(player, value); + ctx.getSource().sendTranslatableMessage("score.command.set", player.getDisplayName(), value); + return code(OK); + } + + private static int removeScore(CommandContext ctx, int counter) throws CommandSyntaxException { + if (counter > 2) { + ctx.getSource().sendTranslatableMessage("score.command.cannot"); + return code(FAIL); + } + final Player player = getPlayer(ctx); + int value = ctx.getArgument("value", Integer.class); + if (value < 0) { + return addScore(ctx, counter + 1); + } + value = CommandScore.subScore(player, value); + ctx.getSource().sendTranslatableMessage("score.command.remove", player.getDisplayName(), value); + return Command.SINGLE_SUCCESS; + } + + private static int infoScore(CommandContext ctx) throws CommandSyntaxException { + Player player = getPlayer(ctx); + ctx.getSource().sendTranslatableMessage("score.command.info", player.getDisplayName(), player.getScore()); + return Command.SINGLE_SUCCESS; + } + + public static int addScore(Player player, int value) { + int currentScore = player.getScore(); + if (currentScore > Integer.MAX_VALUE - value) { + player.score = Integer.MAX_VALUE; + return Integer.MAX_VALUE - currentScore; + } + player.score += value; + return value; + } + + public static int subScore(Player player, int value) { + int currentScore = player.getScore(); + if (currentScore < Integer.MIN_VALUE + value) { + player.score = Integer.MIN_VALUE; + return currentScore - Integer.MIN_VALUE + 1; + } + player.score -= value; + return value; + } + + public static void setScore(Player player, int value) { + player.score = value; + } + + public enum ReturnValues { + CANNOT(-2), + FAIL(-1), + OK(0); + private final int code; + + ReturnValues(int code) { + this.code = code; + } + + public static int code(ReturnValues v) { + return v.code; + } + } + +} diff --git a/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java b/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java index 1d08481..56b147d 100644 --- a/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java +++ b/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java @@ -1,31 +1,33 @@ package useless.moonsteel.fx; -import net.minecraft.client.entity.particle.ParticleSmoke; -import net.minecraft.client.render.LightmapHelper; -import net.minecraft.client.render.tessellator.Tessellator; +import net.minecraft.client.render.particle.ParticleSmoke; +import net.minecraft.client.render.tessellator.TessellatorParticle; import net.minecraft.client.render.texture.stitcher.IconCoordinate; import net.minecraft.client.render.texture.stitcher.TextureRegistry; import net.minecraft.core.util.helper.MathHelper; import net.minecraft.core.world.World; +import org.jetbrains.annotations.NotNull; import static useless.moonsteel.MoonSteel.MOD_ID; public class ParticleMagicSmoke extends ParticleSmoke { private static final IconCoordinate smoke = TextureRegistry.getTexture(MOD_ID + ":item/particle_magicsmoke"); - public float sizeO; + private final float sizeO; + public ParticleMagicSmoke(World world, double x, double y, double z, double xa, double ya, double za) { - super(world, x, y, z, xa, ya, za); + super(world, x, y, z, xa, ya, za, 1.0f, 0); // no scale unsure about data this.rCol = 1; this.gCol = 1; this.bCol = 1; this.tex = smoke; - this.lifetime = (int)(5.0 / (Math.random() * 0.9 + 0.2)); - size *= 1.5f; - sizeO = size; + this.lifetime = (int) (5.0 / (Math.random() * 0.9 + 0.2)); + this.size *= 1.5f; + this.sizeO = size; } + @Override - public void render(Tessellator t, float partialTick, double xOff, double yOff, double zOff, float xa, float ya, float za, float xa2, float za2) { - float f6 = ((float)this.age + partialTick) / (float)this.lifetime * 32.0f; + public void render(@NotNull TessellatorParticle tessellatorParticle, float partialTick) { + float f6 = (this.age + partialTick) / this.lifetime * 16.0f; if (f6 < 0.0f) { f6 = 0.0f; } @@ -33,38 +35,17 @@ public void render(Tessellator t, float partialTick, double xOff, double yOff, d f6 = 1.0f; } this.size = this.sizeO * f6; - if (this.tex != null) { - final float u0 = (float)this.tex.getIconUMin(); - final float u2 = (float)this.tex.getIconUMax(); - final float v0 = (float)this.tex.getIconVMin(); - final float v2 = (float)this.tex.getIconVMax(); - final float r = 0.1F * this.size; - final float x = (float)(this.xo + (this.x - this.xo) * (double)partialTick - xOff); - final float y = (float)(this.yo + (this.y - this.yo) * (double)partialTick - yOff); - final float z = (float)(this.zo + (this.z - this.zo) * (double)partialTick - zOff); - float br = 1.0F; - if (LightmapHelper.isLightmapEnabled()) { - t.setLightmapCoord(this.getLightmapCoord(partialTick)); - } else { - br = this.getBrightness(partialTick); - } - - t.setColorOpaque_F(this.rCol * br, this.gCol * br, this.bCol * br); - t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u2, v2); - t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u2, v0); - t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); - t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v2); - } + super.render(tessellatorParticle, partialTick); } + @Override public float getBrightness(float partialTick) { - float decay = MathHelper.clamp(((float)this.age + partialTick) / (float)this.lifetime, 0.0f, 1.0f); + float decay = MathHelper.clamp((this.age + partialTick) / this.lifetime, 0.0f, 1.0f); return super.getBrightness(partialTick) * decay + (1.0f - decay); } - @Override - public int getParticleTexture() { - return 2; - } + + + @Override public void tick() { super.tick(); diff --git a/src/main/java/useless/moonsteel/fx/ParticleStar.java b/src/main/java/useless/moonsteel/fx/ParticleStar.java index 41b0873..c3ec48c 100644 --- a/src/main/java/useless/moonsteel/fx/ParticleStar.java +++ b/src/main/java/useless/moonsteel/fx/ParticleStar.java @@ -1,57 +1,31 @@ package useless.moonsteel.fx; -import net.minecraft.client.entity.particle.ParticleFlame; -import net.minecraft.client.render.LightmapHelper; +import net.minecraft.client.render.particle.ParticleFlame; import net.minecraft.client.render.tessellator.Tessellator; +import net.minecraft.client.render.tessellator.TessellatorParticle; import net.minecraft.client.render.texture.stitcher.IconCoordinate; import net.minecraft.client.render.texture.stitcher.TextureRegistry; +import net.minecraft.core.util.helper.MathHelper; import net.minecraft.core.world.World; +import org.jetbrains.annotations.NotNull; +import useless.moonsteel.mixin.accessor.ParticleFlameAccessor; import static useless.moonsteel.MoonSteel.MOD_ID; public class ParticleStar extends ParticleFlame { private static final IconCoordinate star = TextureRegistry.getTexture(MOD_ID + ":item/particle_star"); - public float sizeO; + public ParticleStar(final World world, final double x, final double y, final double z, final double xd, final double yd, final double zd) { super(world, x, y, z, xd, yd, zd, Type.ORANGE); this.tex = star; - this.size *= 2.25f; - this.sizeO = this.size; + this.size *= 1.25f; + ((ParticleFlameAccessor) this).setOSize(this.size); } - @Override - public void render(final Tessellator t, final float partialTick, final double xOff, final double yOff, final double zOff, final float xa, final float ya, final float za, final float xa2, final float za2) { - final float s = ((float)this.age + partialTick) / (float)this.lifetime; - this.size = this.sizeO * (1.0f - s * s * 0.5f); - if (this.tex != null) { - final float u0 = (float)this.tex.getIconUMin(); - final float u2 = (float)this.tex.getIconUMax(); - final float v0 = (float)this.tex.getIconVMin(); - final float v2 = (float)this.tex.getIconVMax(); - final float r = 0.1F * this.size; - final float x = (float)(this.xo + (this.x - this.xo) * (double)partialTick - xOff); - final float y = (float)(this.yo + (this.y - this.yo) * (double)partialTick - yOff); - final float z = (float)(this.zo + (this.z - this.zo) * (double)partialTick - zOff); - float br = 1.0F; - if (LightmapHelper.isLightmapEnabled()) { - t.setLightmapCoord(this.getLightmapCoord(partialTick)); - } else { - br = this.getBrightness(partialTick); - } - t.setColorOpaque_F(this.rCol * br, this.gCol * br, this.bCol * br); - t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u2, v2); - t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u2, v0); - t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); - t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v2); - } - } + @Override public void tick() { super.tick(); this.tex = star; } - @Override - public int getParticleTexture() { - return 2; - } } diff --git a/src/main/java/useless/moonsteel/item/ItemConnectedStar.java b/src/main/java/useless/moonsteel/item/ItemConnectedStar.java deleted file mode 100644 index bee58ba..0000000 --- a/src/main/java/useless/moonsteel/item/ItemConnectedStar.java +++ /dev/null @@ -1,52 +0,0 @@ -package useless.moonsteel.item; - -import net.minecraft.core.block.entity.TileEntity; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.item.Item; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.util.helper.MathHelper; -import net.minecraft.core.util.helper.Side; -import net.minecraft.core.world.World; -import net.minecraft.core.world.chunk.Chunk; -import useless.moonsteel.MoonSteel; -import useless.moonsteel.block.TileEntityStellarRewinder; -import useless.moonsteel.interfaces.ITeleporter; - -public class ItemConnectedStar extends Item { - public ItemConnectedStar(String name, String namespaceId, int id) { - super(name, namespaceId, id); - } - - @Override - public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { - if (itemstack.getData().getBoolean("moonsteel$has_location")){ - int destX = itemstack.getData().getInteger("moonsteel$x"); - int destY = itemstack.getData().getInteger("moonsteel$y"); - int destZ = itemstack.getData().getInteger("moonsteel$z"); - int dim = itemstack.getData().getInteger("moonsteel$dimension"); - if (dim != world.dimension.id) { - entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.dimension"); - return itemstack; - } - int cost = MathHelper.floor(entityplayer.distanceTo(destX, destY, destZ)); - if (entityplayer.score < cost) { - entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.score"); - return itemstack; - } - MoonSteel.forceChunkLoads = true; - Chunk chunk = world.getChunkProvider().provideChunk(destX >> 4, destZ >> 4); - MoonSteel.forceChunkLoads = false; - TileEntity te = chunk.getTileEntity(destX &0xF, destY, destZ &0xF); - if (te instanceof TileEntityStellarRewinder && ((TileEntityStellarRewinder) te).canTeleport(itemstack)){ - entityplayer.score -= cost; - Side side = ((TileEntityStellarRewinder) te).side; - ((ITeleporter) entityplayer).moonsteel$teleport(destX + side.getOffsetX() + 0.5f, destY + side.getOffsetY(), destZ + side.getOffsetZ() + 0.5f); - ((TileEntityStellarRewinder) te).setInUse(false); - } else if (!world.isClientSide) { - entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.missing"); - } - itemstack.getData().putBoolean("moonsteel$has_location", false); - } - return itemstack; - } -} diff --git a/src/main/java/useless/moonsteel/item/MoonSteelItems.java b/src/main/java/useless/moonsteel/item/MoonSteelItems.java new file mode 100644 index 0000000..99b7481 --- /dev/null +++ b/src/main/java/useless/moonsteel/item/MoonSteelItems.java @@ -0,0 +1,113 @@ +package useless.moonsteel.item; + +import net.minecraft.core.enums.HumanArmorShape; +import net.minecraft.core.enums.WolfArmorShape; +import net.minecraft.core.item.*; +import net.minecraft.core.item.material.ArmorMaterial; +import net.minecraft.core.item.material.ToolMaterial; +import net.minecraft.core.item.tag.ItemTags; +import net.minecraft.core.item.tool.ItemToolAxe; +import net.minecraft.core.item.tool.ItemToolHoe; +import net.minecraft.core.item.tool.ItemToolPickaxe; +import net.minecraft.core.item.tool.ItemToolShovel; +import net.minecraft.core.item.tool.ItemToolSword; +import turniplabs.halplibe.helper.ArmorHelper; +import turniplabs.halplibe.helper.ItemBuilder; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.api.backpack.BackpackProxy; +import useless.moonsteel.block.MoonSteelBlocks; +import useless.moonsteel.item.connectstar.ItemConnectedStar; +import useless.moonsteel.MoonSteelConstants; + +import static useless.moonsteel.MoonSteel.MOD_ID; + +public class MoonSteelItems { + private MoonSteelItems(){} + + + public static final ToolMaterial MOON_STEEL_TOOL = new ToolMaterial().setDurability(1536).setEfficiency(7.0f, 14.0f).setMiningLevel(3).setDamage(2); + public static final ArmorMaterial MOON_STEEL_ARMOR = ArmorHelper.createArmorMaterial(MOD_ID, "moonsteel", 800, 51f, 45f, 45f, 100f); + + public static Item INGOT_MOONSTEEL; + public static Item INGOT_MOONSTEEL_CRUDE ; + public static Item TOOL_PICKAXE_MOONSTEEL; + public static Item TOOL_AXE_MOONSTEEL; + public static Item TOOL_SHOVEL_MOONSTEEL; + public static Item TOOL_HOE_MOONSTEEL; + public static Item TOOL_SWORD_MOONSTEEL; + + + public static Item ARMOR_HELMET_MOONSTEEL; + public static Item ARMOR_CHESTPLATE_MOONSTEEL; + public static Item ARMOR_LEGGINGS_MOONSTEEL; + public static Item ARMOR_BOOTS_MOONSTEEL; + + public static Item STAR_FALLEN; + public static Item STAR_CONNECTED; + + public static Item BACKPACK_COSMIC; + + // new Items + public static Item STAR_JAR; + public static Item ARMOR_WOLF_MOONSTEEL; + + public static void init() { + // 7.3 and before Items + INGOT_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new Item("ingot.moonsteel", MOD_ID + ":item/ingot_moonsteel", MoonSteel.itemId++)); + INGOT_MOONSTEEL_CRUDE = new ItemBuilder(MOD_ID) + .build(new Item("crude.moonsteel", MOD_ID + ":item/ingot_moonsteel_crude", MoonSteel.itemId++)); + TOOL_PICKAXE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolPickaxe("tool.pickaxe.moonsteel", MOD_ID + ":item/tool_pickaxe_moonsteel", MoonSteel.itemId++, MOON_STEEL_TOOL)); + + TOOL_AXE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolAxe("tool.axe.moonsteel", MOD_ID + ":item/tool_axe_moonsteel", MoonSteel.itemId++, MOON_STEEL_TOOL)); + TOOL_SHOVEL_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolShovel("tool.shovel.moonsteel", MOD_ID + ":item/tool_shovel_moonsteel", MoonSteel.itemId++, MOON_STEEL_TOOL)); + TOOL_HOE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolHoe("tool.hoe.moonsteel", MOD_ID + ":item/tool_hoe_moonsteel", MoonSteel.itemId++, MOON_STEEL_TOOL)); + TOOL_SWORD_MOONSTEEL = new ItemBuilder(MOD_ID) + .addTags(ItemTags.PREVENT_CREATIVE_MINING) + .build(new ItemToolSword("tool.sword.moonsteel", MOD_ID + ":item/tool_sword_moonsteel", MoonSteel.itemId++, MOON_STEEL_TOOL)); + + ARMOR_HELMET_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor<>("helmet.moonsteel", MOD_ID + ":item/armor_helmet_moonsteel", MoonSteel.itemId++, MOON_STEEL_ARMOR, HumanArmorShape.HEAD)); + ARMOR_CHESTPLATE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor<>("chestplate.moonsteel", MOD_ID + ":item/armor_chestplate_moonsteel", MoonSteel.itemId++, MOON_STEEL_ARMOR, HumanArmorShape.CHEST)); + ARMOR_LEGGINGS_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor<>("leggings.moonsteel", MOD_ID + ":item/armor_leggings_moonsteel", MoonSteel.itemId++, MOON_STEEL_ARMOR, HumanArmorShape.LEGS)); + ARMOR_BOOTS_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor<>("boots.moonsteel", MOD_ID + ":item/armor_boots_moonsteel", MoonSteel.itemId++, MOON_STEEL_ARMOR, HumanArmorShape.BOOTS)); + + STAR_FALLEN = new ItemBuilder(MOD_ID) + .build(new Item("star.fallen", MOD_ID + ":item/star_fallen", MoonSteel.itemId++)); + STAR_CONNECTED = new ItemBuilder(MOD_ID) + .setStackSize(1) + .build(new ItemConnectedStar("star.connected", MOD_ID + ":item/star_connected", MoonSteel.itemId++)); + + MoonSteelItems.initBackpack(); + MoonSteel.starZombieSword = MoonSteelItems.TOOL_SWORD_MOONSTEEL.getDefaultStack(); + + // 8.0.1 Items + STAR_JAR = new ItemBuilder(MOD_ID) + .build(new ItemPlaceable("jar.star", MOD_ID + ":item/jar_star", MoonSteel.itemId++, MoonSteelBlocks.JAR_STAR)); + + ARMOR_WOLF_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor<>("armor.wolf.moonsteel", MOD_ID + ":item/armor_wolf_moonsteel", MoonSteel.itemId++, MOON_STEEL_ARMOR, WolfArmorShape.BODY)); + } + + private static void initBackpack() { + boolean backPackIncluded = MoonSteelConstants.BACKPACKS.getAsBoolean(); + MoonSteelConstants.LOGGER.info("Backpacks present: {}", backPackIncluded); + if (backPackIncluded){ + BACKPACK_COSMIC = new ItemBuilder(MOD_ID) + .setStackSize(1) + .build( BackpackProxy.proxyBackpack("backpack.cosmic", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); + } else { + BACKPACK_COSMIC = new ItemBuilder(MOD_ID) + .setStackSize(1) + .setTags(ItemTags.NOT_IN_CREATIVE_MENU) + .build(new Item("backpack.cosmic.missing", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); + } + } +} diff --git a/src/main/java/useless/moonsteel/interfaces/ITeleporter.java b/src/main/java/useless/moonsteel/item/connectstar/ITeleporter.java similarity index 67% rename from src/main/java/useless/moonsteel/interfaces/ITeleporter.java rename to src/main/java/useless/moonsteel/item/connectstar/ITeleporter.java index 74795e1..112cdb5 100644 --- a/src/main/java/useless/moonsteel/interfaces/ITeleporter.java +++ b/src/main/java/useless/moonsteel/item/connectstar/ITeleporter.java @@ -1,4 +1,4 @@ -package useless.moonsteel.interfaces; +package useless.moonsteel.item.connectstar; public interface ITeleporter { void moonsteel$teleport(double x, double y, double z); diff --git a/src/main/java/useless/moonsteel/item/connectstar/ItemConnectedStar.java b/src/main/java/useless/moonsteel/item/connectstar/ItemConnectedStar.java new file mode 100644 index 0000000..5a2c9ac --- /dev/null +++ b/src/main/java/useless/moonsteel/item/connectstar/ItemConnectedStar.java @@ -0,0 +1,88 @@ +package useless.moonsteel.item.connectstar; + +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.sound.SoundCategory; +import net.minecraft.core.util.helper.MathHelper; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.world.World; +import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.chunk.provider.ChunkProvider; +import net.minecraft.core.world.chunk.provider.ChunkProviderThreaded; +import net.minecraft.core.world.pos.ChunkPos; +import net.minecraft.core.world.pos.ChunkTilePos; +import net.minecraft.server.world.chunk.provider.ChunkProviderServer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import turniplabs.halplibe.helper.EnvironmentHelper; +import useless.moonsteel.block.rewinder.TileEntityStellarRewinder; +import useless.moonsteel.mixin.accessor.ChunkProviderServerAccessor; +import useless.moonsteel.mixin.accessor.ChunkProviderThreadedAccessor; + +import java.util.Random; + +public class ItemConnectedStar extends Item { + private Random RANDOM = new Random(); + + + public ItemConnectedStar(String name, String namespaceId, int id) { + super(name, namespaceId, id); + } + + @Override + public @Nullable ItemStack onUse(@NotNull ItemStack itemstack, @NotNull World world, @NotNull Player entityplayer) { + if (itemstack.getData().getBoolean("moonsteel$has_location")) { + int destX = itemstack.getData().getInteger("moonsteel$x"); + int destY = itemstack.getData().getInteger("moonsteel$y"); + int destZ = itemstack.getData().getInteger("moonsteel$z"); + int dim = itemstack.getData().getInteger("moonsteel$dimension"); + if (dim != world.dimension.id) { + entityplayer.sendMessageTranslated("moonsteel.teleport.fail.dimension"); + return itemstack; + } + int cost = MathHelper.floor(entityplayer.distanceTo(destX, destY, destZ)); + if (entityplayer.score < cost) { + entityplayer.sendMessageTranslated("moonsteel.teleport.fail.score"); + return itemstack; + } + Chunk chunk = ItemConnectedStar.provideChunk(world.getChunkProvider(), new ChunkPos(destX >> 4, destZ >> 4)); + TileEntity te = chunk.getTileEntity(new ChunkTilePos(destX, destY, destZ)); + if (te instanceof TileEntityStellarRewinder tileEntityStellarRewinder && tileEntityStellarRewinder.canTeleport(itemstack)) { + entityplayer.score -= cost; + Side side = tileEntityStellarRewinder.side(); + ((ITeleporter) entityplayer).moonsteel$teleport(destX + side.offsetX() + 0.5f, destY + side.offsetY(), destZ + side.offsetZ() + 0.5f); + tileEntityStellarRewinder.setInUse(false); + world.playSoundEffect(null, SoundCategory.WORLD_SOUNDS, entityplayer.x, entityplayer.y, entityplayer.z, "moonsteel:starspawn", 5, 1f + RANDOM.nextFloat() * 0.1f); + } else if (!world.isClientSide) { + entityplayer.sendMessageTranslated("moonsteel.teleport.fail.missing"); + } + itemstack.getData().putBoolean("moonsteel$has_location", false); + } + return itemstack; + } + + private static Chunk provideChunk(ChunkProvider provider, ChunkPos chunkPosc) { + Chunk chunk = provider.provideChunk(chunkPosc, true); + // single Player + if (EnvironmentHelper.isSingleplayerClient() && provider instanceof ChunkProviderThreaded providerThreaded) { + chunk = providerThreaded.provideChunk(chunkPosc, true); + if (!chunk.isLoaded) { + chunk = ((ChunkProviderThreadedAccessor) provider).callLoadChunk(chunkPosc); + } + return chunk; + } + if(EnvironmentHelper.isMultiplayerClient()){ + return chunk; + } + if (provider instanceof ChunkProviderServer providerThreaded) { + chunk = providerThreaded.provideChunk(chunkPosc, true); + if (!chunk.isLoaded) { + chunk = ((ChunkProviderServerAccessor) provider).callLoadChunkFromFile(chunkPosc); + } + return chunk; + } + return chunk; + } +} diff --git a/src/main/java/useless/moonsteel/item/ItemModelConnectStar.java b/src/main/java/useless/moonsteel/item/connectstar/ItemModelConnectStar.java similarity index 80% rename from src/main/java/useless/moonsteel/item/ItemModelConnectStar.java rename to src/main/java/useless/moonsteel/item/connectstar/ItemModelConnectStar.java index 9f92fe6..1d35d4f 100644 --- a/src/main/java/useless/moonsteel/item/ItemModelConnectStar.java +++ b/src/main/java/useless/moonsteel/item/connectstar/ItemModelConnectStar.java @@ -1,4 +1,4 @@ -package useless.moonsteel.item; +package useless.moonsteel.item.connectstar; import net.minecraft.client.render.item.model.ItemModelStandard; import net.minecraft.client.render.texture.stitcher.IconCoordinate; @@ -12,13 +12,15 @@ public class ItemModelConnectStar extends ItemModelStandard { private static final IconCoordinate star_connected = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":item/connected_star"); - public ItemModelConnectStar(final Item item, final String namespace) { - super(item, namespace); + + public ItemModelConnectStar(final Item item) { + super(item, true); } + @NotNull @Override public IconCoordinate getIcon(@Nullable final Entity entity, final ItemStack itemStack) { - if (itemStack.getData().getBoolean("moonsteel$has_location")){ + if (itemStack.getData().getBoolean("moonsteel$has_location")) { return star_connected; } return super.getIcon(entity, itemStack); diff --git a/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java b/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java deleted file mode 100644 index 9a22352..0000000 --- a/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -package useless.moonsteel.mixin; - -import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockLogic; -import net.minecraft.core.block.entity.TileEntity; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.enums.EnumDropCause; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.item.tool.ItemTool; -import net.minecraft.core.world.World; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.MoonSteel; -import useless.moonsteel.MoonSteelBlocks; -import useless.moonsteel.MoonSteelItems; - -@Mixin(value = BlockLogic.class,remap = false) -public abstract class BlockLogicMixin { - - @Shadow - @Final - @NotNull - public Block block; - - @Shadow - public abstract void dropBlockWithCause(World world, EnumDropCause cause, int x, int y, int z, int meta, TileEntity tileEntity, Player player); - - @Inject(method = "harvestBlock(Lnet/minecraft/core/world/World;Lnet/minecraft/core/entity/player/Player;IIIILnet/minecraft/core/block/entity/TileEntity;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/core/block/BlockLogic;dropBlockWithCause(Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;IIIILnet/minecraft/core/block/entity/TileEntity;Lnet/minecraft/core/entity/player/Player;)V", - shift = At.Shift.AFTER)) - private void multiplyHarvest(final World world, final Player entityplayer, final int x, final int y, final int z, final int meta, final TileEntity tileEntity, final CallbackInfo ci){ - final ItemStack heldItemStack = entityplayer.inventory.getCurrentItem(); - if (heldItemStack != null && heldItemStack.getItem() instanceof ItemTool && ((ItemTool) heldItemStack.getItem()).getMaterial() == MoonSteelItems.moonSteelTool && MoonSteelBlocks.canBeFortuned(this.block)){ - for (int i = 0; i < world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); i++) { - dropBlockWithCause(world, EnumDropCause.PROPER_TOOL, x, y, z, meta, tileEntity, entityplayer); - } - } - } -} diff --git a/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java b/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java deleted file mode 100644 index 949ab8e..0000000 --- a/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package useless.moonsteel.mixin; - -import net.minecraft.client.world.chunk.provider.ChunkProviderStatic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import useless.moonsteel.MoonSteel; - -@Mixin(value = ChunkProviderStatic.class, remap = false) -public class ChunkProviderStaticMixin { - @Inject(method = "canChunkExist(II)Z", at = @At("HEAD"), cancellable = true) - private void overrideChunk(final int chunkX, final int chunkZ, final CallbackInfoReturnable cir){ - if (MoonSteel.forceChunkLoads){ - cir.setReturnValue(true); - } - } -} diff --git a/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java b/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java deleted file mode 100644 index 20338e7..0000000 --- a/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package useless.moonsteel.mixin; - -import net.minecraft.client.render.entity.MobRendererBiped; -import net.minecraft.client.render.entity.MobRendererZombieArmored; -import net.minecraft.client.render.model.ModelBiped; -import net.minecraft.core.entity.monster.MobZombieArmored; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import useless.moonsteel.interfaces.IStarZombie; - -@Mixin(value = MobRendererZombieArmored.class, remap = false) -public class MobRenderZombieArmoredMixin extends MobRendererBiped { - public MobRenderZombieArmoredMixin(final ModelBiped model, final float shadowSize) { - super(model, shadowSize); - } - - @Inject(method = "prepareArmor(Lnet/minecraft/core/entity/monster/MobZombieArmored;IF)Z", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/MobRendererZombieArmored;bindTexture(Ljava/lang/String;)V", shift = At.Shift.AFTER)) - private void starZombie(final MobZombieArmored zombie, final int renderPass, final float partialTick, final CallbackInfoReturnable cir){ - if (((IStarZombie)zombie).moonsteel$isStarZombie()){ - this.bindTexture("/assets/moonsteel/textures/armor/moonsteel_" + (renderPass != 2 ? 1 : 2) + ".png"); - } - } -} diff --git a/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java b/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixinRewards.java similarity index 87% rename from src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java rename to src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixinRewards.java index 9d3ba24..5018167 100644 --- a/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java +++ b/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixinRewards.java @@ -2,7 +2,6 @@ import net.minecraft.core.WeightedRandomBag; import net.minecraft.core.WeightedRandomLootObject; -import net.minecraft.core.item.ItemStack; import net.minecraft.core.world.World; import net.minecraft.core.world.generate.feature.WorldFeatureLabyrinth; import org.spongepowered.asm.mixin.Mixin; @@ -10,13 +9,12 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import useless.moonsteel.MoonSteel; -import useless.moonsteel.MoonSteelItems; +import useless.moonsteel.item.MoonSteelItems; import java.util.Random; @Mixin(value = WorldFeatureLabyrinth.class, remap = false) -public class WorldFeatureLabyrinthMixin { +public class WorldFeatureLabyrinthMixinRewards { @Shadow public WeightedRandomBag chestLoot; diff --git a/src/main/java/useless/moonsteel/mixin/accessor/ChunkProviderServerAccessor.java b/src/main/java/useless/moonsteel/mixin/accessor/ChunkProviderServerAccessor.java new file mode 100644 index 0000000..05e240f --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/accessor/ChunkProviderServerAccessor.java @@ -0,0 +1,14 @@ +package useless.moonsteel.mixin.accessor; + +import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.pos.ChunkPosc; +import net.minecraft.server.world.chunk.provider.ChunkProviderServer; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ChunkProviderServer.class) +public interface ChunkProviderServerAccessor { + @Invoker + Chunk callLoadChunkFromFile(@NotNull ChunkPosc chunkPos); +} diff --git a/src/main/java/useless/moonsteel/mixin/accessor/ChunkProviderThreadedAccessor.java b/src/main/java/useless/moonsteel/mixin/accessor/ChunkProviderThreadedAccessor.java new file mode 100644 index 0000000..ed98bc4 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/accessor/ChunkProviderThreadedAccessor.java @@ -0,0 +1,14 @@ +package useless.moonsteel.mixin.accessor; + +import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.chunk.provider.ChunkProviderThreaded; +import net.minecraft.core.world.pos.ChunkPosc; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ChunkProviderThreaded.class) +public interface ChunkProviderThreadedAccessor { + @Invoker + Chunk callLoadChunk(@NotNull ChunkPosc chunkPos); +} diff --git a/src/main/java/useless/moonsteel/mixin/accessor/ParticleFlameAccessor.java b/src/main/java/useless/moonsteel/mixin/accessor/ParticleFlameAccessor.java new file mode 100644 index 0000000..b28fea1 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/accessor/ParticleFlameAccessor.java @@ -0,0 +1,14 @@ +package useless.moonsteel.mixin.accessor; + +import net.minecraft.client.render.particle.ParticleFlame; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ParticleFlame.class) +public interface ParticleFlameAccessor { + + @Mutable + @Accessor + void setOSize(float oSize); +} diff --git a/src/main/java/useless/moonsteel/mixin/entity/MobMixin.java b/src/main/java/useless/moonsteel/mixin/armor/MobMixin.java similarity index 90% rename from src/main/java/useless/moonsteel/mixin/entity/MobMixin.java rename to src/main/java/useless/moonsteel/mixin/armor/MobMixin.java index d2cf89b..2e28891 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/MobMixin.java +++ b/src/main/java/useless/moonsteel/mixin/armor/MobMixin.java @@ -1,4 +1,4 @@ -package useless.moonsteel.mixin.entity; +package useless.moonsteel.mixin.armor; import net.minecraft.core.entity.Entity; import net.minecraft.core.entity.Mob; @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.MoonSteelItems; +import useless.moonsteel.item.MoonSteelItems; import useless.moonsteel.interfaces.IMoonGrav; import useless.moonsteel.MoonSteel; import useless.moonsteel.mixin.accessor.ItemToolSwordAccessor; @@ -24,7 +24,7 @@ public abstract class MobMixin extends Entity { @Shadow protected abstract void dropDeathItems(); - public MobMixin(final World world) { + protected MobMixin(final World world) { super(world); } @@ -54,9 +54,9 @@ private int changeFallDamage(final int i){ @Inject(method = "onDeath(Lnet/minecraft/core/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/entity/Mob;dropDeathItems()V")) private void multiplyDrop(final Entity entity, final CallbackInfo ci){ - if (entity instanceof Player){ - final ItemStack heldStack = ((Player) entity).getHeldItem(); - if (heldStack != null && heldStack.getItem() instanceof ItemToolSword && ((ItemToolSwordAccessor) heldStack.getItem()).getMaterial() == MoonSteelItems.moonSteelTool){ + if (entity instanceof Player player){ + final ItemStack heldStack = player.getHeldItem(); + if (heldStack != null && heldStack.getItem() instanceof ItemToolSword && ((ItemToolSwordAccessor) heldStack.getItem()).getMaterial() == MoonSteelItems.MOON_STEEL_TOOL){ for (int i = 0; i < this.random.nextInt(MoonSteel.LOOTING_AMOUNT); i++) { dropDeathItems(); } diff --git a/src/main/java/useless/moonsteel/mixin/armor/MobRenderZombieArmoredMixin.java b/src/main/java/useless/moonsteel/mixin/armor/MobRenderZombieArmoredMixin.java new file mode 100644 index 0000000..050ebcc --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/armor/MobRenderZombieArmoredMixin.java @@ -0,0 +1,33 @@ +package useless.moonsteel.mixin.armor; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.render.TextureManager; +import net.minecraft.client.render.entity.MobRendererZombieArmored; +import net.minecraft.core.entity.monster.MobZombieArmored; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.useless.dragonfly.models.entity.StaticEntityModel; +import useless.moonsteel.interfaces.IStarZombie; + +@Mixin(value = MobRendererZombieArmored.class, remap = false) +public class MobRenderZombieArmoredMixin { + + @Inject(method = "getAndSetupModelForLayer(Lnet/minecraft/core/entity/monster/MobZombieArmored;FFI)Lorg/useless/dragonfly/models/entity/StaticEntityModel;", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/MobRendererZombieArmored;bindTexture(Ljava/lang/String;)V", shift = At.Shift.AFTER)) + private void starZombie( + MobZombieArmored zombie, + float brightness, + float partialTick, + int renderPass, + CallbackInfoReturnable cir + ){ + if (((IStarZombie)zombie).moonsteel$isStarZombie()){ + String texturePath = "/assets/moonsteel/textures/armor/moonsteel_" + (renderPass != 3 ? 1 : 2) + ".png"; + TextureManager textureManager = Minecraft.getMinecraft().textureManager; + textureManager.bindTexture(textureManager.loadTexture(texturePath)); + + } + } +} diff --git a/src/main/java/useless/moonsteel/mixin/armor/MobWolfMixin.java b/src/main/java/useless/moonsteel/mixin/armor/MobWolfMixin.java new file mode 100644 index 0000000..2c8fa4a --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/armor/MobWolfMixin.java @@ -0,0 +1,22 @@ +package useless.moonsteel.mixin.armor; + +import net.minecraft.core.entity.animal.MobWolf; +import net.minecraft.core.item.IArmorItem; +import org.spongepowered.asm.mixin.Mixin; +import useless.moonsteel.interfaces.IMoonGrav; + +import static useless.moonsteel.item.MoonSteelItems.ARMOR_WOLF_MOONSTEEL; +import static useless.moonsteel.item.MoonSteelItems.MOON_STEEL_ARMOR; + +@Mixin(MobWolf.class) +public class MobWolfMixin implements IMoonGrav { + + static { + MobWolf.ARMOR_MATERIALS.put(MOON_STEEL_ARMOR, (IArmorItem) ARMOR_WOLF_MOONSTEEL); + } + + @Override + public double moonsteel$getGravScalar() { + return 0.5d; + } +} diff --git a/src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java b/src/main/java/useless/moonsteel/mixin/armor/MobZombieArmoredMixin.java similarity index 95% rename from src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java rename to src/main/java/useless/moonsteel/mixin/armor/MobZombieArmoredMixin.java index 63556b7..f88e33b 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java +++ b/src/main/java/useless/moonsteel/mixin/armor/MobZombieArmoredMixin.java @@ -1,4 +1,4 @@ -package useless.moonsteel.mixin.entity; +package useless.moonsteel.mixin.armor; import com.mojang.nbt.tags.CompoundTag; import net.minecraft.core.entity.EntityItem; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import useless.moonsteel.MoonSteel; -import useless.moonsteel.MoonSteelItems; +import useless.moonsteel.item.MoonSteelItems; import useless.moonsteel.interfaces.IMoonGrav; import useless.moonsteel.interfaces.IStarZombie; @@ -29,7 +29,7 @@ public abstract class MobZombieArmoredMixin extends MobZombie implements IMoonGr @Shadow public abstract boolean isHoldingSword(); - public MobZombieArmoredMixin(final World world) { + protected MobZombieArmoredMixin(final World world) { super(world); } diff --git a/src/main/java/useless/moonsteel/mixin/armor/PlayerMixinEquipment.java b/src/main/java/useless/moonsteel/mixin/armor/PlayerMixinEquipment.java new file mode 100644 index 0000000..2f5a30c --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/armor/PlayerMixinEquipment.java @@ -0,0 +1,25 @@ +package useless.moonsteel.mixin.armor; + +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.enums.HumanArmorShape; +import net.minecraft.core.player.inventory.container.ContainerInventory; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import useless.moonsteel.item.MoonSteelItems; +import useless.moonsteel.interfaces.IMoonGrav; + +@Mixin(value = Player.class, remap = false) +public class PlayerMixinEquipment implements IMoonGrav { + @Shadow + public ContainerInventory inventory; + + @Override + public double moonsteel$getGravScalar() { + double scalar = 0d; + if (inventory.armorItemInSlot(HumanArmorShape.HEAD) != null && inventory.armorItemInSlot(HumanArmorShape.HEAD).getItem() == MoonSteelItems.ARMOR_HELMET_MOONSTEEL) scalar += 0.167d; + if (inventory.armorItemInSlot(HumanArmorShape.CHEST) != null && inventory.armorItemInSlot(HumanArmorShape.CHEST).getItem() == MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL) scalar += 0.334d; + if (inventory.armorItemInSlot(HumanArmorShape.LEGS) != null && inventory.armorItemInSlot(HumanArmorShape.LEGS).getItem() == MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL) scalar += 0.167d; + if (inventory.armorItemInSlot(HumanArmorShape.BOOTS) != null && inventory.armorItemInSlot(HumanArmorShape.BOOTS).getItem() == MoonSteelItems.ARMOR_BOOTS_MOONSTEEL) scalar += 0.334d; + return (1/(scalar + 1)); + } +} diff --git a/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixinRespawn.java similarity index 73% rename from src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixin.java rename to src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixinRespawn.java index b64b2b5..a4496b8 100644 --- a/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixin.java +++ b/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixinRespawn.java @@ -9,15 +9,17 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.interfaces.IStarBackpack; +import useless.moonsteel.api.backpack.IStarBackpack; @Mixin(value = Minecraft.class, remap = false) -public class MinecraftMixin { +public class MinecraftMixinRespawn { @Shadow public PlayerLocal thePlayer; @Inject(method = "respawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/player/PlayerLocal;setGamemode(Lnet/minecraft/core/player/gamemode/Gamemode;)V", shift = At.Shift.AFTER)) public void keepBackpack(boolean flag, int i, CallbackInfo ci, @Local Player previousPlayer){ - ((IStarBackpack)thePlayer).moonsteel$setStarBackpackInventory(((IStarBackpack)previousPlayer).moonsteel$getStarBackpackInventory()); + IStarBackpack currentWearer = (IStarBackpack) thePlayer; + IStarBackpack previousWearer = (IStarBackpack) previousPlayer; + currentWearer.moonsteel$setStarBackpackInventory(previousWearer.moonsteel$getStarBackpackInventory()); } } diff --git a/src/main/java/useless/moonsteel/mixin/PacketHandlerClientMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PacketHandlerClientMixinGui.java similarity index 74% rename from src/main/java/useless/moonsteel/mixin/PacketHandlerClientMixin.java rename to src/main/java/useless/moonsteel/mixin/backpack/PacketHandlerClientMixinGui.java index ae9194b..e82fd4f 100644 --- a/src/main/java/useless/moonsteel/mixin/PacketHandlerClientMixin.java +++ b/src/main/java/useless/moonsteel/mixin/backpack/PacketHandlerClientMixinGui.java @@ -1,4 +1,4 @@ -package useless.moonsteel.mixin; +package useless.moonsteel.mixin.backpack; import net.minecraft.client.Minecraft; import net.minecraft.client.net.handler.PacketHandlerClient; @@ -10,19 +10,19 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import useless.moonsteel.MoonSteel; -import useless.moonsteel.interfaces.IStarBackpack; +import useless.moonsteel.api.backpack.IStarBackpack; @Mixin(value= PacketHandlerClient.class,remap = false) -public abstract class PacketHandlerClientMixin { +public abstract class PacketHandlerClientMixinGui { @Final @Shadow private Minecraft mc; - @Inject(method="handleOpenWindow",at=@At("TAIL")) + @Inject(method = "handleContainerOpen", at = @At("TAIL")) public void inject(final PacketContainerOpen packetContainerOpen, final CallbackInfo ci) { if (packetContainerOpen.inventoryType == MoonSteel.GUI_ID) { ((IStarBackpack)(this.mc.thePlayer)).moonsteel$displayGuiStarBackpack(); - this.mc.thePlayer.craftingInventory.containerId = packetContainerOpen.windowId; + this.mc.thePlayer.containerMenu.containerId = packetContainerOpen.windowId; } } } diff --git a/src/main/java/useless/moonsteel/mixin/PlayerListMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerListMixinRespawn.java similarity index 88% rename from src/main/java/useless/moonsteel/mixin/PlayerListMixin.java rename to src/main/java/useless/moonsteel/mixin/backpack/PlayerListMixinRespawn.java index ce6c351..5a091c5 100644 --- a/src/main/java/useless/moonsteel/mixin/PlayerListMixin.java +++ b/src/main/java/useless/moonsteel/mixin/backpack/PlayerListMixinRespawn.java @@ -1,4 +1,4 @@ -package useless.moonsteel.mixin; +package useless.moonsteel.mixin.backpack; import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.server.entity.player.PlayerServer; @@ -7,10 +7,10 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import useless.moonsteel.interfaces.IStarBackpack; +import useless.moonsteel.api.backpack.IStarBackpack; @Mixin(value = PlayerList.class, remap = false) -public class PlayerListMixin { +public class PlayerListMixinRespawn { @Inject(method = "recreatePlayerEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/player/inventory/container/ContainerInventory;transferAllContents(Lnet/minecraft/core/player/inventory/container/ContainerInventory;)V", shift = At.Shift.AFTER)) public void keepBackpackMP(final PlayerServer previousPlayer, final int i, final CallbackInfoReturnable cir, @Local(name = "newPlayer") final PlayerServer newPlayer){ ((IStarBackpack)newPlayer).moonsteel$setStarBackpackInventory(((IStarBackpack)previousPlayer).moonsteel$getStarBackpackInventory()); diff --git a/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixinGui.java similarity index 79% rename from src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixin.java rename to src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixinGui.java index 8616cb9..b15e102 100644 --- a/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixin.java +++ b/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixinGui.java @@ -7,16 +7,16 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import useless.moonsteel.GuiStarBackpack; +import useless.moonsteel.api.backpack.GuiStarBackpack; @Mixin(value = PlayerLocal.class, remap = false) -public class PlayerLocalMixin extends PlayerMixin { +public class PlayerLocalMixinGui extends PlayerMixin { @Shadow protected Minecraft mc; @Unique public PlayerLocal thisAs = (PlayerLocal) (Object)this; - public PlayerLocalMixin(@Nullable World world) { + public PlayerLocalMixinGui(@Nullable World world) { super(world); } diff --git a/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java index 52f4a6a..725bd29 100644 --- a/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java +++ b/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java @@ -5,25 +5,28 @@ import net.minecraft.core.entity.Mob; import net.minecraft.core.entity.player.Player; import net.minecraft.core.world.World; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.StarBackpackInventory; -import useless.moonsteel.interfaces.IStarBackpack; -import useless.moonsteel.interfaces.ITeleporter; +import useless.moonsteel.api.backpack.StarBackpackInventory; +import useless.moonsteel.api.backpack.IStarBackpack; @Mixin(value = Player.class, remap = false) -public abstract class PlayerMixin extends Mob implements IStarBackpack, ITeleporter { +public abstract class PlayerMixin extends Mob implements IStarBackpack { @Unique public StarBackpackInventory starBackpackInventory; - public PlayerMixin(@Nullable final World world) { + protected PlayerMixin(final World world) { super(world); } + @Override + public void moonsteel$displayGuiStarBackpack() { + + } + @Inject(method = "(Lnet/minecraft/core/world/World;)V", at = @At("TAIL")) private void createBackpack(final World world, final CallbackInfo ci){ this.starBackpackInventory = new StarBackpackInventory((Player) (Object)this); @@ -36,6 +39,7 @@ private void addData(final CompoundTag tag, final CallbackInfo ci){ private void loadData(final CompoundTag tag, final CallbackInfo ci){ this.starBackpackInventory.readFromNBT(tag.getList("moonsteel$InventoryStardust")); } + @Override public StarBackpackInventory moonsteel$getStarBackpackInventory() { return this.starBackpackInventory; @@ -45,14 +49,4 @@ private void loadData(final CompoundTag tag, final CallbackInfo ci){ public void moonsteel$setStarBackpackInventory(final StarBackpackInventory backpackInventory) { this.starBackpackInventory = backpackInventory; } - - @Override - public void moonsteel$displayGuiStarBackpack() { - - } - - @Override - public void moonsteel$teleport(final double x, final double y, final double z) { - setPos(x, y + this.bbHeight, z); - } } diff --git a/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java index d0f7461..ecb313a 100644 --- a/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java +++ b/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java @@ -3,17 +3,16 @@ import net.minecraft.core.net.packet.PacketContainerOpen; import net.minecraft.core.world.World; import net.minecraft.server.entity.player.PlayerServer; -import net.minecraft.server.net.handler.PacketHandlerServer; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import useless.moonsteel.ContainerStarBackpack; +import useless.moonsteel.api.backpack.ContainerStarBackpack; import useless.moonsteel.MoonSteel; @Mixin(value = PlayerServer.class, remap = false) public abstract class PlayerServerMixin extends PlayerMixin { - public PlayerServerMixin(@Nullable World world) { + protected PlayerServerMixin(@Nullable World world) { super(world); } @@ -22,8 +21,6 @@ public PlayerServerMixin(@Nullable World world) { @Shadow private int currentWindowId; - @Shadow - public PacketHandlerServer playerNetServerHandler; @Unique public PlayerServer thisAs = (PlayerServer) (Object)this; @@ -36,13 +33,10 @@ public PlayerServerMixin(@Nullable World world) { .sendPacket( new PacketContainerOpen(this.currentWindowId, MoonSteel.GUI_ID, "moonsteel$StarBackpack", backpack.backpackInventory.getContainerSize()) ); - this.thisAs.craftingInventory = backpack; - this.thisAs.craftingInventory.containerId = this.currentWindowId; - this.thisAs.craftingInventory.addSlotListener(this.thisAs); + this.thisAs.containerMenu = backpack; + this.thisAs.containerMenu.containerId = this.currentWindowId; + this.thisAs.containerMenu.addSlotListener(this.thisAs); } - @Override - public void moonsteel$teleport(final double x, final double y, final double z) { - this.playerNetServerHandler.teleport(x, y, z); - } + } diff --git a/src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java b/src/main/java/useless/moonsteel/mixin/chunkprovider/ChunkProviderServerMixin.java similarity index 71% rename from src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java rename to src/main/java/useless/moonsteel/mixin/chunkprovider/ChunkProviderServerMixin.java index 38b3ae7..b6fd316 100644 --- a/src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java +++ b/src/main/java/useless/moonsteel/mixin/chunkprovider/ChunkProviderServerMixin.java @@ -1,6 +1,7 @@ -package useless.moonsteel.mixin; +package useless.moonsteel.mixin.chunkprovider; import net.minecraft.core.world.chunk.Chunk; +import net.minecraft.core.world.pos.ChunkPosc; import net.minecraft.server.world.chunk.provider.ChunkProviderServer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -14,8 +15,8 @@ public class ChunkProviderServerMixin { @Shadow public boolean chunkLoadOverride; - @Inject(method = "provideChunk(II)Lnet/minecraft/core/world/chunk/Chunk;", at = @At("HEAD")) - private void overrideChunks(final int chunkX, final int chunkZ, final CallbackInfoReturnable cir){ + @Inject(method = "provideChunk", at = @At("HEAD")) + private void overrideChunks(ChunkPosc chunkPos, boolean priority, CallbackInfoReturnable cir){ this.chunkLoadOverride = MoonSteel.forceChunkLoads; } } diff --git a/src/main/java/useless/moonsteel/mixin/chunkprovider/ChunkProviderStaticMixin.java b/src/main/java/useless/moonsteel/mixin/chunkprovider/ChunkProviderStaticMixin.java new file mode 100644 index 0000000..4021a89 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/chunkprovider/ChunkProviderStaticMixin.java @@ -0,0 +1,17 @@ +package useless.moonsteel.mixin.chunkprovider; + +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import net.minecraft.client.world.chunk.provider.ChunkProviderStatic; +import net.minecraft.core.world.pos.ChunkPosc; +import org.spongepowered.asm.mixin.Mixin; +import useless.moonsteel.MoonSteel; + +@Mixin(value = ChunkProviderStatic.class, remap = false) +public class ChunkProviderStaticMixin { + + @WrapMethod(method = "canChunkExist") + private boolean overrideChunk(ChunkPosc chunkPos, Operation original){ + return MoonSteel.forceChunkLoads; + } +} diff --git a/src/main/java/useless/moonsteel/mixin/commandly/VeinMinerMixin.java b/src/main/java/useless/moonsteel/mixin/commandly/VeinMinerMixin.java new file mode 100644 index 0000000..689ccf4 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/commandly/VeinMinerMixin.java @@ -0,0 +1,76 @@ +package useless.moonsteel.mixin.commandly; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.core.block.Block; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.enums.EnumDropCause; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.tool.ItemTool; +import net.minecraft.core.world.World; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import redart15.commandly.veincapitator.VeinMining; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.block.MoonSteelBlocks; +import useless.moonsteel.item.MoonSteelItems; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Mixin(VeinMining.class) +public abstract class VeinMinerMixin { + + @WrapOperation(method = "breakBlock", at = @At(value = "INVOKE", target = "Lredart15/commandly/veincapitator/VeinMining;getBreakResult(Lnet/minecraft/core/block/Block;Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;Lnet/minecraft/core/world/pos/TilePosc;ILnet/minecraft/core/block/entity/TileEntity;)[Lnet/minecraft/core/item/ItemStack;")) + private ItemStack[] withItemClumping( + VeinMining veinmining, + @NotNull Block block, + World world, + EnumDropCause dropCause, + TilePosc tilePos, int meta, + TileEntity tileEntity, Operation original + ) { + ItemStack heldItemStack = ((VeinMiningAccessor) veinmining).getTool(); + ItemStack[] result = original.call(veinmining, block, world, dropCause, tilePos, meta, tileEntity); + if (heldItemStack != null + && heldItemStack.getItem() instanceof ItemTool itemTool + && itemTool.getMaterial() == MoonSteelItems.MOON_STEEL_TOOL + && MoonSteelBlocks.canBeFortuned(block) + ) { + List drops = new ArrayList<>(Arrays.asList(result)); + for (int i = 0; i < world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); i++) { + drops.addAll(Arrays.asList(original.call(veinmining, block, world, dropCause, tilePos, meta, tileEntity))); + } + return drops.toArray(ItemStack[]::new); + } + return result; + } + + + + @WrapOperation(method = "breakBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/block/Block;dropWithCause(Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;Lnet/minecraft/core/world/pos/TilePosc;ILnet/minecraft/core/block/entity/TileEntity;Lnet/minecraft/core/entity/player/Player;)V")) + private void withOutItemClumping( + Block block, + World world, + EnumDropCause dropCause, + TilePosc tilePos, int data, + TileEntity tileEntity, + Player player, Operation original + ){ + original.call(block, world, dropCause, tilePos, data, tileEntity, player); + ItemStack heldItemStack = ((VeinMiningAccessor)this).getTool(); + if (heldItemStack != null + && heldItemStack.getItem() instanceof ItemTool itemTool + && itemTool.getMaterial() == MoonSteelItems.MOON_STEEL_TOOL + && MoonSteelBlocks.canBeFortuned(block) + ) { + for (int i = 0; i < world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); i++) { + block.dropWithCause(world, EnumDropCause.PROPER_TOOL, tilePos, data, tileEntity, player); + } + } + } +} diff --git a/src/main/java/useless/moonsteel/mixin/commandly/VeinMiningAccessor.java b/src/main/java/useless/moonsteel/mixin/commandly/VeinMiningAccessor.java new file mode 100644 index 0000000..838b2e6 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/commandly/VeinMiningAccessor.java @@ -0,0 +1,12 @@ +package useless.moonsteel.mixin.commandly; + +import net.minecraft.core.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import redart15.commandly.veincapitator.VeinMining; + +@Mixin(VeinMining.class) +public interface VeinMiningAccessor { + @Accessor + ItemStack getTool(); +} diff --git a/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java b/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java deleted file mode 100644 index 9d42e12..0000000 --- a/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package useless.moonsteel.mixin.entity; - -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.item.IArmorItem; -import net.minecraft.core.player.inventory.container.ContainerInventory; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import useless.moonsteel.MoonSteelItems; -import useless.moonsteel.interfaces.IMoonGrav; - -@Mixin(value = Player.class, remap = false) -public class PlayerMixin implements IMoonGrav { - @Shadow - public ContainerInventory inventory; - - @Override - public double moonsteel$getGravScalar() { - double scalar = 0d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_HEAD) != null && inventory.armorItemInSlot(IArmorItem.PIECE_HEAD).getItem() == MoonSteelItems.ARMOR_HELMET_MOONSTEEL) scalar += 0.167d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_CHEST) != null && inventory.armorItemInSlot(IArmorItem.PIECE_CHEST).getItem() == MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL) scalar += 0.334d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_LEGS) != null && inventory.armorItemInSlot(IArmorItem.PIECE_LEGS).getItem() == MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL) scalar += 0.167d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_BOOTS) != null && inventory.armorItemInSlot(IArmorItem.PIECE_BOOTS).getItem() == MoonSteelItems.ARMOR_BOOTS_MOONSTEEL) scalar += 0.334d; - return (1/(scalar + 1)); - } -} diff --git a/src/main/java/useless/moonsteel/mixin/fortune/BlockLogicMixin.java b/src/main/java/useless/moonsteel/mixin/fortune/BlockLogicMixin.java new file mode 100644 index 0000000..53cd5e7 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/fortune/BlockLogicMixin.java @@ -0,0 +1,94 @@ +package useless.moonsteel.mixin.fortune; + +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; +import net.minecraft.core.block.Block; +import net.minecraft.core.block.BlockLogic; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.enums.EnumDropCause; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.tool.ItemTool; +import net.minecraft.core.world.World; +import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.block.MoonSteelBlocks; +import useless.moonsteel.item.MoonSteelItems; + +@Mixin(value = BlockLogic.class, remap = false) +public abstract class BlockLogicMixin { + + @Shadow + @Final + @NotNull + public Block block; + + @Shadow + public abstract void dropWithCause(World world, EnumDropCause cause, TilePosc tilePosc, int meta, TileEntity tileEntity, Player player); + + @Inject(method = "onHarvest", + at = @At(value = "INVOKE", target = "Lnet/minecraft/core/block/BlockLogic;dropWithCause(Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;Lnet/minecraft/core/world/pos/TilePosc;ILnet/minecraft/core/block/entity/TileEntity;Lnet/minecraft/core/entity/player/Player;)V") + ) + private void multiplyHarvest( + World world, Player entityplayer, + TilePosc tilePos, int data, TileEntity tileEntity, + CallbackInfo ci, + @Share("player") LocalRef sharedPlayer + ) { + sharedPlayer.set(entityplayer); + final ItemStack heldItemStack = entityplayer.inventory.getCurrentItem(); + if (heldItemStack != null && heldItemStack.getItem() instanceof ItemTool itemTool && itemTool.getMaterial() == MoonSteelItems.MOON_STEEL_TOOL && MoonSteelBlocks.canBeFortuned(this.block)) { + for (int i = 0; i < world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); i++) { + dropWithCause(world, EnumDropCause.PROPER_TOOL, tilePos, data, tileEntity, entityplayer); + } + } + } + +// @WrapMethod(method = "getBreakResult(Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;Lnet/minecraft/core/world/pos/TilePosc;ILnet/minecraft/core/block/entity/TileEntity;)[Lnet/minecraft/core/item/ItemStack;") +// private ItemStack[] multiplyBreakResults( +// World world, EnumDropCause dropCause, +// TilePosc tilePos, int data, +// TileEntity tileEntity, Operation original, +// @Share("player") LocalRef sharedPlayer +// ) { +// Player player = sharedPlayer.get(); +// ItemStack[] breakResults = original.call(world, dropCause, tilePos, data, tileEntity); +// if(player != null){ +// final ItemStack heldItemStack = player.inventory.getCurrentItem(); +// if (heldItemStack != null +// && heldItemStack.getItem() instanceof ItemTool itemTool +// && itemTool.getMaterial() == MoonSteelItems.MOON_STEEL_TOOL +// && MoonSteelBlocks.canBeFortuned(this.block) +// ) { +// List extraStacks = new ArrayList<>(); +// for (ItemStack stack : breakResults) { +// int extra = world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); +// if (stack.stackSize + extra <= stack.getMaxStackSize()) { +// stack.stackSize += extra; +// } else { +// int remaining = stack.stackSize + extra - stack.getMaxStackSize(); +// stack.stackSize = stack.getMaxStackSize(); +// ItemStack extraStack = stack.copy(); +// extraStack.stackSize = remaining; +// extraStacks.add(extraStack); +// } +// } +// ItemStack[] returnValue = Arrays.copyOf(breakResults, breakResults.length + extraStacks.size()); +// for (int i = 0; i < extraStacks.size(); i++) { +// returnValue[breakResults.length + i] = extraStacks.get(i); +// } +// return returnValue; +// } +// } +// return breakResults; +// } + + +} diff --git a/src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java b/src/main/java/useless/moonsteel/mixin/starfallen/EntityItemMixin.java similarity index 73% rename from src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java rename to src/main/java/useless/moonsteel/mixin/starfallen/EntityItemMixin.java index ca8d498..521a325 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java +++ b/src/main/java/useless/moonsteel/mixin/starfallen/EntityItemMixin.java @@ -1,4 +1,4 @@ -package useless.moonsteel.mixin.entity; +package useless.moonsteel.mixin.starfallen; import com.mojang.nbt.tags.CompoundTag; import net.minecraft.core.entity.Entity; @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.MoonSteelItems; +import useless.moonsteel.item.MoonSteelItems; import useless.moonsteel.interfaces.IFallenStar; @Mixin(value = EntityItem.class, remap = false) @@ -22,21 +22,30 @@ public abstract class EntityItemMixin extends Entity implements IFallenStar { @Unique public boolean despawnInDay = false; - public EntityItemMixin(final World world) { + protected EntityItemMixin(final World world) { super(world); } + @Inject(method = "(Lnet/minecraft/core/world/World;DDDLnet/minecraft/core/item/ItemStack;)V", at = @At("TAIL")) - private void constuct1(final World world, final double d, final double d1, final double d2, final ItemStack itemstack, final CallbackInfo ci){ - if (itemstack.getItem() == MoonSteelItems.STAR_FALLEN){ + private void constuct1(final World world, final double d, final double d1, final double d2, final ItemStack itemstack, final CallbackInfo ci) { + if (itemstack.getItem() == MoonSteelItems.STAR_FALLEN) { this.viewScale = 30; - if (this.y > world.getWorldType().getMaxY()){ - world.playSoundEffect(null, SoundCategory.WEATHER_SOUNDS, (float) this.x, world.findTopSolidBlock((int) this.x, (int) this.z) + 10, (float) this.z, "moonsteel:starspawn", 5, 1f + this.random.nextFloat() * 0.1f); + if (this.y > world.getWorldType().getMaxY(world)) { + world.playSoundEffect(null, SoundCategory.WEATHER_SOUNDS, (float) this.x, + world.findTopSolidBlock( + (int) this.x, + (int) this.z) + 10, + (float) this.z, + "moonsteel:starspawn", + 5, 1f + this.random.nextFloat() * 0.1f + ); } } } + @Inject(method = "tick()V", at = @At("TAIL")) - private void tick(final CallbackInfo ci){ - if (this.despawnInDay && this.world.isDaytime()){ + private void tick(final CallbackInfo ci) { + if (this.despawnInDay && this.world.isDaytime()) { this.remove(); } } @@ -45,14 +54,16 @@ private void tick(final CallbackInfo ci){ public void moonsteel$setDaylightSensitive(final boolean flag) { this.despawnInDay = flag; } + @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) - private void saveData(final CompoundTag tag, final CallbackInfo ci){ + private void saveData(final CompoundTag tag, final CallbackInfo ci) { tag.putBoolean("moonsteel$daydespawn", this.despawnInDay); } + @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) - private void loadData(final CompoundTag tag, final CallbackInfo ci){ + private void loadData(final CompoundTag tag, final CallbackInfo ci) { this.despawnInDay = tag.getBoolean("moonsteel$daydespawn"); - if (this.item.getItem() == MoonSteelItems.STAR_FALLEN){ + if (this.item.getItem() == MoonSteelItems.STAR_FALLEN) { this.viewScale = 5; } } diff --git a/src/main/java/useless/moonsteel/mixin/WorldMixin.java b/src/main/java/useless/moonsteel/mixin/starfallen/WorldMixinStarFall.java similarity index 58% rename from src/main/java/useless/moonsteel/mixin/WorldMixin.java rename to src/main/java/useless/moonsteel/mixin/starfallen/WorldMixinStarFall.java index 1286579..956eed9 100644 --- a/src/main/java/useless/moonsteel/mixin/WorldMixin.java +++ b/src/main/java/useless/moonsteel/mixin/starfallen/WorldMixinStarFall.java @@ -1,52 +1,52 @@ -package useless.moonsteel.mixin; +package useless.moonsteel.mixin.starfallen; import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.core.entity.EntityItem; import net.minecraft.core.item.ItemStack; import net.minecraft.core.world.World; -import net.minecraft.core.world.chunk.Chunk; -import net.minecraft.core.world.chunk.ChunkCoordinate; +import net.minecraft.core.world.WorldSource; import net.minecraft.core.world.type.WorldType; +import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import useless.moonsteel.MoonSteel; -import useless.moonsteel.MoonSteelItems; +import useless.moonsteel.item.MoonSteelItems; import useless.moonsteel.interfaces.IFallenStar; -import java.util.Iterator; import java.util.Random; @Mixin(value = World.class, remap = false) -public abstract class WorldMixin { - @Shadow - public abstract Chunk getChunkFromChunkCoords(int x, int z); +public abstract class WorldMixinStarFall { @Shadow - public WorldType worldType; + protected int updateLCG; @Shadow - protected int updateLCG; + public Random rand; @Shadow public abstract EntityItem dropItem(int x, int y, int z, ItemStack itemStack); @Shadow - public Random rand; + public abstract @NotNull WorldType getWorldType(); + @Inject(method = "updateBlocksAndPlayCaveSounds()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/world/World;getChunkFromChunkCoords(II)Lnet/minecraft/core/world/chunk/Chunk;", shift = At.Shift.AFTER)) - private void makeTheStarsFall(final CallbackInfo ci, @Local(name = "coordinate") final ChunkCoordinate coordinate){ + private void makeTheStarsFall( + final CallbackInfo ci, + @Local(name = "chunkBlockX") int chunkBlockX, + @Local(name = "chunkBlockZ") int chunkBlockZ + ){ if (!MoonSteel.isStarTime((World) (Object)this)) return; - final Chunk chunk = this.getChunkFromChunkCoords(coordinate.x, coordinate.z); if (this.rand.nextInt(MoonSteel.STAR_SPAWN_RATE) == 0){ this.updateLCG = this.updateLCG * 3 + 1013904223; final int randVal = this.updateLCG >> 2; - final int blockX = chunk.xPosition * 16 + (randVal & 0xF); - final int blockZ = chunk.zPosition * 16 + (randVal / 256 & 0xF); - - ((IFallenStar)dropItem(blockX, this.worldType.getMaxY() + 32, blockZ, MoonSteelItems.STAR_FALLEN.getDefaultStack())).moonsteel$setDaylightSensitive(true); + final int blockX = chunkBlockX + (randVal & 0xF); + final int blockZ = chunkBlockZ + (randVal / 256 & 0xF); + ((IFallenStar)dropItem(blockX, this.getWorldType().getMaxY((WorldSource) this) + 32, blockZ, MoonSteelItems.STAR_FALLEN.getDefaultStack())) + .moonsteel$setDaylightSensitive(true); } } } diff --git a/src/main/java/useless/moonsteel/mixin/stella/PlayerMixinStella.java b/src/main/java/useless/moonsteel/mixin/stella/PlayerMixinStella.java new file mode 100644 index 0000000..4edda2b --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/stella/PlayerMixinStella.java @@ -0,0 +1,22 @@ +package useless.moonsteel.mixin.stella; + +import net.minecraft.core.entity.Mob; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.world.World; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import useless.moonsteel.item.connectstar.ITeleporter; + +@Mixin(Player.class) +public class PlayerMixinStella extends Mob implements ITeleporter { + + public PlayerMixinStella(@NotNull World world) { + super(world); + } + + @Override + public void moonsteel$teleport(final double x, final double y, final double z) { + setPos(x, y + this.bbHeight, z); + } + +} diff --git a/src/main/java/useless/moonsteel/mixin/stella/PlayerServerMixinStella.java b/src/main/java/useless/moonsteel/mixin/stella/PlayerServerMixinStella.java new file mode 100644 index 0000000..ceefb87 --- /dev/null +++ b/src/main/java/useless/moonsteel/mixin/stella/PlayerServerMixinStella.java @@ -0,0 +1,24 @@ +package useless.moonsteel.mixin.stella; + + +import net.minecraft.core.world.World; +import net.minecraft.server.entity.player.PlayerServer; +import net.minecraft.server.net.handler.PacketHandlerServer; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(PlayerServer.class) +public class PlayerServerMixinStella extends PlayerMixinStella { + @Shadow + public PacketHandlerServer playerNetServerHandler; + + public PlayerServerMixinStella(@NotNull World world) { + super(world); + } + + @Override + public void moonsteel$teleport(final double x, final double y, final double z) { + this.playerNetServerHandler.teleport(x, y, z); + } +} diff --git a/src/main/java/useless/moonsteel/MoonSteelRecipes.java b/src/main/java/useless/moonsteel/recipe/MoonSteelRecipes.java similarity index 73% rename from src/main/java/useless/moonsteel/MoonSteelRecipes.java rename to src/main/java/useless/moonsteel/recipe/MoonSteelRecipes.java index 03c9d1d..b4f1ed5 100644 --- a/src/main/java/useless/moonsteel/MoonSteelRecipes.java +++ b/src/main/java/useless/moonsteel/recipe/MoonSteelRecipes.java @@ -1,4 +1,4 @@ -package useless.moonsteel; +package useless.moonsteel.recipe; import net.minecraft.core.WeightedRandomLootObject; import net.minecraft.core.crafting.LookupFuelFurnace; @@ -8,13 +8,17 @@ import net.minecraft.core.util.helper.DyeColor; import tosutosu.betterwithbackpacks.ModItems; import turniplabs.halplibe.helper.RecipeBuilder; -import turniplabs.halplibe.util.RecipeEntrypoint; +import useless.moonsteel.MoonSteelConstants; +import useless.moonsteel.block.MoonSteelBlocks; +import useless.moonsteel.item.MoonSteelItems; import static useless.moonsteel.MoonSteel.MOD_ID; -public class MoonSteelRecipes implements RecipeEntrypoint { - @Override - public void onRecipesReady() { +public class MoonSteelRecipes { + + private MoonSteelRecipes(){} + + public static void onRecipesReady() { LookupFuelFurnace.instance.addFuelEntry(MoonSteelItems.STAR_FALLEN.id, 9600); LookupFuelFurnaceBlast.instance.addFuelEntry(MoonSteelItems.STAR_FALLEN.id, 9600); @@ -112,6 +116,11 @@ public void onRecipesReady() { .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) .create("block_of_moonsteel", MoonSteelBlocks.BLOCK_MOONSTEEL.getDefaultStack()); + RecipeBuilder.Shaped(MOD_ID) + .setShape("M") + .addInput('M', MoonSteelBlocks.BLOCK_MOONSTEEL) + .create("block_to_moonsteel", new ItemStack(MoonSteelItems.INGOT_MOONSTEEL, 9)); + RecipeBuilder.Shaped(MOD_ID) .setShape( "F", @@ -140,7 +149,7 @@ public void onRecipesReady() { .addInput('C', MoonSteelItems.STAR_CONNECTED) .create("stellar_rewinder", MoonSteelBlocks.STELLAR_REWINDER.getDefaultStack()); - if (MoonSteel.backpackPresent){ + if (MoonSteelConstants.BACKPACKS.getAsBoolean()){ RecipeBuilder.Shaped(MOD_ID) .setShape( "MMM", @@ -161,10 +170,42 @@ public void onRecipesReady() { .addEntry(new WeightedRandomLootObject(Items.ORE_RAW_IRON.getDefaultStack(), 1), 5) .addEntry(new WeightedRandomLootObject(Items.ORE_RAW_GOLD.getDefaultStack(), 1), 1) .create("fallenstar"); + + RecipeBuilder.Shaped(MOD_ID) + .setShape("OSO", "OSO") + .addInput('O', Items.OLIVINE) + .addInput('S', MoonSteelItems.STAR_FALLEN) + .create("star_lamp", new ItemStack(MoonSteelBlocks.STAR_LAMP, 8)); + + RecipeBuilder.Shaped(MOD_ID) + .setShape("S", "J") + .addInput('S', MoonSteelItems.STAR_FALLEN) + .addInput('J', Items.JAR) + .create("jar_star", new ItemStack(MoonSteelItems.STAR_JAR)); + + RecipeBuilder.Shaped(MOD_ID) + .setShape(" MM", "MMM", "M M") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .create("moonstee_wolf_armor", new ItemStack(MoonSteelItems.ARMOR_WOLF_MOONSTEEL)); + + RecipeBuilder.Shaped(MOD_ID) + .setShape("MM", "MM") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL_CRUDE) + .create("moonsteel_bricks", new ItemStack(MoonSteelBlocks.MOONSTEEL_BRICKS, 4)); + + RecipeBuilder.Shaped(MOD_ID) + .setShape("M", "MM", "MMM") + .addInput('M', MoonSteelBlocks.MOONSTEEL_BRICKS) + .create("moonsteel_bricks_stairs", new ItemStack(MoonSteelBlocks.STAIR_MOONSTEEL_BRICKS, 6)); + + + RecipeBuilder.Shaped(MOD_ID) + .setShape("MMM") + .addInput('M', MoonSteelBlocks.MOONSTEEL_BRICKS) + .create("moonsteel_bricks_slab", new ItemStack(MoonSteelBlocks.SLAB_MOONSTEEL_BRICK, 6)); } - @Override - public void initNamespaces() { + public static void initNamespaces() { RecipeBuilder.initNameSpace(MOD_ID); } } diff --git a/src/main/resources/lang/moonsteel/en_US.lang b/src/main/resources/assets/moonsteel/lang/en_US/en_US.lang similarity index 68% rename from src/main/resources/lang/moonsteel/en_US.lang rename to src/main/resources/assets/moonsteel/lang/en_US/en_US.lang index 8f86ac3..83573da 100644 --- a/src/main/resources/lang/moonsteel/en_US.lang +++ b/src/main/resources/assets/moonsteel/lang/en_US/en_US.lang @@ -42,3 +42,31 @@ moonsteel.teleport.fail.dimension=Star is linked to a different dimension. moonsteel.container.backpack.star.name=Stardust Backpack subtitles.moonsteel.starspawn=Starfall +subtitles.moonsteel.click.rewinder=Star Link + +score.command.not.applicable= The command is not applicable to this entity. +score.command.cannot= Invalid target. +score.command.add= Added %2$d score to %1$s. +score.command.remove= Subtracted %2$d from %1$s. +score.command.info= Player %1$s has a score of %2$d. +score.command.set= Set %1$s score to %2$d. + +# compat 1 +item.moonsteel.tool.paxel.moonsteel.name=Moonsteel Paxel + +tile.moonsteel.star.lamp.name=Star Lamp +tile.moonsteel.star.lamp.desc=Shiny new lamp. +item.moonsteel.jar.star.name=Jar Star +item.moonsteel.jar.star.desc=A star in a jar, let off dim light. +tile.moonsteel.jar.star.name=Jar Star +tile.moonsteel.jar.star.desc=How did you get this item? +item.moonsteel.armor.wolf.moonsteel.name=Moonsteel Wolf Armor +item.moonsteel.armor.wolf.moonsteel.desc=Keep your best friend spacy! + +tile.moonsteel.brick.moonsteel.name=Moonsteel Bricks +tile.moonsteel.brick.moonsteel.desc=Stacked bricks of moonsteel. +tile.moonsteel.slab.brick.moonsteel.name=Moonsteel Bricks Slab +tile.moonsteel.slab.brick.moonsteel.desc=A slab of moonsteel bricks. +tile.moonsteel.stair.brick.moonsteel.name=Moonsteel Bricks Stairs +tile.moonsteel.stair.brick.moonsteel.desc=Moonsteel brick block used for vertical movement. + diff --git a/src/main/resources/lang/moonsteel/ru_RU.lang b/src/main/resources/assets/moonsteel/lang/ru_RU/ru_RU.lang similarity index 65% rename from src/main/resources/lang/moonsteel/ru_RU.lang rename to src/main/resources/assets/moonsteel/lang/ru_RU/ru_RU.lang index 9e3dec1..89979d9 100644 --- a/src/main/resources/lang/moonsteel/ru_RU.lang +++ b/src/main/resources/assets/moonsteel/lang/ru_RU/ru_RU.lang @@ -37,6 +37,35 @@ tile.moonsteel.stellar.rewinder.name=Звездная перемотка tile.moonsteel.stellar.rewinder.desc=Якорь для соединенный звезды, на которую можно ссылаться. moonsteel.teleport.fail.missing=Якорь был сломан, невозможно вернутса! +moonsteel.teleport.fail.score=Not enough score to establish link. moonsteel.teleport.fail.dimension=Якорь в другом измерение! moonsteel.container.backpack.star.name=Звезвдный Рюкзак +subtitles.moonsteel.starspawn=Звездопад +subtitles.moonsteel.click.rewinder=Звёздный линк + +score.command.not.applicable= Команда не применима к этой сущности. +score.command.cannot= Неверная цель. +score.command.add= Счет игрока %1$s увеличен на %2$d очков. +score.command.remove= Счёт игрока %1$s уменьшен на %2$d очков. +score.command.info= Счёт игрока %1$s: %2$d. +score.command.set= Счёт игрока %1$s установлен на %2$d. + +#paxel +item.moonsteel.tool.paxel.moonsteel.name=Лунсталный паксель + +tile.moonsteel.star.lamp.name=Звёздный лампа +tile.moonsteel.star.lamp.desc=Новая сверкающая лампа. +item.moonsteel.jar.star.name=Звёздный фонарь +item.moonsteel.jar.star.desc=Звезда в банке. +tile.moonsteel.jar.star.name=Jar Star +tile.moonsteel.jar.star.desc=Как вы этого добились? +item.moonsteel.armor.wolf.moonsteel.name=Лунстальная волчья броня +item.moonsteel.armor.wolf.moonsteel.desc=Пусть ваш лучший друг будет космическим! + +tile.moonsteel.brick.moonsteel.name=Лунстальные кирпичи +tile.moonsteel.brick.moonsteel.desc=Сложенные кирпичи из лунстали. +tile.moonsteel.slab.brick.moonsteel.name=Плита лунстальных кирпичей +tile.moonsteel.slab.brick.moonsteel.desc=Плита из лунстальных кирпичей. +tile.moonsteel.stair.brick.moonsteel.name=Ступени из лунстальных кирпичей +tile.moonsteel.stair.brick.moonsteel.desc=Блок лунстальных кирпичей для вертикального подъёма. diff --git a/src/main/resources/assets/moonsteel/models/block/jar_star.json b/src/main/resources/assets/moonsteel/models/block/jar_star.json new file mode 100644 index 0000000..4aaf70f --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/jar_star.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/template_lantern", + "textures": { + "all": "moonsteel:block/jar_star" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/jar_star_hanging.json b/src/main/resources/assets/moonsteel/models/block/jar_star_hanging.json new file mode 100644 index 0000000..da3ce0a --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/jar_star_hanging.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/template_lantern_hanging", + "textures": { + "all": "moonsteel:block/jar_star" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/moonsteel.json b/src/main/resources/assets/moonsteel/models/block/moonsteel.json new file mode 100644 index 0000000..5d045dd --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/moonsteel.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/cube_bottom_top", + "textures": { + "top": "moonsteel:block/moonsteel_block_top", + "bottom": "moonsteel:block/moonsteel_block_bottom", + "side": "moonsteel:block/moonsteel_block_side" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/moonsteel_brick.json b/src/main/resources/assets/moonsteel/models/block/moonsteel_brick.json new file mode 100644 index 0000000..334d704 --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/moonsteel_brick.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "moonsteel:block/moonsteel_brick" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/moonsteel_stair.json b/src/main/resources/assets/moonsteel/models/block/moonsteel_stair.json new file mode 100644 index 0000000..9f92def --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/moonsteel_stair.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/stairs", + "textures": { + "top": "moonsteel:block/moonsteel_brick", + "bottom": "moonsteel:block/moonsteel_brick", + "side": "moonsteel:block/moonsteel_brick" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/slab/full.json b/src/main/resources/assets/moonsteel/models/block/slab/full.json new file mode 100644 index 0000000..334d704 --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/slab/full.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "moonsteel:block/moonsteel_brick" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/slab/lower.json b/src/main/resources/assets/moonsteel/models/block/slab/lower.json new file mode 100644 index 0000000..8aa6e5c --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/slab/lower.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/slab/lower", + "textures": { + "top": "moonsteel:block/moonsteel_brick", + "bottom": "moonsteel:block/moonsteel_brick", + "side": "moonsteel:block/moonsteel_brick" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/slab/upper.json b/src/main/resources/assets/moonsteel/models/block/slab/upper.json new file mode 100644 index 0000000..106076c --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/slab/upper.json @@ -0,0 +1,8 @@ +{ + "parent": "minecraft:block/slab/upper", + "textures": { + "top": "moonsteel:block/moonsteel_brick", + "bottom": "moonsteel:block/moonsteel_brick", + "side": "moonsteel:block/moonsteel_brick" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/star_torch.json b/src/main/resources/assets/moonsteel/models/block/star_torch.json new file mode 100644 index 0000000..36e14b1 --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/star_torch.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/template_torch", + "textures": { + "torch": "moonsteel:block/startorch" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/star_torch_wall.json b/src/main/resources/assets/moonsteel/models/block/star_torch_wall.json new file mode 100644 index 0000000..9fadfa2 --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/star_torch_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/template_torch_wall", + "textures": { + "torch": "moonsteel:block/startorch" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/moonsteel/models/block/starlamp.json b/src/main/resources/assets/moonsteel/models/block/starlamp.json new file mode 100644 index 0000000..dec524c --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/starlamp.json @@ -0,0 +1,86 @@ +{ + "format_version": "1.21.11", + "credit": "Made with Blockbench", + "textures": { + "0": "moonsteel:block/starlamp", + "particle": "moonsteel:block/starlamp" + }, + "elements": [ + { + "name": "top_lamp", + "from": [0, 8.5, 14], + "to": [16, 9.5, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 8.5, 13]}, + "faces": { + "north": {"uv": [0, 11, 16, 12], "texture": "#0"}, + "east": {"uv": [0, 11, 1, 12], "texture": "#0"}, + "west": {"uv": [15, 11, 16, 12], "texture": "#0"}, + "up": {"uv": [0, 10, 16, 11], "texture": "#0"}, + "down": {"uv": [0, 12, 16, 13], "texture": "#0"} + } + }, + { + "name": "bottom_lamp", + "from": [0, 6.5, 14], + "to": [16, 7.5, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 6.5, 13]}, + "faces": { + "north": {"uv": [0, 11, 16, 12], "texture": "#0"}, + "east": {"uv": [0, 11, 1, 12], "texture": "#0"}, + "west": {"uv": [15, 11, 16, 12], "texture": "#0"}, + "up": {"uv": [0, 10, 16, 11], "texture": "#0"}, + "down": {"uv": [0, 12, 16, 13], "texture": "#0"} + } + }, + { + "name": "holder", + "from": [0, 5.5, 15], + "to": [16, 10.5, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 5.5, 15]}, + "faces": { + "north": {"uv": [0, 3, 16, 8], "texture": "#0"}, + "east": {"uv": [0, 3, 1, 8], "texture": "#0"}, + "south": {"uv": [1, 7, 15, 4], "texture": "#0"}, + "west": {"uv": [15, 3, 16, 8], "texture": "#0"}, + "up": {"uv": [0, 3, 16, 4], "texture": "#0"}, + "down": {"uv": [0, 7, 16, 8], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [-90, 90, 10], + "translation": [-7.5, 1.25, 1.25], + "scale": [0.5, 1, 1] + }, + "thirdperson_lefthand": { + "rotation": [-90, 90, 10], + "translation": [-7.5, 1.25, 1.25], + "scale": [0.5, 1, 1] + }, + "firstperson_righthand": { + "rotation": [45, 70, 0], + "translation": [0, 0, -7.5], + "scale": [0.5, 1, 1] + }, + "firstperson_lefthand": { + "rotation": [45, 70, 0], + "translation": [0, 0, -7.5], + "scale": [0.5, 1, 1] + }, + "ground": { + "translation": [0, 0, -8], + "scale": [0.5, 1, 1] + }, + "gui": { + "rotation": [20, -135, 0], + "translation": [10, -3.75, 80], + "scale": [1, 2, 2] + }, + "head": { + "rotation": [90, 0, 0], + "translation": [-0.25, 22, -0.25], + "scale": [1, 1, 2] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/moonsteel/models/block/stellarrewinder.json b/src/main/resources/assets/moonsteel/models/block/stellarrewinder.json new file mode 100644 index 0000000..0314495 --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/stellarrewinder.json @@ -0,0 +1,18 @@ +{ + "parent": "minecraft:block/orientable_with_sides", + "display": { + "firstperson_righthand": { + "rotation": [ 0, -45, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + } + }, + "textures": { + "top": "moonsteel:block/stellarrewinder_top", + "bottom": "moonsteel:block/stellarrewinder_top", + "back": "moonsteel:block/stellarrewinder_side", + "front": "moonsteel:block/stellarrewinder_front", + "left": "moonsteel:block/stellarrewinder_side", + "right": "moonsteel:block/stellarrewinder_side" + } +} diff --git a/src/main/resources/assets/moonsteel/models/block/stellarrewinder_active.json b/src/main/resources/assets/moonsteel/models/block/stellarrewinder_active.json new file mode 100644 index 0000000..c2c799e --- /dev/null +++ b/src/main/resources/assets/moonsteel/models/block/stellarrewinder_active.json @@ -0,0 +1,6 @@ +{ + "parent": "moonsteel:block/stellarrewinder", + "textures": { + "front": "moonsteel:block/stellarrewinder_front_active" + } +} diff --git a/build.gradle b/src/main/resources/assets/moonsteel/oldTex/build.txt similarity index 100% rename from build.gradle rename to src/main/resources/assets/moonsteel/oldTex/build.txt diff --git a/src/main/resources/assets/moonsteel/oldTex/chestplate/full.png b/src/main/resources/assets/moonsteel/oldTex/chestplate/full.png new file mode 100644 index 0000000..409f325 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/chestplate/full.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/chestplate/half.png b/src/main/resources/assets/moonsteel/oldTex/chestplate/half.png new file mode 100644 index 0000000..b90b9e3 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/chestplate/half.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/chestplate/half_flipped.png b/src/main/resources/assets/moonsteel/oldTex/chestplate/half_flipped.png new file mode 100644 index 0000000..e5e6a00 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/chestplate/half_flipped.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/full/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/full/moonsteel.png new file mode 100644 index 0000000..5001fb6 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/full/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/half/flipped/gold.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/half/flipped/gold.png new file mode 100644 index 0000000..9e20c84 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/half/flipped/gold.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/half/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/half/moonsteel.png new file mode 100644 index 0000000..5f5df0c Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/boots/half/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/full/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/full/moonsteel.png new file mode 100644 index 0000000..3e02269 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/full/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/half/flipped/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/half/flipped/moonsteel.png new file mode 100644 index 0000000..d75fd3a Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/half/flipped/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/half/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/half/moonsteel.png new file mode 100644 index 0000000..caf85ab Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/chestplate/half/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/full/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/full/moonsteel.png new file mode 100644 index 0000000..57808a9 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/full/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/half/flipped/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/half/flipped/moonsteel.png new file mode 100644 index 0000000..d0ec6fc Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/half/flipped/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/half/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/half/moonsteel.png new file mode 100644 index 0000000..72e35a2 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/helmet/half/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/full/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/full/moonsteel.png new file mode 100644 index 0000000..4a197ea Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/full/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/half/flipped/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/half/flipped/moonsteel.png new file mode 100644 index 0000000..62eabf9 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/half/flipped/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/half/moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/half/moonsteel.png new file mode 100644 index 0000000..5948739 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/armor/leggings/half/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/climbing_pickaxe_moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/climbing_pickaxe_moonsteel.png new file mode 100644 index 0000000..40d80f3 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/climbing_pickaxe_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/extra_armor_moonsteel_1.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/extra_armor_moonsteel_1.png new file mode 100644 index 0000000..5a83ecd Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/extra_armor_moonsteel_1.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/fishingrod_moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/fishingrod_moonsteel.png new file mode 100644 index 0000000..4964545 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/fishingrod_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/ingot_moonsteel_crude.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/ingot_moonsteel_crude.png new file mode 100644 index 0000000..574fc6c Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/ingot_moonsteel_crude.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/mining_hammer_moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/mining_hammer_moonsteel.png new file mode 100644 index 0000000..48f656f Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/mining_hammer_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_crown.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_crown.png new file mode 100644 index 0000000..6a37260 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_crown.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_pendant_and_gloves.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_pendant_and_gloves.png new file mode 100644 index 0000000..52c6a84 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_pendant_and_gloves.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_shield.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_shield.png new file mode 100644 index 0000000..1345aa2 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteel_shield.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestbottom.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestbottom.png new file mode 100644 index 0000000..5020970 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestbottom.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestfront.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestfront.png new file mode 100644 index 0000000..b8bc37a Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestfront.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestside.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestside.png new file mode 100644 index 0000000..27d6a50 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchestside.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchesttop.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchesttop.png new file mode 100644 index 0000000..ce367c2 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/moonsteelchesttop.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/tool_hammer_moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/tool_hammer_moonsteel.png new file mode 100644 index 0000000..02d5c33 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/tool_hammer_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/tool_sickle_moonsteel.png b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/tool_sickle_moonsteel.png new file mode 100644 index 0000000..bb9f642 Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/moonsteel ruby assets/tool_sickle_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/oldTex/old_moonsteel_crude.png b/src/main/resources/assets/moonsteel/oldTex/old_moonsteel_crude.png new file mode 100644 index 0000000..cb21d4c Binary files /dev/null and b/src/main/resources/assets/moonsteel/oldTex/old_moonsteel_crude.png differ diff --git a/src/main/resources/assets/moonsteel/textures/armor/wolf/moonsteel.png b/src/main/resources/assets/moonsteel/textures/armor/wolf/moonsteel.png new file mode 100644 index 0000000..d966c3a Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/armor/wolf/moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/textures/art/borders/border_moonsteel.png b/src/main/resources/assets/moonsteel/textures/art/borders/border_moonsteel.png new file mode 100644 index 0000000..d46c84c Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/art/borders/border_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/textures/block/jar_star.png b/src/main/resources/assets/moonsteel/textures/block/jar_star.png new file mode 100644 index 0000000..73686a4 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/block/jar_star.png differ diff --git a/src/main/resources/assets/moonsteel/textures/block/moonsteel_brick.png b/src/main/resources/assets/moonsteel/textures/block/moonsteel_brick.png new file mode 100644 index 0000000..0db3cd2 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/block/moonsteel_brick.png differ diff --git a/src/main/resources/assets/moonsteel/textures/block/starlamp.png b/src/main/resources/assets/moonsteel/textures/block/starlamp.png new file mode 100644 index 0000000..ed20ee3 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/block/starlamp.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/full.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/full.png new file mode 100644 index 0000000..391be50 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/full.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/half.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/half.png new file mode 100644 index 0000000..e7e12e2 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/half.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/half_flipped.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/half_flipped.png new file mode 100644 index 0000000..4a850b8 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_boots_moonsteel/half_flipped.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/full.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/full.png new file mode 100644 index 0000000..3e02269 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/full.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/half.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/half.png new file mode 100644 index 0000000..caf85ab Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/half.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/half_flipped.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/half_flipped.png new file mode 100644 index 0000000..d75fd3a Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_chestplate_moonsteel/half_flipped.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/full.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/full.png new file mode 100644 index 0000000..39c5e69 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/full.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/half.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/half.png new file mode 100644 index 0000000..7e532ff Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/half.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/half_flipped.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/half_flipped.png new file mode 100644 index 0000000..0b1db17 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_helmet_moonsteel/half_flipped.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/full.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/full.png new file mode 100644 index 0000000..ce95003 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/full.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/half.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/half.png new file mode 100644 index 0000000..c1d308d Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/half.png differ diff --git a/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/half_flipped.png b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/half_flipped.png new file mode 100644 index 0000000..1254f2a Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/gui/sprites/hud/armor_bar/item/armor_leggings_moonsteel/half_flipped.png differ diff --git a/src/main/resources/assets/moonsteel/textures/item/armor_gloves_moonsteel.png b/src/main/resources/assets/moonsteel/textures/item/armor_gloves_moonsteel.png new file mode 100644 index 0000000..7f04fec Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/item/armor_gloves_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/textures/item/armor_pendant_moonsteel.png b/src/main/resources/assets/moonsteel/textures/item/armor_pendant_moonsteel.png new file mode 100644 index 0000000..9ebf6fe Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/item/armor_pendant_moonsteel.png differ diff --git a/src/main/resources/assets/moonsteel/textures/item/jar_star.png b/src/main/resources/assets/moonsteel/textures/item/jar_star.png new file mode 100644 index 0000000..039b767 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/item/jar_star.png differ diff --git a/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png b/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png index cb21d4c..c15b1df 100644 Binary files a/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png and b/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png differ diff --git a/src/main/resources/assets/moonsteel/textures/item/moonsteel_paxel.png b/src/main/resources/assets/moonsteel/textures/item/moonsteel_paxel.png new file mode 100644 index 0000000..dab53f3 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/item/moonsteel_paxel.png differ diff --git a/src/main/resources/assets/moonsteel/textures/item/moonsteel_wolf_armor.png b/src/main/resources/assets/moonsteel/textures/item/moonsteel_wolf_armor.png new file mode 100644 index 0000000..1ba0a53 Binary files /dev/null and b/src/main/resources/assets/moonsteel/textures/item/moonsteel_wolf_armor.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2449953..5790c80 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -9,7 +9,8 @@ "Useless" ], "contributors": [ - "BigJango" + "BigJango", + "Redart15" ], "contact": { "homepage": "https://github.com/UselessSolutions/moonmoonmoon", @@ -21,38 +22,21 @@ "environment": "*", "entrypoints": { - "main": [ - "useless.moonsteel.MoonSteel" - ], - "beforeGameStart": [ - "useless.moonsteel.MoonSteel" - ], - "afterGameStart": [ - "useless.moonsteel.MoonSteel" - ], - "recipesReady": [ - "useless.moonsteel.MoonSteelRecipes" - ], - "beforeClientStart": [ - "useless.moonsteel.MoonSteelClient" - ], - "afterClientStart": [ - "useless.moonsteel.MoonSteelClient" - ], - "initModels": [ - "useless.moonsteel.MoonSteelModels" - ] + "main": ["useless.moonsteel.MoonSteel"], + "client": ["useless.moonsteel.MoonSteelClient"], + "server": ["useless.moonsteel.MoonSteelServer"] }, "mixins": [ "moonsteel.mixins.json" ], "depends": { - "minecraft": "~7.3", - "fabricloader": ">=0.13.3", - "halplibe": ">=5.2.0" - }, + "fabricloader": ">=${fabricloader}", + "halplibe": ">=${halplibe}", + "minecraft": "*", + "java": ">=${java}" + }, "suggests": { - "betterwithbackpacks": ">=1.1.10" + "betterwithbackpacks": ">=1.2.0-8.0" } } diff --git a/src/main/resources/moonsteel.mixins.json b/src/main/resources/moonsteel.mixins.json index 6d15536..866f659 100644 --- a/src/main/resources/moonsteel.mixins.json +++ b/src/main/resources/moonsteel.mixins.json @@ -2,32 +2,43 @@ "required": true, "minVersion": "0.8", "package": "useless.moonsteel.mixin", - "compatibilityLevel": "JAVA_8", - "plugin": "useless.moonsteel.MoonSteelMixinPlugin", + "compatibilityLevel": "JAVA_${java}", + "plugin": "useless.moonsteel.api.MoonSteelMixinPlugin", + "mixinextras": { + "minVersion": "0.5.0" + }, "injectors": { "defaultRequire": 1 }, "server": [ - "ChunkProviderServerMixin", - "PlayerListMixin", - "backpack.PlayerServerMixin" + "backpack.PlayerListMixinRespawn", + "backpack.PlayerServerMixin", + "chunkprovider.ChunkProviderServerMixin", + "stella.PlayerServerMixinStella" ], "mixins": [ - "BlockLogicMixin", - "WorldFeatureLabyrinthMixin", - "WorldMixin", + "WorldFeatureLabyrinthMixinRewards", + "accessor.ChunkProviderServerAccessor", + "accessor.ChunkProviderThreadedAccessor", "accessor.ItemToolSwordAccessor", + "accessor.ParticleFlameAccessor", + "armor.MobMixin", + "armor.MobWolfMixin", + "armor.MobZombieArmoredMixin", + "armor.PlayerMixinEquipment", + "backpack.MinecraftMixinRespawn", "backpack.PlayerMixin", - "entity.EntityItemMixin", - "entity.MobMixin", - "entity.MobZombieArmoredMixin", - "entity.PlayerMixin" + "commandly.VeinMinerMixin", + "commandly.VeinMiningAccessor", + "fortune.BlockLogicMixin", + "starfallen.EntityItemMixin", + "starfallen.WorldMixinStarFall", + "stella.PlayerMixinStella" ], "client": [ - "ChunkProviderStaticMixin", - "MobRenderZombieArmoredMixin", - "PacketHandlerClientMixin", - "backpack.MinecraftMixin", - "backpack.PlayerLocalMixin" + "armor.MobRenderZombieArmoredMixin", + "backpack.PacketHandlerClientMixinGui", + "backpack.PlayerLocalMixinGui", + "chunkprovider.ChunkProviderStaticMixin" ] }