Skip to content

Commit

Permalink
Try to implement Feature Dye
Browse files Browse the repository at this point in the history
  • Loading branch information
Cierra-Runis committed Nov 18, 2024
1 parent aec349d commit cd07f5c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
15 changes: 0 additions & 15 deletions src/main/java/pers/cierra_runis/survired/mixin/ExampleMixin.java

This file was deleted.

6 changes: 2 additions & 4 deletions src/main/kotlin/pers/cierra_runis/survired/SurviRed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package pers.cierra_runis.survired

import net.fabricmc.api.ModInitializer
import org.slf4j.LoggerFactory
import pers.cierra_runis.survired.pickup.SurviRedPickupEventListener
import pers.cierra_runis.survired.features.pickup.SurviRedPickup

object SurviRed : ModInitializer {
private val logger = LoggerFactory.getLogger(this.javaClass)
override fun onInitialize() {
logger.info("Loading...")
SurviRedPickupEventListener.registerRightClickEvent()
logger.info("Loaded!")
SurviRedPickup.register()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pers.cierra_runis.survired.common

interface SurviRedRegister {
fun register()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package pers.cierra_runis.survired.features.dye

import net.fabricmc.fabric.api.event.player.UseBlockCallback
import net.minecraft.block.entity.ShulkerBoxBlockEntity
import net.minecraft.item.DyeItem
import net.minecraft.util.ActionResult
import org.slf4j.LoggerFactory
import pers.cierra_runis.survired.common.SurviRedRegister

object SurviRedDye : SurviRedRegister {
private val logger = LoggerFactory.getLogger(this.javaClass)

override fun register() {
UseBlockCallback.EVENT.register(UseBlockCallback { playerEntity, world, hand, blockHitResult ->
if (!playerEntity.isSneaking) return@UseBlockCallback ActionResult.PASS
if (playerEntity.inventory.mainHandStack.item !is DyeItem) return@UseBlockCallback ActionResult.PASS
val block = world.getBlockEntity(blockHitResult.blockPos)
if (block !is ShulkerBoxBlockEntity) return@UseBlockCallback ActionResult.PASS

logger.info(block.toString())

return@UseBlockCallback ActionResult.SUCCESS
})
}
}
17 changes: 8 additions & 9 deletions src/main/resources/survired.mixins.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"required": true,
"package": "pers.cierra_runis.survired.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"ExampleMixin"
],
"injectors": {
"defaultRequire": 1
}
"required": true,
"package": "pers.cierra_runis.survired.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit cd07f5c

Please sign in to comment.