1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2024-10-17 08:42:49 +02:00
Hardcore-Ender-Expansion-2/.idea/shelf/Development3/shelved.patch
2021-01-15 18:42:49 +01:00

19 lines
6.8 KiB
Diff

Index: src/main/java/chylex/hee/game/block/entity/TileEntityVoidPortalStorage.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>package chylex.hee.game.block.entity\r\nimport chylex.hee.game.block.BlockAbstractPortal\r\nimport chylex.hee.game.block.BlockVoidPortalInner.IVoidPortalController\r\nimport chylex.hee.game.block.entity.base.TileEntityBase.Context.NETWORK\r\nimport chylex.hee.game.block.entity.base.TileEntityBasePortalController\r\nimport chylex.hee.game.block.entity.base.TileEntityBasePortalController.ForegroundRenderState.Animating\r\nimport chylex.hee.game.block.entity.base.TileEntityBasePortalController.ForegroundRenderState.Invisible\r\nimport chylex.hee.game.block.entity.base.TileEntityBasePortalController.ForegroundRenderState.Visible\r\nimport chylex.hee.game.container.ContainerPortalTokenStorage\r\nimport chylex.hee.game.container.util.ItemStackHandlerInventory\r\nimport chylex.hee.game.mechanics.portal.SpawnInfo\r\nimport chylex.hee.game.world.territory.TerritoryInstance\r\nimport chylex.hee.game.world.territory.storage.TokenPlayerStorage\r\nimport chylex.hee.init.ModItems\r\nimport chylex.hee.init.ModTileEntities\r\nimport chylex.hee.system.migration.vanilla.EntityPlayer\r\nimport chylex.hee.system.migration.vanilla.TextComponentTranslation\r\nimport chylex.hee.system.util.FLAG_SKIP_RENDER\r\nimport chylex.hee.system.util.FLAG_SYNC_CLIENT\r\nimport chylex.hee.system.util.TagCompound\r\nimport chylex.hee.system.util.getIntegerOrNull\r\nimport chylex.hee.system.util.isAnyPlayerWithinRange\r\nimport chylex.hee.system.util.square\r\nimport chylex.hee.system.util.use\r\nimport net.minecraft.entity.Entity\r\nimport net.minecraft.entity.player.PlayerInventory\r\nimport net.minecraft.inventory.container.Container\r\nimport net.minecraft.inventory.container.INamedContainerProvider\r\nimport net.minecraft.item.ItemStack\r\nimport net.minecraft.tileentity.TileEntityType\r\nimport net.minecraft.util.text.ITextComponent\r\nimport kotlin.math.min\r\nimport kotlin.math.nextUp\r\n\r\nclass TileEntityVoidPortalStorage(type: TileEntityType<TileEntityVoidPortalStorage>) : TileEntityBasePortalController(type), IVoidPortalController, INamedContainerProvider{\r\n\tconstructor() : this(ModTileEntities.VOID_PORTAL_STORAGE)\r\n\t\r\n\tprivate companion object{\r\n\t\tprivate const val ACTIVATION_DURATION_TICKS = 20 * 10\r\n\t\t\r\n\t\tprivate const val FADE_IN_PROGRESS_PER_UPDATE = 0.04F\r\n\t\tprivate const val FADE_OUT_PROGRESS_PER_UPDATE = 0.02F\r\n\t\tprivate const val FADE_IN_DURATION_TICKS = 1F / FADE_IN_PROGRESS_PER_UPDATE\r\n\t\t\r\n\t\tprivate const val SLOWING_DURATION_TICKS = 75\r\n\t\tprivate const val SLOWING_EXTRA_DELAY_TICKS = 4\r\n\t\tprivate val SLOWING_PROGRESS_PER_UPDATE = ((1000F / 20F) * BlockAbstractPortal.TRANSLATION_SPEED_INV).toFloat().nextUp()\r\n\t\t\r\n\t\tprivate const val INSTANCE_TAG = \"Instance\"\r\n\t}\r\n\t\r\n\t// Client animation\r\n\t\r\n\toverride val serverRenderState\r\n\t\tget() = when(currentInstance){\r\n\t\t\tnull -> Invisible\r\n\t\t\telse ->\r\n\t\t\t\tif (remainingTime > ACTIVATION_DURATION_TICKS - FADE_IN_DURATION_TICKS)\r\n\t\t\t\t\tAnimating((ACTIVATION_DURATION_TICKS - remainingTime) / FADE_IN_DURATION_TICKS)\r\n\t\t\t\telse\r\n\t\t\t\t\tVisible\r\n\t\t}\r\n\t\r\n\toverride val clientAnimationFadeInSpeed\r\n\t\tget() = FADE_IN_PROGRESS_PER_UPDATE\r\n\t\r\n\toverride val clientAnimationFadeOutSpeed\r\n\t\tget() = FADE_OUT_PROGRESS_PER_UPDATE\r\n\t\r\n\t// Token handling\r\n\t\r\n\toverride var currentInstance: TerritoryInstance? by Notifying(null, FLAG_SYNC_CLIENT or FLAG_SKIP_RENDER)\r\n\t\tprivate set\r\n\t\r\n\tprivate var firstSpawnInfo: SpawnInfo? = null\r\n\t\r\n\tprivate var remainingTime = 0\r\n\tprivate var clientTime = 0\r\n\t\r\n\tfun activateToken(stack: ItemStack){\r\n\t\tcurrentInstance = ModItems.PORTAL_TOKEN.getOrCreateTerritoryInstance(stack)\r\n\t\tremainingTime = ACTIVATION_DURATION_TICKS\r\n\t}\r\n\t\r\n\tfun prepareSpawnPoint(entity: Entity): SpawnInfo?{\r\n\t\treturn firstSpawnInfo ?: currentInstance?.prepareSpawnPoint(entity, clearanceRadius = 1).also { firstSpawnInfo = it }\r\n\t}\r\n\t\r\n\t// Container\r\n\t\r\n\toverride fun getDisplayName(): ITextComponent{\r\n\t\treturn TextComponentTranslation(\"gui.hee.portal_token_storage.title\")\r\n\t}\r\n\t\r\n\toverride fun createMenu(id: Int, inventory: PlayerInventory, player: EntityPlayer): Container{\r\n\t\treturn ContainerPortalTokenStorage(id, player, ItemStackHandlerInventory(TokenPlayerStorage.forPlayer(player)), this)\r\n\t}\r\n\t\r\n\t// Overrides\r\n\t\r\n\toverride fun tick(){\r\n\t\tsuper.tick()\r\n\t\t\r\n\t\tif (!wrld.isRemote){\r\n\t\t\tif ((remainingTime > 0 && --remainingTime == 0) || !pos.isAnyPlayerWithinRange(wrld, 160)){\r\n\t\t\t\tcurrentInstance = null\r\n\t\t\t\tfirstSpawnInfo = null\r\n\t\t\t\tremainingTime = 0\r\n\t\t\t}\r\n\t\t}\r\n\t\telse{\r\n\t\t\tif (clientAnimationProgress.currentValue > 0F){ // just a small effect so don't care about syncing with server\r\n\t\t\t\tval slowingStartTime = ACTIVATION_DURATION_TICKS - SLOWING_DURATION_TICKS - SLOWING_EXTRA_DELAY_TICKS\r\n\t\t\t\t\r\n\t\t\t\tif (++clientTime > slowingStartTime){\r\n\t\t\t\t\tval progress = min(1F, (clientTime - slowingStartTime).toFloat() / SLOWING_DURATION_TICKS)\r\n\t\t\t\t\tval offset = SLOWING_PROGRESS_PER_UPDATE * square(progress)\r\n\t\t\t\t\t\r\n\t\t\t\t\tclientPortalOffset.update(clientPortalOffset.currentValue + offset)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\tclientTime = 0\r\n\t\t\t\tclientPortalOffset.updateImmediately(0F)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\toverride fun writeNBT(nbt: TagCompound, context: Context) = nbt.use {\r\n\t\tsuper.writeNBT(nbt, context)\r\n\t\t\r\n\t\tif (context == NETWORK){\r\n\t\t\tcurrentInstance?.let { putInt(INSTANCE_TAG, it.hash) }\r\n\t\t}\r\n\t}\r\n\t\r\n\toverride fun readNBT(nbt: TagCompound, context: Context) = nbt.use {\r\n\t\tsuper.readNBT(nbt, context)\r\n\t\t\r\n\t\tif (context == NETWORK){\r\n\t\t\tcurrentInstance = getIntegerOrNull(INSTANCE_TAG)?.let(TerritoryInstance.Companion::fromHash) ?: currentInstance // keep previous instance for animation\r\n\t\t}\r\n\t}\r\n}\r\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/chylex/hee/game/block/entity/TileEntityVoidPortalStorage.kt (revision f6f631f6f3dc9b347b19db913cf2be4535813fc7)
+++ src/main/java/chylex/hee/game/block/entity/TileEntityVoidPortalStorage.kt (date 1593104926617)
@@ -36,7 +36,7 @@
constructor() : this(ModTileEntities.VOID_PORTAL_STORAGE)
private companion object{
- private const val ACTIVATION_DURATION_TICKS = 20 * 10
+ private const val ACTIVATION_DURATION_TICKS = 20 * 10 /*TODO*/ * 100
private const val FADE_IN_PROGRESS_PER_UPDATE = 0.04F
private const val FADE_OUT_PROGRESS_PER_UPDATE = 0.02F