Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #145

Merged
merged 5 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class BlockEntityTrialKeystone(pos: BlockPos, state: BlockState) :
val innerBlockPos = BlockPos(x, y, z)
if (
innerBlockPos != pos
&& innerBlockPos.getSquaredDistance(pos) <= config.trial.arenaRadius.squared()
&& innerBlockPos.getSquaredDistance(pos) < config.trial.arenaRadius.squared()
&& world?.getBlockState(innerBlockPos)?.isAir != true
) {
list += innerBlockPos
Expand Down
10 changes: 10 additions & 0 deletions base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.nathanpb.dml.misc

import dev.nathanpb.dml.identifier
import net.minecraft.block.Block
import net.minecraft.registry.RegistryKeys

import net.minecraft.registry.tag.TagKey


val TRIAL_GRIEF_WHITELIST: TagKey<Block> = TagKey.of(RegistryKeys.BLOCK, identifier("trial_grief_whitelist"))
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import dev.nathanpb.dml.data.DataModelData
import dev.nathanpb.dml.data.DeepLearnerData
import dev.nathanpb.dml.data.dataModel
import dev.nathanpb.dml.identifier
import dev.nathanpb.dml.item.ITEM_DEEP_LEARNER
import dev.nathanpb.dml.item.ItemDataModel
import dev.nathanpb.dml.screen.handler.widget.WEntityShowcase
import dev.nathanpb.dml.screen.handler.widget.WStylizedButton
Expand All @@ -35,7 +36,6 @@ import dev.nathanpb.dml.utils.setStacks
import io.github.cottonmc.cotton.gui.SyncedGuiDescription
import io.github.cottonmc.cotton.gui.widget.*
import io.github.cottonmc.cotton.gui.widget.data.Insets
import io.github.cottonmc.cotton.gui.widget.icon.Icon
import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon
import net.fabricmc.api.EnvType
import net.fabricmc.loader.api.FabricLoader
Expand Down Expand Up @@ -243,7 +243,7 @@ class DeepLearnerScreenHandler (
update()
}

root.add(createPlayerInventoryPanel(), 0, 5*18+6)
root.add(DeepLearnerPlayerInv(playerInventory), 0, 5*18+6)
root.validate(this)
update()
}
Expand All @@ -263,7 +263,7 @@ class DeepLearnerScreenHandler (
): WItemSlot(inventory, 0, 2, 2, false) {

init {
setFilter { stack ->
setInputFilter { stack ->
stack.item is ItemDataModel && stack.dataModel.category != null
}

Expand All @@ -278,4 +278,21 @@ class DeepLearnerScreenHandler (
}

}


// Prevent dropping your Deep Learner while it's up, duping it and all data models inside
class DeepLearnerPlayerInv(
playerInventory: PlayerInventory
): WPlayerInvPanel(playerInventory) {

init {
inventory.setOutputFilter {
!it.isOf(ITEM_DEEP_LEARNER)
}
hotbar.setOutputFilter {
!it.isOf(ITEM_DEEP_LEARNER)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

package dev.nathanpb.dml.screen.handler

import dev.nathanpb.dml.MOD_ID
import dev.nathanpb.dml.identifier
import dev.nathanpb.dml.recipe.LootFabricatorRecipe
import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot
import dev.nathanpb.dml.utils.RenderUtils
import io.github.cottonmc.cotton.gui.SyncedGuiDescription
import io.github.cottonmc.cotton.gui.widget.WBar
Expand All @@ -35,7 +33,6 @@ import net.minecraft.entity.player.PlayerEntity
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.inventory.SimpleInventory
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.text.Text

class LootFabricatorHandler(
syncId: Int,
Expand All @@ -53,7 +50,7 @@ class LootFabricatorHandler(
setRootPanel(root)

val inputSlot = WItemSlot(blockInventory, 0, 1, 1, false).apply {
setFilter { stack ->
setInputFilter { stack ->
world.recipeManager.values().filterIsInstance<LootFabricatorRecipe>()
.any { it.input.test(stack) }
}
Expand All @@ -70,7 +67,7 @@ class LootFabricatorHandler(
(0 until 9).forEach {
val x = (it % 3)
val y = (it / 3)
val slot = WItemSlot.of(blockInventory, it + 1).setFilter { false }
val slot = WItemSlot.of(blockInventory, it + 1).setInputFilter { false }
root.add(slot, x + 5, y + 1)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
package dev.nathanpb.dml.trial

import dev.nathanpb.dml.config
import dev.nathanpb.dml.misc.TRIAL_GRIEF_WHITELIST
import dev.nathanpb.dml.utils.runningTrials
import dev.nathanpb.dml.utils.squared
import dev.nathanpb.dml.utils.toBlockPos
import dev.nathanpb.dml.utils.toVec3i
import net.fabricmc.fabric.api.event.player.AttackBlockCallback
import net.fabricmc.fabric.api.event.player.UseBlockCallback
import net.minecraft.block.Blocks
import net.minecraft.entity.Entity
import net.minecraft.entity.damage.DamageSource
import net.minecraft.entity.mob.EndermanEntity
Expand All @@ -39,7 +39,6 @@ import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3d
import net.minecraft.world.World
import net.minecraft.world.explosion.Explosion
import net.minecraft.world.explosion.ExplosionBehavior

class TrialGriefPrevention : AttackBlockCallback, UseBlockCallback {
Expand All @@ -65,11 +64,8 @@ class TrialGriefPrevention : AttackBlockCallback, UseBlockCallback {
!world.isClient
&& config.trial.interactGriefPrevention
&& isBlockProtected(world, pos)
&& world.getBlockState(pos)?.run {
block !== Blocks.CHEST
&& block !== Blocks.TRAPPED_CHEST
&& "grave" !in Registries.BLOCK.getId(block).path
} != false
&& !world.getBlockState(pos).isIn(TRIAL_GRIEF_WHITELIST)
&& "grave" !in Registries.BLOCK.getId(world.getBlockState(pos).block).path
) {
ActionResult.FAIL
} else ActionResult.PASS
Expand Down
1 change: 1 addition & 0 deletions base/src/main/kotlin/dev/nathanpb/dml/utils/Math.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import kotlin.random.Random
fun Double.lerp(min: Double, max: Double) = (1 - this) * min + this * max
fun Int.lerp(min: Double, max: Double) = (1 - this) * min + this * max

fun Double.squared() = this * this
fun Int.squared() = this * this

// https://stackoverflow.com/a/35701777/9893963
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"#c:chests",
{"id": "yigd:grave", "required": false},
{"id": "gravestones:gravestone", "required": false}
]
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fabric_kotlin_version=1.9.5+kotlin.1.8.22

# Other Dependencies
ktdatataglib_version=1.6.7+1.20.1
libguiVersion=8.0.0-beta.1+1.20-rc1
libguiVersion=8.1.0+1.20.1
palVersion=1.8.0
reiVersion=12.0.625
energyVersion=2.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MatterCondenserScreenHandler(

val slots = WPlainPanel()
val armorSlot = WTooltippedItemSlot.of(blockInventory, 0, true, Text.translatable("gui.${MOD_ID}.glitch_armor_only")).apply {
setFilter {
setInputFilter {
it.item is ItemModularGlitchArmor && !ModularArmorData(it).tier().isMaxTier()
}
}
Expand All @@ -74,7 +74,7 @@ class MatterCondenserScreenHandler(

val matterSlots = (1..6).map {
WItemSlot(blockInventory, it, 1, 1, false).apply {
setFilter { stack ->
setInputFilter { stack ->
stack.item is ItemPristineMatter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

package dev.nathanpb.dml.modular_armor.screen

import com.sun.java.accessibility.util.SwingEventMonitor.addChangeListener
import dev.nathanpb.dml.MOD_ID
import dev.nathanpb.dml.data.dataModel
import dev.nathanpb.dml.identifier
import dev.nathanpb.dml.item.ItemDataModel
Expand All @@ -30,7 +28,6 @@ import dev.nathanpb.dml.modular_armor.core.ModularEffectRegistry
import dev.nathanpb.dml.modular_armor.data.ModularArmorData
import dev.nathanpb.dml.modular_armor.net.C2S_MODULAR_EFFECT_TOGGLE
import dev.nathanpb.dml.screen.handler.registerScreenHandlerForItemStack
import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot
import dev.nathanpb.dml.utils.RenderUtils
import dev.nathanpb.dml.utils.takeOrNull
import io.github.cottonmc.cotton.gui.SyncedGuiDescription
Expand All @@ -46,7 +43,6 @@ import net.minecraft.inventory.SimpleInventory
import net.minecraft.item.ItemStack
import net.minecraft.network.PacketByteBuf
import net.minecraft.screen.ArrayPropertyDelegate
import net.minecraft.text.Text
import net.minecraft.util.Hand
import net.minecraft.util.Identifier

Expand Down Expand Up @@ -102,7 +98,7 @@ class ModularArmorScreenHandler(
}

val dataModelSlot = WItemSlot(blockInventory, 0, 1, 1, false).apply {
setFilter {
setInputFilter {
it.isEmpty || (
(it.item as? ItemDataModel)?.category != null
&& data.tier().ordinal >= it.dataModel.tier().ordinal
Expand Down
Loading