Skip to content

Commit

Permalink
update to create 0.5.1.a (fixes #57)
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed May 23, 2023
1 parent 112aa15 commit 4dd9d17
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 169 deletions.
24 changes: 23 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ val flywheel_version: String by extra
val flightlib_version: String by extra
val repository: String by extra
val mod_version: String by extra
val mod_name: String by extra
val mod_author: String by extra
val release_type: String by extra
val modrinth_project_id: String by extra
val curseforge_project_id: String by extra
val curios_version: String by extra
val caelus_version: String by extra
val elytra_slot_version: String by extra
val jei_version: String by extra

val localEnv = file(".env").takeIf { it.exists() }?.readLines()?.associate {
val (key, value) = it.split("=")
Expand Down Expand Up @@ -141,7 +144,7 @@ sourceSets["main"].resources.srcDir("src/generated/resources/")

repositories {
maven {
url = uri("https://dvs1.progwml6.com/files/maven/")
url = uri("https://maven.blamejared.com/")
content {
includeGroup("mezz.jei")
}
Expand Down Expand Up @@ -198,6 +201,8 @@ dependencies {
implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}"))

if (!isCI) {
runtimeOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}"))

// Only here to test jetpack+elytra combination behaviour
runtimeOnly(fg.deobf("top.theillusivec4.caelus:caelus-forge:${caelus_version}"))
runtimeOnly(fg.deobf("curse.maven:elytra-slot-317716:${elytra_slot_version}"))
Expand Down Expand Up @@ -243,6 +248,23 @@ tasks.jarJar {
classifier = ""
}

tasks.withType<ProcessResources> {
// this will ensure that this task is redone when the versions change.
inputs.property("version", version)

filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta", "${mod_id}.mixins.json")) {
expand(
mapOf(
"mod_version" to mod_version,
"mod_name" to mod_name,
"mod_id" to mod_id,
"mod_author" to mod_author,
"repository" to repository,
)
)
}
}

publishing {
repositories {
maven {
Expand Down
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ org.gradle.daemon=false

mc_version=1.19.2
mappings_channel=official
forge_version=43.2.0
forge_version=43.2.3

mod_id=create_jetpack
mod_version=0.0.0-dev
release_type=release
mod_name=Create Jetpack
mod_author=possible_triangle

jei_version=
jei_version=11.6.0.1015
flywheel_version=0.6.8-13
create_version=4371809
create_version=4547147
registrate_version=MC1.19-1.1.5
flightlib_version=1.0.3

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.possible_triangle.create_jetpack.mixins;

import com.possible_triangle.create_jetpack.Content;
import com.possible_triangle.create_jetpack.compat.CuriosCompat;
import com.simibubi.create.content.curiosities.armor.BackTankUtil;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.equipment.armor.BacktankUtil;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
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;

@Mixin(value = BackTankUtil.class, remap = false)
@Mixin(value = BacktankUtil.class, remap = false)
public class BackTankUtilMixin {

@Inject(at = @At("HEAD"), cancellable = true, method = "get(Lnet/minecraft/world/entity/LivingEntity;)Lnet/minecraft/world/item/ItemStack;")
private static void provideCuriosAir(LivingEntity entity, CallbackInfoReturnable<ItemStack> cir) {
var stacks = CuriosCompat.INSTANCE.getCuriosStacksSafe(entity);
stacks.stream()
.filter(it -> it.is(Content.INSTANCE.getPRESSURIZED_AIR_SOURCES()))
.filter(AllTags.AllItemTags.PRESSURIZED_AIR_SOURCES::matches)
.findFirst().ifPresent(cir::setReturnValue);
}

Expand Down
54 changes: 24 additions & 30 deletions src/main/kotlin/com/possible_triangle/create_jetpack/Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@ package com.possible_triangle.create_jetpack
import com.possible_triangle.create_jetpack.CreateJetpackMod.MOD_ID
import com.possible_triangle.create_jetpack.block.JetpackBlock
import com.possible_triangle.create_jetpack.client.ControlsDisplay
import com.possible_triangle.create_jetpack.client.JetpackArmorLayer
import com.possible_triangle.create_jetpack.config.Configs
import com.possible_triangle.create_jetpack.item.BrassJetpack
import com.simibubi.create.Create
import com.simibubi.create.content.AllSections
import com.simibubi.create.content.CreateItemGroup
import com.simibubi.create.content.curiosities.armor.CopperBacktankInstance
import com.simibubi.create.content.curiosities.armor.CopperBacktankItem.CopperBacktankBlockItem
import com.simibubi.create.content.curiosities.armor.CopperBacktankRenderer
import com.simibubi.create.content.curiosities.armor.CopperBacktankTileEntity
import com.simibubi.create.foundation.block.BlockStressDefaults
import com.simibubi.create.AllCreativeModeTabs
import com.simibubi.create.AllTags.AllItemTags
import com.simibubi.create.content.equipment.armor.BacktankBlockEntity
import com.simibubi.create.content.equipment.armor.BacktankInstance
import com.simibubi.create.content.equipment.armor.BacktankItem.BacktankBlockItem
import com.simibubi.create.content.equipment.armor.BacktankRenderer
import com.simibubi.create.content.kinetics.BlockStressDefaults
import com.simibubi.create.foundation.data.AssetLookup
import com.simibubi.create.foundation.data.CreateRegistrate
import com.simibubi.create.foundation.data.SharedProperties
import com.simibubi.create.foundation.data.TagGen
import com.simibubi.create.foundation.item.ItemDescription
import com.simibubi.create.foundation.item.KineticStats
import com.simibubi.create.foundation.item.TooltipHelper
import com.simibubi.create.foundation.item.TooltipModifier
import com.tterrag.registrate.builders.BlockEntityBuilder
import com.tterrag.registrate.util.entry.ItemEntry
import com.tterrag.registrate.util.nullness.NonNullFunction
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
import net.minecraft.core.Registry
import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.TagKey
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.storage.loot.LootPool
import net.minecraft.world.level.storage.loot.LootTable
Expand All @@ -49,10 +50,11 @@ import java.util.function.Supplier
object Content {

private val REGISTRATE = CreateRegistrate.create(MOD_ID)
.creativeModeTab { CreateItemGroup.TAB_TOOLS }
.startSection(AllSections.CURIOSITIES)

val PRESSURIZED_AIR_SOURCES = TagKey.create(Registry.ITEM_REGISTRY, Create.asResource("pressurized_air_sources"))
.creativeModeTab { AllCreativeModeTabs.BASE_CREATIVE_TAB }
.setTooltipModifierFactory {
ItemDescription.Modifier(it, TooltipHelper.Palette.STANDARD_CREATE)
.andThen(TooltipModifier.mapNull(KineticStats.create(it)))
}

val JETPACK_BLOCK = REGISTRATE.block<JetpackBlock>("jetpack", ::JetpackBlock)
.initialProperties { SharedProperties.copperMetal() }
Expand Down Expand Up @@ -90,34 +92,26 @@ object Content {
}
.register()

val JETPACK_TILE = REGISTRATE
.tileEntity(
"jetpack",
::CopperBacktankTileEntity
)
.instance {
BiFunction { manager, tile ->
CopperBacktankInstance(manager, tile)
}
}
val JETPACK_TILE = REGISTRATE.blockEntity("jetpack", BlockEntityBuilder.BlockEntityFactory(::BacktankBlockEntity))
.instance { BiFunction { manager, tile -> BacktankInstance(manager, tile) } }
.validBlocks(JETPACK_BLOCK)
.renderer {
NonNullFunction { context: BlockEntityRendererProvider.Context? ->
CopperBacktankRenderer(context)
BacktankRenderer(context)
}
}
.register()

val JETPACK_PLACEABLE = REGISTRATE.item<CopperBacktankBlockItem>("jetpack_placeable") {
CopperBacktankBlockItem(JETPACK_BLOCK.get(), it)
val JETPACK_PLACEABLE = REGISTRATE.item<BacktankBlockItem>("jetpack_placeable") {
BacktankBlockItem(JETPACK_BLOCK.get(), { JETPACK.get() }, it)
}.model { context, provider ->
provider.withExistingParent(context.name, provider.mcLoc("item/barrier"))
}.register()

val JETPACK: ItemEntry<BrassJetpack> =
REGISTRATE.item<BrassJetpack>("jetpack") { BrassJetpack(it, JETPACK_PLACEABLE) }
.model(AssetLookup.customGenericItemModel("_", "item"))
.tag(PRESSURIZED_AIR_SOURCES)
.tag(AllItemTags.PRESSURIZED_AIR_SOURCES.tag)
.register()

private fun attachCapabilities(stack: ItemStack, add: BiConsumer<ResourceLocation, ICapabilityProvider>) {
Expand All @@ -135,7 +129,7 @@ object Content {

modBus.addListener { _: EntityRenderersEvent.AddLayers ->
val dispatcher = Minecraft.getInstance().entityRenderDispatcher
JetpackArmorLayer.registerOnAll(dispatcher)
//JetpackArmorLayer.registerOnAll(dispatcher)
}

modBus.addListener(ControlsDisplay::register)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.possible_triangle.create_jetpack.block

import com.possible_triangle.create_jetpack.Content
import com.simibubi.create.content.curiosities.armor.CopperBacktankBlock
import com.simibubi.create.content.curiosities.armor.CopperBacktankTileEntity
import com.simibubi.create.content.equipment.armor.BacktankBlock
import com.simibubi.create.content.equipment.armor.BacktankBlockEntity
import net.minecraft.core.BlockPos
import net.minecraft.nbt.ListTag
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState

class JetpackBlock(properties: Properties) : CopperBacktankBlock(properties) {
class JetpackBlock(properties: Properties) : BacktankBlock(properties) {

override fun getCloneItemStack(
world: BlockGetter,
pos: BlockPos,
state: BlockState
): ItemStack {
val item = ItemStack(Content.JETPACK.get())
val tile = getTileEntityOptional(world, pos)
val tile = getBlockEntityOptional(world, pos)

val air = tile.map { it.getAirLevel() }.orElse(0) as Int
item.orCreateTag.putInt("Air", air)
Expand All @@ -35,7 +35,7 @@ class JetpackBlock(properties: Properties) : CopperBacktankBlock(properties) {
return item
}

override fun getTileEntityType(): BlockEntityType<out CopperBacktankTileEntity> {
override fun getBlockEntityType(): BlockEntityType<out BacktankBlockEntity> {
return Content.JETPACK_TILE.get()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.possible_triangle.flightlib.api.ControlType
import com.possible_triangle.flightlib.api.FlightKey
import com.possible_triangle.flightlib.api.IFlightApi
import com.possible_triangle.flightlib.api.IJetpack
import com.simibubi.create.content.curiosities.armor.BackTankUtil
import com.simibubi.create.content.equipment.armor.BacktankUtil
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiComponent
import net.minecraft.network.chat.Component
Expand Down Expand Up @@ -115,9 +115,9 @@ object ControlsDisplay : IGuiOverlay {
}

val blink = player.level.gameTime % 20 < 5
val airSource = BackTankUtil.get(player)
val maxAir = BackTankUtil.maxAir(airSource)
val air = BackTankUtil.getAir(airSource)
val airSource = BacktankUtil.get(player)
val maxAir = BacktankUtil.maxAir(airSource)
val air = BacktankUtil.getAir(airSource)
val barHeight = ceil(air / maxAir * 14).toInt()
val shrinking = context.jetpack.isThrusting(context)

Expand Down

This file was deleted.

Loading

0 comments on commit 4dd9d17

Please sign in to comment.