Skip to content

Commit

Permalink
Merge pull request #1 from bms-1984/1.20.5
Browse files Browse the repository at this point in the history
1.20.5 update
  • Loading branch information
bms-1984 authored Apr 29, 2024
2 parents 762fcbd + 9c24c35 commit 4c27413
Show file tree
Hide file tree
Showing 167 changed files with 553 additions and 691 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
fetch-depth: 1000
fetch-tags: true

- name: Setup JDK 17
- name: Setup JDK 21
uses: actions/setup-java@v2
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Build with Gradle
Expand Down
16 changes: 8 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ minecraft {

subsystems {
parchment {
minecraftVersion(minecraft_version)
minecraftVersion("1.20.4")
mappingsVersion(mappings_version)
}
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withSourcesJar()
}

Expand Down Expand Up @@ -111,11 +111,11 @@ dependencies {

implementation("thedarkcolour:kotlinforforge-neoforge:${kotlinforforge_version}")

compileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
compileOnly("mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}")
runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}")
compileOnly("mezz.jei:jei-1.20.4-common-api:${jei_version}")
compileOnly("mezz.jei:jei-1.20.4-neoforge-api:${jei_version}")
runtimeOnly("mezz.jei:jei-1.20.4-neoforge:${jei_version}")

implementation ("mcjty.theoneprobe:theoneprobe:${minecraft_version}_neo-${top_version}")
implementation ("mcjty.theoneprobe:theoneprobe:1.20.4_neo-${top_version}")
}

tasks {
Expand All @@ -137,13 +137,13 @@ tasks {
)
inputs.properties(replaceProperties)

filesMatching(mutableListOf("META-INF/mods.toml", "pack.mcmeta")) {
filesMatching(mutableListOf("META-INF/neoforge.mods.toml", "pack.mcmeta")) {
expand(replaceProperties)
}
}

withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "17"
kotlinOptions.jvmTarget = "21"
kotlinOptions.verbose = true
}

Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ org.gradle.jvmargs=-Xmx4G -Xms4G
org.gradle.daemon=false
org.gradle.debug=false

mappings_version=2024.02.25
minecraft_version=1.20.4
minecraft_version_range=[1.20.4,1.21)
neo_version=20.4.226
neo_version_range=[20.4,)
loader_version_range=[4.7 ,)
kotlinforforge_version=4.10.0
kotlinforforge_version_range=[4.10.0,)
mappings_version=2024.04.14
minecraft_version=1.20.5
minecraft_version_range=[1.20.5,1.21)
neo_version=20.5.16-beta
neo_version_range=[20.5,)
loader_version_range=[5.0.1,)
kotlinforforge_version=5.0.1
kotlinforforge_version_range=[5.0.1,)
top_version=11.0.2-3
jei_version=17.3.0.49

Expand All @@ -37,4 +37,4 @@ mod_version=0.0.1.0
mod_group_id=net.benjimadness.triad
mod_authors=BenjiMadness
mod_description=Tech Mod
pack_format_id=26
pack_format_id=32
43 changes: 10 additions & 33 deletions src/main/kotlin/net/benjimadness/triad/TriadMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,33 @@ package net.benjimadness.triad
import com.mojang.logging.LogUtils
import net.benjimadness.triad.compat.TheOneProbe
import net.benjimadness.triad.config.TriadConfig
import net.benjimadness.triad.gui.BoilerScreen
import net.benjimadness.triad.gui.ElectricFurnaceScreen
import net.benjimadness.triad.gui.TurbineScreen
import net.benjimadness.triad.gui.GrinderScreen
import net.benjimadness.triad.item.tool.TriadToolTiers
import net.benjimadness.triad.gui.screen.BoilerScreen
import net.benjimadness.triad.gui.screen.ElectricFurnaceScreen
import net.benjimadness.triad.gui.screen.TurbineScreen
import net.benjimadness.triad.gui.screen.GrinderScreen
import net.benjimadness.triad.registry.*
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.Tiers
import net.neoforged.bus.api.SubscribeEvent
import net.neoforged.fml.ModLoadingContext
import net.neoforged.fml.common.EventBusSubscriber
import net.neoforged.fml.common.Mod
import net.neoforged.fml.config.ModConfig
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent
import net.neoforged.neoforge.capabilities.Capabilities
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent
import net.neoforged.neoforge.common.TierSortingRegistry
import org.slf4j.Logger
import thedarkcolour.kotlinforforge.neoforge.forge.LOADING_CONTEXT
import thedarkcolour.kotlinforforge.neoforge.forge.MOD_BUS
import thedarkcolour.kotlinforforge.neoforge.forge.runForDist

@Mod(TriadMod.MODID)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
object TriadMod {
const val MODID = "triad"
val LOGGER: Logger = LogUtils.getLogger()
init {
TierSortingRegistry.registerTier(
TriadToolTiers.BRONZE,
ResourceLocation(MODID, "bronze"),
listOf(Tiers.IRON),
listOf(Tiers.DIAMOND)
)
TierSortingRegistry.registerTier(
TriadToolTiers.STEEL,
ResourceLocation(MODID, "steel"),
listOf(Tiers.DIAMOND),
listOf(Tiers.NETHERITE)
)
runForDist(
clientTarget = { MOD_BUS.addListener(::onClientSetup) },
serverTarget = { MOD_BUS.addListener(::onServerSetup) })
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, TriadConfig.SPEC)
LOADING_CONTEXT.activeContainer.registerConfig(ModConfig.Type.COMMON, TriadConfig.SPEC)
TriadBlocks.REGISTRY.register(MOD_BUS)
TriadItems.REGISTRY.register(MOD_BUS)
TriadItems.ARMOR_MATERIAL_REGISTRY.register(MOD_BUS)
TriadFluids.REGISTRY.register(MOD_BUS)
TriadBlockEntities.REGISTRY.register(MOD_BUS)
MOD_BUS.addListener(::registerCapabilities)
Expand All @@ -77,6 +57,7 @@ object TriadMod {
TriadMenus.REGISTRY.register(MOD_BUS)
}

@Suppress("UNUSED_PARAMETER")
@SubscribeEvent
private fun onCommonSetup(event: FMLCommonSetupEvent) {
LOGGER.info("Trying Triad, David, Stephen, Neil, Graham, Joni, YESSIREE!")
Expand Down Expand Up @@ -133,15 +114,11 @@ object TriadMod {
) { o, _ -> o.energyStorage }
}

private fun onClientSetup(event: FMLClientSetupEvent) {}

@SubscribeEvent
private fun onRegisterMenuScreens(event: RegisterMenuScreensEvent) {
event.register(TriadMenus.GRINDER_MENU_TYPE.get(), ::GrinderScreen)
event.register(TriadMenus.FURNACE_MENU_TYPE.get(), ::ElectricFurnaceScreen)
event.register(TriadMenus.TURBINE_MENU_TYPE.get(), ::TurbineScreen)
event.register(TriadMenus.ITEM_BOILER_MENU_TYPE.get(), ::BoilerScreen)
}

private fun onServerSetup(event: FMLDedicatedServerSetupEvent) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import net.minecraft.core.Direction
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.ItemInteractionResult
import net.minecraft.world.entity.item.ItemEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
Expand Down Expand Up @@ -45,22 +47,32 @@ abstract class AbstractMachineBlock(properties: Properties, blockEntity: KClass<
builder.add(FACING, LEVER, RUNNING)
}

@Deprecated("Deprecated in Java", ReplaceWith(
"super.use(pState, pLevel, pPos, pPlayer, pHand, pHit)",
"net.minecraft.world.level.block.Block"))
override fun use(
override fun useWithoutItem(
state: BlockState,
level: Level,
pos: BlockPos,
player: Player,
hand: InteractionHand,
hit: BlockHitResult
): InteractionResult {
if (!level.isClientSide && player is ServerPlayer)
state.getMenuProvider(level, pos)?.let { player.openMenu(it) { buf -> buf.writeBlockPos(pos) } }
return InteractionResult.sidedSuccess(level.isClientSide())
}

override fun useItemOn(
stack: ItemStack,
state: BlockState,
level: Level,
pos: BlockPos,
player: Player,
hand: InteractionHand,
result: BlockHitResult
): ItemInteractionResult {
if (!level.isClientSide && player is ServerPlayer)
state.getMenuProvider(level, pos)?.let { player.openMenu(it) { buf -> buf.writeBlockPos(pos) } }
return ItemInteractionResult.sidedSuccess(level.isClientSide())
}

@Deprecated("Deprecated in Java", ReplaceWith(
"super.onRemove(pState, pLevel, pPos, pNewState, pMovedByPiston)",
"net.minecraft.world.level.block.Block"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.benjimadness.triad.api.block

import net.benjimadness.triad.block.GrinderBlock.Blades
import net.benjimadness.triad.TriadMod
import net.minecraft.network.chat.Component
import net.minecraft.util.StringRepresentable
import net.minecraft.world.level.block.state.properties.BooleanProperty
import net.minecraft.world.level.block.state.properties.EnumProperty
Expand All @@ -18,4 +19,13 @@ enum class LeverPositions : StringRepresentable {
NONE, SOUTH, EAST, WEST, BOTTOM, TOP, BOTTOM_ROT, TOP_ROT;
override fun getSerializedName(): String = name.lowercase()
override fun toString(): String = serializedName
}

enum class Blades : StringRepresentable {
NONE, BRONZE, STEEL;
override fun getSerializedName(): String = name.lowercase()
override fun toString(): String = serializedName
private fun getCapitalizedName(): String = serializedName.replaceFirstChar { it.uppercase() }
fun getComponent(): Component = Component.translatableWithFallback(
"${TriadMod.MODID}.message.blade.${serializedName}", getCapitalizedName())
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import net.benjimadness.triad.api.block.TriadBlockStateProperties
import net.benjimadness.triad.registry.TriadFluids
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.core.HolderLookup
import net.minecraft.nbt.CompoundTag
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
Expand Down Expand Up @@ -53,16 +54,16 @@ abstract class AbstractBoilerBlockEntity(capacity: Int, private val transfer: In
water.drain(gen, IFluidHandler.FluidAction.EXECUTE)
}

override fun saveAdditional(tag: CompoundTag) {
super.saveAdditional(tag)
tag.put("Steam", steam.writeToNBT(CompoundTag()))
tag.put("Water", water.writeToNBT(CompoundTag()))
override fun saveAdditional(tag: CompoundTag, registry: HolderLookup.Provider) {
super.saveAdditional(tag, registry)
tag.put("Steam", steam.writeToNBT(registry, CompoundTag()))
tag.put("Water", water.writeToNBT(registry, CompoundTag()))
}

override fun load(tag: CompoundTag) {
super.load(tag)
if (tag.contains("Steam")) steam.readFromNBT(tag.getCompound("Steam"))
if (tag.contains("Water")) water.readFromNBT(tag.getCompound("Water"))
override fun loadAdditional(tag: CompoundTag, registry: HolderLookup.Provider) {
super.loadAdditional(tag, registry)
if (tag.contains("Steam")) steam.readFromNBT(registry, tag.getCompound("Steam"))
if (tag.contains("Water")) water.readFromNBT(registry, tag.getCompound("Water"))
}

private fun hasWater() = !water.isEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import net.benjimadness.triad.api.block.TriadBlockStateProperties
import net.benjimadness.triad.api.util.MiscUtil.getLeverOrientation
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.core.HolderLookup
import net.minecraft.core.HolderLookup.Provider
import net.minecraft.nbt.CompoundTag
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
Expand Down Expand Up @@ -45,13 +47,13 @@ AbstractTriadBlockEntity(type, pos, state) {
setChanged()
}

override fun saveAdditional(tag: CompoundTag) {
super.saveAdditional(tag)
tag.put("Energy", energy.serializeNBT())
override fun saveAdditional(tag: CompoundTag, registry: Provider) {
super.saveAdditional(tag, registry)
tag.put("Energy", energy.serializeNBT(registry))
}

override fun load(tag: CompoundTag) {
super.load(tag)
if (tag.contains("Energy")) tag.get("Energy")?.let { energy.deserializeNBT(it) }
override fun loadAdditional(tag: CompoundTag, registry: Provider) {
super.loadAdditional(tag, registry)
if (tag.contains("Energy")) tag.get("Energy")?.let { energy.deserializeNBT(registry, it) }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.benjimadness.triad.api.block.entity

import net.minecraft.core.BlockPos
import net.minecraft.core.HolderLookup
import net.minecraft.nbt.CompoundTag
import net.minecraft.world.Container
import net.minecraft.world.item.ItemStack
Expand Down Expand Up @@ -31,14 +32,14 @@ abstract class AbstractElectricFurnaceBlockEntity(capacity: Int, type: BlockEnti
val itemHandler: IItemHandler by lazy { items }
override val check: RecipeManager.CachedCheck<Container, SmeltingRecipe> = RecipeManager.createCheck(RecipeType.SMELTING)

override fun saveAdditional(tag: CompoundTag) {
super.saveAdditional(tag)
tag.put("Items", items.serializeNBT())
override fun saveAdditional(tag: CompoundTag, registry: HolderLookup.Provider) {
super.saveAdditional(tag, registry)
tag.put("Items", items.serializeNBT(registry))
}

override fun load(tag: CompoundTag) {
super.load(tag)
if (tag.contains("Items")) items.deserializeNBT(tag.getCompound("Items"))
override fun loadAdditional(tag: CompoundTag, registry: HolderLookup.Provider) {
super.loadAdditional(tag, registry)
if (tag.contains("Items")) items.deserializeNBT(registry, tag.getCompound("Items"))
}

override fun execute() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
package net.benjimadness.triad.api.block.entity

import net.benjimadness.triad.TriadMod
import net.benjimadness.triad.block.GrinderBlock
import net.benjimadness.triad.api.block.TriadBlockStateProperties
import net.benjimadness.triad.api.item.ReusableItem
import net.benjimadness.triad.recipe.GrinderRecipe
import net.benjimadness.triad.registry.TriadRecipes
import net.minecraft.core.BlockPos
import net.minecraft.core.HolderLookup
import net.minecraft.nbt.CompoundTag
import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.ItemTags
import net.minecraft.util.RandomSource
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.RecipeManager
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState
import net.neoforged.neoforge.energy.EnergyStorage
import net.neoforged.neoforge.energy.IEnergyStorage
import net.neoforged.neoforge.items.IItemHandler
import net.neoforged.neoforge.items.ItemStackHandler
import net.neoforged.neoforge.items.wrapper.RecipeWrapper

abstract class AbstractElectricGrinderBlockEntity(capacity: Int, type: BlockEntityType<*>, pos: BlockPos, state: BlockState) :
AbstractGrinderBlockEntity(type, pos, state) {

private val energy = EnergyStorage(capacity)
val energyStorage: IEnergyStorage by lazy { energy }

override fun saveAdditional(tag: CompoundTag) {
super.saveAdditional(tag)
tag.put("Energy", energy.serializeNBT())
override fun saveAdditional(tag: CompoundTag, registry: HolderLookup.Provider) {
super.saveAdditional(tag, registry)
tag.put("Energy", energy.serializeNBT(registry))
}

override fun load(tag: CompoundTag) {
super.load(tag)
if (tag.contains("Energy")) tag.get("Energy")?.let { energy.deserializeNBT(it) }
override fun loadAdditional(tag: CompoundTag, registry: HolderLookup.Provider) {
super.loadAdditional(tag, registry)
if (tag.contains("Energy")) tag.get("Energy")?.let { energy.deserializeNBT(registry, it) }
}

override fun shouldRun(): Boolean = super.shouldRun() && level?.hasNeighborSignal(blockPos) == false
Expand Down
Loading

0 comments on commit 4c27413

Please sign in to comment.