Skip to content

Commit

Permalink
#471 Changed to raw nbt tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Oct 28, 2023
1 parent a804b58 commit 54505fc
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 283 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN ./gradlew build pluginJar --no-daemon
# 4. Launch a minecraft server with jdk17 and plugin
FROM amazoncorretto:17
# Change to the current plugin version present in build.gradle
ENV PLUGIN_VERSION=6.36.0
ENV PLUGIN_VERSION=6.36.1
# Change to the server version you want to test.
ENV SERVER_VERSION=spigot-1.18.jar
# Port of the Minecraft Server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,4 @@ interface ItemTypeService {
* Tries to find the data value of the given hint.
*/
fun findItemDataValue(sourceHint: Any): Int

/**
* Converts the given item to an ItemStack.
*/
fun <I> toItemStack(item: Item): I

/**
* Converts the given itemStack ot an item.
*/
fun <I> toItem(itemStack: I): Item
}
}
2 changes: 1 addition & 1 deletion blockball-bukkit-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ dependencies {
implementation(project(":blockball-bukkit-api"))
implementation(project(":blockball-core"))

implementation("com.github.shynixn.mcutils:common:1.0.23")
implementation("com.github.shynixn.mcutils:common:1.0.37")
implementation("com.github.shynixn.mcutils:packet:1.0.52")

implementation("com.github.shynixn.org.bstats:bstats-bukkit:1.7")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import com.github.shynixn.blockball.core.logic.business.service.*
import com.github.shynixn.blockball.core.logic.persistence.repository.ArenaFileRepository
import com.github.shynixn.blockball.core.logic.persistence.repository.LinkSignFileRepository
import com.github.shynixn.mcutils.common.Version
import com.github.shynixn.mcutils.common.item.ItemService
import com.github.shynixn.mcutils.common.item.ItemServiceImpl
import com.github.shynixn.mcutils.packet.api.EntityService
import com.github.shynixn.mcutils.packet.api.PacketService
import com.github.shynixn.mcutils.packet.impl.service.EntityServiceImpl
Expand Down Expand Up @@ -64,6 +66,8 @@ class BlockBallDependencyInjectionBinder(
bind(GameMiniGameActionService::class.java).to(GameMiniGameActionServiceImpl::class.java).`in`(Scopes.SINGLETON)
bind(GameBungeeCordGameActionService::class.java).to(GameBungeeCordGameActionServiceImpl::class.java)
.`in`(Scopes.SINGLETON)
bind(ItemService::class.java).to(ItemServiceImpl::class.java)
.`in`(Scopes.SINGLETON)
bind(GameSoccerService::class.java).to(GameSoccerServiceImpl::class.java).`in`(Scopes.SINGLETON)
bind(RightclickManageService::class.java).to(RightclickManageServiceImpl::class.java).`in`(Scopes.SINGLETON)
bind(HubGameForcefieldService::class.java).to(HubGameForcefieldServiceImpl::class.java).`in`(Scopes.SINGLETON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,24 @@
package com.github.shynixn.blockball.bukkit.logic.business.proxy

import com.github.shynixn.blockball.api.business.enumeration.BallSize
import com.github.shynixn.blockball.api.business.enumeration.MaterialType
import com.github.shynixn.blockball.api.business.proxy.BallProxy
import com.github.shynixn.blockball.api.business.service.ItemTypeService
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.persistence.entity.Position
import com.github.shynixn.blockball.bukkit.logic.business.extension.toLocation
import com.github.shynixn.blockball.bukkit.logic.business.extension.toVector
import com.github.shynixn.blockball.core.logic.persistence.entity.ItemEntity
import com.github.shynixn.blockball.core.logic.persistence.entity.PositionEntity
import com.github.shynixn.mcutils.common.Vector3d
import com.github.shynixn.mcutils.common.item.Item
import com.github.shynixn.mcutils.common.item.ItemService
import com.github.shynixn.mcutils.common.toEulerAngle
import com.github.shynixn.mcutils.common.toVector3d
import com.github.shynixn.mcutils.packet.api.ArmorSlotType
import com.github.shynixn.mcutils.packet.api.EntityType
import com.github.shynixn.mcutils.packet.api.PacketService
import com.github.shynixn.mcutils.packet.api.packet.*
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.nio.charset.Charset
import java.util.*

class BallDesignEntity(val entityId: Int) {
private val helmetItemStack by lazy {
val item = ItemEntity {
this.type = MaterialType.SKULL_ITEM.MinecraftNumericId.toString()
this.dataValue = 3
this.skin = ball.meta.skin
this.nbt = ball.meta.itemNbt
}

itemService.toItemStack<Any>(item)
}

/**
* Rotation of the design in euler angles.
*/
Expand All @@ -52,7 +39,7 @@ class BallDesignEntity(val entityId: Int) {
/**
* Item service dependency.
*/
lateinit var itemService: ItemTypeService
lateinit var itemService: ItemService

/**
* Reference.
Expand All @@ -71,9 +58,21 @@ class BallDesignEntity(val entityId: Int) {
})

if (!ball.meta.isSlimeVisible) {
val encodingSkinUrl = Base64.getEncoder().encodeToString(
"{\"textures\":{\"SKIN\":{\"url\":\"${ball.meta.skin}\"}}}".toByteArray(
Charset.forName("UTF-8")
)
)
val item = Item().also {
it.typeName = "PLAYER_HEAD,397"
it.durability = 3
it.nbt = "{SkullOwner:{Id:[I;1,1,1,1],Name:\"FootBall\",Properties:{textures:[{Value:\"${encodingSkinUrl}\"}]}}}"
}
val stack = itemService.toItemStack(item)

packetService.sendPacketOutEntityEquipment(player, PacketOutEntityEquipment().also {
it.entityId = entityId
it.items = listOf(Pair(ArmorSlotType.HELMET, helmetItemStack as ItemStack))
it.items = listOf(Pair(ArmorSlotType.HELMET, stack))
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import com.github.shynixn.blockball.bukkit.logic.business.proxy.BallCrossPlatfor
import com.github.shynixn.blockball.bukkit.logic.business.proxy.BallDesignEntity
import com.github.shynixn.blockball.bukkit.logic.business.proxy.BallHitboxEntity
import com.github.shynixn.blockball.core.logic.persistence.event.BallSpawnEventEntity
import com.github.shynixn.mcutils.common.item.ItemService
import com.github.shynixn.mcutils.packet.api.PacketService
import com.google.inject.Inject

class BallEntityServiceImpl @Inject constructor(
private val proxyService: ProxyService,
private val packetService: PacketService,
private val concurrencyService: ConcurrencyService,
private val itemTypeService: ItemTypeService,
private val itemService: ItemService,
private val rayTracingService: RayTracingService,
private val loggingService: LoggingService,
private val eventService: EventService
Expand Down Expand Up @@ -51,7 +52,7 @@ class BallEntityServiceImpl @Inject constructor(
val ballDesignEntity = BallDesignEntity(proxyService.createNewEntityId())
ballDesignEntity.proxyService = proxyService
ballDesignEntity.packetService = packetService
ballDesignEntity.itemService = itemTypeService
ballDesignEntity.itemService = itemService

val ball = BallCrossPlatformProxy(meta, ballDesignEntity, ballHitBoxEntity)
ballDesignEntity.ball = ball
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import com.github.shynixn.blockball.core.logic.business.extension.cast
import com.github.shynixn.blockball.core.logic.business.extension.stripChatColors
import com.github.shynixn.blockball.core.logic.business.extension.sync
import com.github.shynixn.blockball.core.logic.persistence.entity.ItemEntity
import com.github.shynixn.mcutils.common.translateChatColors
import com.google.inject.Inject
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.*
Expand Down Expand Up @@ -201,12 +203,11 @@ class BlockSelectionServiceImpl @Inject constructor(
}
}

val item = ItemEntity {
this.type = MaterialType.GOLDEN_AXE.MinecraftNumericId.toString()
this.displayName = axeName
}

player.inventory.addItem(itemTypeService.toItemStack(item))
val itemStack = ItemStack(itemTypeService.findItemType<Material>(MaterialType.GOLDEN_AXE.MinecraftNumericId.toString()))
val meta = itemStack.itemMeta!!
meta.setDisplayName(axeName.translateChatColors())
itemStack.itemMeta = meta
player.inventory.addItem(itemStack)
player.sendMessage(prefix + "Take a look into your inventory. Use this golden axe for selection.")
}

Expand All @@ -220,4 +221,4 @@ class BlockSelectionServiceImpl @Inject constructor(

return Optional.empty()
}
}
}
Loading

0 comments on commit 54505fc

Please sign in to comment.